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
| 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 |
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 |
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. |
| Name | Type | Description |
|---|
obfuscated_account_id | String | An obfuscated string that is uniquely associated with the user's account in your app. |