question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to decode base64 result.latest_receipt returned by validateReceiptIos ?

See original GitHub issue

Version of react-native-iap

1.2.1

Platforms you faced the error (IOS or Android or both?)

iOS I was digging into validateReceiptIos to get more information on subscriptions status, I did this

RNIap.validateReceiptIos({
        'receipt-data': purchase.transactionReceipt,
        'password': "****",
      }, false, 54).then(result => {
        console.log("DEBUG pending_renewal_info ", result.pending_renewal_info);
        console.log("DEBUG lastest_receipt ", result.latest_receipt)
      });

result.latest_receipt is a base64 encoded json, does someone know the best way to convert it to readable json ?

Ref links : https://developer.apple.com/library/archive/releasenotes/General/ValidateAppStoreReceipt/Chapters/ValidateRemotely.html https://developer.apple.com/library/archive/releasenotes/General/ValidateAppStoreReceipt/Chapters/ReceiptFields.html#//apple_ref/doc/uid/TP40010573-CH106-SW1

I’ve noticed an error in isTest param, if isTest is true, it should run as sandbox

export const validateReceiptIos = async (receiptBody, isTest, RNVersion) => {
  if (Platform.OS === 'ios') {
const URL = !isTest ? 'https://sandbox.itunes.apple.com/verifyReceipt' : 'https://buy.itunes.apple.com/verifyReceipt';

should be

export const validateReceiptIos = async (receiptBody, isTest, RNVersion) => {
  if (Platform.OS === 'ios') {
const URL = isTest ? 'https://sandbox.itunes.apple.com/verifyReceipt' : 'https://buy.itunes.apple.com/verifyReceipt';

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ramonsenadevcommented, Jul 25, 2018

@lc3t35 For decode this base64 (from subscriptions), you will need to send it to apple server. Like described in https://developer.apple.com/library/archive/releasenotes/General/ValidateAppStoreReceipt/Chapters/ValidateRemotely.html

I was trying to copy the base64 from console while I was debugging my app and trying to make the call to Apple end-point, but it looks like the chrome was truncating the receipt, since I was always getting “invalid receipt” from Apple server.

After I sent the base64 receipt data to my local server and made the call to apple, I finally decoded the receipt.

0reactions
lincdhcommented, Aug 15, 2022

After calling RNIap.validateReceiptIos I see the object with these keys: ['environment', 'latest_receipt', 'latest_receipt_info', 'pending_renewal_info', 'receipt', 'status']. Then why does one need to decode latest_receipt?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Base64 Decode and Encode - Online
Decode files from Base64 format. Select a file to upload and process, then you can download the decoded result. 0 Click (or tap) ......
Read more >
How to Decode Base64 to Original Values | React Tutorial
You will learn how to decode Base64 to the original string in this tutorial. This application is written in ReactJS. Enjoy, guys!
Read more >
Decoding Base64 String Returns nil - Stack Overflow
Whenever I try to convert this base64 encoded data to Normal string, it returns nil. Here is the string
Read more >
Base64 - MDN Web Docs Glossary: Definitions of ... - Mozilla
Base64 is a group of similar binary-to-text encoding schemes that ... to Base64 string decoding function b64ToUint6(nChr) { return nChr > 64 ...
Read more >
base64 — Base16, Base32, Base64, Base85 Data Encodings ...
Decode the Base64 encoded bytes-like object or ASCII string s and return the ... If validate is True , these non-alphabet characters in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found