alt

Important information

The API reference is now available here.
The deprecated API reference is available here.

Unzer

Apple Pay - Merchant validation

Overview

The SDK provides an adapter to simplify creating the Apple Pay Merchant Identity Certificate that is required for the Apple Pay Merchant Validation. If you want, you can also build the Merchant Validation Request by yourself.

Go to the Apple Pay integration guide for a detailed description of various requirements.

Prerequisite

  • Merchant Identity Certificate in the Apple Developer account.
  • Apple Pay prerequisites page.
  • The merchant_id.pem and the merchant_id.key file from the Generate a Merchant Identity Certificate section.

Apple Pay merchant validation request

The Controller for the validation request should be called by your shop frontend and provides the merchantValidationURL for the request.
The SDK provides the \UnzerSDK\Adapter\ApplepayAdapter class.

$applepaySession = new ApplepaySession('your.merchantIdentifier', 'ExampleTitle', 'your-domain.com');
$appleAdapter = new ApplepayAdapter();
$appleAdapter->init('/path/to/merchant_id.pem', '/path/to/merchant_id.key');

try {
    $validationUrl = 'https://apple-pay-gateway-cert.apple.com/paymentservices/startSession';
    $validationResponse = $appleAdapter->validateApplePayMerchant(
        $validationUrl,
        $applepaySession
    );
    
    print_r($validationResponse);
} catch (\Exception $e) {
    ...
}

\UnzerSDK\Adapter\ApplepayAdapter::validateApplePayMerchant calls the Apple Pay validation URL and returns the session Data in JSON format on success. This should be the response to your shop frontend.

Only the domains available in \UnzerSDK\Constants\ApplepayValidationDomains and listed by Apple, are allowed for this request.

Unlisted domains cause an ApplepayMerchantValidationException.

Arguments to ApplepayAdapter::init

ParameterTypeDescription
sslCert
(required)
stringPath to merchant identification certificate.
sslKey
(required)
stringPath to merchant identification key file. This is necessary if the SSL certificate file doesn’t contain key already.
caCertstringPath to CA certificate. Certificate should usually already be configured on server level. If this is not the case, or you need to use another one you can set it here.

Arguments to ApplepayAdapter::validateApplePayMerchant

The validateApplePayMerchant($merchantValidationURL, $applePaySession) method requires following parameters to perform the validation:

ParameterTypeDescription
merchantValidationURL
(required)
stringURL of the merchant validation request.
applePaySession
(required)
ApplepaySessionApplepaySession object containing Apple Pay session data.

Performing transactions

Performing transactions is similar to the other payment types. However, the Apple Pay workflow requires a response to the frontend, for example, in JSON that indicates the result of the transaction.

echo json_encode(['transactionResult' => $transaction->isSuccess()]);