norfolkmustard / ApplePayJS

Working draft of ApplePayJS with php
GNU General Public License v3.0
144 stars 60 forks source link

ApplePayJS

Working draft of ApplePayJS with php

using the apple reference pages here https://developer.apple.com/reference/applepayjs

To check if your site is using one of the supported cipher suites https://developer.apple.com/reference/applepayjs#2166536

use https://www.ssllabs.com/ssltest/

here's how to do the last bit..

In that third section "Apple Pay Merchant Identity"...

it's this xxx.p12 file which you then use openssl in terminal.app on your mac ......

openssl pkcs12 -in ApplePayMerchantIdentity_and_privatekey.p12 -out ApplePay.crt.pem -clcerts -nokeys
openssl pkcs12 -in ApplePayMerchantIdentity_and_privatekey.p12 -out ApplePay.key.pem -nocerts

...to create two .pem files. Remember the password you're asked to create when you extract ApplePay.key.pem above. You'll need to add this to apple_pay_conf.php. These are the two files your webserver will use to authenticate its conversations with Apple, requesting a session etc for each ApplePay transaction your customers make.

If at all possible, keep these two .pem files outside your root/public web folder. e.g. if your root web folder is /var/www/html/ then store these in /var/www/applepay_includes and include(); them in your php script.

Throughout index.php I've sprinkled loads of console.log(). Plug your iphone into your Mac, goto your applepay test page on safari on your iPhone. Goto Safari on your Mac and select your iPhone from the Develop menu in Safari - voila - you now see what your phone's safari browser is telling you via the javascript console.

If you don't see your connected iPhone in the develop menu in safari on your Mac then it may not have been enabled. On the iPhone, go to Settings > safari > advanced > web inspector > enable

Make sure safari on the iphone is the active app, then, on the connected (with a cable) mac go to Safari > develop > {your iPhone}

Remove the logit() lines in index.php (or set debug to false in apple_pay_conf.php) once you see how it all works and before you go-live with it.