j3k0 / cordova-plugin-purchase

In-App Purchase for Cordova on iOS, Android and Windows
https://purchase.cordova.fovea.cc
1.29k stars 529 forks source link

Help with receipt validation #1477

Closed Afrykakod123 closed 7 months ago

Afrykakod123 commented 7 months ago

Hello!

I'm creating my own receipt validation, and I'm stuck at the point of creating a callback after server-side validation

callback({ ok: true, data: { id: ob.subscriptionId, latest_receipt: true, collection: ?, transaction: resData } });

I can't figure out how to handle the "collection" The collection of purchases in this receipt. An array of ValidatorPurchase

"NativeTransactions" is the result of server-side verification, "collection" is something I can't find; do I need to create it myself?

Please provide guidance or a link to instructions on how to do it.

System Info

Output of cordova info. OS: Microsoft Windows 11 Home 10.0.22621 (22621) (Windows 10.0.22621) #x64

Node: v18.14.2 npm: 9.5.0

Afrykakod123 commented 7 months ago

It's working fine, I created the VerifiedPurchase object myself, and it's working. Please delete or close it.

bboldi commented 6 months ago

Could you share an example of how you construct these object successfully for ok: true and ok: false cases?

Afrykakod123 commented 6 months ago

I create a callback when prepaid subscription

false - callback({ ok: false });

true
const collectionPurchase: VerifiedPurchase = { id: JSON.parse(product.transaction.receipt).productId, expiryDate: new Date(resData.lineItems[0].expiryTime).getTime(), isBillingRetryPeriod: false, isExpired: false, purchaseDate: new Date(resData.startTime).getTime(), } callback({ ok: true, data: { id: JSON.parse(product.transaction.receipt).productId, latest_receipt: true, collection: [collectionPurchase], transaction: resData } });

//    resData -server validation response
bboldi commented 6 months ago

@Afrykakod123 Thank You!