Link

How to integrate with Apple InApp Purchases?

Configuration steps:


Configure payment gateway settings

You need following details in Configure > Payment Gateways > Apple IAP.

  • Issuer Id
  • Bundle Id
  • Private Api Key (Refer here)
  • Shared Secret (Refer here)

    When downloading private api key, it will be downloaded as a file. Open this file in any text editor. The content should be similar to -

    -----BEGIN PRIVATE KEY-----
    <generated text>
    -----END PRIVATE KEY-----
    

    Copy the whole content from the file, including -----BEGIN PRIVATE KEY----- and -----END PRIVATE KEY-----.

  • Key Id (for the above generated Private Api Key).
  • Environment - Select Live for production and Sandbox for test account.

Note: In Accesstype Production Account the Environment should always be selected as Live after making the app live on Appstore.

configuration page

Create subscription plans

Create a private subscription group. Add subscription plans. Make sure you create recurring or one time based on your requirement and that the desired assets are added.

Note: Trial is not supported in Accesstype for Apple In app purchases recurring flow.

Create inApp products in Apple App Store Connect console

For each of the plans created above, you need to create one inApp product(managed product or subscription for one-time and recurring respectively) in Apple App Store Connect. While creating an inApp product, ensure that the product Id is same as Accesstype plan Id.

Note: While configuring plans on App Store Connect dashboard, one of the steps would be to configure plan prices for different currencies.

  • You can only select prices from a set of possible values.
  • Apple may charge the end user in the user’s local currency. This may differ from the currency and price set in Accesstype Dashboard.

subscritption product id

plan id

Fill in all other details as required to create a product successfully. These details will be displayed to the end users while purchasing products.

Configure notifications

Accesstype supports App store server notifications V2. For this to work, you need to set url for appstore notification as

  • Production: https://www.accesstype.com/api/v1/callbacks/:account_key/applepay.json
  • Staging: https://staging.accesstype.com/api/v1/callbacks/:account_key/applepay.json

webhook url

v2 notifications

App code changes

A purchase via Apple IAP can only be triggered natively from the app.

After all the configurations are done, make below changes inside the App code:

  • List products
  • When user selects a product for purchase, Make preview API call to Accesstype with the id of selected plan as subscription_plan_id. Ensure that payment_type for a subscription product is applepay_recurring and for managed one-time product its applepay.
  • Trigger purchase. The response for the purchase flow will contain transactionId and originalTransactionIdentifierIOS.
  • For Gift and Onetime purchases, receipt_data parameter is needed for server side validation, see Server side Receipt Validation
  • When the purchase is successful, the createSubscription call shall be made to AT including these details. For example, subscriptionParams.payment object may have the following details
    {
    "payment_type": "applepay_recurring",  //"applepay" for one time payments
    "amount_cents": 3000,
    "amount_currency": "USD",
    "payment_token": "1000000900265",  // transactionId received in the IAP purchase response
    "receipt_data": "<receipt-data>", // for Gift and Onetime subscriptions
    "original_payment_token": "10000041498"  // originalTransactionIdentifierIOS received in the IAP purchase response
    }