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, Google or Amazon account. Apple, Google and Amazon 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_requiredset totrue - 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_requiredset totrue
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_createdflag in the response is set totrue
process_apple_payment
This will send a JWT Receipt or Transaction ID to the backend.
Parameters
| Name | Type | Description |
|---|---|---|
subscription_transaction_jws | String | The subscription transaction JWS from Apple after the purchase. |
app_receipt_base64 | String | The base64 representation of the receipt data. |
transaction_id | String | This is the transaction id of the transaction. You need to provide either the receipt or the transaction id. |
customer_details | InAppCustomerDetailsBody | Optional 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_details | InAppAflyrBody | Optional Conversion Details for Appsflyer Conversion, usually required only for new purchases |
client_id | String | Optional Keycloak client ID the returned login token is generated for. If omitted, the backend picks the client from the bundle ID. |
Returns
Returns an InAppPaymentResponse upon success, otherwise SDKException.
process_google_payment
This will send a Google Playstore Purchase Token to the backend.
Parameters
| Name | Type | Description |
|---|---|---|
purchase_token | String | This is the Purchase |
sku | String | The SKU identifier of the purchased product |
customer_details | InAppCustomerDetailsBody | Optional 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_details | InAppAflyrBody | Optional Conversion Details for Appsflyer Conversion, usually required only for new purchases |
client_id | String | Optional Keycloak client ID the returned login token is generated for. If omitted, the backend picks the client from the package ID. |
Returns
Returns an InAppPaymentResponse upon success, otherwise SDKException.
process_amazon_payment
This will send an Amazon Appstore purchase receipt to the backend. The package ID is taken from the SDK configuration when it is set. Unlike process_google_payment, it is optional: Amazon receipts are accepted without it.
Parameters
| Name | Type | Description |
|---|---|---|
receipt_id | String | The receipt ID of the Amazon Appstore purchase receipt |
amazon_user_id | String | The Amazon user ID the receipt belongs to, from the Appstore UserData |
price_in_micros | Int64 | The price paid, in millionths of the currency unit (e.g. 9.99 is 9990000) |
currency | String | The ISO 4217 currency code of the price |
marketplace | String | The ISO 3166-1 alpha-2 code of the Amazon marketplace the purchase was made in |
customer_details | InAppCustomerDetailsBody | Optional 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_details | InAppAflyrBody | Optional Conversion Details for Appsflyer Conversion, usually required only for new purchases |
client_id | String | Optional Keycloak client ID the returned login token is generated for. If omitted, the OpenID client ID from the client details is used; if that is not set either, the backend picks the client from the package ID. |
Returns
Returns an InAppPaymentResponse upon success, otherwise SDKException.
Types
InAppCustomerDetailsBody
| Name | Type | Description |
|---|---|---|
email | String | E-Mail to be set or updated |
InAppAflyrBody
| Name | Type | Description |
|---|---|---|
referrer_id | String | Referrer ID |
apple_search_ads | String | JSON Content of the Apple Search Ads JSON |
InAppPaymentResponse
| Name | Type | Description |
|---|---|---|
login_url | String | This 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_switched | Bool | This value is true if the Access Token is for a different account than the one logged in during the request. |
email_confirmation_required | Bool | If 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_created | Bool | If 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_set | Bool | Indicates whether the email address has been set on the account. |
extra | InAppPaymentExtraData | Additional data as part of the in-app payment response. |
InAppPaymentExtraData
| Name | Type | Description |
|---|---|---|
obfuscated_account_id | String | An obfuscated string that is uniquely associated with the user's account in your app. |