简体   繁体   中英

App store in app purchase subscription validation fail

Using:

For purchasing: react-native-in-app-utils

For validation: iap-receipt-validator

After successfully purchase a subscription, I would like to validate it every time user enters the app.

receiptData returns the correct receipt string.

InAppUtils.receiptData((error, receiptData)=> {
            if(error) {
            } else {
                IOSReceiptValidator.validate(receiptData).then(function (result) {
                }).catch(function (error) {
                });
            }
        });

IOSReceiptValidator:

static async validate(receiptData) {
        try {
            const validationData = await validateReceipt(receiptData);
            console.log(validationData);
        } catch(err) {
            console.log(err.valid, err.error, err.message) // Here is the error
        }
    }

Validation fails, every time,

Error:

"Failed to execute 'readAsText' on 'FileReader': parameter 1 is not of type 'Blob'."

I've tried to look for other issues with the libraries I'm using, but no issue was found. I'm not sure, but maybe is has something to do with debugging on Chrome? (On Real device, just debugging in Chrome) Anyone has any idea?

Thanks.

If anyone is facing the same issue, I've used "react-native-fetch-blob" to fix this.

POST to this URL:

const url = isProduction ? "https://buy.itunes.apple.com/verifyReceipt" : "https://sandbox.itunes.apple.com/verifyReceipt";

With content:

{"receipt-data": receiptData, password: password}

And wait for response 0 for validation.

As documented here: https://developer.apple.com/library/content/releasenotes/General/ValidateAppStoreReceipt/Chapters/ValidateRemotely.html

resolved.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM