https://developer.apple.com/documentation/appstoreserverapi/get_transaction_info
Is there a status code that can identify whether transactionid is in the sandbox or production environment?
App Store Server API
RSS for tagCall 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
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!! :)
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?
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.
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.
here is original thread
And I got a way to handle it:
By SDK upload introductory_price 😂
introductory_price > 0 that means it is Pay as you go or Pay up front
introductory_price = 0 means it is free trial
So here is another question, is there any api Apple could introduce for backend to query product price?
Looking forward to your response, sincerely!! :)
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?
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.
Hi,
We are using V2 App Store Server Notifications but can't figure out where to get the following subscription info:
the price of the subscription (can't find anywhere)
billing period duration e.g. "P1M" for monthly subscription
Google Play billing has these properties so we expect that these properties also exist in the app store.
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!! :)
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
Hi there,
i trying to get notifications use curl:
curl -X POST https://api.storekit.itunes.apple.com/inApps/v1/notifications/history -H "Authorization: Bearer 88z9....E0N3Q" -d "startDate=1685577600&endDate=1696118400"
but Apple returned 415 HTTP code that means "Unsupported Media Type"
What i do wrong?
Thanx!
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?
In the verifyReceipt API response, there is a "is_trial_period" field.
As detailed in WWDC 2023 the verifyReceipt is deprecated, how to fetch the fact that the subscription is during the free trial period via recommended App Store server APIs?
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”?
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?
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
How can I track on backend that the subscription has been cancelled? I didn't find notification type which handles this thing.
Hey i am trying to Link Zelle API with SWIFT Based Ecommerce Store , Getting error code 8889275440 , and 18889275440 , Am trying to track and put balance into users account as i receive the payment from user and post directly to his account when he tries to add funds , But getting the above two error codes
I am planning to use the Get Notification History API to receive refund notifications for consumable in-app purchases.
In order to receive notification data from this API, do I need to set up an HTTPS URL in App Store Connect to receive App Store Server Notifications?