Apple Pay Sandbox test cards with Payment Not Completed

Testing apple pay in our app is not working in the sandbox environment. When using a test card - the response returns with "Payment not completed". We've tested with these cards:


Discover: 6011 0009 9446 2780

11/2022


Visa: 4761 1200 1000 0492

11/2022


The code works fine in production but we'd like to have a sandbox environment for further testing. Has anyone encountered this?

There are a few things that can cause this; first, if your Apply Pay supportted regions is set to the United States, then you will need to test with American Express. Second, if you are not signed into a testing device with an iCloud account that supports a sandbox user.



Matt Eaton

DTS Engineering, CoreOS

meaton3 at apple.com

Hi Matt,

I use a sandbox account, I configured Settings>General>Language&Region>Region to US, I selected the region my sandbox account as US but I get the error "Could Not Add Card" when I try to add Discover card. Could you please help with that? Thank you.
I have had this issue more times than I care to count.

After several emails with people at Apple that didn't get me far (they acknowledged the issue likely was on their side), I tried creating a new sandbox Apple ID in App Store Connect and signed into iCloud on the device, and added the sandbox cards again, and this worked.

This suggested to me that the sandbox Apple IDs can somehow become corrupted or otherwise unusable for this purpose.
@Daniil Evsienko, are you signed out of your iCloud account and signed into your test device with your sandbox testing account?

If so, plug your device into your macOS workstation and open the Console.app and filter on your test device. When you try and add your test card and receive the error does it provide any other messages in the Console app that you can add here for debugging purposes?


Matt Eaton
DTS Engineering, CoreOS
meaton3@apple.com
@meaton we're having the same issue too - we can't get any test card to actually complete a payment when logged in as a test user. Is there any way to reliably test apple pay via a test user using test credit cards? We've tried about a dozen of the ones listed and always get back "Payment not completed".
Hi @Matt,

I am using a sandbox account and I have set United States in region column, I configured Settings>General>Language&Region>Region to US. I have added test cards (VISA and Master) and my cards is successfully activated. But I am trying pay then I got error "Payment Not Completed". I have tried many approaches like make other sandbox user, change devices regions as US, but error same. Note: I am trying from India. I don't know any issue with the country.

Could you please help with that? Thank you.
@Tarvinder Malhotra

A few things you can do here to debug this:

1) Make sure that you are correctly completing the Providing Merchant Validation steps outlined on the this page. Note that this includes getting an Apple Pay Payment session on your server and sending it back to your client side.

2) Make sure the your have a valid Apple Pay Session that you are passing into completeMerchantValidation to complete step 1.

3) Make sure you are authorizing the payment via one of the approved methods, i.e., Face ID, Touch ID, or a passcode. Note that Touch ID can be done directly on a macOS device while Face ID, Touch ID, or a passcode are done while a paired iOS or possibly watchOS device.


Matt Eaton
DTS Engineering, CoreOS
meaton3@apple.com
We have similar kind of issue, after passing the apple pay session to completeMerchantValidation() giving the error 'Payment not completed'  and the onpaymentauthorized() event not triggered and the touch id not shown in the payment sheet.
oncancel() triggered with {"isTrusted":true}. Any suggestion will be great

@Prashantha

These errors are a bit harder to track down, but when debugging this, there are a few things I recommend:

1) Make sure that the Payment Session your are passing into completeMerchantValidation is a valid formatted JSON object. I have seen this issue happen due to a malformed object sent back from the server.

2) Make sure you are testing with a Sandbox testing account if you are testing in a Sandbox environment:

<https://developer.apple.com/apple-pay/sandbox-testing/>

3) If you hit a wall here you a log out was passd is giving when you reproduce the error. For example, try testing in Safari on macOS; try opening two terminals and run each of these commands in a separate Terminal:

$ log stream --level debug --predicate 'process == "passd"'
$ log stream --level debug --predicate 'subsystem == "com.apple.passkit”'

Then open Safari and reproduce the error on macOS. The error should be in one of these two logs from the Terminal and should lead you in the right direction to track this down.

Matt Eaton
DTS Engineering, CoreOS
meaton3@apple.com
Hi Matt from Apple - your URL isn't valid.
@FireFish

Thank you for finding that typo. There was an extra semicolon for some reason at the end of the URL. Here is the correct URL for Sandbox Testing.


Matt Eaton
DTS Engineering, CoreOS
meaton3@apple.com
@Matt,
I would suggest Apple to rethink about Apple Pay integration/testing process. It is clearly visible from many raised questions that a lot of developers have issues with Apple Pay integration/testing for website.

I tried to use terminal logs to have more data, but your proposed second line gives error:

command: log stream --level debug --predicate 'subsystem == "com.apple.passkit”'

response: log: Bad predicate (Unable to parse the format string "subsystem == "com.apple.passkit”"): subsystem == "com.apple.passkit”

Thanks!
@Matt,
I found the type that caused error (marked in bold): log stream --level debug --predicate 'subsystem == "com.apple.passkit'

@Matt,
could you please help to understand what might be the issue? This is what I got from log information you suggested to use:

com.apple.PassKit.PaymentAuthorizationUIExtension: (PassKitCore) [com.apple.passkit:Payment] Evaluating merchant session using PROD trust policy.
com.apple.PassKit.PaymentAuthorizationUIExtension: (PassKitCore) [com.apple.passkit:Payment] Application failed to provide a valid merchant session. We can't proceed to authorize the transaction.

But in JSON response I got:
Code Block
"epochTimestamp":1621947760916,"expiresAt":1621951360916,"merchantSessionIdentifier":"SSH4C2B96FDBEB64F25BE4EFDFDAAD51803_916523AAED1343F5BC5815E12BEE9250AFFDC1A17C46B0DE5A943F0F94927C24","nonce":"8c15c0d9","merchantIdentifier":"BAF57BA4113......2728DB39845","domainName":"xxxxx.xx","displayName":"XXXXXX","signature":"308...............000000000000","operationalAnalyticsIdentifier":"xxxxxx:BAF57BA.........39845","retries":0}


Tests are made with test account and with test card ending xxxx 5996.

Thanks.


@Raimonds

I found the type that caused error (marked in bold)
could you please help to understand what might be the issue? This is what I got from log information you suggested to use:

Application failed to provide a valid merchant session. We can't proceed to authorize the transaction.

This is exactly as it sounds, when the Merchant Session was passed it into session.completeMerchantValidation(merchantSession); it failed validation. The why here is the hard part as there are many reasons this can happen. Typically, if your Merchant Identity Formatting is bad then the request will fail on your server when the session is requested. Instead I would focus on one of the following as the root cause:
  1. A mis-match between the Apple Pay domain that you requested a session for and the domain that you are validating the session on the client side from. For example pay.mydomainA.com requested the session on the server and pay.mydomainB.com is completing and validating the session on the client side.

  2. You are accidentally using a test user in a production system and the production validation that is tied to the Merchant Session is failing.

  3. The transaction was not successfully authorized by a user.


Matt Eaton
DTS Engineering, CoreOS
meaton3@apple.com
Apple Pay Sandbox test cards with Payment Not Completed
 
 
Q