I have done everything needed, I have it running on a verified domain with a SSL certificate, but it still always giving me payment not complete.
{
"epochTimestamp":1631532235832,
"expiresAt":1631535835832,
"merchantSessionIdentifier":"S--3",
"nonce":"6--6",
"merchantIdentifier":"DA--2E",
"domainName":"Company.com",
"displayName":"Company Name",
"signature":"4--0",
"operationalAnalyticsIdentifier":"B--E",
"retries":0
}
I have checked the epochTimestamp and expiresAt when I convert the epochTimestamp to time and date I get this date
epochTimestamp -----> Fri, 13 Mar 53671 22:50:32 +0000
CurrentDate -----> 13-Sep-2021 11:33:16
When you remove the last 3 digits from the epochTimestamp it gives the correct time. In my code it reaches CompleteMerchantValidation then cancels right after that
onPaymentAuthorized and everything else runs before the session even begins
Could it be that what I'm receiving from apple server is incorrect due to having something wrong with the certificates
applePayButton.addEventListener("click", function(){
const request = {
countryCode: 'US',
currencyCode: 'USD',
merchantCapabilities: [
'supports3DS'
],
supportedNetworks: [
'visa',
'masterCard',
'amex',
'discover'
],
lineItems: [{
label: 'Amount',
amount: 0.95,
},
{
label: 'Tax',
amount: 0.05,
}
],
total: {
label: 'Total',
amount: 10,
}
};
var session = new ApplePaySession(10, request);
session.begin();
try{
session.onvalidatemerchant = function(event){
printMessage("starting session.onvalidatemerchant" + JSON.stringify(event));
var promise = performValidation(event.validationURL);
promise.then(function(merchantSession) {
printMessage("Complete Merchant Validation: " + JSON.stringify(merchantSession));
session.completeMerchantValidation(merchantSession);
}).catch((error) => printMessage("OnCompleteMerchantValidation: " + error));
}
}
catch(error){
printMessage("On Validate Merchant Error: " + error)
}
try{
printMessage("onpaymentmethodselected");
session.onpaymentmethodselected = function(event) {
printMessage("In On Payment Method Selected");
//var myPaymentMethod = event.paymentMethod;
const update = {};
session.completePaymentMethodSelection(update);
};
}
catch(error){
printMessage("On Payment Method Selected Error: " + error)
}
try{
printMessage("onpaymentauthorized");
session.onpaymentauthorized = function(event) {
printMessage("starting session.onpaymentauthorized");
var applePaymentToken = event.payment.token;
printMessage("Token" + applePaymentToken);
// Define ApplePayPaymentAuthorizationResult
session.completePayment(session.STATUS_SUCCESS);
};
}
catch(error){
printMessage("On Payment Authorized Error: " + error)
}
try{
session.oncancel = function(event) {
printMessage("starting session.oncancel" + JSON.stringify(event));
// Payment cancelled by WebKit
};
}
catch(error){
printMessage("On Cancel Error: " + error)
}
These are the messages that comes when I start apple pay Session: Step 1: applePay working
Step 2: onpaymentmethodselected
Step 3: onpaymentauthorized
Step 4: starting session.onvalidatemerchant{"isTrusted":true}
Step 5: Complete Merchant Validation:
Step 6: starting session.oncancel{"isTrusted":true}