agisboye / app-store-server-api

A Node.js client for the App Store Server API
MIT License
218 stars 36 forks source link

Sandbox Testing Not Working? #17

Closed pnostudiodeveloper closed 2 years ago

pnostudiodeveloper commented 2 years ago

Thanks for the great framework!

I am able to successfully look up Order IDs in the Production environment. Production environment seems to generally be working perfectly for preexisting order IDs from my real users.

I now need to test the purchase workflow for new purchases, which requires testing in the Sandbox environment.

When I switch the environment to Environment.Sandbox, and try to lookup a sandbox orderId, I then receive the following error on my server:

Error: {"message":"invalid json response body at https://api.storekit-sandbox.itunes.apple.com/inApps/v1/lookup/2000000087140012 reason: Unexpected end of JSON input","code":141} {"error":{"code":141,"message":"invalid json response body at https://api.storekit-sandbox.itunes.apple.com/inApps/v1/lookup/2000000087140012 reason: Unexpected end of JSON input"} error: invalid json response body at https://api.storekit-sandbox.itunes.apple.com/inApps/v1/lookup/2000000087140012 reason: Unexpected end of JSON input {"code":141,"stack":"FetchError: invalid json response body at https://api.storekit-sandbox.itunes.apple.com/inApps/v1/lookup/2000000087140012 reason: Unexpected end of JSON input\n at /app/node_modules/app-store-server-api/node_modules/node-fetch/lib/index.js:27

Here is the code I am using to lookup the Order ID:

`

const api = new AppStoreServerAPI(
  KEY, KEY_ID, ISSUER_ID, APP_BUNDLE_ID, Environment.Sandbox
);

const response = await api.lookupOrder(orderId);

//console.log(response);

console.log(response.status);

if (response.status === OrderLookupStatus.Valid) {
    const transactions = await decodeTransactions(response.signedTransactions);`

Could something have changed on Apple's end for Sandbox testing? Is the Sandbox Environment confirmed to currently be working in the framework?

Any advice or fixes would be very much appreciated!

Thank you

pnostudiodeveloper commented 2 years ago

I can see from Apple this endpoint is not available in the Sandbox environment.

https://developer.apple.com/documentation/appstoreserverapi/look_up_order_id

agisboye commented 2 years ago

That explains it. Have you had any trouble with the other endpoints in the sandbox environment?

pnostudiodeveloper commented 2 years ago

I'm trying to use Transaction History for my implementation now instead.

The call and response appears to be working in Sandbox.