Skip to main content

InApp Payments

While InApp Purchase is not only a very convinient way to pay for a subscription, it can also be used to replace an account creation flow, if the user only wants to use the product on one specific device or devices which are linked to his Apple or Google account. Apple and Google will take care of the authentication and the returned Receipt or Purchase Token can be used as an alternative way to authenticate the customer.

SDK is authenticated with existing user credentials, no customer details provided

  • Purchase is assigned to the existing account

SDK is authenticated with existing user credentials and customer details are provided

  • Purchase is assigned to the existing account
  • Account e-mail is being updated with the provided e-mail address
  • User will receive a mail which asks him to confirm the new e-mail address
  • The response will have email_confirmation_required set to true
  • The next time, the user tries to login with the provided e-mail address, the "reset password" flow is being triggered, allowing the user to set a password.

SDK is not authenticated yet, customer details provided

  • Backend will create a new account and links the purchase to that account
  • The account is created using the specified details
  • The next time, the user tries to login with the provided e-mail address, the "reset password" flow is being triggered, allowing the user to set a password.
  • The response will have email_confirmation_required set to true

SDK is not authenticated yet, NO customer details provided

  • Similar to the previous scenario, just that the backend will generate a random username and password without sending a confirmation mail and the auto_account_created flag in the response is set to true

process_apple_payment

This will send a JWT Receipt or Transaction ID to the backend.

Parameters

NameTypeDescription
subscription_transaction_jwsStringThe subscription transaction JWS from Apple after the purchase.
app_receipt_base64StringThe base64 representation of the receipt data.
transaction_idStringThis is the transaction id of the transaction. You need to provide either the receipt or the transaction id.
customer_detailsInAppCustomerDetailsBodyOptional Customer Details, if provided a new account will be created with the details, if an account is already linked with the receipt, the account is updated with the new details
conversion_detailsInAppAflyrBodyOptional Conversion Details for Appsflyer Conversion, usually required only for new purchases

Returns

Returns an InAppPaymentResponse upon success, otherwise SDKException.

process_google_payment

This will send a Google Playstore Purchase Token to the backend.

Parameters

NameTypeDescription
purchase_tokenStringThis is the Purchase
skuStringThe SKU identifier of the purchased product
customer_detailsInAppCustomerDetailsBodyOptional Customer Details, if provided a new account will be created with the details, if an account is already linked with the receipt, the account is updated with the new details
conversion_detailsInAppAflyrBodyOptional Conversion Details for Appsflyer Conversion, usually required only for new purchases

Returns

Returns an InAppPaymentResponse upon success, otherwise SDKException.

Types

InAppCustomerDetailsBody

NameTypeDescription
emailStringE-Mail to be set or updated

InAppAflyrBody

NameTypeDescription
referrer_idStringReferrer ID
apple_search_adsStringJSON Content of the Apple Search Ads JSON

InAppPaymentResponse

NameTypeDescription
login_urlStringThis URL needs to be opened in order to log the user in. It will basically follow the OpenID Connect Login flow and as such requires the same mechanism to be applied (e.g. opening the URL with ASWebAuthenticationSession in iOS)
account_switchedBoolThis value is true if the Access Token is for a different account than the one logged in during the request.
email_confirmation_requiredBoolIf customer_details are provided and setting or updating the email requires the user to click on a confirmation link, this value will be true
auto_account_createdBoolIf true, it indicates, that the account has been automatically created and the customer might want to customize it, by providing an e-mail
is_email_setBoolIndicates whether the email address has been set on the account.
extraInAppPaymentExtraDataAdditional data as part of the in-app payment response.

InAppPaymentExtraData

NameTypeDescription
obfuscated_account_idStringAn obfuscated string that is uniquely associated with the user's account in your app.