Page tree
Skip to end of metadata
Go to start of metadata





RU  UA  EN

Apple Pay

The easiest way to pay in web-stores and app with Apple Pay



Apple Pay - is a mobile payment and digital wallet service by Apple Inc. that allows users to make payments in iOS apps, and on the web without having to enter their payment details each time.  It is supported on the iPhone, Apple Watch, iPad and Mac.


 Easy and fast way to get payments from customers

  Easy and quick integration with your website or mobile app

 Connection without additional integrations via the WayForPay page

 Ability of direct integration Apple Pay payment method on website or mobile app

 Convenient payment method for Apple devices owners

 Payment security




How it works?

For quick and easy payment, it is enough to have payment cards added in Apple Wallet





1. Customer adds a payment card to Google Pay account


2. To finish the purchase just select previously added payment card in Apple Pay and confirm payment 



3. Seller will receive payment notification





Integration

Apple Pay connection is possible via the WayForPay payment page or via Google Pay API

Apple Pay s available to all shops/merchants connected to the WayForPay system without additional agreements and operations





Connection via the page WayForPay

With this method, there is no need for additional integrations. The Apple Pay button will be displayed on WayForPay payment page.

If you are already registered in WayForPay, the payment method will be enabled automatically. You can manage payment methods in your Personal Account, in the "Payment Methods" menu.


Connection with Google Pay API    

With this integration a button Apple Pay can be added to your website without any additional forms. In this case, you will need to go through the connection procedure and other checks. A website or a mobile application must meet certain requirements. Your website should use HTTPS and support TLS 1.2. 



Connection with Apple Pay API  

Direct connection allows you to display the Apple Pay button on the website or in a mobile application.

To use Apple Pay technology with direct integration, must be observed the following terms of use from Apple:


 Availability of account registration in the program Apple Developer. In which you need to register an individual Merchant ID.

 Prohibited uses Apple Pay for tobacco products, replicas, products for adults, the purchase of virtual currency, to replenish wallets.

 Recommendations for use and branding


Necessary steps to use Apple Pay:


1. Register a Merchant ID

In the Apple Developer Account console,go to the section «Certificates, IDs & Profiles», after «Merchant IDs» and register a new Merchant ID: in the Description field specify description; in the Identifier field must be specified the domain name of your site in the reverse order with the addition of «merchant» in the beginning (for example, the site shop.ua, the Identifier will look like - merchant.ua.shop).

  

2. Create a certificate

Write a letter on support@wayforpay.com  with your Merchant ID registered in the Apple Developer Account. 

The support team will generate a certificate and send  it to you with return letter. Next, in the Apple Developer console, create an Apple Pay Payment Processing Certificate and transfer it to our support team.

3. Confirm Domain

In the Apple Developer Account console,  add domains for each site where you will receive payments through Apple Pay. Sites should work under the HTTPS scheme and support the TLS 1.2 protocol.


Confirm domain ownership.




 Apple Pay direct integration on website


The implementation consists of the client part (javascript) and server.

1.Verify payment options using Apple Pay

Checking supports the device or the browser Apple Pay payment, and check has been added payment card to the Wallet.

if (window.ApplePaySession) {
    var promise = ApplePaySession.canMakePaymentsWithActiveCard({YOUR_MERCHANT_ID});
    promise.then(function(canMakePayments) {
        if (canMakePayments)
            //карта привязана, можно запускать сессию
    });
} else {
    //невозможно оплатить
}


2. Payment structure formation for the session

Specify the name of the product/service, the amount and currency of payment. Create a new payment session.

document.getElementById("apple-pay-button").onclick = function(event) {
    var paymentRequest = {
        currencyCode: 'UAH',
        countryCode: 'UA',
        total: {
            label: {PRODUCT_NAME},
            amount: {PAYMENT_AMOUNT}
        },
        merchantCapabilities: ['supports3DS'],
        supportedNetworks: ['masterCard', 'visa']
    };

var session = new ApplePaySession(3, paymentRequest);  



3. Validate the merchant

To check the possibility of payment for your merchant identifier and obtain the necessary data for making a payment, you need to create a data structure.

Also execute a request for payment in WayForPay using the Charge API and process the received response from the system.

session.onvalidatemerchant = function(event) {
    var promise = validateMerchant(event.validationURL);
    promise.then(function(merchantSession) {
        session.completeMerchantValidation(merchantSession);
    });
}

function validateMerchant(validationURL) {
    return new Promise(function(resolve, reject) {
        var applePayPayload = {
            'merchantId': {YOUR_MERCHANT_ID},
            'validationURL': {YOUR_VALIDATION_URL},
            'body': {
                'merchantIdentifier': {YOUR_MERCHANT_ID},
                'domainName': {YOUR_DOMAIN_NAME},
                'displayName': {PRODUCT_NAME}
            }
        };

        var xhr = new XMLHttpRequest();
        xhr.onload = function() {
            var data = JSON.parse(this.responseText);
            resolve(data);
        };
        xhr.onerror = reject;
        xhr.open('POST', merchantValidationEndpoint, true);
        xhr.setRequestHeader('Content-Type', 'application/json;charset=utf-8');
        xhr.send(JSON.stringify(applePayPayload));
    });
}


4. Запускаем сессию и обрабатываем оплату

session.onpaymentauthorized = function(event) {
    //после получения токена передаем его в wayforpay

    session.completePayment(ApplePaySession.STATUS_SUCCESS);
}

session.begin();


Example js code:

js code example:
//в примере используется библиотека 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: 'UA',
        currencyCode: 'UAH',
        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
        };

        // отправьте запрос на ваш сервер
        // для запуска сессии
        $.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)
        };

        //отправьте запрос на ваш сервер, а далее выполните запрос Charge api wayforpay.com
        //для проведения оплаты
        $.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();
});


Sample dataset sent by Charge wayforpay API

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42

{
"apiVersion":1,
"transactionType":"CHARGE",
"merchantAccount":"test_merch_n1",
"merchantDomainName":"www.ggg.com",
"orderReference":"A550500763641",
"orderDate":1550500763,
"amount":1,
"currency":"UAH",
"productName":[
"dung W100F",
"Sdung d 7.0 Black"
],
"productPrice":[
21.1,
30.99
],
"productCount":[
1,
2
],
"clientFirstName":"Kgwed",
"clientLastName":"Antnd",
"clientCountry":"UKR",
"clientEmail":"rob@mail.com",
"clientPhone":"380612527744",
"clientIpAddress":"127.0.0.1",
"merchantSignature":"cdd678b727be03c6810f98a551a3faa0",
"merchantTransactionType":"SALE",
"merchantTransactionSecureType":"NON3DS",
"applePayString":"{"version":"EC_v1","data":"tB2ubO0fbh39SWRNB9HUEo1XjbSz65PjJl1z6VunEcIES1aLamgmdhkWRqFLcucGH5cO21magwmOXqCjip1xX83LM9okiyRXe2Rssmrb5by5OkHZeafSioqaq0n7IjDqPTu0gwtwAzpqe+0gfSnDa+M0hVWcbxe7FgXhQxLQCa7vGVbzI+d9R4Y3PdPPVIWNW9i09McNZ4Sc5xqGbHEgJ28z0K/3s2yR0O82mlxBe5SSvfTcf7rlSNBdmDq8xMYSapjv3U5YmBBAErxdaAU7bWmvEGkjONCiBJUHQzwqEhQDAnivKRTI/LiSfMs3Vv53+Vk6FHGc6DxiAClmAXBxu+Z2W+iTlzI8LYzZb4PNc6F691Ca7kfF7YIsRY+qb/rgKwsaFfHqi26cUoEV","signature":"MIAGCSqGSIb3DQEHAqCAMIACAQExDzANBglghkgBZQMEAgEFADCABgkqhkiG9w0BBwEAAKCAMIID4jCCA4igAwIBAgIIJEPyqAad9XcwCgYIKoZIzj0EAwIwejEuMCwGA1UEAwwlQXBwbGUgQXBwbGljYXRp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6+8ZyBXkK3ifiY95tZn5jVQQ2PnenC/gIwMi3VRCGwowV3bF3zODuQZ/0XfCwhbZZPxnJpghJvVPh6fRuZy5sJiSFhBpkPCZIdAAAxggGMMIIBiAIBATCBhjB6MS4wLAYDVQQDDCVBcHBsZSBBcHBsaWNhdGlvbiBJbnRlZ3JhdGlvbiBDQSAtIEczMSYwJAYDVQQLDB1BcHBsZSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTETMBEGA1UECgwKQXBwbGUgSW5jLjELMAkGA1UEBhMCVVMCCCRD8qgGnfV3MA0GCWCGSAFlAwQCAQUAoIGVMBgGCSqGSIb3DQEJAzELBgkqhkiG9w0BBwEwHAYJKoZIhvcNAQkFMQ8XDTE5MDIxNTEwMzMyNVowKgYJKoZIhvcNAQk0MR0wGzANBglghkgBZQMEAgEFAKEKBggqhkjOPQQDAjAvBgkqhkiG9w0BCQQxIgQgDARTlPaUQwgOAWGrBpdkYCh+Yt9PR+QNrJML+rsAliowCgYIKoZIzj0EAwIERzBFAiEA9pKsQLRkwftlXnmLkTCrmFMyvi+biVCtCpizmzWoMwECIFi3+v7qhI/o/RKUbhYR6JoBUm1GswjzXhIXZiGcMq58AAAAAAAA","header":{"ephemeralPublicKey":"MFkwDQgAE88rVlkeu4xpPqMWDw59BRYO+zqqlCjcfLO3mE0/S9xhKZJfmIEcJlxtDJ1hwQ+U2L+HF7OJXL+WMsGHA==","publicKeyHash":"eUhXLM2/Z05nnAcntk0tjzFBzHgqJarnBDnovx5WMkc=","transactionId":"9845723470cc9722355763fd5b5689847842f09591855764d29322de4a319bf9"}}",
"socialUri":"socialUri",
"holdTimeout":1000000
}



Apple Pay direct integration in a mobile application

To integrate the method into the application, use the Apple  SDK PassKit to get the PaymentToken and the Charge payment method in the WayForPay API for making a payment.



Payment process:


 Compatibility Check

If the user's device supports Apple Pay, the branded payment button will be displayed 

  Quick purchase

The user confirms the payment using the Touch ID or Face ID functions, or by entering a password.

 Security without 3-D Secure

Bank card data is not stored in devices and is not transferred anywhere when paying.





 Requirements

For using Apple Pay method you shall comply with  Acceptable Use Guidelines

 Commission

The standard commission for the store is applied to the payment method 


Not with WayForPay yet?

Sign up and connect a popular payment method to your customers.





Still have questions? We are in touch 24/7

 sales@wayforpay.com

+380 44 379 48 49 
+380 97 007 58 20

Write to us in messengers