I'm having issues with grabbing solely the Apple Receipt from a promise.
This is the usual response: Promise {_40: 0, _65: 0, _55: null, _72: null} The _55: null contains the receipt whereas null is actually the receipt since the body is too big to be read.
I am also using Ignite-Andross boilerplate for my API calls. They're using apisauce.
I am using react-native-iap by dooboolab. I have tried these options.
getLatestReceipt = async () => {
var recentReceipt = await RNIap.requestReceiptIOS();
this.setState({latestReceipt: recentReceipt});
// Alert.alert(this.state.latestReceipt);
console.log(this.state.latestReceipt);
};
This prints out the current receipt in the console which is correct.
However, when I try to pass over the current receipt, the field is either read as undefined, null, or Promise {_40: 0, _65: 0, _55: null, _72: null}.
var data = {
apple_request: [
{
subscription_number: "A-S00000001",
// Apple Receipt
receipt_id: this.state.latestReceipt
}
]
};
Another solution that I tried was to JSON.parse(latestReceipt)["_55"] However, the result returned as 0-M, 1-I, 2-I, 3-m, 4-B... It was spitting out each individual receipt index, and I needed the whole value of _55 instead.
Lastly, the only option that worked was to hardcode the whole Apple Receipt in the receipt_id field. I'm looking for a way to avoid this.
Expected output
receipt_id: whatever apple receipt is read