Apple Pay

Apple Pay is a state-of-the-art, convenient and secure Apple’s payment method. A buyer binds once his card to a phone, and then during a payment he only confirms a payment using a fingerprint. This technology is supported in mobile applications and the Safari browser at iPhone, iPad, Apple Watch and latest MacBook devices.
The Apple Pay can be used with Visa and MasterCard cards and is available to all enterprises and private entrepreneurs, connected to the CloudPayments system without any additional agreements and with no modifications of working conditions.

Conditions of Use
You can use Apple Pay with the CloudPayments system on web sites and in mobile applications, if complying with Apple’s conditions of use:

  • You need your account in the Apple Developer software to register an individual Merchant ID.
  • Apple Pay cannot be used to pay for tobacco products, replications, goods for adults, purchase of virtual currency, replenishment of web wallets.
  • Apple Pay does not replace In App Purchase in mobile applications.
  • You shall adhere to Apple’s usage recommendations, see https://developer.apple.com/apple-pay/Apple-Pay-Identity-Guidelines.pdf
  • To use Apple Pay in order to get charitable donations, you shall be registered on the Benevity portal

ntegration
Apple Pay Merchant ID, certificates and domains
To use Apple Pay, you shall register your Merchant ID, generate a payment certificate, a certificate for web payments and confirm an ownership of web site domains where payments will be made.
Registration of Merchant ID:
1. Open the Apple Developer Account console, and then Certificates, IDs & Profiles -> Merchant IDs. Register a new Merchant ID:
o Enter any description to the Description field
o In the Identifier field specify your basic web site’s URL in the reversed order and add a «merchant» prefix. For example, if your basic web site’s URL is shop.domain.ru, then Identifier is equal to merchant.ru.domain.shop
2. Save a result.
Creation of Certificates:
1. Send an e-mail to support@cloudpayments.ru and specify a Merchant ID, which is registered in Apple. Our support service will generate two requests for certificates and will send you these by e-mail. This process takes no more than 10 minutes, but depending on a load can take the whole day.
2. Generate two certificates in the Apple Developer console: Payment Processing Certificate and Merchant Identity Certificate, and send them to our support service.
Confirmation) of Domains:
1. Add domains in the Apple Developer console for each web site where you want to accept payment via Apple Pay. Please note that web sites have to use of HTTPS and support TLS 1.2.
2. Confirm you own domains.
Acceptance of Payments via Apple Pay
A payment scheme includes 3 stages:

  • Verification of a device compatibility. If a device is supported, it is necessary to show the Apple Pay button to a buyer.
  • A payment authorization is a payment confirmation by a buyer by entering a code or using a fingerprint.
  • Payment processing. After an authorization, Apple generates an encrypted token which shall be sent to CloudPayments API.


Apple Pay in Mobile Applications
Use SDK PassKit from Apple to get a PaymentToken and the payment with cryptogram in API to make a payment.

//в примере используется библиотека jquery
//дополнительные скрипты прописывать не требуется, все объекты для платежей Apple Pay уже есть в браузере Safari

if (window.ApplePaySession) { //проверка устройства
    var merchantIdentifier = 'Ваш Apple Merchant ID';
    var promise = ApplePaySession.canMakePaymentsWithActiveCard(merchantIdentifier);
    promise.then(function (canMakePayments) {
        if (canMakePayments) {
            $('#apple-pay').show(); //кнопка Apple Pay
        }
    });
}
$('#apple-pay').click(function () { //обработчик кнопки
    var request = {
        // requiredShippingContactFields: ['email'], //Раскомментируйте, если вам нужен e-mail. Также можно запросить postalAddress, phone, name.
        countryCode: 'RU',
        currencyCode: 'RUB',
        supportedNetworks: ['visa', 'masterCard'],
        merchantCapabilities: ['supports3DS'],
        //Назначение платежа указывайте только латиницей!
        total: { label: 'Test', amount: '1.00' }, //назначение платежа и сумма
    }
    var session = new ApplePaySession(1, request);

    // обработчик события для создания merchant session.
    session.onvalidatemerchant = function (event) {

        var data = {
            validationUrl: event.validationURL
        };

        // отправьте запрос на ваш сервер, а далее запросите API CloudPayments
        // для запуска сессии
        $.post("/ApplePay/StartSession", data).then(function (result) {
            session.completeMerchantValidation(result.Model);
        });
    };

    // обработчик события авторизации платежа
    session.onpaymentauthorized = function (event) {

        //var email = event.payment.shippingContact.emailAddress; //если был запрошен адрес e-mail
        //var phone = event.payment.shippingContact.phoneNumber; //если был запрошен телефон
        //все варианты смотрите на сайте https://developer.apple.com/reference/applepayjs/paymentcontact

        var data = {
            cryptogram: JSON.stringify(event.payment.token)
        };

        //отправьте запрос на ваш сервер, а далее запросите API CloudPayments
        //для проведения оплаты
        $.post("/ApplePay/Pay", data).then(function (result) {
            var status;
            if (result.Success) {
                status = ApplePaySession.STATUS_SUCCESS;
            } else {
                status = ApplePaySession.STATUS_FAILURE;
            }

            session.completePayment(status);
        });
    };

    // Начало сессии Apple Pay
    session.begin();
});