I am testing cordova-plugin-purchase in my App and everything is working in my sandbox testing except I am unable to get storekit.appStoreReceipt
. I am using Capacitorjs (not with Ionic) and the CapacitorHttp plugin. I mostly want to get the original_application_version
and original_application_date
data.
My code is is this:
let receipt = storekit.appStoreReceipt;
let body = {
'receipt-data': receipt,
'password': 'my iOS Shared Key',
'exclude-old-transactions': true
};
const options = {
url: 'https://sandbox.itunes.apple.com/verifyReceipt',
method: 'post',
body: JSON.stringify(body),
headers: {'Content-Type': 'application/json'},
};
Capacitor.Plugins.CapacitorHttp.post(options)
.then(function (res) {
if (res.status === 200) {
const data = res.data;
console.log(data)
console.log('APP version '+ data.original_application_version)
console.log('APP purchase date '+ data.original_purchase_date_ms)
}
})
.catch(e => {
console.log(e)
})
The results show error 21002 which means an issue with the base64 returned receipt. I am new to this and not sure how to fix this issue. Any help would be appreciated.