Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ashish_pithava's avatar

How to Decode Base64-Encoded App Store In-App Purchase Receipt Using PHP/Laravel?

I need to manually decode a Base64-encoded receipt from an In-App Purchase and extract the transaction ID using PHP and Laravel. I would like to avoid using the deprecated verifyReceipt endpoint.

Can anyone provide guidance on how to achieve this? Specifically, I'm looking for PHP libraries or steps to parse the receipt data and retrieve the transaction ID without relying on the verifyReceipt endpoint.

Any help or code samples would be greatly appreciated!

0 likes
5 replies
tykus's avatar

What have you tried already? It is very difficult to guide you without knowing what you're working with, i.e. what is the expected form of the decoded data; image, document, string, JSON...

There is a native base64_decode function which will decode the message:

$decoded = base64_decode($message);

Depending on what you get, or what you expect, you will take the next steps accordingly.

1 like
ashish_pithava's avatar

@tykus Thank you for your response! I understand the need for more details—apologies for not including them earlier. Here's what I've tried so far:

I'm using PHP's base64_decode function to decode an In-App Purchase receipt, which is in Base64-encoded ASN.1 format. After decoding, I get a binary string. From my understanding, it needs further processing to extract the transaction details (e.g., transaction ID, product ID, etc.). The expected form of the decoded data is a receipt payload, likely in a JSON format. However, since Apple deprecated the verifyReceipt endpoint, I’m trying to decode and extract these details directly in PHP/Laravel.

I’d appreciate your guidance on the best way to handle this data—especially if you know how to parse it into a human-readable format or retrieve specific transaction fields like the transaction ID.

tykus's avatar

@ashish_pithava okay, if you are expecting to be working with a binary file, then you can either store it using file_put_contents, and then parse the ASN.1 file e.g.

file_put_contents('filename.asn1', base64_decode($message));

or, you can utilise a PHP package such as adapik/PHPASN1 to read your decoded message into the ASN.1 parser directly without storing the binary:

use FG\ASN1\Object;

$base64String = ...
$binaryData = base64_decode($message);        
$asnObject = Object::fromBinary($binaryData);
// do stuff
ashish_pithava's avatar

@tykus Thank you for your suggestion, I really appreciate the effort you put into providing a detailed explanation. I tried both approaches you mentioned—storing the file using file_put_contents and parsing it using the adapik/PHPASN1 package. Unfortunately, neither approach worked in my case.

The issue might be related to the specific structure of the data I'm working with or some underlying compatibility concerns. If you have any further suggestions or ideas, I’d be happy to try them out. Thank you once again for your time and support!

You can see the demo receipt here: gist.github.com/sergey-zhuravel/a512a332464c299ab567dd8b5eff7a5f#file-appstorereceipt

tykus's avatar

@ashish_pithava is the Receipt / Transaction ID information actually encoded in that data? I have had a brief look over the decoded ASN.1 and cannot see anything describing a transactionID?

Please or to participate in this conversation.