App Store Server API

RSS for tag

Call this REST API from your server to request and provide information about your customers' in-app purchases.

Posts under App Store Server API tag

89 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

Is there any status code indicate that transactionId is from sandbox?
In the old verifyReceipt endpoint doc, there is an important desc As a best practice, always call the production URL https://buy.itunes.apple.com/verifyReceipt first and proceed to verify with the sandbox URL if you receive a 21007 status code. Following this approach ensures that you don’t have to switch between URLs while your app is in testing, in review by App Review, or live in the App Store. So I can know the transactionId is for sandbox if return back 21007. And I am about to access to new App Store Server API, so the same, I wonder how can I recognize the transactionId is from sandbox by status code? The most likely desc is this: If you don’t have environment information, follow these steps: Call the endpoint using the production URL. If the call succeeds, the original transaction identifier belongs to the production environment. If you receive an [errorCode 4040005] with errorMessage as OriginalTransactionIdNotFoundError, (or HTTP response code 404 from the Send Consumption Information endpoint), call the endpoint using the sandbox environment. If the call succeeds, the original transaction identifier belongs to the sandbox environment. If the call fails with the same error code, the original transaction identifier isn’t present in either environment. And I have a try for Get Transaction Info API, but actually get 4040010, Transaction id not found. as return. So I just wanna clear that is there any doc clarify this point that I miss? Looking forward to your response, sincerely!! :)
1
0
1.3k
Sep ’23
No REFUND notification in sandbox
I have verified that my sandbox endpoint works for App Store Server Notifications (V2), by requesting a Test Notification. When I issue a beginRefundRequest in my app for a Sandbox account, my backend does not receive a request. According to the docs this should work in Sandbox too: https://developer.apple.com/documentation/storekit/transaction/testing_refund_requests What could possible be missing if the TEST notification works, but the REFUND notification doesn't?
1
0
501
Sep ’23
JWT for App Store Server API requests
Hello, I'm trying to generate a JWT in C# for calling this endpoint -> https://developer.apple.com/documentation/appstoreserverapi/look_up_order_id I have followed the instructions in the documentation, but I'm always getting "Unauthenticated" as a response. The private key used is of type "In-App Purchase" as the documentation says. Here you have a response with a Request ID: Unauthenticated Request ID: YGV3ELXFCFHA5IPRZEW76S66NQ.0.0 This is the code used to generate the JWT: public string CreateNewApiToken() { const string audience = "appstoreconnect-v1"; var kid = "***"; var privateKey = "***"; var bundleId = "***"; var issuerId = "***"; var now = DateTime.UtcNow; using var ecdsa = ECDsa.Create(); ecdsa?.ImportPkcs8PrivateKey(Convert.FromBase64String(privateKey), out _); var signingCredentials = new SigningCredentials(new ECDsaSecurityKey(ecdsa), SecurityAlgorithms.EcdsaSha256); signingCredentials.Key.KeyId = kid; var payload = new JObject { { "iss", issuerId }, { "iat", now.ToUnixTime() }, { "exp", now.AddMinutes(30).ToUnixTime() }, { "aud", audience }, { "bid", bundleId} }; var handler = new JsonWebTokenHandler(); var token = handler.CreateToken(payload.ToJson(), signingCredentials); return token; } Thanks in advance.
2
0
724
Sep ’23
How to Determine Trial-Related Information Using App Store Server API
As we transition from using verifyReceipt to the App Store Server API, I'd like to know how we can determine trial-related information such as is_trial_period and is_in_intro_offer_period. Specifically, can we differentiate these details using the offerType value (https://developer.apple.com/documentation/appstoreserverapi/offertype)? Any guidance or suggestions would be greatly appreciated. Thank you.
0
0
351
Aug ’23
many questions about App Store Server API
Hello, I have a few questions about the App Store Server API. According to the document, if 'OriginalTransactionIdNotFoundError(errorCode: 4040005)' is received as a response after calling the production environment API if there is no environment information, it is written to call the sandbox environment, but 'Get Transaction Info' / 'Get Transaction History' API call and when 'TransactionIdNotFoundError(errorCode: 4040010)' is received, can I call it in the sandbox environment? Is the root certificate of the X.509 certificate chain on x5c claim in JWSDecodedHeader always AppleRootCA-G3? If I add and recall the query parameter '?sort=DESCENDING' in the Get Transaction History API, will the first transaction information always have the largest expiration date?
0
0
475
Aug ’23
There are some field describe missing sth in App Store Server Api
here are some field in JWSTransactionDecodedPayload and JWSRenewalInfoDecodedPayload, miss this kind of desc: This field is present only for xxxxx Such as revocationReason in JWSTransactionDecodedPayload, this field is present only when transaction is refunded. And its possible value is 0 and 1, when this field not present, golang would still unmarshal to default 0 for int32 type isInBillingRetryPeriod in JWSRenewalInfoDecodedPayload, this field is present only when transaction in billing-retry state(relative doc), and because this field type is boolean, so possible value is true and false, base on the old api desc, true - The App Store is attempting to renew the subscription. false - The App Store has stopped attempting to renew the subscription. When this field not present, golang would still unmarshal to default false for bool type priceIncreaseStatus in JWSRenewalInfoDecodedPayload, this field is present only when an auto-renewable subscription price increase that requires customer consent. Its possible value is 0 - The customer hasn’t yet responded to an auto-renewable subscription price increase that requires customer consent. 1 - The customer consented to an auto-renewable subscription price increase that requires customer consent, or the App Store has notified the customer of an auto-renewable subscription price increase that doesn’t require consent.
0
0
409
Aug ’23
How to guarantee that user won't be able to makeup transaction_id to call new api
If my user purchase and get transaction_id: 2000000395609292, and then another user just makeup a same transaction_id to call the App Store Server API If in the old way, the receipt seems impossiable to makeup, how about now? Is that equally safe as before? Or is there any way to protect transaction_id. I am not that good at security, so please forgive me about missing any point. o(╥﹏╥)o Looking forward to your response, sincerely!! :)
3
0
509
Aug ’23
Not Receiving Server Notifications for Auto-Renewable Notifications when in free trial phase
Hi, we have an auto-renewable subscription with an introductory offer configured. The introductory offer is a 7 days free trial. We're observing a possibly wrong behavior and we wanted to make sure we're not missing anything. We suspect that our server is not receiving notifications from the App Store when the free trial period starts, we only receive notifications when the user starts paying. To double-check, we've tested the same subscription in sandbox with a brand new test account with a 3 minutes renewal frequency: the behavior is exactly the same, we only get 1 notification every 3 minutes for the renewals, we get no notification when the free trial starts. So we have 2 main questions: does "free trial" work in sandbox too? If so, what's the duration of free trial in sandbox if it's set to 7 days in production? do we get a notification when the free trial period starts or we only get one when and if the user starts paying after 7 days? Thanks
1
0
841
Aug ’23
Why Non-Consumable product has originalTransactionId?
I try to call Get Transaction Info from App Store Server API, and the transactionId is for a Non-consumable type product, but it is odd that there are so many different transactionId and they have a same originalTransactionId { "bundleId": "${bundleId}", "environment": "Production", "inAppOwnershipType": "PURCHASED", "originalPurchaseDate": 1691220528000, "originalTransactionId": "${originalTransactionId}", "productId": "${productId}", "purchaseDate": 1691220528000, "quantity": 1, "signedDate": 1692590989925, "storefront": "USA", "storefrontId": "143441", "transactionId": "${originalTransactionId}", "transactionReason": "PURCHASE", "type": "Non-Consumable" } the defination of Non-Consumable is can only purchase once for same apple account. But why there would have originalTransactionId?
1
0
546
Aug ’23
When does AccountNotFound get returned from "Get All Subscription Statuses"?
Hi, I’m investigating switching from the /verifyReceipt endpoint to the App Store Server API. I’ve noticed that some transaction IDs we have in our system return 4040001 (AccountNotFound) from the “Get All Subscription Statuses” endpoint. These transaction IDs are associated with receipts that used to verify OK with the /verifyReceipt endpoint, but now return 21010 (receipt unauthorized). Under what circumstances do transactions which used to be valid start returning “account not found”?
3
0
840
Aug ’23
Get custom codes used in transaction receipt (renewable subscription)
Issue Currently I have multiple subscription offers available for yearly/monthly subscriptions. Each of the subscription offers have multiple different custom codes available. When the customer buys a subscription and the receipt is being handled in the backend, I need to know which of the custom codes was used. What I have tried When i call the https://buy.itunes.apple.com/verifyReceipt I get the values offer_code_ref_name and promotional_offer_id. The offer_code_ref_name is the subscription offer name AND NOT the custom code. I tried to get more info using the https://api.storekit.itunes.apple.com/inApps/v1/subscriptions/{transactionId} request, but it does not give me any info about the custom code used either. I do however see which custom code has been used if I go to Sales and Trends > Sales and Trends Reports and download Subscritpion Reports. There the offer code can be found ref. as "Promotional Offer ID" my question How can I get which custom code was used when purchasing a renewable subscription using transaction id or transaction Receipt?
1
0
436
Aug ’23
Subscription price and duration from server
Hey, Let's say I have configured in-app purchase subscription product configured. I have a server where I'm listening for App Store Server Notifications v2 (https://developer.apple.com/documentation/appstoreservernotifications/responsebodyv2) I'm able to decode payload and transaction information. Now I want to get information about how much customer paid for this product. how long this subscription lasts for. How I can achieve that from server? I see that there is subscriptionGroupIdentifier & offerIdentifier & storefrontId in response that I could potentially use to search for it, but I could not find any API that could help me from server side. Is it possible only from mobile? App Store Server API doesn't really helps me https://developer.apple.com/documentation/appstoreserverapi Regards, DL
1
0
573
Jul ’23