Apple Pay JS: onpaymentauthorized only getting isTrusted

I'm trying to get apple pay working with the JS integration, I've got my payment cert, merchant cert, and merchant id in place. I'm able to verify the merchant, click the checkout button, get the pay sheet and then verify the transaction.

But when I authorize the payment, the only thing that gets passed to session.onpaymentauthorized is

Code Block
{ "isTrusted": true }

There does not appear to be any payment property on the event.

I have tried re-creating a new merchantid/cert/processing cert, and the domain is verified.

Here's my boilerplate

Code Block
onApplePayButtonClicked() {
this.session = new ApplePaySession(1, testOrder);
this.session.onvalidatemerchant = (function (e) {
console.log(e);
const validationURL = e.validationURL;
this.apiClient.getApplepaySession({ url: validationURL }).then(x => {
this.session.completeMerchantValidation(x);
})
}).bind(this);
this.session.onpaymentauthorized = (function (e) {
console.log("onpaymentauthorized start");
console.log(JSON.stringify(e, null, 4));
this.apiClient.commitApplePay(e).then(() => {
this.session.completePayment(ApplePaySession.STATUS_SUCCESS);
console.log("onpaymentauthorized done");
})
}).bind(this);
this.session.begin();
}



Hi there..

Were you able to resolve this issue yet?
I am stumbling over the same issue with my ApplePay integration and was wondering if there is anything you found out?

Thanks!
Okay, just to run through a few things here:

1) You are able to see a valid payment session being passed into completeMerchantValidation here, correct:

Code Block Javascript
this.apiClient.getApplepaySession({ url: validationURL }).then(x => {
this.session.completeMerchantValidation(x);
})


2) You are able to authorize the payment either on iOS, macOS, or watchOS in some way and then see the callback hit for, correct:

Code Block Javascript
this.session.onpaymentauthorized { ... }


If all of this is true and you are not seeing any issues on your server with requesting a payment session then I would try to reproduce this issue on your macOS device and then record some logs in the Terminal while this is happening.

For example, in two terminals run each command below and try to reproduce the issue:

Code Block bash
% log stream --level debug --predicate 'process == "passd"'
% log stream --level debug --predicate 'subsystem == "com.apple.passkit”'


From there you should be able to review these logs and see what the issue is. There will be a lot of information in these logs but if there is an issue, it should be there.

Matt Eaton
DTS Engineering, CoreOS
meaton3@apple.com
Hi! @scaledfury

So after a lot of fiddling around, I observed that by sending the object's properties I needed on the server side extra, as opposed to passing the whole event object to the server, it worked!

So it seems somehow that javascript does not know how to resolve the object to properly send it via JSON to the server, so it just ignores it altogether..

Hope this helps!

Hi @srdevs!

Could you please elaborate more on what and how you managed it? It is so frustrating that so many people have issue with Apple Pay JS integration....

Looks like you are tryning to visualize event in this way:

session.onpaymentauthorized = function (event) {
  console.log(JSON.stringify(event))
}

this would shows only

{"isTrusted":true}

you can't stringify event: https://stackoverflow.com/questions/11547672/how-to-stringify-event-object

try visualize payment responce from envent directly:

console.log(JSON.stringify(event.payment))
Apple Pay JS: onpaymentauthorized only getting isTrusted
 
 
Q