j3k0 / cordova-plugin-purchase

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

iOS receipt is undefined at onPurchase callback #335

Closed cquezpro closed 7 years ago

cquezpro commented 9 years ago

Hi everyone! After call IAP buy with product ID, I got onPurchase callback successfully, and got transactionID: 10000000179227042, productId: diett.unlock_yearly correctly.

But receipt is 'undefined',

Anyone help this please? Thank you $scope.purchase1Year = function () { IAP.buy('diett.unlock_yearly'); }; IAP.buy = function (productId) { storekit.purchase(productId); };

IAP.onPurchase = function (transactionId, productId, receipt) { alert("onPurchase: " + transactionId + " ," + receipt + ", " + productId); };

kjakub commented 8 years ago

help me too !

https://github.com/j3k0/cordova-plugin-purchase/issues/331

moskalen commented 8 years ago

@sirius2013 @kjakub You must be using the examples for the old version of this plugin. In the last version (4.0.0) the receipt is not sent into onPurchase rather than it should be explicitly loaded from the storekit (https://forum.ionicframework.com/t/check-for-already-purchased-iaps-with-ng-storekit-on-ios/7844/5):

IAM.onPurchase = function (transactionId, productId) {
        storekit.finish(transactionId);
        storekit.loadReceipts((receipts) => {
            console.log('Receipt for appStore = ' + receipts.appStoreReceipt);
            console.log('Receipt for ' + transactionId + ' = ' + receipts.forTransaction(transactionId));
        });
    }

The same situation is with onRestore().

kjakub commented 8 years ago

@moskalen thank you, will try