what I know so far is that I have to send a POST request to the apple server.
How or where can I get the merchIdentityCert cert and key??
NOTE: I'm going to send the post request from PHP
const options= {
url: endpointURL,
cert: merchIdentityCert,
key: merchIdentityCert,
method: 'post',
body:{
merchantIdentifier: "merchant.com.example.mystore",
displayName: "MyStore",
initiative: "web",
initiativeContext: "mystore.example.com"
},
json: true,
}
I figured how to connect to apple Servers and create the needed certificates for the POST request to work.
These steps must be done from a mac
Go to Apple Developer -> Create Certificate -> Apple Pay Merchant Identity
From your Mac go to KeyChain Access-> On the top right Select Keychain Access-> Certificate Assistant -> Request a Certificate From a Certificate Authority
Select Save to Disk & Let me specify key pair information
Key Size = 2048 bits / Algorithm = RSA
Upload the CSR to your Apple Pay Merchant Identity
Download the certificate given by Apple Pay and upload it to your Keychain Access
Export the certificate from Keychain Access as .p12 format
Open terminal direct it to the folder with the exported .p12 certificate
Run these commands "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"
$path = "yourPath/ApplePay.crt.pem"; $path_key = "yourPath/ApplePay.key.pem";
// create a new cURL resource $ch = curl_init();
$data = array( "merchantIdentifier" => "Your merchant Name", "displayName" => "Your Shop Name", "initiative" => "web", // If you're going to use it on the web "initiativeContext" => "Domain" );
$data = json_encode($data);
$header = array( 'Content-Type: application/json' );
curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_SSLCERT, $path); curl_setopt($ch, CURLOPT_SSLCERTPASSWD, ""); // For the Certificate Password curl_setopt($ch, CURLOPT_SSLKEY, $path_key); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
$serverOutput = curl_exec($ch);