Palbase IAP · API
/iap/apple/transactionsReport what StoreKit gave the app
The signed-in customer's app — a guest's too: a guest buys in the app — reports the transactions StoreKit gave it: a purchase just made, Transaction.updates, or on a restore every one of currentEntitlements. Each is verified as the App Store signed it for the connected app, of the sandbox or production; with an Xcode certificate set, one Xcode signed with it on the developer's Mac (StoreKit Testing, environment Xcode, for one of the environment's iOS apps) is taken too — a test purchase, the sandbox's, gated by sandbox_access as the sandbox's are, of which nothing is asked of Apple — key connected or not. One that is neither refuses the report, naming it. A subscription's state is not taken from the device: it is read from Apple with the project's own key (Get All Subscription Statuses). Whose a purchase is: one nobody has becomes the customer's its appAccountToken names, or the reporter's; one another customer has stays theirs — unless a new purchase on it (a switch of plan, a resubscription, an offer bought: a transaction new to Palbase that is no renewal, the newest bought of it) carries another customer's appAccountToken, which moves it to that customer, who paid, whoever reports it (an Apple ID shared among the app's accounts); or restore from the device StoreKit signed its transaction for (device_verification_id), which moves it to the reporter (an account's is never taken by a guest's restore). One purchase moves 3 times in 30 days at most, restores and new purchases counted together. A restore, or the reporter's own new purchase, that leaves a purchase where it was answers why once the rest of the report is applied (403 restore_not_this_device, 403 restore_account_owned, 409 restore_limit). Apple is asked of a subscription once however many copies of it the report holds. A guest that signed in to an account reports for the account: what StoreKit gave it is the account's, and the answer is the account's. Sent again, a report applies nothing twice. Answers what the customer has now, as GET /iap/me. Emits what a purchase changed — iap.purchase.completed, iap.subscription.changed, iap.entitlement.changed, iap.ownership.transferred on a move, credits' events — and iap.customer.changed.
Called by a signed-in user of your app, with their token and the publishable key.
Request body
device_verification_idstring (uuid) · optionalThe reporting device's AppStore.deviceVerificationID (its uuidString). StoreKit signs each transaction for one device: its deviceVerification is the SHA-384 of its deviceVerificationNonce and this id, both lowercase. A restore moves a purchase another customer has only when the transaction was signed for this device; without it, a restore moves none.restoreboolean · optionalThe customer asked to restore their purchases: each purchase moves to them from the customer that has it — only with a transaction StoreKit signed for this device (`device_verification_id`), never an account's by a guest's restore, and one purchase 3 times in 30 days at most, with the new purchases that moved it; one that stays is answered (403, 409) once the rest is applied. Without it (false, the default), a purchase another customer has stays theirs — unless a new purchase on it carries another customer's appAccountToken, which moves it to its buyer.transactionsstring[] · requiredThe transactions, as StoreKit 2 signs each (Transaction.jwsRepresentation): a purchase just made, Transaction.updates, or every one of currentEntitlements on a restore.curl -X POST "https://<your-ref>.palbase.studio/iap/apple/transactions" \
-H "apikey: $PALBASE_PUBLISHABLE_KEY" \
-H "authorization: Bearer $USER_ACCESS_TOKEN" \
-H "content-type: application/json" \
-d '{"transactions":["string"]}'Responses
200What the customer has now
400`transactions` holds no transaction or more than 100 (`invalid_transactions`), `device_verification_id` is not a UUID (`invalid_device_verification_id`), or the body is not the request
401No customer's session (`session_required`): a customer's own is reached with the publishable key and their access token; or the edge refused the key or token
403A restore left purchases another customer has where they were; the rest of the report is applied (read GET /iap/me), and the description says how many and why: StoreKit did not sign their transactions for the device `device_verification_id` names, or none was named (`restore_not_this_device`); an account has them and the reporter is a guest (`restore_account_owned`). When a restore was refused for more than one reason, the code is the first of these and of `restore_limit`.
404The user's id is longer than a customer's (128 characters; `customer_not_found`)
409The project has no In-App Purchase key connected and no Xcode certificate set (`apple_not_connected`), a production purchase before the app's Apple ID is known (`apple_not_bound`: see GET /iap/apple), Apple no longer takes the project's key (`apple_key_refused`), or a restore, or the reporter's new purchase, left purchases where they were because each moved between customers 3 times in 30 days (`restore_limit`): the rest of the report is applied, and the description says how many
410The user was deleted (`customer_erased`): their id is no customer's again
413The body is over 2 MiB
422A transaction is not one the App Store signed for the connected app, or Apple does not know it (`invalid_transaction`: the description names which, `transactions[i]`)
429Over the project's request limit; Retry-After says when to try again
503Another change to this customer is in progress (`customer_busy`), or the App Store could not be asked now (`apple_unreachable`); retrying is safe after Retry-After
defaultAn error: the envelope names it (`error`) and explains it (`error_description`).
Operation ReportAppleTransactions of iap's contract.