💸 A middleware for Express which can be used to serve the Payment Request API.
A middleware for Express which can be used to serve the Payment Request API.
Hey, you. Yes you.
Don’t use this for anything. It’s currently highly experimental and most likely doesn’t do what you’d like it to.Check back soon though. ;)
Using yarn
:
yarn add express-payment-request
To authenticate Apply Pay payment requests using express-payment-request
, transactions between the express
middleware and Apple Pay must be properly signed using the Apple Pay Merchant Identity Certificate.
E-Mail Address
, CA Email Address
(this can be the same as the Email Address
), and set the Common Name
to something memorable, like “Apple Pay 2048 RSA”.merchant_id.csr
generated by Apple.password
that you’ll want to use for the certificate you’ll be using to sign your mutual TLS with Apple Pay.password
you decided on at the beginning of this section.private.p12
.At this stage, your RSA certificate for secure TLS transactions between your server and Apple Pay has been recognized, and you have merchant_id.cer
and your private.p12
on the desktop.
Before going onto the next section, be sure you have OpenSSL installed. You can verify it exists by executing openssl -v
in your Terminal.
merchant_id.cer
into a .p12
certificate.On your Desktop, execute the following commands:
# generate .pem
openssl x509 -in merchant_id.cer -inform DER -out merchant_id.pem -outform PEM
# generate .key (requires access password)
openssl pkcs12 -in private.p12 -nodes -out private.key -nocerts
# generate p12
openssl pkcs12 -export -out merchant_id.p12 -inkey private.key -in merchant_id.pem
The resulting file merchant_id.p12
can now be used to sign transactions with Apple Pay.
To verify the correctness of your certificate, you can use cURL
:
curl --data '{"merchantIdentifier":"your.merchant.identifier","domainName":"yourdomainname.com","displayName":"MyStore"}' --cert-type P12 --cert ~/Desktop/merchant_id.p12 --pass "your-password-here" https://apple-pay-gateway.apple.com/paymentservices/startSession -v
Upon success, curl should print a valid payment nonce negotiated with Apple Pay. 🚀