voltrue2 / in-app-purchase

A Node.js module for in-App-Purchase for iOS, Android, Amazon and Windows.
http://iap.gracenode.org
Other
1.05k stars 289 forks source link

in_app is not in the response. (Apple) #262

Open ghost opened 5 years ago

ghost commented 5 years ago

I'm trying to get all receipts while validating one and thought it could be achieved using this package since a lot of other issues include in_app somewhere (the array of all receipts as defined in Apple's doc https://developer.apple.com/library/archive/releasenotes/General/ValidateAppStoreReceipt/Chapters/ReceiptFields.html)

Our App is subscription based.

My code looks like this, I was expecting to see in_app in the response.

iap.setup().then(() => 
{
    iap.validate(user.appleReceiptData).then((response) =>
    {
        var options = {
            ignoreCanceled: false, 
            ignoreExpired: false
        };
        var purchaseData = iap.getPurchaseData(response, options);
        console.log('@purchaseData: ', purchaseData); // no in_app here
        console.log('@response: ', response);        // no in_app here

    }).catch((error) => 
    {
        console.log('@error: ', error);
    });
}).catch((error) => 
{
    console.log('@error: ', error);
});

But the response "only contains" (the usual, I guess.):

{ auto_renew_status: 1,
    status: 0,
    auto_renew_product_id: 'subscriptionForAYear',
    receipt:
     { original_purchase_date_pst: '2019-04-12 05:14:34 America/Los_Angeles',
       quantity: '1',
       unique_vendor_identifier: 'blahblah',
       bvrs: '1',
       expires_date_formatted: '2020-04-19 12:14:34 Etc/GMT',
       is_in_intro_offer_period: 'false',
       purchase_date_ms: '1555676074000',
       expires_date_formatted_pst: '2020-04-19 05:14:34 America/Los_Angeles',
       is_trial_period: 'false',
       item_id: '1187371573',
       unique_identifier: 'blahblah',
       original_transaction_id: 'blahblah',
       expires_date: '1587298474000',
       app_item_id: 'blahblah',
       transaction_id: 'blahblah',
       web_order_line_item_id: 'blahblah',
       version_external_identifier: '830949232',
       product_id: 'subscriptionForAYear',
       purchase_date: '2019-04-19 12:14:34 Etc/GMT',
       original_purchase_date: '2019-04-12 12:14:34 Etc/GMT',
       purchase_date_pst: '2019-04-19 05:14:34 America/Los_Angeles',
       bid: 'com.blahblah.blahblah',
       original_purchase_date_ms: '1555071274000' },
    latest_receipt_info:
     { original_purchase_date_pst: '2019-04-12 05:14:34 America/Los_Angeles',
       quantity: '1',
       unique_vendor_identifier: 'blahblah-blahblah-blahblah-blahblah-blahblah',
       bvrs: '1',
       expires_date_formatted: '2020-04-19 12:14:34 Etc/GMT',
       is_in_intro_offer_period: 'false',
       purchase_date_ms: '1555676074000',
       expires_date_formatted_pst: '2020-04-19 05:14:34 America/Los_Angeles',
       is_trial_period: 'false',
       item_id: 'blahblah',
       unique_identifier: 'blahblah',
       original_transaction_id: 'blahblah',
       expires_date: '1587298474000',
       app_item_id: 'blahblah',
       transaction_id: 'blahblah',
       web_order_line_item_id: 'blahblah',
       bid: 'com.blahblah.blahblah',
       product_id: 'subscriptionForAYear',
       purchase_date: '2019-04-19 12:14:34 Etc/GMT',
       original_purchase_date: '2019-04-12 12:14:34 Etc/GMT',
       purchase_date_pst: '2019-04-19 05:14:34 America/Los_Angeles',
       original_purchase_date_ms: '1555071274000' },
    latest_receipt:
     'blahblahblahblahblahblahblahblahblahblahblahblah==',
    sandbox: false,
    service: 'apple' }

TL;DR: How can I get the in_app array? or... Is there another way to list all receipts?

chintan100 commented 5 years ago

I have the same question as well.

If we set verbose: true , the in_app array is logged in console with "Sandbox validation successful:" but I couldn't find a way to access in_app array to store each renewal transaction in database.

chintan100 commented 5 years ago

Figured out soon after my comment. You can access in_app array by using:

let allTransactions = appleReceipt.receipt.in_app;