store.deferStorePurchases()

Type Function
Return value none
Revision Release 2024.3703
Keywords Apple, IAP, in-app purchases, App Store Promoted Purchases
See also store.proceedToPayment
store.*

Overview

Some times In-App Purchase can be triggered from outside of your app, say from the App Store promotion. If your app is not able to handle purchases at any time, or you require to implement the age gate before proceeding to the purchase, you can use this function to pick time when payment dialog would be shown.

When listener is set and user initiates IAP purchase from the App Store purchase would not proceed to payment immediately. Instead, appStorePurchase event would be generated and when it is better time to show the payment screen you can show it manually with the store.proceedToPayment() method.

Under the hood, having a listener set would case plugin to return NO from the paymentQueue(_:shouldAddStorePayment:for:). You can pass nil to remove the listener.

Syntax

store.deferStorePurchases( appStorePurchaseListener )
appStorePurchaseListener (required)

Listener. The listener that will receive the appStorePurchase event instead of showing the purchase window immediately when purchase is triggered from outside your app.

Example

local store = require( "plugin.apple.iap" )

local function transactionListener( event )
    -- ...
end
store.init( transactionListener )


local function deferredPurchases(event)
    local payment = event.payment

    -- Tore `payment` somewhere and when time is right call
    store.proceedToPayment(payment)
end
store.deferStorePurchases(deferredPurchases)