Synchronize a purchase
Verify a store purchase and attach its Feature access to a customer.
https://i.nuxie.ai/purchaseAttach a verified App Store or Google Play purchase to a customer and return the resulting Feature access. type selects the store; distinct_id identifies the customer for either store.
The iOS SDK’s default StoreKit integration sends verified transactions, retries synchronization, and finishes transactions for you. For another billing provider, see purchase ownership.
Request body
apiKeybodystringrequiredPublishable key for the app platform. A pk_test_ key selects test data; a pk_live_ key selects live data. Copy it from Connect your app.
typebodystringrequiredappstore, playstore, or test_store.
distinct_idbodystringrequiredThe identified or anonymous customer ID your app supplies to the SDK, rather than Nuxie’s internal customer record ID. See Customer identifiers.
transaction_jwtbodystringRequired for appstore: the signed transaction returned by StoreKit 2.
purchase_tokenbodystringRequired for playstore: the token returned by Google Play Billing.
reasonbodystringRequired for appstore and playstore: why the purchase is being sent. purchase for a purchase the customer just made, restore when the customer asked to restore purchases, and sync for everything else, such as app start or sign-in. Only purchase and restore can move a purchase that another customer holds to this customer.
customer_kindbodystringRequired for appstore and playstore: identified when the customer has signed in on this device, otherwise anonymous. When a customer who never signed in holds the purchase, a restore or purchase merges them into this customer; a purchase held by a signed-in customer moves only to a customer who has signed in.
product_idbodystringGoogle Play Product identifier, when relevant.
base_plan_idbodystringGoogle Play subscription base plan, when relevant.
purchase_option_idbodystringGoogle Play one-time purchase option, when relevant.
offer_idbodystringSelected Google Play store offer, when relevant.
product_typebodystringGoogle Play subscription or one_time.
catalog_product_idbodystringRequired for test_store: the Nuxie catalog Product ID from the published Experience.
transaction_idbodystringRequired for test_store: the Test Store’s own transaction ID. Nuxie grants each ID once.
Use the publishable key for the matching iOS or Android platform. The configured Google Play connection supplies the package context. Nuxie verifies the purchase with the store before attaching access to the customer.
The SDKs send test_store from the Test Store in debug builds. Nuxie accepts it only with a pk_test_ key and only for a Product in the platform’s published catalog, and grants that Product’s Features to the customer once. It records no transaction, so it never counts as revenue.
Response
successbooleanrequiredtrue when the purchase is attached.
customer_idstringrequiredNuxie’s resolved customer record ID.
featuresobject[]requiredResulting Feature access.
idempotent_replaybooleanrequiredWhether this purchase was already processed.
transaction_idstringApp Store transaction identifier, returned for appstore.
purchase_tokenstringGoogle Play purchase token, returned for playstore.
order_idstringGoogle Play order identifier, returned for playstore.
catalog_productobjectGoogle Play mapping to the matched Product, base plan, purchase option, offer, and store product type.
Repeat the same evidence when retrying. Nuxie recognizes the existing transaction or token instead of granting it twice.
Purchase errors
A test_store purchase answers 403 with test_store_requires_test_key for a live key, and 400 with test_store_product_unavailable for a Product the published catalog does not have. Store purchase error codes use the prefix app_store_purchase_ or google_play_purchase_:
| Suffix | Status | Action |
|---|---|---|
reason_required |
400 |
Send reason with the purchase |
customer_kind_required |
400 |
Send customer_kind with the purchase |
invalid |
400 |
Check the evidence, Product identifiers, App, and environment |
owner_unverified |
400 |
Check the customer identity used for checkout and synchronization |
unsupported |
400 |
Inspect detail for why the purchase cannot be attached |
conflict |
409 |
Resolve the ownership or conflicting replay before resubmitting |
reconciliation_retryable |
503 |
Retry with the same evidence after a delay |
unavailable |
503, or 429 for Google Play |
Retry with backoff |