session.onvalidatemerchant = function(event) {
const validationURL = event.validationURL;
console.log("Validation URL:", validationURL);
document.getElementById('methodapplepay').value = "validate";
document.getElementById('validationURL').value = validationURL;
$.ajax({
url: 'ajax/processInternalDonate.php',
type: 'POST',
data: $("#payment_form").serialize(),
success: function(dataValidate) {
dataValidate = JSON.parse(dataValidate);
session.completeMerchantValidation(dataValidate);
},
error: function(xhr, status, error) {
console.error('Merchant validation failed:', error);
session.abort();
}
});
};
session.onpaymentauthorized = function(event) {
var payment = event.payment;
$.ajax({
url: 'ajax/processInternalDonate.php',
type: 'POST',
data: {pay_mode:"pay_mode",method:"process_payment",payment:JSON.stringify(payment)},
success: function(dataprocess) {
if (dataprocess.success) {
session.completePayment(ApplePaySession.STATUS_SUCCESS);
} else {
session.completePayment(ApplePaySession.STATUS_FAILURE);
}
},
error: function(xhr, status, error) {
console.error('Payment processing failed:', error);
session.completePayment(ApplePaySession.STATUS_FAILURE);
}
});
};
from this above two session methods for the first method I got the merchant validation response from the API calling from that method but for the session.onpaymentauthorized when the second API is calling then I got the message payment not processed on my apple pay popup upon autorisation from my phone so I want that you provide me the correct backend flow for this API calling so we get the amount charged and I also got the payment object from event.object on logging in my console.
Apple Pay on the Web
RSS for tagApple Pay on the Web allows you to accept Apple Pay on your website using JavaScript-based APIs.
Posts under Apple Pay on the Web tag
135 Posts
Sort by:
Post
Replies
Boosts
Views
Activity
I can't pay for my apple developer membership, I tried to reach apple support team and apple developer many times. Apple support says I need to contact developer team and after contacting developer team, I'am not getting any response.
Topic:
Developer Tools & Services
SubTopic:
Apple Developer Program
Tags:
Beta
Developer Tools
Apple Pay on the Web
We are trying to retrieve merchant tokens from ApplePay. We used the javascript codes from Apple Pay demo site to request for a recurring payment from the frontend.
"recurringPaymentRequest": {
"paymentDescription": "A description of the recurring payment to display to the user in the payment sheet.",
"regularBilling": {
"label": "Recurring",
"amount": "4.99",
"paymentTiming": "recurring",
"recurringPaymentStartDate": "2023-08-11T11:20:32.369Z"
},
"trialBilling": {
"label": "7 Day Trial",
"amount": "0.00",
"paymentTiming": "recurring",
"recurringPaymentEndDate": "2023-08-11T11:20:32.369Z"
},
"billingAgreement": "A localized billing agreement displayed to the user in the payment sheet prior to the payment authorization.",
"managementURL": "https://applepaydemo.apple.com",
"tokenNotificationURL": "https://applepaydemo.apple.com"
}
Payment was successful, but merchantTokenIdentifier is not shown in the in decrypted ApplePay token, regardless of test card used. We tried Visa and MasterCard.
I am using a sandbox account, and I set United States in the region column (Settings>General>Language & Region>Region to US). I added test cards like (American Express and Visa) and the cards added successfully.
But I am trying to pay then I get an error like "Payment Not Completed".
Note: I am trying from India.
Please let me know what exactly i am doing mistake here
Following code i am using.
function onApplePayButtonClicked() {
if (!ApplePaySession) {
return;
}
// Define ApplePayPaymentRequest
const request = {
"countryCode": "US",
"currencyCode": "USD",
"merchantCapabilities": [
"supports3DS"
],
"supportedNetworks": [
"visa",
"masterCard",
"amex",
"discover"
],
"total": {
"label": "Demo (Card is not charged.)",
"type": "final",
"amount": "1.99"
}
};
// Create ApplePaySession
const session = new ApplePaySession(3, request);
session.onvalidatemerchant = event => {
// Call your own server to request a new merchant session.
var merchantSession = merchantValidation(event.validationURL);
session.completeMerchantValidation(merchantSession);
};
session.onpaymentmethodselected = event => {
// Define ApplePayPaymentMethodUpdate based on the selected payment method.
// No updates or errors are needed, pass an empty object.
const update = {};
session.completePaymentMethodSelection(update);
};
session.onshippingmethodselected = event => {
// Define ApplePayShippingMethodUpdate based on the selected shipping method.
// No updates or errors are needed, pass an empty object.
const update = {};
session.completeShippingMethodSelection(update);
};
session.onshippingcontactselected = event => {
// Define ApplePayShippingContactUpdate based on the selected shipping contact.
const update = {};
session.completeShippingContactSelection(update);
};
session.onpaymentauthorized = event => {
// Define ApplePayPaymentAuthorizationResult
const result = {
"status": ApplePaySession.STATUS_SUCCESS
};
session.completePayment(result);
};
session.oncouponcodechanged = event => {
// Define ApplePayCouponCodeUpdate
const newTotal = calculateNewTotal(event.couponCode);
const newLineItems = calculateNewLineItems(event.couponCode);
const newShippingMethods = calculateNewShippingMethods(event.couponCode);
const errors = calculateErrors(event.couponCode);
session.completeCouponCodeChange({
newTotal: newTotal,
newLineItems: newLineItems,
newShippingMethods: newShippingMethods,
errors: errors,
});
};
session.oncancel = event => {
// Payment canceled by WebKit
};
session.begin();
}
Hi,
I understand that it's possible to add a virtual debit or credit card from a mobile app into the iOS Wallet using PassKit from the Apple SDK. However, I haven't come across documentation on how to achieve this directly from a web app. I found this article on Apple's support site (https://support.apple.com/en-gb/guide/security/secdc2567239/web), which mentions adding cards from a card issuer’s website, but it doesn’t provide details on the process.
Could you please confirm if it's possible to add a card directly from a web app without using a mobile app? If so, could you guide me to the relevant documentation?
Thanks in advance!
Hello everyone,
**I created a certificat using openssl using the steps below **
Generate a Certificate Signing Request (ecccertreq.csr)
Generate key pair in a key file
Code
openssl ecparam -genkey -name prime256v1 -out ecckey.key
Generate CSR from key pair in key file
Code
openssl req -new -sha256 -key ecckey.key -out ecccertreq.csr -subj '/O=Nahdi Merchant Identity'
Upload the Payment Processing Certificate CSR
Download the Apple signed Payment Processing Certificate
The certificate file (apple_pay.cer) appears in my Downloads folder
Generate the .p12 file (ecckeystore.p12)
Convert apple_pay.cer to PEM
Code
openssl x509 -inform DER -in apple_pay.cer -out apple_pay.pem
Import merchant certificate and private key to generate .p12
Code
openssl pkcs12 -export -out ecckeystore.p12 -inkey ecckey.key -in apple_pay.pem
But I am getting this error when testing using the curl_test.php file and also when trying to make a payment on our website, we already have a working certificat for another merchant id and we don't get the same error
Verbose info:
cURL Error
56 - OpenSSL SSL_read: error:14094418:SSL routines:ssl3_read_bytes:tlsv1 alert unknown ca, errno 0
Verbose information
* Trying 17.141.128.71:443...
* TCP_NODELAY set
* Connected to apple-pay-gateway.apple.com (17.141.128.71) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
* CAfile: /etc/ssl/certs/ca-certificates.crt
CApath: /etc/ssl/certs
* SSL connection using TLSv1.3 / TLS_AES_128_GCM_SHA256
* ALPN, server accepted to use http/1.1
* Server certificate:
* subject: businessCategory=Private Organization; jurisdictionC=US; jurisdictionST=California; serialNumber=C0806592; C=US; ST=California; L=Cupertino; O=Apple Inc.; CN=apple-pay-gateway.apple.com
* start date: Jul 24 19:05:42 2024 GMT
* expire date: Oct 22 19:15:42 2024 GMT
* subjectAltName: host "apple-pay-gateway.apple.com" matched cert's "apple-pay-gateway.apple.com"
* issuer: C=US; O=Apple Inc.; CN=Apple Public EV Server RSA CA 1 - G1
* SSL certificate verify ok.
> POST /paymentservices/paymentSession HTTP/1.1
Host: apple-pay-gateway.apple.com
Accept: */*
Content-Length: 131
Content-Type: application/x-www-form-urlencoded
* upload completely sent off: 131 out of 131 bytes
* OpenSSL SSL_read: error:14094418:SSL routines:ssl3_read_bytes:tlsv1 alert unknown ca, errno 0
* Closing connection 0
code-block
Topic:
App & System Services
SubTopic:
Apple Pay
Tags:
Apple Pay on the Web
Signing Certificates
Apple Pay
when i integrate apple pay to our website, i pass `ApplePayPaymentRequest
` like this:
const paymentRequest = {
countryCode,
currencyCode,
merchantCapabilities,
supportedNetworks,
total: {
label: "Demo (Card is not charged)",
amount: totalAmount,
type: "final",
},
requiredBillingContactFields: [
"postalAddress",
],
requiredShippingContactFields: [
"postalAddress",
],
shippingContact: {
addressLines: ['402 Vinnie Brooks Suite 707'],
administrativeArea: "NB",
country: "Canada",
countryCode: "CA",
emailAddress: "qqq@qq.com",
familyName: "gfhh",
givenName: "dfg",
locality: "W*********h",
phoneNumber: "6******7",
postalCode: "M*****4",
},
};
but when apple pay sheet show, the shippingContact dispaly like this (it just show user name, not show the details):
should i do what in order to display the details of the shippingContact, please help me. Thanks.
调用 API 时,返回以下错误:Apple Pay 处理证书、Apple Pay 商家身份证书和商家域均已设置
{
“statusMessage”: “支付服务异常 merchantId=1A9569E9792DB13B9BEE22EDB30515DE75D512B91A2C86C54D4065AD1ECC712E 未经授权代表 merchantId=4D08091EACD9C0D2E25CB94895D1B0DAE73970D6A517EF2988D6D929D1336DA1 reason=4D08091EACD9C0D2E25CB94895D1B0DAE73970D6A517EF2988D6D929D1336DA1 不是 WWDR 的注册商家,也没有通过 Mass Enabling 获得适当授权。
“状态代码”: “417”
连接到主机的 #0 apple-pay-gateway.apple.com 完好无损
}
I am currently testing Apple Pay integration on my sandbox environment and I am in need of test cards for failed cases such as insufficient balance. Does anyone have access to or know where I can find Apple Pay test cards specifically for scenarios where transactions fail due to reasons like insufficient balance? Any help or guidance on this matter would be greatly appreciated. Thank you.
I am getting error while await applePayClient.PostAsJsonAsync(validationUrl, validationPayload)
I am testing it on local machine. Am I even can test this on local machine or not?
Error: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host..
validationUrl: https://apple-pay-gateway.apple.com/paymentservices/startSession
JS
C# code:
var applePayClientHandler = new HttpClientHandler
{
SslProtocols = System.Security.Authentication.SslProtocols.Tls12 | System.Security.Authentication.SslProtocols.Tls13
};
var applePayClient = new HttpClient(applePayClientHandler);
var merchantId = "merchant.com.xxxxxx.sandbox";
var _displayName = "Sandbox";
var domainName = "xxxxxx.co";
var validationUrl = request.ValidationURL;
var validationPayload = new
{
MerchantIdentifier = merchantId,
DisplayName = _displayName,
Initiative = "web",
InitiativeContext = domainName
};
try
{
var response = await applePayClient.PostAsJsonAsync(validationUrl, validationPayload);
var merchantSession = await response.Content.ReadAsStringAsync();
return merchantSession;
}
catch (HttpRequestException httpEx)
{
// Log detailed HTTP request/response information
Console.WriteLine($"HttpRequestException: {httpEx.Message}");
if (httpEx.InnerException != null)
{
Console.WriteLine($"InnerException: {httpEx.InnerException.Message}");
}
throw;
}
Topic:
App & System Services
SubTopic:
Apple Pay
Tags:
Apple Pay on the Web
Apple Pay
Tap to Pay on iPhone
Hi.
About to start integrating Apple Pay for the first time. Other gateways I've integrated have a limit from the initial authorisation, above which you can't capture payment. E.g. customer authorizes £100, but then adds items to their order taking the value to £120. Is there such a limit with Apple Pay? Is there a workaround without having to contact the customer again.
Jon
Hello,
I've recently created a merchant ID and added two domains to it. I placed the verification .txt files in the right place (under the .well-known dir) and both verified successfully and show as such in the merchant id setup page.
I am intermittently getting the following error:
{
"statusMessage": "Payment Services Exception merchantId=XXXXX not registered for domain=my.domain.com",
"statusCode": "400"
}
(merchantId and domain have been masked in the above error) -- What's odd is that this is intermittent -- It'll work fine, and then stop and start giving the above error, and then start working fine again, with no intervention from me.
Some context: This is a single server application, so it's not like we've got a server out of sync somewhere.
Thoughts?
Any thoughts?
I'm attempting to add a sandbox user to test web Apple Pay. Accessing Users and Access -> Sandbox gives me more often than not the error: "Something went wrong. Try again later." Attempting to add a new tester gives me the same error. I've been trying this since yesterday, so it's more than a transient error.
Details at Stack Overflow
We're trying to enable Apple Pay on the Web for a web application of ours, but getting this error when trying to construct the PaymentRequest object:
TypeError: Type error: PaymentRequest@[native code] startApplePay@https:-myurl-:319:47 onclick@https://-myurl-:606:14:undefined
Hello there,
I have a couple of question about Apple Pay guidelines:
• if we offer Apple Pay payment method in our app, can we disable the selection (I mean the method selection NOT the Payment button!) IF certain condition happens? E.g. the user cannot select apple pay payment method because our basket is not ready yet.
• Are we forced to move the apple pay payment method on the top of our selection? E.g. Cards, Cash On Delivery, Coupon, Apple Pay --> Apple Pay, Cards, Cash On Delivery, Coupon
One last technical question:
• when we start the payment process we are gonna create the request and present the sheet BUT we have to call our backend for pre-authorization, is it allowed?
@objc private func applePayButtonTapped(sender: UIButton) {
// TODO: Is it allowed?
// We need to ask to our backend a pre-authorization and THEN procced with Apple Pay flow
// but this could be done ONLY after the user TAP on BUY with APPLE PAY and BEFORE
// paymentAuthorizationViewController is called.
// Are we compliant to do that?
if PKPaymentAuthorizationViewController.canMakePayments(usingNetworks: FakeData.paymentInfo()) {
let request = PKPaymentRequest()
request.blablabla = blabla
let authorizationViewController = PKPaymentAuthorizationViewController(paymentRequest: request)
if let viewController = authorizationViewController {
viewController.delegate = self
present(viewController, animated: true, completion: nil)
}
}
}
Thanks in advance :)
Hi,
I'm adding deferredPaymentRequest container to get MPan, but payment is now cancelled by Webkit, no other explanation
What is the next step to get mpan ?
Regards,
Louis
"deferredPaymentRequest": {
"deferredBilling": {
"label": "Deferred Payment",
"amount": "1.99",
"type": "final",
"paymentTiming": "deferred",
"deferredPaymentDate": "2024-06-1",
},
"managementURL": 'https://.../apmsim/pay/appleManagement',
"paymentDescription": "this is a paymentDescription",
}
Hello team ,
We have created a sandbox tester and added all the setting as per the guidelines but the sandbox tester account is blocked from adding the test card . All the test cards show as invalid card .
We are not able to able to add wallet from iCloud .
We are not able to sign into iTunes with the sandbox tester account .
Please help on how to resolve this .
Thanks in Advance
I have a Developer account with a Developer Role, although apparently without the stated ability to create my own Sandbox ID. So, our company's Administrator is trying to create one for me.
But each time he enters a new icloud.com address to create one, he gets the error,
"Your Apple ID or password was entered incorrectly."
(The example at the above link uses icloud.com, and that seems the natural place to do this. I'm assuming that since you can't actually create an icloud.com email without an Apple ID, that this sandbox creation process should be ok with the email not existing yet.)
Hi,
We are integrating with Apple Pay via Stripe. Payment works as expected and is shown as successful in the Stripe dashboard. Our Frontend and Backend have verified the payment and decided it is successful as well. But the Apple Pay UI shows "Payment not completed". Any tips on how to troubleshoot this please?
best,
Chandru
does anyone have an example of the decrypted payload for an interac payment would look like? Couldnt find an example within the apple documentation