<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://docs.barion.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Salamongy%40barion.dev</id>
	<title>Barion Documentation - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://docs.barion.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Salamongy%40barion.dev"/>
	<link rel="alternate" type="text/html" href="https://docs.barion.com/Special:Contributions/Salamongy@barion.dev"/>
	<updated>2026-11-23T02:48:12Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.11</generator>
	<entry>
		<id>https://docs.barion.com/index.php?title=Marketplace_Example&amp;diff=4974</id>
		<title>Marketplace Example</title>
		<link rel="alternate" type="text/html" href="https://docs.barion.com/index.php?title=Marketplace_Example&amp;diff=4974"/>
		<updated>2026-11-12T14:17:24Z</updated>

		<summary type="html">&lt;p&gt;Salamongy@barion.dev: /* Refunding the payment */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{PageTitle|title=Detailed example of a marketplace payment}}&lt;br /&gt;
&lt;br /&gt;
{{TableOfContents}}&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
This example is to show the full life cycle of a purchase made at a marketplace scenario. Through this you will be familiar with how the Barion payment system works in a complex payment situation - how the payments are processed, how the money travels between participants and how the systems communicate with each other. &#039;&#039;&#039;Please read this carefully.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=WARNING|text=Do &#039;&#039;&#039;NOT&#039;&#039;&#039; copy any JSON content to your project - these are for demonstration purposes only!|color=#FF7A3D}}&lt;br /&gt;
&lt;br /&gt;
Imagine Chef Chris would like to buy some groceries and products at the Marketplace. In this case, we are talking about a facilitated payment scenario, where the Marketplace is the facilitator. The facilitator manages and organizes the whole payment process, but they do not take part in it as a final payee. Instead, they distribute the money between the different sellers of the chosen products.&lt;br /&gt;
&lt;br /&gt;
=== Starting the payment ===&lt;br /&gt;
&lt;br /&gt;
The process starts with the shopping. Chris has put some products / services (referred to as &#039;&#039;items&#039;&#039;) in his shopping cart on the Marketplace website. These items belong to different manufacturers / providers / distributors - other users of the Barion system, henceforth referred to as &#039;&#039;sellers&#039;&#039;. They all have registered, active Barion wallets but they do not own a shop in the system.&lt;br /&gt;
&lt;br /&gt;
Chris has selected four items from two sellers and went to checkout. The Marketplace informs him that there is a one-day period of confirmation from the sellers upon placing an order.&lt;br /&gt;
&lt;br /&gt;
[[File:marketplace_products_example.png]]&lt;br /&gt;
&lt;br /&gt;
At this point, the Marketplace prepares the payment through the Barion API, using the [[Payment-Start-v2|/v2/Payment/Start]] endpoint. Chris is purchasing items from two separate sellers, the payment will contain two payment transactions, with the respective items and payees set accordingly. Since there is a time window where the sellers should confirm the order, the Marketplace prepares a [[Reservation_payment|reservation payment]] with a reservation period of one day.&lt;br /&gt;
&lt;br /&gt;
For this API call the request JSON looks like this :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt; &lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;xxxx&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Reservation&amp;quot;,&lt;br /&gt;
    &amp;quot;ReservationPeriod&amp;quot;: &amp;quot;1.00:00:00&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;MARKETPAY-123456&amp;quot;,&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;Locale&amp;quot;:&amp;quot;en-US&amp;quot;,&lt;br /&gt;
    &amp;quot;OrderNumber&amp;quot;: &amp;quot;1234-5678&amp;quot;,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;:&amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;MP-TR-01&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;terry@example.com&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: &amp;quot;49&amp;quot;,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Order 1&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Fresh potatoes&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Fresh potatoes&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 3,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;kg&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 3,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 9,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;SM-01&amp;quot;&lt;br /&gt;
                },&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Ginger, sliced&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Ginger, sliced&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 2,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;packs&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 10,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 20,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;SM-02&amp;quot;&lt;br /&gt;
                },&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Truffle box&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Truffle box&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;pc&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 20,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 20,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;SM-03&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        },&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;MP-TR-02&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;robert@example.com&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: &amp;quot;35&amp;quot;,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Order  2&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;8 piece kitchen knives set&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;8 piece kitchen knives set&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;pc&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 35,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 35,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;SM-04&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Barion API accepts the request and prepares the payment. The response JSON content is sent to the Marketplace:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt; {&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;c2283b509e424b729cabca6437079d6e&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;MARKETPAY-123456&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Prepared&amp;quot;,&lt;br /&gt;
    &amp;quot;QRUrl&amp;quot;: &amp;quot;https://api.barion.com/qr/generate?paymentId=c2283b509e424b729cabca6437079d6e&amp;amp;size=Large&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;MP-TR-01&amp;quot;,&lt;br /&gt;
            &amp;quot;TransactionId&amp;quot;: &amp;quot;07ecff0bb7404b40aeae1bb285ed38c8&amp;quot;,&lt;br /&gt;
            &amp;quot;Status&amp;quot;: &amp;quot;Prepared&amp;quot;,&lt;br /&gt;
            &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
            &amp;quot;TransactionTime&amp;quot;: &amp;quot;2017-12-20T12:37:39.696&amp;quot;,&lt;br /&gt;
            &amp;quot;RelatedId&amp;quot;: null&lt;br /&gt;
        },&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;MP-TR-02&amp;quot;,&lt;br /&gt;
            &amp;quot;TransactionId&amp;quot;: &amp;quot;b673b95ee96746ca8e182a8596d67a9e&amp;quot;,&lt;br /&gt;
            &amp;quot;Status&amp;quot;: &amp;quot;Prepared&amp;quot;,&lt;br /&gt;
            &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
            &amp;quot;TransactionTime&amp;quot;: &amp;quot;2017-12-20T12:37:39.696&amp;quot;,&lt;br /&gt;
            &amp;quot;RelatedId&amp;quot;: null&lt;br /&gt;
        }&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;RecurrenceResult&amp;quot;: &amp;quot;None&amp;quot;,&lt;br /&gt;
    &amp;quot;GatewayUrl&amp;quot;: &amp;quot;https://secure.barion.com:443/Pay?Id=c2283b509e424b729cabca6437079d6e&amp;quot;,&lt;br /&gt;
    &amp;quot;RedirectUrl&amp;quot;: &amp;quot;https://testshop.barion.com/Redirect?paymentId=c2283b509e424b729cabca6437079d6e&amp;quot;,&lt;br /&gt;
    &amp;quot;CallbackUrl&amp;quot;: &amp;quot;https://testshop.barion.com/callback?paymentId=c2283b509e424b729cabca6437079d6e&amp;quot;,&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Marketplace system logs the result and stores the appropriate parameters of the order (eg. the identifiers for the payment and its transactions) for later use.&lt;br /&gt;
&lt;br /&gt;
=== Paying on the Barion Smart Gateway === &lt;br /&gt;
&lt;br /&gt;
At this point, the Marketplace has all necessary data. It successfully processed the response from the Barion API, so they redirect Chris&#039;s browser to the Barion Smart Gateway:&lt;br /&gt;
&lt;br /&gt;
[[File:marketplace_example_payment_gateway.png|800px]]&lt;br /&gt;
&lt;br /&gt;
Chris logs in to the Barion system and chooses one of his saved bank cards to pay for the order.&lt;br /&gt;
&lt;br /&gt;
The payment is successfully finished in a few seconds. The Barion Smart Gateway confirms the successful payment in a summary window.&lt;br /&gt;
&lt;br /&gt;
[[File:marketplace_example_payment_completed.png|800px]]&lt;br /&gt;
&lt;br /&gt;
Chris&#039;s browser is redirected back to the Marketplace&#039;s website, where he may get another confirmation of the order being processed.&lt;br /&gt;
At this point, the reservation timer is started. The Marketplace has one day to finish the reservation.&lt;br /&gt;
&lt;br /&gt;
The paid amount is transferred to the Barion wallets of Terry Wellington (€49) and Robert Craig (€35), but the amount is blocked and is not available to use until the reservation is finished.&lt;br /&gt;
&lt;br /&gt;
The Barion system also sends a [[Callback_mechanism|callback]] to the Marketplace so they can process data accordingly even if Chris never returns to the Marketplace website.&lt;br /&gt;
&lt;br /&gt;
=== Finishing the reservation ===&lt;br /&gt;
&lt;br /&gt;
The next day the facilitator is informed that one of the items (€9 worth of fresh potatoes) ran out of stock at Terry Wellington. The Marketplace removes this item from Chris&#039;s order and modifies the transaction accordingly. All other items are available. &lt;br /&gt;
&lt;br /&gt;
Because the total amount due to the payment is changed, the Marketplace has to finish the reservation with an amount lower than the initial value. The Marketplace sends a request to the Barion API to finish the reservation, via the [[Payment-FinishReservation-v2|/v2/Payment/FinishReservation]] API endpoint, using the payment and transaction identifiers received earlier when preparing the payment.&lt;br /&gt;
The JSON content of the request looks like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt; &lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;xxxx&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;c2283b509e424b729cabca6437079d6e&amp;quot;,&lt;br /&gt;
     &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;TransactionId&amp;quot;: &amp;quot;07ecff0bb7404b40aeae1bb285ed38c8&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;terry@example.com&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: &amp;quot;40&amp;quot;,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Order 1&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Ginger, sliced&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Ginger, sliced&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 2,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;packs&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 10,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 20,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;SM-02&amp;quot;&lt;br /&gt;
                },&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Truffle box&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Truffle box&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;pc&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 20,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 20,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;SM-03&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        },&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;TransactionId&amp;quot;: &amp;quot;b673b95ee96746ca8e182a8596d67a9e&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;robert@example.com&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: &amp;quot;35&amp;quot;,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Order  2&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;8 piece kitchen knives set&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;8 piece kitchen knives set&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;pc&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 35,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 35,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;SM-04&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=NOTE|text=See the items and the total amount for the first payment transaction has changed!|color=#1993c7}}&lt;br /&gt;
&lt;br /&gt;
The Barion API accepts and processes the request. Both transactions are finished successfully. The payment is set to &amp;lt;code&amp;gt;Succeeded&amp;lt;/code&amp;gt; state.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;IsSuccessful&amp;quot;: true,&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;c2283b509e424b729cabca6437079d6e&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;MARKETPAY-123456&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;MP-TR-01&amp;quot;,&lt;br /&gt;
            &amp;quot;TransactionId&amp;quot;: &amp;quot;07ecff0bb7404b40aeae1bb285ed38c8&amp;quot;,&lt;br /&gt;
            &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
            &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
            &amp;quot;TransactionTime&amp;quot;: &amp;quot;2017-12-20T13:47:11.251Z&amp;quot;,&lt;br /&gt;
            &amp;quot;RelatedId&amp;quot;: null&lt;br /&gt;
        },&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;MP-TR-02&amp;quot;,&lt;br /&gt;
            &amp;quot;TransactionId&amp;quot;: &amp;quot;b673b95ee96746ca8e182a8596d67a9e&amp;quot;,&lt;br /&gt;
            &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
            &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
            &amp;quot;TransactionTime&amp;quot;: &amp;quot;2017-12-20T13:47:11.251Z&amp;quot;,&lt;br /&gt;
            &amp;quot;RelatedId&amp;quot;: null&lt;br /&gt;
        }&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Even though the Marketplace just received a response and probably processed it, the Barion system also sends a [[Callback_mechanism|callback]] to the respective callback URL of the payment - should there be any extra processing required in the Marketplace system.&lt;br /&gt;
&lt;br /&gt;
From the reserved amount of €49 in Terry Wellington&#039;s wallet, €40 is released and is now available for him to use. The €9 difference from the initially reserved amount is automatically refunded to Chris&#039;s bank card. Robert Craig receives the whole amount of €35.&lt;br /&gt;
&lt;br /&gt;
The Marketplace informs Chris about the confirmed order and that the items are being shipped.&lt;br /&gt;
&lt;br /&gt;
=== Refunding the payment === &lt;br /&gt;
&lt;br /&gt;
Chris receives the items he ordered and discovers that the knife set he ordered from Robert Craig has broken during shipment. He informs the Marketplace about this.&lt;br /&gt;
&lt;br /&gt;
The Marketplace forwards his feedback to Robert, who arranges a full refund with Chris in compensation. &lt;br /&gt;
Robert can do the refund via the Barion web user interface under the details of the corresponding payment after logging into his Barion wallet.&lt;br /&gt;
&lt;br /&gt;
If Robert is not available for some reason, the Marketplace may also refund the payment via the Barion API, using the [[Payment-Refund-v2|/v2/Payment/Refund]] endpoint.&lt;br /&gt;
In this case, the following JSON content is sent in the request:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;xxxx&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;c2283b509e424b729cabca6437079d6e&amp;quot;,&lt;br /&gt;
    &amp;quot;TransactionsToRefund&amp;quot;: [{&lt;br /&gt;
        &amp;quot;TransactionId&amp;quot;: &amp;quot;b673b95ee96746ca8e182a8596d67a9e&amp;quot;,&lt;br /&gt;
        &amp;quot;AmountToRefund&amp;quot;: 35,&lt;br /&gt;
        &amp;quot;POSTransactionId&amp;quot;: &amp;quot;MP-TR-02&amp;quot;,&lt;br /&gt;
        &amp;quot;Comment&amp;quot;: &amp;quot;Refund due to broken product sold at Marketplace&amp;quot;&lt;br /&gt;
    }],&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Barion API receives the refund request and processes it. The refund successfully takes place, although Chris might have to wait up to 30 days to receive the refund on his bank card, depending on the bank system.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;c2283b509e424b729cabca6437079d6e&amp;quot;,&lt;br /&gt;
    &amp;quot;RefundedTransactions&amp;quot;: [{&lt;br /&gt;
        &amp;quot;TransactionId&amp;quot;: &amp;quot;b673b95ee96746ca8e182a8596d67a9e&amp;quot;,&lt;br /&gt;
        &amp;quot;Total&amp;quot;: 35,&lt;br /&gt;
        &amp;quot;POSTransactionId&amp;quot;: &amp;quot;MP-TR-02&amp;quot;,&lt;br /&gt;
        &amp;quot;Comment&amp;quot;: &amp;quot;Refund due to broken product sold at Marketplace&amp;quot;,&lt;br /&gt;
        &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;&lt;br /&gt;
    }],&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Whoever initiated the refund, the Barion system sends a [[Callback_mechanism|callback]] to the Marketplace so they can do additional processing if they need to.&lt;br /&gt;
&lt;br /&gt;
== Reference ==&lt;br /&gt;
* [[Payment-Start-v2|/Payment/Start]]&lt;br /&gt;
* [[Payment-PaymentState-v4|/v4/Payment/&amp;lt;PaymentId&amp;gt;/PaymentState]]&lt;br /&gt;
* [[Payment-FinishReservation-v2|/Payment/FinishReservation]]&lt;br /&gt;
* [[Payment-Refund-v2|/Payment/Refund]]&lt;/div&gt;</summary>
		<author><name>Salamongy@barion.dev</name></author>
	</entry>
	<entry>
		<id>https://docs.barion.com/index.php?title=Facilitated_payments&amp;diff=4973</id>
		<title>Facilitated payments</title>
		<link rel="alternate" type="text/html" href="https://docs.barion.com/index.php?title=Facilitated_payments&amp;diff=4973"/>
		<updated>2026-11-12T14:08:23Z</updated>

		<summary type="html">&lt;p&gt;Salamongy@barion.dev: /* Refunding facilitated payments */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{PageTitle|title=Marketplace, sharing economy, and facilitated payments}}&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;margin-left:2em;&amp;quot; align=&amp;quot;right&amp;quot;&lt;br /&gt;
| __TOC__&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Payment facilitation is a special kind of payment scenario, where the payment itself is supervised by a third party. This means that a supervising shop (called the &#039;&#039;&#039;facilitator&#039;&#039;&#039;) defines all parameters for a payment, but it does not take part in the process as a payee. This is useful in marketplace and sharing economy scenarios, where the customer buys products and services from various sellers, under the management of a service provider. The service provider may also charge fees for the service that is paid by the seller.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;Example:&#039;&#039;&#039; consider calling an Uber - the car driver is the seller, the passenger is the customer, and the company Uber is the facilitator. The money travels between the passenger and the driver, while the company deducts a fee from the driver.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
To successfully implement facilitated payments, you need to familiarize yourself with the simple [[Responsive_web_payment|Responsive Web Payment]] scenario, and, in case you wish to combine it with the reservation feature, also [[Reservation_payment|Reservation payments]]. The preparation of payments, redirection to the Barion Smart Gateway and handling the [[Callback mechanism]] are identical to all other scenarios. &lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=NOTE|text=It is VERY strongly advised to have a detailed knowledge about the payment process, the simple immediate payment scenario and the callback processing.|color=#1993C7}}&lt;br /&gt;
&lt;br /&gt;
== The marketplace scenario ==&lt;br /&gt;
The payment process is similar to all other scenarios. The only difference is that the API calls are placed by the facilitator. Neither the customer nor the payee takes any action.&lt;br /&gt;
&lt;br /&gt;
The basic structure of a facilitated payment consists of the facilitator, the customer, and one or more sellers. See the figure below.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
[[file:sharing-economy-marketplace-nocontributor.png|700px]]&lt;br /&gt;
&lt;br /&gt;
== Seller accounts ==&lt;br /&gt;
&lt;br /&gt;
When taking part in a facilitated payment, the seller (payee) must have a registered, activated Barion wallet. They do not need to have a shop though.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Good to know:&#039;&#039;&#039; if the seller does not have an account with the payment&#039;s currency, it will automatically be created for them upon successful payment.&lt;br /&gt;
&lt;br /&gt;
== The lifecycle of a facilitated payment ==&lt;br /&gt;
==== 1. The facilitator prepares the payment ====&lt;br /&gt;
Preparing the payment is identical to the [[Responsive_web_payment|Responsive Web Payment]] scenario. The facilitator specifies the payee[s], and the optional payment parameters.&lt;br /&gt;
&lt;br /&gt;
==== 2. The customer completes the payment ====&lt;br /&gt;
After the customer completes the payment via the Barion Smart Gateway, the money is transferred to the facilitator.&lt;br /&gt;
A callback is sent to the facilitator.&lt;br /&gt;
&lt;br /&gt;
On the Barion Smart Gateway user interface the customer will see that the payee is the facilitator, while the sellers and items are listed in the payment details&lt;br /&gt;
&lt;br /&gt;
[[file:barion_marketplace_example_screenshot.png|700px]]&lt;br /&gt;
&lt;br /&gt;
==== 3. The sellers receive the money ====&lt;br /&gt;
The Barion system distributes the paid amount among the sellers, according to the payment transactions specified by the facilitator when preparing the payment, and also processes all payee transactions (if applicable).&lt;br /&gt;
* At this point the location and availability of the money depends on wether the facilitator uses [[Responsive_web_payment|Immediate]] or [[Reservation_payment|Reservation]] payments. See the corresponding article for details.&lt;br /&gt;
&lt;br /&gt;
== Refunding facilitated payments ==&lt;br /&gt;
As long as a reservation payment is not finished, the facilitator has complete control of the process and is able to refund the amount by finishing the payment transactions with zero amount.&lt;br /&gt;
&lt;br /&gt;
After a completed immediate or a finished reservation payment, a payment transaction can be refunded by either party:&lt;br /&gt;
&lt;br /&gt;
* the &#039;&#039;&#039;facilitator&#039;&#039;&#039;, via the [[Payment-Refund-v2|/v2/Payment/Refund]] API endpoint using the POSKey of the shop that started the payment, or in the Payment Monitor of that shop on the Barion web interface;&lt;br /&gt;
* the &#039;&#039;&#039;seller&#039;&#039;&#039;, on the Barion web interface under the details of the corresponding transaction, after logging into their Barion wallet.&lt;br /&gt;
&lt;br /&gt;
The refunded amount is always deducted from the seller’s Barion wallet, regardless of who initiated the refund. No approval from the seller is required. If the seller’s available balance does not cover the refund, the request is rejected with the &amp;lt;code&amp;gt;TooLowBalanceToMakeRefund&amp;lt;/code&amp;gt; error.&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
&lt;br /&gt;
Please check out the [[Marketplace_Example|detailed example of a marketplace payment]] page for more informations.&lt;br /&gt;
&lt;br /&gt;
== Reference ==&lt;br /&gt;
* [[Payment-Start-v2|/Payment/Start]]&lt;br /&gt;
* [[Payment-PaymentState-v4|/v4/Payment/&amp;lt;PaymentId&amp;gt;/PaymentState]]&lt;br /&gt;
* [[Payment-FinishReservation-v2|/Payment/FinishReservation]]&lt;/div&gt;</summary>
		<author><name>Salamongy@barion.dev</name></author>
	</entry>
	<entry>
		<id>https://docs.barion.com/index.php?title=Payment-Reject-v2&amp;diff=4959</id>
		<title>Payment-Reject-v2</title>
		<link rel="alternate" type="text/html" href="https://docs.barion.com/index.php?title=Payment-Reject-v2&amp;diff=4959"/>
		<updated>2026-10-21T14:00:23Z</updated>

		<summary type="html">&lt;p&gt;Salamongy@barion.dev: link update&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! style=&amp;quot;width:80px;&amp;quot; | POST&lt;br /&gt;
| &amp;lt;code&amp;gt;/v2/Payment/Reject&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;/payment/reject&amp;lt;/code&amp;gt; API endpoint is used to cancel a payment in the Barion system before the payer completes it. After a successful call, the payer can no longer pay it.&lt;br /&gt;
&lt;br /&gt;
Prerequisites before use:&lt;br /&gt;
* [[Creating an account|Creating an account in Barion]]&lt;br /&gt;
* [[Creating a shop|Creating a shop in Barion]]&lt;br /&gt;
* [[Calling the API|Calling the Barion API]]&lt;br /&gt;
* [[Payment-Start-v2|Initializing a payment]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;small&amp;gt;v2&amp;lt;/small&amp;gt; This API endpoint is available in &#039;&#039;&#039;API v2&#039;&#039;&#039; only.&lt;br /&gt;
&lt;br /&gt;
== Authentication ==&lt;br /&gt;
[[Barion Shop Authentication]]&lt;br /&gt;
&lt;br /&gt;
== Use cases ==&lt;br /&gt;
This API endpoint is designed to be used in the following scenarios:&lt;br /&gt;
* [[Responsive web payment|Responsive Web Payment]]&lt;br /&gt;
&lt;br /&gt;
Only payments in &#039;&#039;&#039;Prepared&#039;&#039;&#039; status can be rejected, meaning the payer has not completed them yet. The result is the same as when the payer clicks &#039;&#039;&#039;&amp;quot;Back to shop without payment&amp;quot;&#039;&#039;&#039; on the Barion Smart Gateway:&lt;br /&gt;
* the payment status becomes &#039;&#039;&#039;Canceled&#039;&#039;&#039;,&lt;br /&gt;
* its unpaid transactions become &#039;&#039;&#039;Rejected&#039;&#039;&#039;,&lt;br /&gt;
* Barion sends a [[Callback mechanism|callback]] to the shop.&lt;br /&gt;
&lt;br /&gt;
Use other endpoints for payments in other stages:&lt;br /&gt;
* to release an &#039;&#039;&#039;authorized&#039;&#039;&#039; delayed capture payment, use [[Payment-CancelAuthorization-v2|Payment/CancelAuthorization]],&lt;br /&gt;
* to return money from a &#039;&#039;&#039;completed&#039;&#039;&#039; payment, use [[Payment-Refund-v2|Payment/Refund]].&lt;br /&gt;
&lt;br /&gt;
== Input properties ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Property name !! Property type !! Limitations and constraints !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;POSKey&#039;&#039;&#039;&lt;br /&gt;
| Guid&lt;br /&gt;
|&lt;br /&gt;
* Required&lt;br /&gt;
| The secret API key of the shop, generated by Barion. This lets the shop authenticate through the Barion API, but does not provide access to the account owning the shop itself.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PaymentId&#039;&#039;&#039;&lt;br /&gt;
| Guid&lt;br /&gt;
|&lt;br /&gt;
* Required&lt;br /&gt;
* The payment must be in &amp;lt;code&amp;gt;Prepared&amp;lt;/code&amp;gt; status&lt;br /&gt;
| The identifier of the payment to reject, as returned by [[Payment-Start-v2|Payment/Start]]. If the payment is already &amp;lt;code&amp;gt;Canceled&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;Expired&amp;lt;/code&amp;gt;, or is in any other status, the call returns an error.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Output properties ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Property name !! Property type !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PaymentId&#039;&#039;&#039;&lt;br /&gt;
| Guid&lt;br /&gt;
| The identifier of the payment, the same as in the request.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;IsSuccessful&#039;&#039;&#039;&lt;br /&gt;
| bool&lt;br /&gt;
| &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; if the payment was rejected successfully.&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Salamongy@barion.dev</name></author>
	</entry>
	<entry>
		<id>https://docs.barion.com/index.php?title=Barion_Shop_Authentication&amp;diff=4952</id>
		<title>Barion Shop Authentication</title>
		<link rel="alternate" type="text/html" href="https://docs.barion.com/index.php?title=Barion_Shop_Authentication&amp;diff=4952"/>
		<updated>2026-10-20T14:20:57Z</updated>

		<summary type="html">&lt;p&gt;Salamongy@barion.dev: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= What is shop authentication? =&lt;br /&gt;
&lt;br /&gt;
The API endpoints related to handling a shop&#039;s payment flow are accessible using the shop&#039;s own unique API key, known as &amp;lt;i&amp;gt;POS key&amp;lt;/i&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
For a full list of such endpoints see [[List_of_API_endpoints|List of Barion API endpoints]].&lt;br /&gt;
&lt;br /&gt;
Optionally, the shop can also use an &amp;lt;i&amp;gt;HMAC key&amp;lt;/i&amp;gt; to sign its API requests and to verify the messages Barion sends to it. See [[#Message signature (HMAC)|Message signature (HMAC)]].&lt;br /&gt;
&lt;br /&gt;
= Using POS keys =&lt;br /&gt;
&lt;br /&gt;
To use an endpoint which requires shop-level authentication, pass your Barion shop&#039;s POS key as the &#039;&#039;&#039;x-pos-key&#039;&#039;&#039; header parameter.&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=NOTE|text=&amp;lt;tt&amp;gt;GET&amp;lt;/tt&amp;gt; API endpoints below v4 also accept the &amp;lt;code&amp;gt;PosKey&amp;lt;/code&amp;gt; property as a query parameter.|color=#038Ed3}}&lt;br /&gt;
== Errors ==&lt;br /&gt;
&lt;br /&gt;
An invalid key generates an &amp;lt;code&amp;gt;AuthenticationFailed&amp;lt;/code&amp;gt; error.&lt;br /&gt;
&lt;br /&gt;
= Managing POS keys =&lt;br /&gt;
&lt;br /&gt;
A POS key is automatically generated for your shop when you create it, and cannot be changed later. To obtain it, either&lt;br /&gt;
* get the key from the confirmation e-mail that was sent to you when you opened the shop, or&lt;br /&gt;
* go to the shop&#039;s detail page on the [https://secure.barion.com Barion secure site] and use the &amp;lt;i&amp;gt;Secret key&amp;lt;/i&amp;gt; value (Shops -&amp;gt; Actions -&amp;gt; Details)&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=NOTE|text=The test and live environment are completely separate environments, you need to create different shops. Make sure that you use the POSkey and not the public key:&lt;br /&gt;
&lt;br /&gt;
[[File:Poskey.jpg]] |color=#038Ed3}}&lt;br /&gt;
&lt;br /&gt;
= Message signature (HMAC) =&lt;br /&gt;
&lt;br /&gt;
A shop can have an HMAC key in addition to its POS key. While the shop has an &amp;lt;b&amp;gt;active&amp;lt;/b&amp;gt; HMAC key:&lt;br /&gt;
* every API request authenticated with the shop&#039;s POS key &amp;lt;b&amp;gt;must be signed&amp;lt;/b&amp;gt; with the HMAC key, otherwise Barion rejects it,&lt;br /&gt;
* Barion signs its responses to these requests, and&lt;br /&gt;
* Barion signs the payment IPN (callback) messages it sends to the shop.&lt;br /&gt;
&lt;br /&gt;
This lets your server verify that a message really comes from Barion and was not changed on the way, and lets Barion verify that a request really comes from your shop.&lt;br /&gt;
&lt;br /&gt;
The signature is an HMAC-SHA512 computed with the shop&#039;s HMAC key. It is sent in HTTP headers, so the request and response bodies do not change.&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=IMPORTANT|text=Activating a key takes effect &amp;lt;b&amp;gt;immediately&amp;lt;/b&amp;gt;: from that moment, every unsigned or wrongly signed request of the shop is rejected, payment start included. Signature headers are ignored while the shop has no active key, so start signing your requests &amp;lt;b&amp;gt;before&amp;lt;/b&amp;gt; you activate the key.|color=#D73E48}}&lt;br /&gt;
&lt;br /&gt;
== Managing HMAC keys ==&lt;br /&gt;
&lt;br /&gt;
HMAC keys are managed on the [https://secure.barion.com Barion secure site], on the shop&#039;s security page (Shops -&amp;gt; Actions -&amp;gt; Settings -&amp;gt; Security -&amp;gt; Manage).&lt;br /&gt;
&lt;br /&gt;
* A shop can have at most 2 HMAC keys. To generate a third one, delete one of the two first.&lt;br /&gt;
* A new key is created &amp;lt;b&amp;gt;inactive&amp;lt;/b&amp;gt;. Mark it as &amp;lt;i&amp;gt;Active&amp;lt;/i&amp;gt; when your server is ready.&lt;br /&gt;
* At most one key is active at a time. If no key is active, nothing is signed and no signature is checked.&lt;br /&gt;
* The active key cannot be deleted. Deactivate it, or activate the other key, first.&lt;br /&gt;
* The key is shown and copied as a base64 string. &amp;lt;b&amp;gt;Decode it from base64&amp;lt;/b&amp;gt; and use the resulting 64 bytes as the HMAC key.&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=NOTE|text=Keep the HMAC key on your server only, like the POS key. If you think a key is compromised, generate a new one, switch to it and delete the old one.|color=#038Ed3}}&lt;br /&gt;
&lt;br /&gt;
== Signature headers ==&lt;br /&gt;
&lt;br /&gt;
Every signed request and response carries these three headers:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Header !! Content&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;x-timestamp&#039;&#039;&#039; || The time of signing as a Unix timestamp in seconds (UTC), e.g. &amp;lt;code&amp;gt;1760968800&amp;lt;/code&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;x-nonce&#039;&#039;&#039; || A GUID, e.g. &amp;lt;code&amp;gt;3f2b6c1e-8d4a-4b9e-9a51-0c7d2e6f1a84&amp;lt;/code&amp;gt;. In a request it must be new for every request. In a response it is the nonce of the request being answered.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;x-signature-sha512&#039;&#039;&#039; || The HMAC-SHA512 of the signed text (see below), base64-encoded.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== The signed text ==&lt;br /&gt;
&lt;br /&gt;
The signature is computed over a text made of the following parts, joined with a single line feed character (&amp;lt;code&amp;gt;\n&amp;lt;/code&amp;gt;, LF, no carriage return). The text is UTF-8 encoded before signing.&lt;br /&gt;
&lt;br /&gt;
=== Requests (your API requests and Barion&#039;s IPN) ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{x-timestamp}\n{x-nonce}\n{HTTP method}\n{path and query}\n{body}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;HTTP method&#039;&#039;&#039;: in upper case, e.g. &amp;lt;code&amp;gt;POST&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;GET&amp;lt;/code&amp;gt;.&lt;br /&gt;
* &#039;&#039;&#039;path and query&#039;&#039;&#039;: the path and the query string of the URL as it appears on the request line, e.g. &amp;lt;code&amp;gt;/v2/Payment/Start&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;/v4/Payment/GetPaymentState?PaymentId=...&amp;lt;/code&amp;gt;. The scheme, the host and the port are not part of it.&lt;br /&gt;
* &#039;&#039;&#039;body&#039;&#039;&#039;: the exact request body, byte for byte as it is sent. For a request without a body (e.g. &amp;lt;code&amp;gt;GET&amp;lt;/code&amp;gt;) it is an empty string, so the text ends with the line feed after the path.&lt;br /&gt;
&lt;br /&gt;
=== Responses (Barion&#039;s answers to your signed requests) ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{x-timestamp}\n{x-nonce}\n{HTTP status code}\n{body}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;x-nonce&#039;&#039;&#039;: the nonce of &amp;lt;b&amp;gt;your request&amp;lt;/b&amp;gt; that the response answers. It is echoed back in the response&#039;s &amp;lt;code&amp;gt;x-nonce&amp;lt;/code&amp;gt; header, and binds the response to your request.&lt;br /&gt;
* &#039;&#039;&#039;HTTP status code&#039;&#039;&#039;: as a number, e.g. &amp;lt;code&amp;gt;200&amp;lt;/code&amp;gt;.&lt;br /&gt;
* &#039;&#039;&#039;body&#039;&#039;&#039;: the exact response body as received.&lt;br /&gt;
&lt;br /&gt;
Responses are signed only when the request was signed correctly.&lt;br /&gt;
&lt;br /&gt;
== Signing your API requests ==&lt;br /&gt;
&lt;br /&gt;
# Generate a new GUID for &amp;lt;code&amp;gt;x-nonce&amp;lt;/code&amp;gt; and take the current Unix time in seconds for &amp;lt;code&amp;gt;x-timestamp&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Build the signed text from the timestamp, the nonce, the method, the path and query, and the exact body you are going to send.&lt;br /&gt;
# Compute the HMAC-SHA512 of the UTF-8 text with the base64-decoded HMAC key, and base64-encode the result.&lt;br /&gt;
# Send the request with the &amp;lt;code&amp;gt;x-pos-key&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;x-timestamp&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;x-nonce&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;x-signature-sha512&amp;lt;/code&amp;gt; headers.&lt;br /&gt;
&lt;br /&gt;
Barion checks that:&lt;br /&gt;
* the timestamp is within 5 minutes of the server time, in either direction,&lt;br /&gt;
* the nonce has not been used by the shop before (so a captured request cannot be replayed),&lt;br /&gt;
* the signature matches the request signed with the active key.&lt;br /&gt;
&lt;br /&gt;
== Verifying Barion&#039;s messages ==&lt;br /&gt;
&lt;br /&gt;
For a response to your request, and for a payment IPN message:&lt;br /&gt;
# Read the &amp;lt;code&amp;gt;x-timestamp&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;x-nonce&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;x-signature-sha512&amp;lt;/code&amp;gt; headers.&lt;br /&gt;
# Build the signed text: for a response with the response&#039;s status code and body, for an IPN with &amp;lt;code&amp;gt;POST&amp;lt;/code&amp;gt;, the path and query of your callback URL as it was called (including the &amp;lt;code&amp;gt;paymentId&amp;lt;/code&amp;gt; query parameter) and the request body.&lt;br /&gt;
# Compute the HMAC-SHA512 with your active key and compare it with &amp;lt;code&amp;gt;x-signature-sha512&amp;lt;/code&amp;gt;. Use a constant-time comparison.&lt;br /&gt;
# Reject the message if the signature does not match. We also recommend rejecting it if the timestamp is more than a few minutes off your server time, and, for an IPN, if you have already processed its nonce.&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=NOTE|text=Only the payment IPN is signed. Its body is &amp;lt;code&amp;gt;PaymentId=...&amp;lt;/code&amp;gt;, form-encoded. The IPN still carries no payment details: get the result of the payment with a separate, authenticated &amp;lt;code&amp;gt;GetPaymentState&amp;lt;/code&amp;gt; call.|color=#038Ed3}}&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
&lt;br /&gt;
Signing a request in C#:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Security.Cryptography;&lt;br /&gt;
using System.Text;&lt;br /&gt;
&lt;br /&gt;
static string Sign(string base64HmacKey, string timestamp, string nonce, string method, string pathAndQuery, string body)&lt;br /&gt;
{&lt;br /&gt;
    string text = string.Join(&amp;quot;\n&amp;quot;, timestamp, nonce, method.ToUpperInvariant(), pathAndQuery, body ?? &amp;quot;&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
    using (var hmac = new HMACSHA512(Convert.FromBase64String(base64HmacKey)))&lt;br /&gt;
    {&lt;br /&gt;
        return Convert.ToBase64String(hmac.ComputeHash(Encoding.UTF8.GetBytes(text)));&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
string timestamp = DateTimeOffset.UtcNow.ToUnixTimeSeconds().ToString();&lt;br /&gt;
string nonce = Guid.NewGuid().ToString();&lt;br /&gt;
string body = &amp;quot;{\&amp;quot;PaymentRequestId\&amp;quot;:\&amp;quot;...\&amp;quot;}&amp;quot;;&lt;br /&gt;
string signature = Sign(hmacKey, timestamp, nonce, &amp;quot;POST&amp;quot;, &amp;quot;/v2/Payment/Start&amp;quot;, body);&lt;br /&gt;
&lt;br /&gt;
// Send with the headers: x-pos-key, x-timestamp: {timestamp}, x-nonce: {nonce}, x-signature-sha512: {signature}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Rotating the key ==&lt;br /&gt;
&lt;br /&gt;
# Generate a second key on the security page. The current key keeps working.&lt;br /&gt;
# Prepare your server to sign with the new key and to verify with it.&lt;br /&gt;
# Mark the new key as &amp;lt;i&amp;gt;Active&amp;lt;/i&amp;gt;. From that moment Barion signs with the new key and checks your requests against it, so your server must already sign with the new key.&lt;br /&gt;
# Once your server no longer uses the old key, delete the old key.&lt;br /&gt;
&lt;br /&gt;
== Turning signing off ==&lt;br /&gt;
&lt;br /&gt;
Untick &amp;lt;i&amp;gt;Active&amp;lt;/i&amp;gt; on the active key. Barion stops signing its messages right away and no longer checks the signature of your requests. If your server rejects unsigned messages, it will reject Barion&#039;s IPN messages and responses too.&lt;br /&gt;
&lt;br /&gt;
== Errors ==&lt;br /&gt;
&lt;br /&gt;
If the shop has an active HMAC key and the signature check fails, the request is rejected with HTTP status &amp;lt;code&amp;gt;401&amp;lt;/code&amp;gt; and one of these errors:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Error code !! Meaning&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;MissingSignature&amp;lt;/code&amp;gt; || One or more of the &amp;lt;code&amp;gt;x-timestamp&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;x-nonce&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;x-signature-sha512&amp;lt;/code&amp;gt; headers is missing.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;InvalidNonce&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;x-nonce&amp;lt;/code&amp;gt; is not a GUID.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;InvalidTimestamp&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;x-timestamp&amp;lt;/code&amp;gt; is not a Unix timestamp in seconds, or is more than 5 minutes off the server time.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;InvalidSignature&amp;lt;/code&amp;gt; || The signature does not match the request signed with the shop&#039;s active HMAC key.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;ReplayedRequest&amp;lt;/code&amp;gt; || A request with this &amp;lt;code&amp;gt;x-nonce&amp;lt;/code&amp;gt; has already been received.&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Salamongy@barion.dev</name></author>
	</entry>
	<entry>
		<id>https://docs.barion.com/index.php?title=List_of_API_endpoints&amp;diff=4951</id>
		<title>List of API endpoints</title>
		<link rel="alternate" type="text/html" href="https://docs.barion.com/index.php?title=List_of_API_endpoints&amp;diff=4951"/>
		<updated>2026-10-19T14:03:48Z</updated>

		<summary type="html">&lt;p&gt;Salamongy@barion.dev: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{PageTitle|title=List of Barion API endpoints}}&lt;br /&gt;
&lt;br /&gt;
On this page you can find the currently available API endpoints in the Barion system. If you are new here, first please read the [[Getting_started|Getting started]] page.&lt;br /&gt;
&lt;br /&gt;
==API base URL==&lt;br /&gt;
&lt;br /&gt;
Base URL for API requests in the &#039;&#039;&#039;Live (production)&#039;&#039;&#039; environment: &amp;lt;code&amp;gt;https://api.barion.com&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Base URL for API requests in the &#039;&#039;&#039;Sandbox (test)&#039;&#039;&#039; environment: &amp;lt;code&amp;gt;https://api.test.barion.com&amp;lt;/code&amp;gt; (learn more about the Sandbox environment [[Sandbox|here]])&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=IMPORTANT|text=Always double check that you are connecting to the proper environment to avoid unnecessary troubleshooting!|color=#FF7A3D}}&lt;br /&gt;
&lt;br /&gt;
==Endpoint list==&lt;br /&gt;
&lt;br /&gt;
Currently, the following endpoints are available in the Barion API.&lt;br /&gt;
&lt;br /&gt;
{| &lt;br /&gt;
|&#039;&#039;&#039;Barion Smart Gateway&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Barion Wallet&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Barion Bridge&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding-right: 100px;vertical-align: top&amp;quot; |&lt;br /&gt;
To authenticate for these endpoints, use [[Barion Shop Authentication]].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span class=&amp;quot;api-ver&amp;quot;&amp;gt;v2&amp;lt;/span&amp;gt; [[Payment-Start-v2|/Payment/Start]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span class=&amp;quot;api-ver&amp;quot;&amp;gt;v2&amp;lt;/span&amp;gt; [[Payment-GetPaymentState-v2|/Payment/GetPaymentState]] (deprecated)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span class=&amp;quot;api-ver&amp;quot;&amp;gt;v4&amp;lt;/span&amp;gt; [[Payment-PaymentState-v4|/Payment/&amp;lt;PaymentId&amp;gt;/paymentstate]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span class=&amp;quot;api-ver&amp;quot;&amp;gt;v2&amp;lt;/span&amp;gt; [[Payment-Complete-v2|/Payment/Complete]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span class=&amp;quot;api-ver&amp;quot;&amp;gt;v2&amp;lt;/span&amp;gt; [[Payment-FinishReservation-v2|/Payment/FinishReservation]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span class=&amp;quot;api-ver&amp;quot;&amp;gt;v2&amp;lt;/span&amp;gt; [[Payment-Capture-v2|/Payment/Capture]] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;span class=&amp;quot;api-ver&amp;quot;&amp;gt;v2&amp;lt;/span&amp;gt; [[Payment-CancelAuthorization-v2|/Payment/CancelAuthorization]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span class=&amp;quot;api-ver&amp;quot;&amp;gt;v2&amp;lt;/span&amp;gt; [[Payment-Refund-v2|/Payment/Refund]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span class=&amp;quot;api-ver&amp;quot;&amp;gt;v2&amp;lt;/span&amp;gt; [[Payment-Reject-v2|/Payment/Reject]]&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;padding-right: 100px;vertical-align: top&amp;quot;  |&lt;br /&gt;
To authenticate for these endpoints, use [[Barion Wallet Authentication]].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span class=&amp;quot;api-ver&amp;quot;&amp;gt;v2&amp;lt;/span&amp;gt; [[Accounts-Get-v2|/Accounts]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span class=&amp;quot;api-ver&amp;quot;&amp;gt;v3&amp;lt;/span&amp;gt; [[UserHistory-GetHistory-v3|/GetHistory]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span class=&amp;quot;api-ver&amp;quot;&amp;gt;v3&amp;lt;/span&amp;gt; [[TransactionHistory-GetDetail-v3|/TransactionHistory/GetDetail]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span class=&amp;quot;api-ver&amp;quot;&amp;gt;v3&amp;lt;/span&amp;gt; [[Withdraw-BankTransfer-v3|/Withdraw/BankTransfer]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span class=&amp;quot;api-ver&amp;quot;&amp;gt;v6&amp;lt;/span&amp;gt; [[Withdraw-Fee-v6|/Withdraw/Fee]] &amp;lt;span class=&amp;quot;new-label&amp;quot; style=&amp;quot;background: green;color: white;display: inline-block;padding: 0 5px;font-weight: bold;font-size: 0.8em;&amp;quot;&amp;gt;NEW&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span class=&amp;quot;api-ver&amp;quot;&amp;gt;v2&amp;lt;/span&amp;gt; [[Withdraw-BankTransfer-v2|/Withdraw/BankTransfer]] (obsolete)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span class=&amp;quot;api-ver&amp;quot;&amp;gt;v2&amp;lt;/span&amp;gt; [[Statement-Download-v2|/Statement/Download]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span class=&amp;quot;api-ver&amp;quot;&amp;gt;v2&amp;lt;/span&amp;gt; [[Transfer-Email-v2|/Transfer/Email]]&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;padding-right: 100px;vertical-align: top&amp;quot; |&lt;br /&gt;
To authenticate for these endpoints, use [[Barion Wallet Authentication]].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span class=&amp;quot;api-ver&amp;quot;&amp;gt;v1&amp;lt;/span&amp;gt; [[Pos-Create-v1|/Pos]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span class=&amp;quot;api-ver&amp;quot;&amp;gt;v6&amp;lt;/span&amp;gt; [[Pos-Create-v6|/Pos]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span class=&amp;quot;api-ver&amp;quot;&amp;gt;v1&amp;lt;/span&amp;gt; [[Pos-Get-v1|/Pos/{PublicKey}]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To register wallets with pre-filled values on secure.barion.com,&amp;lt;br /&amp;gt;&lt;br /&gt;
you can use the following method:&lt;br /&gt;
&lt;br /&gt;
[[Registration_with_pre-filled_values|/Registration]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| &lt;br /&gt;
|&#039;&#039;&#039;Recipient Management&#039;&#039;&#039; &amp;lt;span class=&amp;quot;new-label&amp;quot; style=&amp;quot;background: green;color: white;display: inline-block;padding: 0 5px;font-weight: bold;font-size: 0.8em;&amp;quot;&amp;gt;NEW&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding-right: 100px;vertical-align: top&amp;quot; |&lt;br /&gt;
To authenticate for these endpoints, use [[Barion Wallet Authentication]].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span class=&amp;quot;api-ver&amp;quot;&amp;gt;v6&amp;lt;/span&amp;gt; [[Recipients-Get-v6|GET /v6/recipients]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span class=&amp;quot;api-ver&amp;quot;&amp;gt;v6&amp;lt;/span&amp;gt; [[Recipient-Get-v6|GET /v6/recipients/{recipientid}]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span class=&amp;quot;api-ver&amp;quot;&amp;gt;v6&amp;lt;/span&amp;gt; [[Recipients-Post-v6|POST /v6/recipients]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span class=&amp;quot;api-ver&amp;quot;&amp;gt;v6&amp;lt;/span&amp;gt; [[Recipient-Patch-v6|PATCH /v6/recipients/{recipientid}]]&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;span class=&amp;quot;api-ver&amp;quot;&amp;gt;v6&amp;lt;/span&amp;gt; [[Recipient-Delete-v6|DELETE /v6/recipients/{recipientid}]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span class=&amp;quot;api-ver&amp;quot;&amp;gt;v6&amp;lt;/span&amp;gt; [[PayoutMethods-Get-v6|GET /v6/recipients/{recipientid}/payout-methods]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span class=&amp;quot;api-ver&amp;quot;&amp;gt;v6&amp;lt;/span&amp;gt; [[PayoutMethod-Post-v6|POST /v6/recipients/{recipientid}/payout-methods]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span class=&amp;quot;api-ver&amp;quot;&amp;gt;v6&amp;lt;/span&amp;gt; [[PayoutMethod-Delete-v6|DELETE /v6/recipients/{recipientid}/payout-methods/{payoutmethodid}]]&lt;br /&gt;
| style=&amp;quot;padding-right: 100px;vertical-align: top&amp;quot;  |&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;padding-right: 100px;vertical-align: top&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=IMPORTANT|text=Always prefix endpoints with the corresponding API version.|color=#FF7A3D}}&lt;br /&gt;
&lt;br /&gt;
==Other interfaces==&lt;br /&gt;
[[Callback_mechanism|Barion callback mechanism - how to properly get notified about the results of Barion Smart Gateway payments]]&lt;/div&gt;</summary>
		<author><name>Salamongy@barion.dev</name></author>
	</entry>
	<entry>
		<id>https://docs.barion.com/index.php?title=Payment-Reject-v2&amp;diff=4950</id>
		<title>Payment-Reject-v2</title>
		<link rel="alternate" type="text/html" href="https://docs.barion.com/index.php?title=Payment-Reject-v2&amp;diff=4950"/>
		<updated>2026-10-19T14:01:57Z</updated>

		<summary type="html">&lt;p&gt;Salamongy@barion.dev: Created page with &amp;quot;__TOC__  {| class=&amp;quot;wikitable&amp;quot; ! style=&amp;quot;width:80px;&amp;quot; | POST | &amp;lt;code&amp;gt;/v2/Payment/Reject&amp;lt;/code&amp;gt; |}  The &amp;lt;code&amp;gt;/payment/reject&amp;lt;/code&amp;gt; API endpoint is used to cancel a payment in the Barion system before the payer completes it. After a successful call, the payer can no longer pay it.  Prerequisites before use: * Creating an account in Barion * Creating a shop in Barion * Calling the Barion API * Initializing a payment  &amp;lt;small&amp;gt;v...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! style=&amp;quot;width:80px;&amp;quot; | POST&lt;br /&gt;
| &amp;lt;code&amp;gt;/v2/Payment/Reject&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;/payment/reject&amp;lt;/code&amp;gt; API endpoint is used to cancel a payment in the Barion system before the payer completes it. After a successful call, the payer can no longer pay it.&lt;br /&gt;
&lt;br /&gt;
Prerequisites before use:&lt;br /&gt;
* [[Creating an account in Barion]]&lt;br /&gt;
* [[Creating a shop in Barion]]&lt;br /&gt;
* [[Calling the API|Calling the Barion API]]&lt;br /&gt;
* [[Payment-Start-v2|Initializing a payment]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;small&amp;gt;v2&amp;lt;/small&amp;gt; This API endpoint is available in &#039;&#039;&#039;API v2&#039;&#039;&#039; only.&lt;br /&gt;
&lt;br /&gt;
== Authentication ==&lt;br /&gt;
[[Barion Shop Authentication]]&lt;br /&gt;
&lt;br /&gt;
== Use cases ==&lt;br /&gt;
This API endpoint is designed to be used in the following scenarios:&lt;br /&gt;
* [[Responsive Web Payment]]&lt;br /&gt;
&lt;br /&gt;
Only payments in &#039;&#039;&#039;Prepared&#039;&#039;&#039; status can be rejected, meaning the payer has not completed them yet. The result is the same as when the payer clicks &#039;&#039;&#039;&amp;quot;Back to shop without payment&amp;quot;&#039;&#039;&#039; on the Barion Smart Gateway:&lt;br /&gt;
* the payment status becomes &#039;&#039;&#039;Canceled&#039;&#039;&#039;,&lt;br /&gt;
* its unpaid transactions become &#039;&#039;&#039;Rejected&#039;&#039;&#039;,&lt;br /&gt;
* Barion sends a [[Callback mechanism|callback]] to the shop.&lt;br /&gt;
&lt;br /&gt;
Use other endpoints for payments in other stages:&lt;br /&gt;
* to release an &#039;&#039;&#039;authorized&#039;&#039;&#039; delayed capture payment, use [[Payment-CancelAuthorization-v2|Payment/CancelAuthorization]],&lt;br /&gt;
* to return money from a &#039;&#039;&#039;completed&#039;&#039;&#039; payment, use [[Payment-Refund-v2|Payment/Refund]].&lt;br /&gt;
&lt;br /&gt;
== Input properties ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Property name !! Property type !! Limitations and constraints !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;POSKey&#039;&#039;&#039;&lt;br /&gt;
| Guid&lt;br /&gt;
|&lt;br /&gt;
* Required&lt;br /&gt;
| The secret API key of the shop, generated by Barion. This lets the shop authenticate through the Barion API, but does not provide access to the account owning the shop itself.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PaymentId&#039;&#039;&#039;&lt;br /&gt;
| Guid&lt;br /&gt;
|&lt;br /&gt;
* Required&lt;br /&gt;
* The payment must be in &amp;lt;code&amp;gt;Prepared&amp;lt;/code&amp;gt; status&lt;br /&gt;
| The identifier of the payment to reject, as returned by [[Payment-Start-v2|Payment/Start]]. If the payment is already &amp;lt;code&amp;gt;Canceled&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;Expired&amp;lt;/code&amp;gt;, or is in any other status, the call returns an error.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Output properties ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Property name !! Property type !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PaymentId&#039;&#039;&#039;&lt;br /&gt;
| Guid&lt;br /&gt;
| The identifier of the payment, the same as in the request.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;IsSuccessful&#039;&#039;&#039;&lt;br /&gt;
| bool&lt;br /&gt;
| &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; if the payment was rejected successfully.&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Salamongy@barion.dev</name></author>
	</entry>
	<entry>
		<id>https://docs.barion.com/index.php?title=Apple_Pay&amp;diff=4946</id>
		<title>Apple Pay</title>
		<link rel="alternate" type="text/html" href="https://docs.barion.com/index.php?title=Apple_Pay&amp;diff=4946"/>
		<updated>2026-09-18T06:42:56Z</updated>

		<summary type="html">&lt;p&gt;Salamongy@barion.dev: Remove empty paragraph&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{PageTitle|title=Apple Pay integration}}&lt;br /&gt;
{{TableOfContents}}&lt;br /&gt;
&lt;br /&gt;
Apple Pay is a wallet solution created by Apple for Apple customers. It is only accessible in the Apple ecosystem. You can use it with your iPhone, iWatch or with your desktop/laptop Macintosh computer. When it comes to Barion there are two different ways to use this payment option:&lt;br /&gt;
&lt;br /&gt;
* on the Barion Smart Gateway (called hosted mode)&lt;br /&gt;
* in their webshop if they integrate the so-called integrated mode&lt;br /&gt;
&lt;br /&gt;
The customer who wants to pay with Apple Pay Wallet must have an Apple device that supports authentication. This could be&lt;br /&gt;
&lt;br /&gt;
* an iPhone,&lt;br /&gt;
* a modern MacBook with fingerprint authentication or&lt;br /&gt;
* an older MacBook with a paired iPhone&lt;br /&gt;
&lt;br /&gt;
=== Browser support ===&lt;br /&gt;
Apple Pay behaves differently depending on the customer&#039;s browser:&amp;lt;blockquote&amp;gt;&lt;br /&gt;
* In Safari, and in any browser built on Apple&#039;s WebKit engine (Chrome, Firefox, or Edge on iOS), the button works natively, and the customer confirms the payment with Touch ID or Face ID.&lt;br /&gt;
* In other desktop browsers that can&#039;t run Apple Pay directly (for example Chrome, Firefox, or Edge on Windows), Apple&#039;s SDK automatically shows a QR code that the customer scans with their iPhone&#039;s Camera app (requires &#039;&#039;&#039;iOS 18 or later&#039;&#039;&#039;) to complete the payment there.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;Furthermore, the customer must fill out their home address and their contact information in their Apple Pay wallet as well. Without this, they won&#039;t be able to use their card in their Apple Wallet. This can be done even during the payment process.&lt;br /&gt;
&lt;br /&gt;
This feature is listed as an available payment method on the shop&#039;s admin site&lt;br /&gt;
&lt;br /&gt;
In case it is switched off the shop won&#039;t be able to display it as a funding source. This won&#039;t produce any error message, the Apple Pay option just won&#039;t be visible.&lt;br /&gt;
&lt;br /&gt;
=== Hosted mode ===&lt;br /&gt;
This is the &amp;quot;out of the box&amp;quot; mode that is available on the Barion Smart Gateway. It works in every browser described in the &#039;&#039;&#039;Browser support&#039;&#039;&#039; section above — natively in &#039;&#039;&#039;Safari&#039;&#039;&#039; and other WebKit-based browsers, and via the QR code hand-off in other desktop browsers.&lt;br /&gt;
&lt;br /&gt;
If the customer selects the Apple Pay accordion, the Apple Pay button will be visible.&lt;br /&gt;
&lt;br /&gt;
Once the customer clicks the Pay button the Apple Pay screen is displayed. This screen is actually controlled by the device, we don&#039;t have any control over it.&lt;br /&gt;
&lt;br /&gt;
On this screen, the customer may change the used credit card, the home address, or the e-mail address. These are all required to pay via Apple Pay. Once the customer approves the transaction everything continues as with a normal card would.&lt;br /&gt;
&lt;br /&gt;
=== Integrated mode ===&lt;br /&gt;
In integrated mode (called processor mode in Apple documentation) the webshop owner puts the Apple Pay button in their webshop and does not need to redirect the customer to the Barion Smart Gateway. This feature requires custom development from the webshop owner. The shop has to implement the Apple Pay button (instead of just relying on our gateway). To do this, they have to read through [[Apple Pay#Steps|this documentation]].&lt;br /&gt;
&lt;br /&gt;
The Apple Pay button can be displayed anywhere on the webshop. For example, on our demomerchant site is next to the Google Pay button.&lt;br /&gt;
&lt;br /&gt;
This integration requires a developer and is beneficial for shops that want to provide their customer a faster payment experience (since there is no need to redirect them to our gateway).&lt;br /&gt;
&lt;br /&gt;
To enable the button on the merchant&#039;s website the website has to be registered at Apple services. To help with this task we created a setting screen in our system. This setting page is available from the shop&#039;s setting page. (The one accessible by the owner)&lt;br /&gt;
&lt;br /&gt;
On this page, the owner has to input all the domains that the shop is using for the Apple Pay button. In addition to this the owner also has to upload a domain verification file to its domain.&lt;br /&gt;
&lt;br /&gt;
=== After payment ===&lt;br /&gt;
After the successful payment, the customer receives the usual confirmation letter, however, the bank card is clearly flagged, so the customer is aware that the payment was funded with a card from their Apple Wallet.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Warning:&#039;&#039;&#039; The card number displayed here is not the real card number. Apple creates a fake card number to protect the real card, so we are only aware of the fake number.&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting domain association errors ==&lt;br /&gt;
Some common pitfalls with domain association files can be found below.&lt;br /&gt;
&lt;br /&gt;
* domain association file cannot be reached without authentication&lt;br /&gt;
* response doesn’t contain “Content-Type” header with value “application/json”&lt;br /&gt;
* merchant’s server only supports TLS 1.3 (Barion uses 1.2 for checking this file)&lt;br /&gt;
* merchant has some form of bot/scraping protection enabled, which filters out requests that has a non-browser shaped or missing User-Agent header&lt;br /&gt;
&lt;br /&gt;
== Contact ==&lt;br /&gt;
George Maroufidis &amp;lt;gmaroufidis@apple.com&amp;gt;&lt;br /&gt;
&lt;br /&gt;
George Maroufidis |  Pay eCommerce EMEIA | OneBattersea Power Station, London, SW11 8BZ, United Kingdom | iPhone: +44 7591 916 527&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
* Apple Pay Marketing Guidelines&lt;br /&gt;
* Human Interface Guidelines&lt;br /&gt;
&lt;br /&gt;
== Reference ==&lt;br /&gt;
&lt;br /&gt;
* Configuring the environment&lt;br /&gt;
* Apple Pay on the web&lt;br /&gt;
* PaymentToken&lt;br /&gt;
* Sandbox&lt;br /&gt;
&amp;lt;blockquote&amp;gt;This article is about directly integrating the Apple Pay button in your webshop.&lt;br /&gt;
&lt;br /&gt;
If you simply want to display Apple Pay as a payment option in the Barion Smart Gateway, no further configuration is necessary; pass &amp;quot;ApplePay&amp;quot; in [[FundingSources|the FundingSources array]] when preparing a payment.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
The appeal of Apple Pay is that it requires only two actions from the customer: selecting the ‘Pay with Apple Pay’ button, and confirming the payment with Touch ID or Face ID.&lt;br /&gt;
&lt;br /&gt;
Another advantage to your Barion shop’s payment workflow is that customers aren’t navigated away from your checkout page when using Apple Pay.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;prerequisites&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=IMPORTANT|text=You do not need to register an Apple Developer Account! Should you need an Apple Merchant Id, use the PublicId (guid) of your shop!|color=#FF7A3D}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;access to and being able to modify both your webshop’s front-end and back-end code&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;your webshop using HTTPS (having a TLS 1.2 or higher certificate installed) for all its pages that include the Apple Pay button&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Barion Wallet with an approved Barion shop&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;the Barion shop complies with [https://developer.apple.com/apple-pay/acceptable-use-guidelines-for-websites/ Apple’s acceptable use guidelines], including not selling prohibited products or services&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;Note that Apple’s policies regarding acceptable products and services are more limiting than those of Barion.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;It may happen that even though Barion approves your Barion shop to sell a certain item, you will not be allowed to display the Apple Pay button as a payment option for customers to pay for that item.&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;an account in the Barion Wallet for each of the currencies that you’d like to accept using Apple Pay&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Limitations ==&lt;br /&gt;
&lt;br /&gt;
* you can’t yet tokenize your customer’s card details when using the Apple Pay button, so [[Token payment 3D Secure|recurring payments]] aren’t available&lt;br /&gt;
* Barion currently only supports Apple Pay button on the web, and not on native iOS apps&lt;br /&gt;
* regardless of the integration detailed here, the Apple Pay button will only be displayed to your customers if they comply with Apple’s requirements:&lt;br /&gt;
** they’re using [https://support.apple.com/en-us/102896 an Apple Pay-compatible device]&lt;br /&gt;
** they’re viewing your webshop using a browser that supports Apple Pay&lt;br /&gt;
** they’re located [https://support.apple.com/en-us/102775 in a country or region where Apple Pay is available]&lt;br /&gt;
== Steps ==&lt;br /&gt;
=== Setting up your Apple prerequisites ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;When using Barion’s Apple Pay API endpoints, Barion gives you [https://developer.apple.com/support/app-account/ an Apple developer account], and registers [https://developer.apple.com/documentation/applepaywebmerchantregistrationapi/registering_with_apple_pay_and_applying_to_use_the_api a Merchant ID], [https://help.apple.com/developer-account/#/devb2e62b839?sub=devf31990e3f Payment Processing Certificate], and [https://help.apple.com/developer-account/#/dev1731126fb Merchant Identity Certificate] for you as a subsidiary of Barion’s Apple Pay credentials.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
Verify and register your webshop’s domain name or names:&lt;br /&gt;
&lt;br /&gt;
# Log in to your Barion Wallet, and go to your Barion shop’s Shops&amp;amp;gt;Actions&amp;amp;gt;Settings screen.&lt;br /&gt;
# Click the “Manage Apple Pay settings”, and then “Download domain verification file” to save the verification file for your shop’s domain.&lt;br /&gt;
# Save the domain verification file that you downloaded in the &amp;lt;code&amp;gt;/.well-known&amp;lt;/code&amp;gt; directory of all the sites that your specified domains use, making sure of the following:&lt;br /&gt;
#* the file should send the &amp;lt;code&amp;gt;&amp;lt;mimeMap fileExtension=&amp;quot;.&amp;quot; mimeType=&amp;quot;application/json&amp;quot; /&amp;gt;&amp;lt;/code&amp;gt; MIME data;&lt;br /&gt;
#* the file must be accessible externally, and not be password-protected, or behind a proxy or redirect;&lt;br /&gt;
#* the sites must be served over HTTPS.&lt;br /&gt;
# Enter all the domains that you’d like to use Apple Pay on (into whose root you’ve downloaded the domain verification file) in the text box provided, then click “Save”.&lt;br /&gt;
&lt;br /&gt;
=== Configuring and displaying the Apple Pay button ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol style=&amp;quot;list-style-type: decimal;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Load the button script into your checkout page by adding the following script tag inside the page head:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;html&amp;quot;&amp;gt;&amp;lt;script crossorigin src=&amp;quot;https://applepay.cdn-apple.com/jsapi/1.latest/apple-pay-sdk.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Always load the always-current &amp;lt;code&amp;gt;1.latest&amp;lt;/code&amp;gt; path instead of a pinned version, and keep the &amp;lt;code&amp;gt;crossorigin&amp;lt;/code&amp;gt; attribute — it is required for the native &amp;lt;code&amp;gt;&amp;amp;lt;apple-pay-button&amp;amp;gt;&amp;lt;/code&amp;gt; element and for the cross-browser behaviour (native in WebKit, QR code hand-off on other desktop browsers) to work correctly.&amp;lt;/blockquote&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;This script makes an ApplePaySession available to your site front-end, among other things.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;ol start=&amp;quot;2&amp;quot; style=&amp;quot;list-style-type: decimal;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Add the &amp;lt;code&amp;gt;apple-pay-button&amp;lt;/code&amp;gt; custom element (for example, &amp;lt;code&amp;gt;&amp;amp;lt;apple-pay-button id=&amp;quot;apple-pay-button&amp;quot; buttonstyle=&amp;quot;black&amp;quot; type=&amp;quot;plain&amp;quot;&amp;amp;gt;&amp;amp;lt;/apple-pay-button&amp;amp;gt;&amp;lt;/code&amp;gt;) to your checkout page. The official SDK renders this element natively — you no longer need to write your own CSS to display it.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=IMPORTANT|text=The &amp;amp;lt;apple-pay-button&amp;amp;gt; element&#039;s size can&#039;t be set with ordinary CSS height/border-radius properties — its internal shadow-DOM content won&#039;t follow them. Use the dedicated CSS custom properties instead: --apple-pay-button-height and --apple-pay-button-border-radius.|color=#FF7A3D}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;css&amp;quot;&amp;gt;apple-pay-button {&lt;br /&gt;
  --apple-pay-button-height: 48px;&lt;br /&gt;
  --apple-pay-button-border-radius: 8px;&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Start a new ApplePaySession when the checkout page loads:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;  const request = {&lt;br /&gt;
    countryCode: &#039;US&#039;,&lt;br /&gt;
    currencyCode: &#039;USD&#039;,&lt;br /&gt;
    supportedNetworks: [&#039;visa&#039;, &#039;masterCard&#039;, &#039;discover&#039;],&lt;br /&gt;
    merchantCapabilities: [&#039;supports3DS&#039;],&lt;br /&gt;
    total: { label: &#039;Your Merchant Name&#039;, amount: &#039;10.00&#039; }&lt;br /&gt;
  }&lt;br /&gt;
  const applePlaySession = new ApplePaySession(3, request);&lt;br /&gt;
&lt;br /&gt;
  // add an isSessionCanceled boolean to easily be able to cancel the session if your user abandons the in-progress payment process&lt;br /&gt;
  var isSessionCanceled = false;&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&amp;lt;blockquote&amp;gt;The merchant may supply the shipping and billing contact information directly, or request it when starting the ApplePaySession by including the [https://developer.apple.com/documentation/applepayontheweb/applepaypaymentrequest/requiredshippingcontactfields requiredShippingContactFields]  and [https://developer.apple.com/documentation/applepayontheweb/applepaypaymentrequest/requiredbillingcontactfields requiredBillingContactFields] properties in the payment request. More about the Apple Pay payment request [https://developer.apple.com/documentation/applepayontheweb/applepaypaymentrequest here].&amp;lt;/blockquote&amp;gt;&amp;lt;ol start=&amp;quot;4&amp;quot; style=&amp;quot;list-style-type: decimal;&amp;quot;&amp;gt;&amp;lt;li&amp;gt;&lt;br /&gt;
    &amp;lt;p&amp;gt;Make sure to only display the Apple Pay button to users who can use it, by have your webshop’s checkout pages do&lt;br /&gt;
      the following when they load:&amp;lt;/p&amp;gt;&lt;br /&gt;
    &amp;lt;p&amp;gt;Call [https://developer.apple.com/documentation/applepayontheweb/applepaysession/canmakepayments &amp;lt;code&amp;gt;ApplePaySession.canMakePayments()&amp;lt;/code&amp;gt;] to check, in a single simple boolean call, whether Apple Pay is available at all on the customer&#039;s device/browser — this is the method needed to decide whether to show the button.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;p&amp;gt;If you additionally need detailed status about a specific merchant and the customer&#039;s stored cards, use [https://developer.apple.com/documentation/applepayontheweb/applepaysession/applepaycapabilities &amp;lt;code&amp;gt;applePaySession.applePayCapabilities()&amp;lt;/code&amp;gt;], passing it your Barion shop’s public Id as the merchantId parameter.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;blockquote&amp;gt;&amp;lt;code&amp;gt;applePaySession.canMakePaymentsWithActiveCard&amp;lt;/code&amp;gt; is &#039;&#039;&#039;deprecated&#039;&#039;&#039; by Apple — use &amp;lt;code&amp;gt;applePayCapabilities&amp;lt;/code&amp;gt; instead for that detailed check.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;p&amp;gt;If Apple can verify your Barion shop as a registered Apple Pay provider, the detailed check reports the following:&amp;lt;/p&amp;gt;&lt;br /&gt;
    &amp;lt;ul&amp;gt;&lt;br /&gt;
      &amp;lt;li&amp;gt;that your customer&#039;s device is capable of using Apple Pay&amp;lt;/li&amp;gt;&lt;br /&gt;
      &amp;lt;li&amp;gt;that Apple Pay is enabled on your customer&#039;s device, and&amp;lt;/li&amp;gt;&lt;br /&gt;
      &amp;lt;li&amp;gt;that the customer has the details of at least one active and web payment-eligible bank card stored in their Apple  Pay wallet.&amp;lt;/li&amp;gt;&lt;br /&gt;
    &amp;lt;/ul&amp;gt;&lt;br /&gt;
  &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;Handle [https://developer.apple.com/documentation/apple_pay_on_the_web/paymentcredentialstatus the &amp;lt;code&amp;gt;PaymentCredentialStatus&amp;lt;/code&amp;gt; object] that the method returns to make a decision about displaying the Apple Pay button.&lt;br /&gt;
  &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Handling payments ===&lt;br /&gt;
&lt;br /&gt;
Set up your webshop to perform these steps each time a user selects the Apple Pay button.&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=IMPORTANT|text=The &amp;amp;lt;apple-pay-button&amp;amp;gt; element does not dispatch a standard bubbling DOM click event, so addEventListener / jQuery .on(&#039;click&#039;, ...) (whether bound to the element or to a container around it) will not fire. Bind your click handler directly to the element&#039;s onclick property instead.|color=#FF7A3D}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;document.getElementById(&#039;apple-pay-button&#039;).onclick = function (event) {&lt;br /&gt;
    // start your ApplePaySession here&lt;br /&gt;
};&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol style=&amp;quot;list-style-type: decimal;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Set up an event handler for [https://developer.apple.com/documentation/apple_pay_on_the_web/applepaysession/1778021-onvalidatemerchant &amp;lt;code&amp;gt;ApplePaySession.onvalidatemerchant&amp;lt;/code&amp;gt;] that notifies your site&#039;s back-end, and passes it the event response.&amp;lt;/p&amp;gt;&amp;lt;blockquote&amp;gt;Don&#039;t call the ValidateSession Barion API endpoint directly from the browser, as this could expose your Barion shop&#039;s POSKey.&amp;lt;/blockquote&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Have your site&#039;s back-end call [[ApplePay-ValidateSession|the ValidateSession Barion API endpoint]], passing it the &amp;lt;code&amp;gt;onvalidatemerchant&amp;lt;/code&amp;gt; event’s &amp;lt;code&amp;gt;ValidationUrl&amp;lt;/code&amp;gt; attribute.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;async function validateApplePaySession(POSKey, SessionRequestUrl, ShopUrl) {&lt;br /&gt;
  const url = &amp;quot;https://api.test.barion.com/v2/ApplePay/ValidateSession&amp;quot;;&lt;br /&gt;
  const data = {&lt;br /&gt;
    POSKey,&lt;br /&gt;
    SessionRequestUrl,&lt;br /&gt;
    ShopUrl,&lt;br /&gt;
  };&lt;br /&gt;
&lt;br /&gt;
  try {&lt;br /&gt;
    const response = await fetch(url, {&lt;br /&gt;
      method: &amp;quot;POST&amp;quot;,&lt;br /&gt;
      headers: {&lt;br /&gt;
        &amp;quot;Content-Type&amp;quot;: &amp;quot;application/json&amp;quot;,&lt;br /&gt;
      },&lt;br /&gt;
      body: JSON.stringify(data),&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
    if (!response.ok) {&lt;br /&gt;
      throw new Error(`Error: ${response.status} ${response.statusText}`);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    const result = await response.json();&lt;br /&gt;
    return result;&lt;br /&gt;
  } catch (error) {&lt;br /&gt;
    // handle the error according to your business logic&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
applePaySession.onvalidatemerchant = async function (event) {&lt;br /&gt;
  const validationResult = await validateApplePaySession(POSKey, event.validationURL, ShopUrl);&lt;br /&gt;
  &lt;br /&gt;
  applePaySession.completeMerchantValidation(validationResult.ApplePaySessionResponse);&lt;br /&gt;
};&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;This event is triggered when the Apple Pay payment sheet is displayed to the customer.&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Set up an event handler for [https://developer.apple.com/documentation/apple_pay_on_the_web/applepaysession/1778020-onpaymentauthorized &amp;lt;code&amp;gt;ApplePaySession.onpaymentauthorized&amp;lt;/code&amp;gt;]&amp;lt;/p&amp;gt;&amp;lt;blockquote&amp;gt;Don&#039;t call the StartPaymentWithAppleToken Barion API endpoint directly from the browser, as this could expose your Barion shop&#039;s POSKey.&amp;lt;/blockquote&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;that calls the [[ApplePay-StartPaymentWithAppleToken|StartPaymentWithAppleToken Barion API endpoint]], passing it the event’s following attributes:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;token&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;shippingContact&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;billingContact&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note that &amp;lt;code&amp;gt;StartPaymentWithAppleToken&amp;lt;/code&amp;gt; is actually a specialized version of [[Payment-Start-v2|the payment/start API endpoint]], and so will also require all the usual parameters that you’d pass to that endpoint.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
async function startApplePayPayment(&lt;br /&gt;
  POSKey,&lt;br /&gt;
  ShippingContact,&lt;br /&gt;
  BillingContact,&lt;br /&gt;
  Token,&lt;br /&gt;
  /** include other required and optional Payment/Start params */&lt;br /&gt;
  PaymentStartProperties&lt;br /&gt;
) {&lt;br /&gt;
  const url =&lt;br /&gt;
    &amp;quot;https://api.test.barion.com/v2/ApplePay/StartPaymentWithAppleToken&amp;quot;;&lt;br /&gt;
  const data = {&lt;br /&gt;
    POSKey,&lt;br /&gt;
    ShippingContact,&lt;br /&gt;
    BillingContact,&lt;br /&gt;
    Token,&lt;br /&gt;
    ...PaymentStartProperties,&lt;br /&gt;
  };&lt;br /&gt;
&lt;br /&gt;
  try {&lt;br /&gt;
    const response = await fetch(url, {&lt;br /&gt;
      method: &amp;quot;POST&amp;quot;,&lt;br /&gt;
      headers: {&lt;br /&gt;
        &amp;quot;Content-Type&amp;quot;: &amp;quot;application/json&amp;quot;,&lt;br /&gt;
      },&lt;br /&gt;
      body: JSON.stringify(data),&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
    if (!response.ok) {&lt;br /&gt;
      throw new Error(`Error: ${response.status} ${response.statusText}`);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    const result = await response.json();&lt;br /&gt;
    return result;&lt;br /&gt;
  } catch (error) {&lt;br /&gt;
    // handle the error according to your business logic&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
const PaymentStartProperties = {&lt;br /&gt;
  PaymentType: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
applePaySession.onpaymentauthorized = function (event) {&lt;br /&gt;
  startApplePayPayment(&lt;br /&gt;
    POSKey,&lt;br /&gt;
    event.paymentInfo.shippingContent,&lt;br /&gt;
    event.paymentInfo.billingContact,&lt;br /&gt;
    event.paymentInfo.Token,&lt;br /&gt;
    PaymentStartProperties&lt;br /&gt;
  );&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;This event is triggered when the customer has authorized the Apple Pay payment using their Touch ID or Face ID.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Set up an event handler for &amp;lt;code&amp;gt;oncancel&amp;lt;/code&amp;gt; to implement your business logic for when the user abandons the Apple Pay payment.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Make sure that your event handler indicates that the session is canceled so the ApplePaySession’s &amp;lt;code&amp;gt;completePayment&amp;lt;/code&amp;gt; method doesn’t get executed.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;  applePaySession.oncancel = function (event) {&lt;br /&gt;
    // your oncancel business logic&lt;br /&gt;
&lt;br /&gt;
    isSessionCanceled = true;&lt;br /&gt;
  };&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Call [https://developer.apple.com/documentation/apple_pay_on_the_web/applepaysession/1778001-begin ApplePaySession.begin] to kick off the payment process.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;  applePaySession.begin();&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;This starts the merchant validation process that results in &amp;lt;code&amp;gt;ApplePaySession.onvalidatemerchant&amp;lt;/code&amp;gt; being triggered.&amp;lt;/blockquote&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Testing your implementation ===&lt;br /&gt;
&lt;br /&gt;
The following steps are needed in order to test your implementation:&lt;br /&gt;
# request access by sending an email to devsupport@barion.com!&lt;br /&gt;
# include an email address, that has no Apple Id yet&lt;br /&gt;
# we will register &amp;amp; connect it to our test account&lt;br /&gt;
# after that, you will be able to [https://developer.apple.com/apple-pay/sandbox-testing/ use Apple&#039;s test cards]&lt;br /&gt;
To test the new cross-browser QR code hand-off (for customers on desktop non-Safari browsers), you need an iPhone running &#039;&#039;&#039;iOS 18 or later&#039;&#039;&#039; — this is a separate, newer requirement that applies only to this specific feature.&lt;br /&gt;
&lt;br /&gt;
macOS is not enough to use Apple Pay. To use Apple Pay natively on macOS, you should configure the Handoff function on your devices. This Handoff requirement applies to &#039;&#039;&#039;Safari&#039;&#039;&#039; on macOS. Non-Safari desktop browsers (including Chrome or Firefox on macOS) don&#039;t need Handoff configured at all — they use the QR code hand-off flow instead.&lt;br /&gt;
&lt;br /&gt;
== Related links ==&lt;br /&gt;
&lt;br /&gt;
[[ApplePay-ValidateSession|ValidateSession API endpoint]]&lt;br /&gt;
&lt;br /&gt;
[[ApplePay-StartPaymentWithAppleToken|StartPaymentWithAppleToken API endpoint]]&lt;/div&gt;</summary>
		<author><name>Salamongy@barion.dev</name></author>
	</entry>
	<entry>
		<id>https://docs.barion.com/index.php?title=Apple_Pay&amp;diff=4945</id>
		<title>Apple Pay</title>
		<link rel="alternate" type="text/html" href="https://docs.barion.com/index.php?title=Apple_Pay&amp;diff=4945"/>
		<updated>2026-09-18T06:41:25Z</updated>

		<summary type="html">&lt;p&gt;Salamongy@barion.dev: link update&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{PageTitle|title=Apple Pay integration}}&lt;br /&gt;
{{TableOfContents}}&lt;br /&gt;
&lt;br /&gt;
Apple Pay is a wallet solution created by Apple for Apple customers. It is only accessible in the Apple ecosystem. You can use it with your iPhone, iWatch or with your desktop/laptop Macintosh computer. When it comes to Barion there are two different ways to use this payment option:&lt;br /&gt;
&lt;br /&gt;
* on the Barion Smart Gateway (called hosted mode)&lt;br /&gt;
* in their webshop if they integrate the so-called integrated mode&lt;br /&gt;
&lt;br /&gt;
The customer who wants to pay with Apple Pay Wallet must have an Apple device that supports authentication. This could be&lt;br /&gt;
&lt;br /&gt;
* an iPhone,&lt;br /&gt;
* a modern MacBook with fingerprint authentication or&lt;br /&gt;
* an older MacBook with a paired iPhone&lt;br /&gt;
&lt;br /&gt;
=== Browser support ===&lt;br /&gt;
Apple Pay behaves differently depending on the customer&#039;s browser:&amp;lt;blockquote&amp;gt;&lt;br /&gt;
* In Safari, and in any browser built on Apple&#039;s WebKit engine (Chrome, Firefox, or Edge on iOS), the button works natively, and the customer confirms the payment with Touch ID or Face ID.&lt;br /&gt;
* In other desktop browsers that can&#039;t run Apple Pay directly (for example Chrome, Firefox, or Edge on Windows), Apple&#039;s SDK automatically shows a QR code that the customer scans with their iPhone&#039;s Camera app (requires &#039;&#039;&#039;iOS 18 or later&#039;&#039;&#039;) to complete the payment there.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;Furthermore, the customer must fill out their home address and their contact information in their Apple Pay wallet as well. Without this, they won&#039;t be able to use their card in their Apple Wallet. This can be done even during the payment process.&lt;br /&gt;
&lt;br /&gt;
This feature is listed as an available payment method on the shop&#039;s admin site&lt;br /&gt;
&lt;br /&gt;
In case it is switched off the shop won&#039;t be able to display it as a funding source. This won&#039;t produce any error message, the Apple Pay option just won&#039;t be visible.&lt;br /&gt;
&lt;br /&gt;
=== Hosted mode ===&lt;br /&gt;
This is the &amp;quot;out of the box&amp;quot; mode that is available on the Barion Smart Gateway. It works in every browser described in the &#039;&#039;&#039;Browser support&#039;&#039;&#039; section above — natively in &#039;&#039;&#039;Safari&#039;&#039;&#039; and other WebKit-based browsers, and via the QR code hand-off in other desktop browsers.&lt;br /&gt;
&lt;br /&gt;
If the customer selects the Apple Pay accordion, the Apple Pay button will be visible.&lt;br /&gt;
&lt;br /&gt;
Once the customer clicks the Pay button the Apple Pay screen is displayed. This screen is actually controlled by the device, we don&#039;t have any control over it.&lt;br /&gt;
&lt;br /&gt;
On this screen, the customer may change the used credit card, the home address, or the e-mail address. These are all required to pay via Apple Pay. Once the customer approves the transaction everything continues as with a normal card would.&lt;br /&gt;
&lt;br /&gt;
=== Integrated mode ===&lt;br /&gt;
In integrated mode (called processor mode in Apple documentation) the webshop owner puts the Apple Pay button in their webshop and does not need to redirect the customer to the Barion Smart Gateway. This feature requires custom development from the webshop owner. The shop has to implement the Apple Pay button (instead of just relying on our gateway). To do this, they have to read through [[Apple Pay#Steps|this documentation]].&lt;br /&gt;
&lt;br /&gt;
The Apple Pay button can be displayed anywhere on the webshop. For example, on our demomerchant site is next to the Google Pay button.&lt;br /&gt;
&lt;br /&gt;
This integration requires a developer and is beneficial for shops that want to provide their customer a faster payment experience (since there is no need to redirect them to our gateway).&lt;br /&gt;
&lt;br /&gt;
To enable the button on the merchant&#039;s website the website has to be registered at Apple services. To help with this task we created a setting screen in our system. This setting page is available from the shop&#039;s setting page. (The one accessible by the owner)&lt;br /&gt;
&lt;br /&gt;
On this page, the owner has to input all the domains that the shop is using for the Apple Pay button. In addition to this the owner also has to upload a domain verification file to its domain.&lt;br /&gt;
&lt;br /&gt;
=== After payment ===&lt;br /&gt;
After the successful payment, the customer receives the usual confirmation letter, however, the bank card is clearly flagged, so the customer is aware that the payment was funded with a card from their Apple Wallet.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Warning:&#039;&#039;&#039; The card number displayed here is not the real card number. Apple creates a fake card number to protect the real card, so we are only aware of the fake number.&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting domain association errors ==&lt;br /&gt;
Some common pitfalls with domain association files can be found below.&lt;br /&gt;
&lt;br /&gt;
* domain association file cannot be reached without authentication&lt;br /&gt;
* response doesn’t contain “Content-Type” header with value “application/json”&lt;br /&gt;
* merchant’s server only supports TLS 1.3 (Barion uses 1.2 for checking this file)&lt;br /&gt;
* merchant has some form of bot/scraping protection enabled, which filters out requests that has a non-browser shaped or missing User-Agent header&lt;br /&gt;
&lt;br /&gt;
== Contact ==&lt;br /&gt;
George Maroufidis &amp;lt;gmaroufidis@apple.com&amp;gt;&lt;br /&gt;
&lt;br /&gt;
George Maroufidis |  Pay eCommerce EMEIA | OneBattersea Power Station, London, SW11 8BZ, United Kingdom | iPhone: +44 7591 916 527&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
* Apple Pay Marketing Guidelines&lt;br /&gt;
* Human Interface Guidelines&lt;br /&gt;
&lt;br /&gt;
== Reference ==&lt;br /&gt;
&lt;br /&gt;
* Configuring the environment&lt;br /&gt;
* Apple Pay on the web&lt;br /&gt;
* PaymentToken&lt;br /&gt;
* Sandbox&lt;br /&gt;
&amp;lt;blockquote&amp;gt;This article is about directly integrating the Apple Pay button in your webshop.&lt;br /&gt;
&lt;br /&gt;
If you simply want to display Apple Pay as a payment option in the Barion Smart Gateway, no further configuration is necessary; pass &amp;quot;ApplePay&amp;quot; in [[FundingSources|the FundingSources array]] when preparing a payment.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
The appeal of Apple Pay is that it requires only two actions from the customer: selecting the ‘Pay with Apple Pay’ button, and confirming the payment with Touch ID or Face ID.&lt;br /&gt;
&lt;br /&gt;
Another advantage to your Barion shop’s payment workflow is that customers aren’t navigated away from your checkout page when using Apple Pay.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;prerequisites&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=IMPORTANT|text=You do not need to register an Apple Developer Account! Should you need an Apple Merchant Id, use the PublicId (guid) of your shop!|color=#FF7A3D}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;access to and being able to modify both your webshop’s front-end and back-end code&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;your webshop using HTTPS (having a TLS 1.2 or higher certificate installed) for all its pages that include the Apple Pay button&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Barion Wallet with an approved Barion shop&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;the Barion shop complies with [https://developer.apple.com/apple-pay/acceptable-use-guidelines-for-websites/ Apple’s acceptable use guidelines], including not selling prohibited products or services&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;Note that Apple’s policies regarding acceptable products and services are more limiting than those of Barion.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;It may happen that even though Barion approves your Barion shop to sell a certain item, you will not be allowed to display the Apple Pay button as a payment option for customers to pay for that item.&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;an account in the Barion Wallet for each of the currencies that you’d like to accept using Apple Pay&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Limitations ==&lt;br /&gt;
&lt;br /&gt;
* you can’t yet tokenize your customer’s card details when using the Apple Pay button, so [[Token payment 3D Secure|recurring payments]] aren’t available&lt;br /&gt;
* Barion currently only supports Apple Pay button on the web, and not on native iOS apps&lt;br /&gt;
* regardless of the integration detailed here, the Apple Pay button will only be displayed to your customers if they comply with Apple’s requirements:&lt;br /&gt;
** they’re using [https://support.apple.com/en-us/102896 an Apple Pay-compatible device]&lt;br /&gt;
** they’re viewing your webshop using a browser that supports Apple Pay&lt;br /&gt;
** they’re located [https://support.apple.com/en-us/102775 in a country or region where Apple Pay is available]&lt;br /&gt;
== Steps ==&lt;br /&gt;
=== Setting up your Apple prerequisites ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;When using Barion’s Apple Pay API endpoints, Barion gives you [https://developer.apple.com/support/app-account/ an Apple developer account], and registers [https://developer.apple.com/documentation/applepaywebmerchantregistrationapi/registering_with_apple_pay_and_applying_to_use_the_api a Merchant ID], [https://help.apple.com/developer-account/#/devb2e62b839?sub=devf31990e3f Payment Processing Certificate], and [https://help.apple.com/developer-account/#/dev1731126fb Merchant Identity Certificate] for you as a subsidiary of Barion’s Apple Pay credentials.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
Verify and register your webshop’s domain name or names:&lt;br /&gt;
&lt;br /&gt;
# Log in to your Barion Wallet, and go to your Barion shop’s Shops&amp;amp;gt;Actions&amp;amp;gt;Settings screen.&lt;br /&gt;
# Click the “Manage Apple Pay settings”, and then “Download domain verification file” to save the verification file for your shop’s domain.&lt;br /&gt;
# Save the domain verification file that you downloaded in the &amp;lt;code&amp;gt;/.well-known&amp;lt;/code&amp;gt; directory of all the sites that your specified domains use, making sure of the following:&lt;br /&gt;
#* the file should send the &amp;lt;code&amp;gt;&amp;lt;mimeMap fileExtension=&amp;quot;.&amp;quot; mimeType=&amp;quot;application/json&amp;quot; /&amp;gt;&amp;lt;/code&amp;gt; MIME data;&lt;br /&gt;
#* the file must be accessible externally, and not be password-protected, or behind a proxy or redirect;&lt;br /&gt;
#* the sites must be served over HTTPS.&lt;br /&gt;
# Enter all the domains that you’d like to use Apple Pay on (into whose root you’ve downloaded the domain verification file) in the text box provided, then click “Save”.&lt;br /&gt;
&lt;br /&gt;
=== Configuring and displaying the Apple Pay button ===&lt;br /&gt;
&lt;br /&gt;
=== Configuring and displaying the Apple Pay button ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol style=&amp;quot;list-style-type: decimal;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Load the button script into your checkout page by adding the following script tag inside the page head:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;html&amp;quot;&amp;gt;&amp;lt;script crossorigin src=&amp;quot;https://applepay.cdn-apple.com/jsapi/1.latest/apple-pay-sdk.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Always load the always-current &amp;lt;code&amp;gt;1.latest&amp;lt;/code&amp;gt; path instead of a pinned version, and keep the &amp;lt;code&amp;gt;crossorigin&amp;lt;/code&amp;gt; attribute — it is required for the native &amp;lt;code&amp;gt;&amp;amp;lt;apple-pay-button&amp;amp;gt;&amp;lt;/code&amp;gt; element and for the cross-browser behaviour (native in WebKit, QR code hand-off on other desktop browsers) to work correctly.&amp;lt;/blockquote&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;This script makes an ApplePaySession available to your site front-end, among other things.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;ol start=&amp;quot;2&amp;quot; style=&amp;quot;list-style-type: decimal;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Add the &amp;lt;code&amp;gt;apple-pay-button&amp;lt;/code&amp;gt; custom element (for example, &amp;lt;code&amp;gt;&amp;amp;lt;apple-pay-button id=&amp;quot;apple-pay-button&amp;quot; buttonstyle=&amp;quot;black&amp;quot; type=&amp;quot;plain&amp;quot;&amp;amp;gt;&amp;amp;lt;/apple-pay-button&amp;amp;gt;&amp;lt;/code&amp;gt;) to your checkout page. The official SDK renders this element natively — you no longer need to write your own CSS to display it.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=IMPORTANT|text=The &amp;amp;lt;apple-pay-button&amp;amp;gt; element&#039;s size can&#039;t be set with ordinary CSS height/border-radius properties — its internal shadow-DOM content won&#039;t follow them. Use the dedicated CSS custom properties instead: --apple-pay-button-height and --apple-pay-button-border-radius.|color=#FF7A3D}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;css&amp;quot;&amp;gt;apple-pay-button {&lt;br /&gt;
  --apple-pay-button-height: 48px;&lt;br /&gt;
  --apple-pay-button-border-radius: 8px;&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Start a new ApplePaySession when the checkout page loads:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;  const request = {&lt;br /&gt;
    countryCode: &#039;US&#039;,&lt;br /&gt;
    currencyCode: &#039;USD&#039;,&lt;br /&gt;
    supportedNetworks: [&#039;visa&#039;, &#039;masterCard&#039;, &#039;discover&#039;],&lt;br /&gt;
    merchantCapabilities: [&#039;supports3DS&#039;],&lt;br /&gt;
    total: { label: &#039;Your Merchant Name&#039;, amount: &#039;10.00&#039; }&lt;br /&gt;
  }&lt;br /&gt;
  const applePlaySession = new ApplePaySession(3, request);&lt;br /&gt;
&lt;br /&gt;
  // add an isSessionCanceled boolean to easily be able to cancel the session if your user abandons the in-progress payment process&lt;br /&gt;
  var isSessionCanceled = false;&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&amp;lt;blockquote&amp;gt;The merchant may supply the shipping and billing contact information directly, or request it when starting the ApplePaySession by including the [https://developer.apple.com/documentation/applepayontheweb/applepaypaymentrequest/requiredshippingcontactfields requiredShippingContactFields]  and [https://developer.apple.com/documentation/applepayontheweb/applepaypaymentrequest/requiredbillingcontactfields requiredBillingContactFields] properties in the payment request. More about the Apple Pay payment request [https://developer.apple.com/documentation/applepayontheweb/applepaypaymentrequest here].&amp;lt;/blockquote&amp;gt;&amp;lt;ol start=&amp;quot;4&amp;quot; style=&amp;quot;list-style-type: decimal;&amp;quot;&amp;gt;&amp;lt;li&amp;gt;&lt;br /&gt;
    &amp;lt;p&amp;gt;Make sure to only display the Apple Pay button to users who can use it, by have your webshop’s checkout pages do&lt;br /&gt;
      the following when they load:&amp;lt;/p&amp;gt;&lt;br /&gt;
    &amp;lt;p&amp;gt;Call [https://developer.apple.com/documentation/applepayontheweb/applepaysession/canmakepayments &amp;lt;code&amp;gt;ApplePaySession.canMakePayments()&amp;lt;/code&amp;gt;] to check, in a single simple boolean call, whether Apple Pay is available at all on the customer&#039;s device/browser — this is the method needed to decide whether to show the button.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;p&amp;gt;If you additionally need detailed status about a specific merchant and the customer&#039;s stored cards, use [https://developer.apple.com/documentation/applepayontheweb/applepaysession/applepaycapabilities &amp;lt;code&amp;gt;applePaySession.applePayCapabilities()&amp;lt;/code&amp;gt;], passing it your Barion shop’s public Id as the merchantId parameter.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;blockquote&amp;gt;&amp;lt;code&amp;gt;applePaySession.canMakePaymentsWithActiveCard&amp;lt;/code&amp;gt; is &#039;&#039;&#039;deprecated&#039;&#039;&#039; by Apple — use &amp;lt;code&amp;gt;applePayCapabilities&amp;lt;/code&amp;gt; instead for that detailed check.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;p&amp;gt;If Apple can verify your Barion shop as a registered Apple Pay provider, the detailed check reports the following:&amp;lt;/p&amp;gt;&lt;br /&gt;
    &amp;lt;ul&amp;gt;&lt;br /&gt;
      &amp;lt;li&amp;gt;that your customer&#039;s device is capable of using Apple Pay&amp;lt;/li&amp;gt;&lt;br /&gt;
      &amp;lt;li&amp;gt;that Apple Pay is enabled on your customer&#039;s device, and&amp;lt;/li&amp;gt;&lt;br /&gt;
      &amp;lt;li&amp;gt;that the customer has the details of at least one active and web payment-eligible bank card stored in their Apple  Pay wallet.&amp;lt;/li&amp;gt;&lt;br /&gt;
    &amp;lt;/ul&amp;gt;&lt;br /&gt;
  &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;Handle [https://developer.apple.com/documentation/apple_pay_on_the_web/paymentcredentialstatus the &amp;lt;code&amp;gt;PaymentCredentialStatus&amp;lt;/code&amp;gt; object] that the method returns to make a decision about displaying the Apple Pay button.&lt;br /&gt;
  &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Handling payments ===&lt;br /&gt;
&lt;br /&gt;
Set up your webshop to perform these steps each time a user selects the Apple Pay button.&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=IMPORTANT|text=The &amp;amp;lt;apple-pay-button&amp;amp;gt; element does not dispatch a standard bubbling DOM click event, so addEventListener / jQuery .on(&#039;click&#039;, ...) (whether bound to the element or to a container around it) will not fire. Bind your click handler directly to the element&#039;s onclick property instead.|color=#FF7A3D}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;document.getElementById(&#039;apple-pay-button&#039;).onclick = function (event) {&lt;br /&gt;
    // start your ApplePaySession here&lt;br /&gt;
};&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol style=&amp;quot;list-style-type: decimal;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Set up an event handler for [https://developer.apple.com/documentation/apple_pay_on_the_web/applepaysession/1778021-onvalidatemerchant &amp;lt;code&amp;gt;ApplePaySession.onvalidatemerchant&amp;lt;/code&amp;gt;] that notifies your site&#039;s back-end, and passes it the event response.&amp;lt;/p&amp;gt;&amp;lt;blockquote&amp;gt;Don&#039;t call the ValidateSession Barion API endpoint directly from the browser, as this could expose your Barion shop&#039;s POSKey.&amp;lt;/blockquote&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Have your site&#039;s back-end call [[ApplePay-ValidateSession|the ValidateSession Barion API endpoint]], passing it the &amp;lt;code&amp;gt;onvalidatemerchant&amp;lt;/code&amp;gt; event’s &amp;lt;code&amp;gt;ValidationUrl&amp;lt;/code&amp;gt; attribute.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;async function validateApplePaySession(POSKey, SessionRequestUrl, ShopUrl) {&lt;br /&gt;
  const url = &amp;quot;https://api.test.barion.com/v2/ApplePay/ValidateSession&amp;quot;;&lt;br /&gt;
  const data = {&lt;br /&gt;
    POSKey,&lt;br /&gt;
    SessionRequestUrl,&lt;br /&gt;
    ShopUrl,&lt;br /&gt;
  };&lt;br /&gt;
&lt;br /&gt;
  try {&lt;br /&gt;
    const response = await fetch(url, {&lt;br /&gt;
      method: &amp;quot;POST&amp;quot;,&lt;br /&gt;
      headers: {&lt;br /&gt;
        &amp;quot;Content-Type&amp;quot;: &amp;quot;application/json&amp;quot;,&lt;br /&gt;
      },&lt;br /&gt;
      body: JSON.stringify(data),&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
    if (!response.ok) {&lt;br /&gt;
      throw new Error(`Error: ${response.status} ${response.statusText}`);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    const result = await response.json();&lt;br /&gt;
    return result;&lt;br /&gt;
  } catch (error) {&lt;br /&gt;
    // handle the error according to your business logic&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
applePaySession.onvalidatemerchant = async function (event) {&lt;br /&gt;
  const validationResult = await validateApplePaySession(POSKey, event.validationURL, ShopUrl);&lt;br /&gt;
  &lt;br /&gt;
  applePaySession.completeMerchantValidation(validationResult.ApplePaySessionResponse);&lt;br /&gt;
};&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;This event is triggered when the Apple Pay payment sheet is displayed to the customer.&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Set up an event handler for [https://developer.apple.com/documentation/apple_pay_on_the_web/applepaysession/1778020-onpaymentauthorized &amp;lt;code&amp;gt;ApplePaySession.onpaymentauthorized&amp;lt;/code&amp;gt;]&amp;lt;/p&amp;gt;&amp;lt;blockquote&amp;gt;Don&#039;t call the StartPaymentWithAppleToken Barion API endpoint directly from the browser, as this could expose your Barion shop&#039;s POSKey.&amp;lt;/blockquote&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;that calls the [[ApplePay-StartPaymentWithAppleToken|StartPaymentWithAppleToken Barion API endpoint]], passing it the event’s following attributes:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;token&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;shippingContact&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;billingContact&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note that &amp;lt;code&amp;gt;StartPaymentWithAppleToken&amp;lt;/code&amp;gt; is actually a specialized version of [[Payment-Start-v2|the payment/start API endpoint]], and so will also require all the usual parameters that you’d pass to that endpoint.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
async function startApplePayPayment(&lt;br /&gt;
  POSKey,&lt;br /&gt;
  ShippingContact,&lt;br /&gt;
  BillingContact,&lt;br /&gt;
  Token,&lt;br /&gt;
  /** include other required and optional Payment/Start params */&lt;br /&gt;
  PaymentStartProperties&lt;br /&gt;
) {&lt;br /&gt;
  const url =&lt;br /&gt;
    &amp;quot;https://api.test.barion.com/v2/ApplePay/StartPaymentWithAppleToken&amp;quot;;&lt;br /&gt;
  const data = {&lt;br /&gt;
    POSKey,&lt;br /&gt;
    ShippingContact,&lt;br /&gt;
    BillingContact,&lt;br /&gt;
    Token,&lt;br /&gt;
    ...PaymentStartProperties,&lt;br /&gt;
  };&lt;br /&gt;
&lt;br /&gt;
  try {&lt;br /&gt;
    const response = await fetch(url, {&lt;br /&gt;
      method: &amp;quot;POST&amp;quot;,&lt;br /&gt;
      headers: {&lt;br /&gt;
        &amp;quot;Content-Type&amp;quot;: &amp;quot;application/json&amp;quot;,&lt;br /&gt;
      },&lt;br /&gt;
      body: JSON.stringify(data),&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
    if (!response.ok) {&lt;br /&gt;
      throw new Error(`Error: ${response.status} ${response.statusText}`);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    const result = await response.json();&lt;br /&gt;
    return result;&lt;br /&gt;
  } catch (error) {&lt;br /&gt;
    // handle the error according to your business logic&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
const PaymentStartProperties = {&lt;br /&gt;
  PaymentType: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
applePaySession.onpaymentauthorized = function (event) {&lt;br /&gt;
  startApplePayPayment(&lt;br /&gt;
    POSKey,&lt;br /&gt;
    event.paymentInfo.shippingContent,&lt;br /&gt;
    event.paymentInfo.billingContact,&lt;br /&gt;
    event.paymentInfo.Token,&lt;br /&gt;
    PaymentStartProperties&lt;br /&gt;
  );&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;This event is triggered when the customer has authorized the Apple Pay payment using their Touch ID or Face ID.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Set up an event handler for &amp;lt;code&amp;gt;oncancel&amp;lt;/code&amp;gt; to implement your business logic for when the user abandons the Apple Pay payment.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Make sure that your event handler indicates that the session is canceled so the ApplePaySession’s &amp;lt;code&amp;gt;completePayment&amp;lt;/code&amp;gt; method doesn’t get executed.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;  applePaySession.oncancel = function (event) {&lt;br /&gt;
    // your oncancel business logic&lt;br /&gt;
&lt;br /&gt;
    isSessionCanceled = true;&lt;br /&gt;
  };&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Call [https://developer.apple.com/documentation/apple_pay_on_the_web/applepaysession/1778001-begin ApplePaySession.begin] to kick off the payment process.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;  applePaySession.begin();&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;This starts the merchant validation process that results in &amp;lt;code&amp;gt;ApplePaySession.onvalidatemerchant&amp;lt;/code&amp;gt; being triggered.&amp;lt;/blockquote&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Testing your implementation ===&lt;br /&gt;
&lt;br /&gt;
The following steps are needed in order to test your implementation:&lt;br /&gt;
# request access by sending an email to devsupport@barion.com!&lt;br /&gt;
# include an email address, that has no Apple Id yet&lt;br /&gt;
# we will register &amp;amp; connect it to our test account&lt;br /&gt;
# after that, you will be able to [https://developer.apple.com/apple-pay/sandbox-testing/ use Apple&#039;s test cards]&lt;br /&gt;
To test the new cross-browser QR code hand-off (for customers on desktop non-Safari browsers), you need an iPhone running &#039;&#039;&#039;iOS 18 or later&#039;&#039;&#039; — this is a separate, newer requirement that applies only to this specific feature.&lt;br /&gt;
&lt;br /&gt;
macOS is not enough to use Apple Pay. To use Apple Pay natively on macOS, you should configure the Handoff function on your devices. This Handoff requirement applies to &#039;&#039;&#039;Safari&#039;&#039;&#039; on macOS. Non-Safari desktop browsers (including Chrome or Firefox on macOS) don&#039;t need Handoff configured at all — they use the QR code hand-off flow instead.&lt;br /&gt;
&lt;br /&gt;
== Related links ==&lt;br /&gt;
&lt;br /&gt;
[[ApplePay-ValidateSession|ValidateSession API endpoint]]&lt;br /&gt;
&lt;br /&gt;
[[ApplePay-StartPaymentWithAppleToken|StartPaymentWithAppleToken API endpoint]]&lt;/div&gt;</summary>
		<author><name>Salamongy@barion.dev</name></author>
	</entry>
	<entry>
		<id>https://docs.barion.com/index.php?title=Apple_Pay&amp;diff=4944</id>
		<title>Apple Pay</title>
		<link rel="alternate" type="text/html" href="https://docs.barion.com/index.php?title=Apple_Pay&amp;diff=4944"/>
		<updated>2026-09-18T06:38:31Z</updated>

		<summary type="html">&lt;p&gt;Salamongy@barion.dev: Remove Barion-internal details from Technical implementation section&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{PageTitle|title=Apple Pay integration}}&lt;br /&gt;
{{TableOfContents}}&lt;br /&gt;
&lt;br /&gt;
Apple Pay is a wallet solution created by Apple for Apple customers. It is only accessible in the Apple ecosystem. You can use it with your iPhone, iWatch or with your desktop/laptop Macintosh computer. When it comes to Barion there are two different ways to use this payment option:&lt;br /&gt;
&lt;br /&gt;
* on the Barion Smart Gateway (called hosted mode)&lt;br /&gt;
* in their webshop if they integrate the so-called integrated mode&lt;br /&gt;
&lt;br /&gt;
The customer who wants to pay with Apple Pay Wallet must have an Apple device that supports authentication. This could be&lt;br /&gt;
&lt;br /&gt;
* an iPhone,&lt;br /&gt;
* a modern MacBook with fingerprint authentication or&lt;br /&gt;
* an older MacBook with a paired iPhone&lt;br /&gt;
&lt;br /&gt;
=== Browser support ===&lt;br /&gt;
Apple Pay behaves differently depending on the customer&#039;s browser:&amp;lt;blockquote&amp;gt;&lt;br /&gt;
* In Safari, and in any browser built on Apple&#039;s WebKit engine (Chrome, Firefox, or Edge on iOS), the button works natively, and the customer confirms the payment with Touch ID or Face ID.&lt;br /&gt;
* In other desktop browsers that can&#039;t run Apple Pay directly (for example Chrome, Firefox, or Edge on Windows), Apple&#039;s SDK automatically shows a QR code that the customer scans with their iPhone&#039;s Camera app (requires &#039;&#039;&#039;iOS 18 or later&#039;&#039;&#039;) to complete the payment there.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;Furthermore, the customer must fill out their home address and their contact information in their Apple Pay wallet as well. Without this, they won&#039;t be able to use their card in their Apple Wallet. This can be done even during the payment process.&lt;br /&gt;
&lt;br /&gt;
This feature is listed as an available payment method on the shop&#039;s admin site&lt;br /&gt;
&lt;br /&gt;
In case it is switched off the shop won&#039;t be able to display it as a funding source. This won&#039;t produce any error message, the Apple Pay option just won&#039;t be visible.&lt;br /&gt;
&lt;br /&gt;
=== Hosted mode ===&lt;br /&gt;
This is the &amp;quot;out of the box&amp;quot; mode that is available on the Barion Smart Gateway. It works in every browser described in the &#039;&#039;&#039;Browser support&#039;&#039;&#039; section above — natively in &#039;&#039;&#039;Safari&#039;&#039;&#039; and other WebKit-based browsers, and via the QR code hand-off in other desktop browsers.&lt;br /&gt;
&lt;br /&gt;
If the customer selects the Apple Pay accordion, the Apple Pay button will be visible.&lt;br /&gt;
&lt;br /&gt;
Once the customer clicks the Pay button the Apple Pay screen is displayed. This screen is actually controlled by the device, we don&#039;t have any control over it.&lt;br /&gt;
&lt;br /&gt;
On this screen, the customer may change the used credit card, the home address, or the e-mail address. These are all required to pay via Apple Pay. Once the customer approves the transaction everything continues as with a normal card would.&lt;br /&gt;
&lt;br /&gt;
=== Integrated mode ===&lt;br /&gt;
In integrated mode (called processor mode in Apple documentation) the webshop owner puts the Apple Pay button in their webshop and does not need to redirect the customer to the Barion Smart Gateway. This feature requires custom development from the webshop owner. The shop has to implement the Apple Pay button (instead of just relying on our gateway). To do this, they have to read through [[Apple Pay|this documentation]].&lt;br /&gt;
&lt;br /&gt;
The Apple Pay button can be displayed anywhere on the webshop. For example, on our demomerchant site is next to the Google Pay button.&lt;br /&gt;
&lt;br /&gt;
This integration requires a developer and is beneficial for shops that want to provide their customer a faster payment experience (since there is no need to redirect them to our gateway).&lt;br /&gt;
&lt;br /&gt;
To enable the button on the merchant&#039;s website the website has to be registered at Apple services. To help with this task we created a setting screen in our system. This setting page is available from the shop&#039;s setting page. (The one accessible by the owner)&lt;br /&gt;
&lt;br /&gt;
On this page, the owner has to input all the domains that the shop is using for the Apple Pay button. In addition to this the owner also has to upload a domain verification file to its domain.&lt;br /&gt;
&lt;br /&gt;
=== After payment ===&lt;br /&gt;
After the successful payment, the customer receives the usual confirmation letter, however, the bank card is clearly flagged, so the customer is aware that the payment was funded with a card from their Apple Wallet.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Warning:&#039;&#039;&#039; The card number displayed here is not the real card number. Apple creates a fake card number to protect the real card, so we are only aware of the fake number.&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting domain association errors ==&lt;br /&gt;
Some common pitfalls with domain association files can be found below.&lt;br /&gt;
&lt;br /&gt;
* domain association file cannot be reached without authentication&lt;br /&gt;
* response doesn’t contain “Content-Type” header with value “application/json”&lt;br /&gt;
* merchant’s server only supports TLS 1.3 (Barion uses 1.2 for checking this file)&lt;br /&gt;
* merchant has some form of bot/scraping protection enabled, which filters out requests that has a non-browser shaped or missing User-Agent header&lt;br /&gt;
&lt;br /&gt;
== Contact ==&lt;br /&gt;
George Maroufidis &amp;lt;gmaroufidis@apple.com&amp;gt;&lt;br /&gt;
&lt;br /&gt;
George Maroufidis |  Pay eCommerce EMEIA | OneBattersea Power Station, London, SW11 8BZ, United Kingdom | iPhone: +44 7591 916 527&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
* Apple Pay Marketing Guidelines&lt;br /&gt;
* Human Interface Guidelines&lt;br /&gt;
&lt;br /&gt;
== Reference ==&lt;br /&gt;
&lt;br /&gt;
* Configuring the environment&lt;br /&gt;
* Apple Pay on the web&lt;br /&gt;
* PaymentToken&lt;br /&gt;
* Sandbox&lt;br /&gt;
&amp;lt;blockquote&amp;gt;This article is about directly integrating the Apple Pay button in your webshop.&lt;br /&gt;
&lt;br /&gt;
If you simply want to display Apple Pay as a payment option in the Barion Smart Gateway, no further configuration is necessary; pass &amp;quot;ApplePay&amp;quot; in [[FundingSources|the FundingSources array]] when preparing a payment.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
The appeal of Apple Pay is that it requires only two actions from the customer: selecting the ‘Pay with Apple Pay’ button, and confirming the payment with Touch ID or Face ID.&lt;br /&gt;
&lt;br /&gt;
Another advantage to your Barion shop’s payment workflow is that customers aren’t navigated away from your checkout page when using Apple Pay.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;prerequisites&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=IMPORTANT|text=You do not need to register an Apple Developer Account! Should you need an Apple Merchant Id, use the PublicId (guid) of your shop!|color=#FF7A3D}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;access to and being able to modify both your webshop’s front-end and back-end code&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;your webshop using HTTPS (having a TLS 1.2 or higher certificate installed) for all its pages that include the Apple Pay button&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Barion Wallet with an approved Barion shop&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;the Barion shop complies with [https://developer.apple.com/apple-pay/acceptable-use-guidelines-for-websites/ Apple’s acceptable use guidelines], including not selling prohibited products or services&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;Note that Apple’s policies regarding acceptable products and services are more limiting than those of Barion.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;It may happen that even though Barion approves your Barion shop to sell a certain item, you will not be allowed to display the Apple Pay button as a payment option for customers to pay for that item.&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;an account in the Barion Wallet for each of the currencies that you’d like to accept using Apple Pay&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Limitations ==&lt;br /&gt;
&lt;br /&gt;
* you can’t yet tokenize your customer’s card details when using the Apple Pay button, so [[Token payment 3D Secure|recurring payments]] aren’t available&lt;br /&gt;
* Barion currently only supports Apple Pay button on the web, and not on native iOS apps&lt;br /&gt;
* regardless of the integration detailed here, the Apple Pay button will only be displayed to your customers if they comply with Apple’s requirements:&lt;br /&gt;
** they’re using [https://support.apple.com/en-us/102896 an Apple Pay-compatible device]&lt;br /&gt;
** they’re viewing your webshop using a browser that supports Apple Pay&lt;br /&gt;
** they’re located [https://support.apple.com/en-us/102775 in a country or region where Apple Pay is available]&lt;br /&gt;
== Steps ==&lt;br /&gt;
=== Setting up your Apple prerequisites ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;When using Barion’s Apple Pay API endpoints, Barion gives you [https://developer.apple.com/support/app-account/ an Apple developer account], and registers [https://developer.apple.com/documentation/applepaywebmerchantregistrationapi/registering_with_apple_pay_and_applying_to_use_the_api a Merchant ID], [https://help.apple.com/developer-account/#/devb2e62b839?sub=devf31990e3f Payment Processing Certificate], and [https://help.apple.com/developer-account/#/dev1731126fb Merchant Identity Certificate] for you as a subsidiary of Barion’s Apple Pay credentials.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
Verify and register your webshop’s domain name or names:&lt;br /&gt;
&lt;br /&gt;
# Log in to your Barion Wallet, and go to your Barion shop’s Shops&amp;amp;gt;Actions&amp;amp;gt;Settings screen.&lt;br /&gt;
# Click the “Manage Apple Pay settings”, and then “Download domain verification file” to save the verification file for your shop’s domain.&lt;br /&gt;
# Save the domain verification file that you downloaded in the &amp;lt;code&amp;gt;/.well-known&amp;lt;/code&amp;gt; directory of all the sites that your specified domains use, making sure of the following:&lt;br /&gt;
#* the file should send the &amp;lt;code&amp;gt;&amp;lt;mimeMap fileExtension=&amp;quot;.&amp;quot; mimeType=&amp;quot;application/json&amp;quot; /&amp;gt;&amp;lt;/code&amp;gt; MIME data;&lt;br /&gt;
#* the file must be accessible externally, and not be password-protected, or behind a proxy or redirect;&lt;br /&gt;
#* the sites must be served over HTTPS.&lt;br /&gt;
# Enter all the domains that you’d like to use Apple Pay on (into whose root you’ve downloaded the domain verification file) in the text box provided, then click “Save”.&lt;br /&gt;
&lt;br /&gt;
=== Configuring and displaying the Apple Pay button ===&lt;br /&gt;
&lt;br /&gt;
=== Configuring and displaying the Apple Pay button ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol style=&amp;quot;list-style-type: decimal;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Load the button script into your checkout page by adding the following script tag inside the page head:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;html&amp;quot;&amp;gt;&amp;lt;script crossorigin src=&amp;quot;https://applepay.cdn-apple.com/jsapi/1.latest/apple-pay-sdk.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Always load the always-current &amp;lt;code&amp;gt;1.latest&amp;lt;/code&amp;gt; path instead of a pinned version, and keep the &amp;lt;code&amp;gt;crossorigin&amp;lt;/code&amp;gt; attribute — it is required for the native &amp;lt;code&amp;gt;&amp;amp;lt;apple-pay-button&amp;amp;gt;&amp;lt;/code&amp;gt; element and for the cross-browser behaviour (native in WebKit, QR code hand-off on other desktop browsers) to work correctly.&amp;lt;/blockquote&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;This script makes an ApplePaySession available to your site front-end, among other things.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;ol start=&amp;quot;2&amp;quot; style=&amp;quot;list-style-type: decimal;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Add the &amp;lt;code&amp;gt;apple-pay-button&amp;lt;/code&amp;gt; custom element (for example, &amp;lt;code&amp;gt;&amp;amp;lt;apple-pay-button id=&amp;quot;apple-pay-button&amp;quot; buttonstyle=&amp;quot;black&amp;quot; type=&amp;quot;plain&amp;quot;&amp;amp;gt;&amp;amp;lt;/apple-pay-button&amp;amp;gt;&amp;lt;/code&amp;gt;) to your checkout page. The official SDK renders this element natively — you no longer need to write your own CSS to display it.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=IMPORTANT|text=The &amp;amp;lt;apple-pay-button&amp;amp;gt; element&#039;s size can&#039;t be set with ordinary CSS height/border-radius properties — its internal shadow-DOM content won&#039;t follow them. Use the dedicated CSS custom properties instead: --apple-pay-button-height and --apple-pay-button-border-radius.|color=#FF7A3D}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;css&amp;quot;&amp;gt;apple-pay-button {&lt;br /&gt;
  --apple-pay-button-height: 48px;&lt;br /&gt;
  --apple-pay-button-border-radius: 8px;&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Start a new ApplePaySession when the checkout page loads:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;  const request = {&lt;br /&gt;
    countryCode: &#039;US&#039;,&lt;br /&gt;
    currencyCode: &#039;USD&#039;,&lt;br /&gt;
    supportedNetworks: [&#039;visa&#039;, &#039;masterCard&#039;, &#039;discover&#039;],&lt;br /&gt;
    merchantCapabilities: [&#039;supports3DS&#039;],&lt;br /&gt;
    total: { label: &#039;Your Merchant Name&#039;, amount: &#039;10.00&#039; }&lt;br /&gt;
  }&lt;br /&gt;
  const applePlaySession = new ApplePaySession(3, request);&lt;br /&gt;
&lt;br /&gt;
  // add an isSessionCanceled boolean to easily be able to cancel the session if your user abandons the in-progress payment process&lt;br /&gt;
  var isSessionCanceled = false;&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&amp;lt;blockquote&amp;gt;The merchant may supply the shipping and billing contact information directly, or request it when starting the ApplePaySession by including the [https://developer.apple.com/documentation/applepayontheweb/applepaypaymentrequest/requiredshippingcontactfields requiredShippingContactFields]  and [https://developer.apple.com/documentation/applepayontheweb/applepaypaymentrequest/requiredbillingcontactfields requiredBillingContactFields] properties in the payment request. More about the Apple Pay payment request [https://developer.apple.com/documentation/applepayontheweb/applepaypaymentrequest here].&amp;lt;/blockquote&amp;gt;&amp;lt;ol start=&amp;quot;4&amp;quot; style=&amp;quot;list-style-type: decimal;&amp;quot;&amp;gt;&amp;lt;li&amp;gt;&lt;br /&gt;
    &amp;lt;p&amp;gt;Make sure to only display the Apple Pay button to users who can use it, by have your webshop’s checkout pages do&lt;br /&gt;
      the following when they load:&amp;lt;/p&amp;gt;&lt;br /&gt;
    &amp;lt;p&amp;gt;Call [https://developer.apple.com/documentation/applepayontheweb/applepaysession/canmakepayments &amp;lt;code&amp;gt;ApplePaySession.canMakePayments()&amp;lt;/code&amp;gt;] to check, in a single simple boolean call, whether Apple Pay is available at all on the customer&#039;s device/browser — this is the method needed to decide whether to show the button.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;p&amp;gt;If you additionally need detailed status about a specific merchant and the customer&#039;s stored cards, use [https://developer.apple.com/documentation/applepayontheweb/applepaysession/applepaycapabilities &amp;lt;code&amp;gt;applePaySession.applePayCapabilities()&amp;lt;/code&amp;gt;], passing it your Barion shop’s public Id as the merchantId parameter.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;blockquote&amp;gt;&amp;lt;code&amp;gt;applePaySession.canMakePaymentsWithActiveCard&amp;lt;/code&amp;gt; is &#039;&#039;&#039;deprecated&#039;&#039;&#039; by Apple — use &amp;lt;code&amp;gt;applePayCapabilities&amp;lt;/code&amp;gt; instead for that detailed check.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;p&amp;gt;If Apple can verify your Barion shop as a registered Apple Pay provider, the detailed check reports the following:&amp;lt;/p&amp;gt;&lt;br /&gt;
    &amp;lt;ul&amp;gt;&lt;br /&gt;
      &amp;lt;li&amp;gt;that your customer&#039;s device is capable of using Apple Pay&amp;lt;/li&amp;gt;&lt;br /&gt;
      &amp;lt;li&amp;gt;that Apple Pay is enabled on your customer&#039;s device, and&amp;lt;/li&amp;gt;&lt;br /&gt;
      &amp;lt;li&amp;gt;that the customer has the details of at least one active and web payment-eligible bank card stored in their Apple  Pay wallet.&amp;lt;/li&amp;gt;&lt;br /&gt;
    &amp;lt;/ul&amp;gt;&lt;br /&gt;
  &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;Handle [https://developer.apple.com/documentation/apple_pay_on_the_web/paymentcredentialstatus the &amp;lt;code&amp;gt;PaymentCredentialStatus&amp;lt;/code&amp;gt; object] that the method returns to make a decision about displaying the Apple Pay button.&lt;br /&gt;
  &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Handling payments ===&lt;br /&gt;
&lt;br /&gt;
Set up your webshop to perform these steps each time a user selects the Apple Pay button.&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=IMPORTANT|text=The &amp;amp;lt;apple-pay-button&amp;amp;gt; element does not dispatch a standard bubbling DOM click event, so addEventListener / jQuery .on(&#039;click&#039;, ...) (whether bound to the element or to a container around it) will not fire. Bind your click handler directly to the element&#039;s onclick property instead.|color=#FF7A3D}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;document.getElementById(&#039;apple-pay-button&#039;).onclick = function (event) {&lt;br /&gt;
    // start your ApplePaySession here&lt;br /&gt;
};&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol style=&amp;quot;list-style-type: decimal;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Set up an event handler for [https://developer.apple.com/documentation/apple_pay_on_the_web/applepaysession/1778021-onvalidatemerchant &amp;lt;code&amp;gt;ApplePaySession.onvalidatemerchant&amp;lt;/code&amp;gt;] that notifies your site&#039;s back-end, and passes it the event response.&amp;lt;/p&amp;gt;&amp;lt;blockquote&amp;gt;Don&#039;t call the ValidateSession Barion API endpoint directly from the browser, as this could expose your Barion shop&#039;s POSKey.&amp;lt;/blockquote&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Have your site&#039;s back-end call [[ApplePay-ValidateSession|the ValidateSession Barion API endpoint]], passing it the &amp;lt;code&amp;gt;onvalidatemerchant&amp;lt;/code&amp;gt; event’s &amp;lt;code&amp;gt;ValidationUrl&amp;lt;/code&amp;gt; attribute.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;async function validateApplePaySession(POSKey, SessionRequestUrl, ShopUrl) {&lt;br /&gt;
  const url = &amp;quot;https://api.test.barion.com/v2/ApplePay/ValidateSession&amp;quot;;&lt;br /&gt;
  const data = {&lt;br /&gt;
    POSKey,&lt;br /&gt;
    SessionRequestUrl,&lt;br /&gt;
    ShopUrl,&lt;br /&gt;
  };&lt;br /&gt;
&lt;br /&gt;
  try {&lt;br /&gt;
    const response = await fetch(url, {&lt;br /&gt;
      method: &amp;quot;POST&amp;quot;,&lt;br /&gt;
      headers: {&lt;br /&gt;
        &amp;quot;Content-Type&amp;quot;: &amp;quot;application/json&amp;quot;,&lt;br /&gt;
      },&lt;br /&gt;
      body: JSON.stringify(data),&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
    if (!response.ok) {&lt;br /&gt;
      throw new Error(`Error: ${response.status} ${response.statusText}`);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    const result = await response.json();&lt;br /&gt;
    return result;&lt;br /&gt;
  } catch (error) {&lt;br /&gt;
    // handle the error according to your business logic&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
applePaySession.onvalidatemerchant = async function (event) {&lt;br /&gt;
  const validationResult = await validateApplePaySession(POSKey, event.validationURL, ShopUrl);&lt;br /&gt;
  &lt;br /&gt;
  applePaySession.completeMerchantValidation(validationResult.ApplePaySessionResponse);&lt;br /&gt;
};&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;This event is triggered when the Apple Pay payment sheet is displayed to the customer.&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Set up an event handler for [https://developer.apple.com/documentation/apple_pay_on_the_web/applepaysession/1778020-onpaymentauthorized &amp;lt;code&amp;gt;ApplePaySession.onpaymentauthorized&amp;lt;/code&amp;gt;]&amp;lt;/p&amp;gt;&amp;lt;blockquote&amp;gt;Don&#039;t call the StartPaymentWithAppleToken Barion API endpoint directly from the browser, as this could expose your Barion shop&#039;s POSKey.&amp;lt;/blockquote&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;that calls the [[ApplePay-StartPaymentWithAppleToken|StartPaymentWithAppleToken Barion API endpoint]], passing it the event’s following attributes:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;token&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;shippingContact&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;billingContact&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note that &amp;lt;code&amp;gt;StartPaymentWithAppleToken&amp;lt;/code&amp;gt; is actually a specialized version of [[Payment-Start-v2|the payment/start API endpoint]], and so will also require all the usual parameters that you’d pass to that endpoint.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
async function startApplePayPayment(&lt;br /&gt;
  POSKey,&lt;br /&gt;
  ShippingContact,&lt;br /&gt;
  BillingContact,&lt;br /&gt;
  Token,&lt;br /&gt;
  /** include other required and optional Payment/Start params */&lt;br /&gt;
  PaymentStartProperties&lt;br /&gt;
) {&lt;br /&gt;
  const url =&lt;br /&gt;
    &amp;quot;https://api.test.barion.com/v2/ApplePay/StartPaymentWithAppleToken&amp;quot;;&lt;br /&gt;
  const data = {&lt;br /&gt;
    POSKey,&lt;br /&gt;
    ShippingContact,&lt;br /&gt;
    BillingContact,&lt;br /&gt;
    Token,&lt;br /&gt;
    ...PaymentStartProperties,&lt;br /&gt;
  };&lt;br /&gt;
&lt;br /&gt;
  try {&lt;br /&gt;
    const response = await fetch(url, {&lt;br /&gt;
      method: &amp;quot;POST&amp;quot;,&lt;br /&gt;
      headers: {&lt;br /&gt;
        &amp;quot;Content-Type&amp;quot;: &amp;quot;application/json&amp;quot;,&lt;br /&gt;
      },&lt;br /&gt;
      body: JSON.stringify(data),&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
    if (!response.ok) {&lt;br /&gt;
      throw new Error(`Error: ${response.status} ${response.statusText}`);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    const result = await response.json();&lt;br /&gt;
    return result;&lt;br /&gt;
  } catch (error) {&lt;br /&gt;
    // handle the error according to your business logic&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
const PaymentStartProperties = {&lt;br /&gt;
  PaymentType: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
applePaySession.onpaymentauthorized = function (event) {&lt;br /&gt;
  startApplePayPayment(&lt;br /&gt;
    POSKey,&lt;br /&gt;
    event.paymentInfo.shippingContent,&lt;br /&gt;
    event.paymentInfo.billingContact,&lt;br /&gt;
    event.paymentInfo.Token,&lt;br /&gt;
    PaymentStartProperties&lt;br /&gt;
  );&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;This event is triggered when the customer has authorized the Apple Pay payment using their Touch ID or Face ID.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Set up an event handler for &amp;lt;code&amp;gt;oncancel&amp;lt;/code&amp;gt; to implement your business logic for when the user abandons the Apple Pay payment.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Make sure that your event handler indicates that the session is canceled so the ApplePaySession’s &amp;lt;code&amp;gt;completePayment&amp;lt;/code&amp;gt; method doesn’t get executed.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;  applePaySession.oncancel = function (event) {&lt;br /&gt;
    // your oncancel business logic&lt;br /&gt;
&lt;br /&gt;
    isSessionCanceled = true;&lt;br /&gt;
  };&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Call [https://developer.apple.com/documentation/apple_pay_on_the_web/applepaysession/1778001-begin ApplePaySession.begin] to kick off the payment process.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;  applePaySession.begin();&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;This starts the merchant validation process that results in &amp;lt;code&amp;gt;ApplePaySession.onvalidatemerchant&amp;lt;/code&amp;gt; being triggered.&amp;lt;/blockquote&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Testing your implementation ===&lt;br /&gt;
&lt;br /&gt;
The following steps are needed in order to test your implementation:&lt;br /&gt;
# request access by sending an email to devsupport@barion.com!&lt;br /&gt;
# include an email address, that has no Apple Id yet&lt;br /&gt;
# we will register &amp;amp; connect it to our test account&lt;br /&gt;
# after that, you will be able to [https://developer.apple.com/apple-pay/sandbox-testing/ use Apple&#039;s test cards]&lt;br /&gt;
To test the new cross-browser QR code hand-off (for customers on desktop non-Safari browsers), you need an iPhone running &#039;&#039;&#039;iOS 18 or later&#039;&#039;&#039; — this is a separate, newer requirement that applies only to this specific feature.&lt;br /&gt;
&lt;br /&gt;
macOS is not enough to use Apple Pay. To use Apple Pay natively on macOS, you should configure the Handoff function on your devices. This Handoff requirement applies to &#039;&#039;&#039;Safari&#039;&#039;&#039; on macOS. Non-Safari desktop browsers (including Chrome or Firefox on macOS) don&#039;t need Handoff configured at all — they use the QR code hand-off flow instead.&lt;br /&gt;
&lt;br /&gt;
== Related links ==&lt;br /&gt;
&lt;br /&gt;
[[ApplePay-ValidateSession|ValidateSession API endpoint]]&lt;br /&gt;
&lt;br /&gt;
[[ApplePay-StartPaymentWithAppleToken|StartPaymentWithAppleToken API endpoint]]&lt;/div&gt;</summary>
		<author><name>Salamongy@barion.dev</name></author>
	</entry>
	<entry>
		<id>https://docs.barion.com/index.php?title=Apple_Pay&amp;diff=4941</id>
		<title>Apple Pay</title>
		<link rel="alternate" type="text/html" href="https://docs.barion.com/index.php?title=Apple_Pay&amp;diff=4941"/>
		<updated>2026-09-03T07:03:00Z</updated>

		<summary type="html">&lt;p&gt;Salamongy@barion.dev: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{PageTitle|title=Apple Pay integration}}&lt;br /&gt;
{{TableOfContents}}&lt;br /&gt;
&lt;br /&gt;
Apple Pay is a wallet solution created by Apple for Apple customers. It is only accessible in the Apple ecosystem. You can use it with your iPhone, iWatch or with your desktop/laptop Macintosh computer. When it comes to Barion there are two different ways to use this payment option:&lt;br /&gt;
&lt;br /&gt;
* on the Barion Smart Gateway (called hosted mode)&lt;br /&gt;
* in their webshop if they integrate the so-called integrated mode&lt;br /&gt;
&lt;br /&gt;
The customer who wants to pay with Apple Pay Wallet must have an Apple device that supports authentication. This could be&lt;br /&gt;
&lt;br /&gt;
* an iPhone,&lt;br /&gt;
* a modern MacBook with fingerprint authentication or&lt;br /&gt;
* an older MacBook with a paired iPhone&lt;br /&gt;
&lt;br /&gt;
=== Browser support ===&lt;br /&gt;
Apple Pay behaves differently depending on the customer&#039;s browser:&amp;lt;blockquote&amp;gt;&lt;br /&gt;
* In Safari, and in any browser built on Apple&#039;s WebKit engine (Chrome, Firefox, or Edge on iOS), the button works natively, and the customer confirms the payment with Touch ID or Face ID.&lt;br /&gt;
* In other desktop browsers that can&#039;t run Apple Pay directly (for example Chrome, Firefox, or Edge on Windows), Apple&#039;s SDK automatically shows a QR code that the customer scans with their iPhone&#039;s Camera app (requires &#039;&#039;&#039;iOS 18 or later&#039;&#039;&#039;) to complete the payment there.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;Furthermore, the customer must fill out their home address and their contact information in their Apple Pay wallet as well. Without this, they won&#039;t be able to use their card in their Apple Wallet. This can be done even during the payment process.&lt;br /&gt;
&lt;br /&gt;
This feature is listed as an available payment method on the shop&#039;s admin site&lt;br /&gt;
&lt;br /&gt;
In case it is switched off the shop won&#039;t be able to display it as a funding source. This won&#039;t produce any error message, the Apple Pay option just won&#039;t be visible.&lt;br /&gt;
&lt;br /&gt;
=== Hosted mode ===&lt;br /&gt;
This is the &amp;quot;out of the box&amp;quot; mode that is available on the Barion Smart Gateway. It works in every browser described in the &#039;&#039;&#039;Browser support&#039;&#039;&#039; section above — natively in &#039;&#039;&#039;Safari&#039;&#039;&#039; and other WebKit-based browsers, and via the QR code hand-off in other desktop browsers.&lt;br /&gt;
&lt;br /&gt;
If the customer selects the Apple Pay accordion, the Apple Pay button will be visible.&lt;br /&gt;
&lt;br /&gt;
Once the customer clicks the Pay button the Apple Pay screen is displayed. This screen is actually controlled by the device, we don&#039;t have any control over it.&lt;br /&gt;
&lt;br /&gt;
On this screen, the customer may change the used credit card, the home address, or the e-mail address. These are all required to pay via Apple Pay. Once the customer approves the transaction everything continues as with a normal card would.&lt;br /&gt;
&lt;br /&gt;
=== Integrated mode ===&lt;br /&gt;
In integrated mode (called processor mode in Apple documentation) the webshop owner puts the Apple Pay button in their webshop and does not need to redirect the customer to the Barion Smart Gateway. This feature requires custom development from the webshop owner. The shop has to implement the Apple Pay button (instead of just relying on our gateway). To do this, they have to read through [[Apple Pay|this documentation]].&lt;br /&gt;
&lt;br /&gt;
The Apple Pay button can be displayed anywhere on the webshop. For example, on our demomerchant site is next to the Google Pay button.&lt;br /&gt;
&lt;br /&gt;
This integration requires a developer and is beneficial for shops that want to provide their customer a faster payment experience (since there is no need to redirect them to our gateway).&lt;br /&gt;
&lt;br /&gt;
To enable the button on the merchant&#039;s website the website has to be registered at Apple services. To help with this task we created a setting screen in our system. This setting page is available from the shop&#039;s setting page. (The one accessible by the owner)&lt;br /&gt;
&lt;br /&gt;
On this page, the owner has to input all the domains that the shop is using for the Apple Pay button. In addition to this the owner also has to upload a domain verification file to its domain.&lt;br /&gt;
&lt;br /&gt;
=== After payment ===&lt;br /&gt;
After the successful payment, the customer receives the usual confirmation letter, however, the bank card is clearly flagged, so the customer is aware that the payment was funded with a card from their Apple Wallet.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Warning:&#039;&#039;&#039; The card number displayed here is not the real card number. Apple creates a fake card number to protect the real card, so we are only aware of the fake number.&lt;br /&gt;
&lt;br /&gt;
= Technical implementation =&lt;br /&gt;
&lt;br /&gt;
== Merchants ==&lt;br /&gt;
The production and non-production environments use different merchants to keep the processing private key secret. Barion has two registered merchants at Apple Pay:&lt;br /&gt;
&lt;br /&gt;
* merchant.com.barion.applepay (used in the production environment)&lt;br /&gt;
* merchant.com.barion.test.applepay (used in non-production environments)&lt;br /&gt;
&lt;br /&gt;
This means the certificate installations, domain validations, and registrations must be completed separately in every environment. All necessary files and certificates are in a separate folder here: &#039;&#039;R:\Development\Sensitive\ApplePay\Merchants&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Certificates for production environment are handled by the Operator team.&lt;br /&gt;
&lt;br /&gt;
== Certificates ==&lt;br /&gt;
Apple Pay certificates for the Dev|Demo environments are here: &#039;&#039;R:\Development\Sensitive\ApplePay\Merchants&#039;&#039;. They were created by the operators, use the following page to create the Apple Pay merchant ID and certificates, and verify the domains: Configuring the environment&lt;br /&gt;
&lt;br /&gt;
There are two certificate files with different purposes. The &#039;&#039;merchant&#039;&#039; certificate is to validate and create Apple Pay sessions and the &#039;&#039;processor&#039;&#039; certificate is to decrypt the payload. Each of the certificates has to contain a private key. The preferred format is P12.&lt;br /&gt;
&lt;br /&gt;
The merchant certificate has to be installed on the Windows certificate store, the application will use it from the Personal container.&lt;br /&gt;
&lt;br /&gt;
From the processing certificate we need the private key only, to retrieve it use the following OpenSSL (3.2.1+ version required) command:&lt;br /&gt;
&lt;br /&gt;
After the PEM file is created, the content of the file should be saved into a text file. This text file is used in the configuration file(ApplePay.ProcessingPrivateKeyPath):&lt;br /&gt;
&lt;br /&gt;
== Changing of the certificates ==&lt;br /&gt;
Certificates can be obtained from Apple. Apple can only handle one certificate at a time, when the new certificate is enabled, the old one is automatically revoked. Since this process takes about 15-45 minutes to complete, it is advised to do it in a low-traffic period.&lt;br /&gt;
&lt;br /&gt;
Steps:&lt;br /&gt;
&lt;br /&gt;
# Obtain the new certificates from the Apple Developer Portal&lt;br /&gt;
# Generate the private key for the certificate as described in the previous point&lt;br /&gt;
# Update the appropriate config files (Secure, Api, Admin, Tools.QuedTaskInstaller as of 2023.04.21.) with the new certificate thumbprint and private key&lt;br /&gt;
# Enable the new certificates on the Apple Developer Portal&lt;br /&gt;
# Deploy the new configs to our servers (since the old certificates are revoked, and the new onew take about 15-45 minutes for the certificates to go live on Apple&#039;s side, there will be a downtime of about 15-45 minutes, during this time, ApplePay payments will fail)&lt;br /&gt;
# Done :)&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
Apple Pay on the web can be tested with Apple devices. The minimum OS versions are:&lt;br /&gt;
&lt;br /&gt;
* macOS 10.14.4&lt;br /&gt;
* iOS 12.2&lt;br /&gt;
&lt;br /&gt;
There are some example message here: &#039;&#039;R:\Development\Sensitive\ApplePay\Sample messages&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
These messages can be posted via Postman using the following API endpoint:&lt;br /&gt;
&lt;br /&gt;
Use the WalletMessage object in the CardInformation object to post the Apple Pay payload.&lt;br /&gt;
&lt;br /&gt;
To test the new cross-browser QR code hand-off (for customers on desktop non-Safari browsers), you need an iPhone running &#039;&#039;&#039;iOS 18 or later&#039;&#039;&#039; — this is a separate, newer requirement from the general &amp;quot;iOS 12.2&amp;quot; minimum above, which only covers using Apple Pay natively in &#039;&#039;&#039;Safari&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
MacOS is not enough to use Apple Pay. To use Apple Pay on MacOS you should configure Handoff function on the devices, follow this to set up the devices properly. This Handoff requirement applies to &#039;&#039;&#039;Safari&#039;&#039;&#039; on macOS. Non-Safari desktop browsers (including Chrome or Firefox on macOS) don&#039;t need Handoff configured at all — they use the QR code hand-off flow described above instead.&lt;br /&gt;
&lt;br /&gt;
You can test which certificate is used to encrypt the payment data with this command:&lt;br /&gt;
&lt;br /&gt;
The 2023_proc_Certificates.p12 should be the new certificate!&lt;br /&gt;
&lt;br /&gt;
The output of the above script should be the same as that of PaymentData.Header.PublicKeyHash&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting domain association errors ==&lt;br /&gt;
Some common pitfalls with domain association files can be found below.&lt;br /&gt;
&lt;br /&gt;
* domain association file cannot be reached without authentication&lt;br /&gt;
* response doesn’t contain “Content-Type” header with value “application/json”&lt;br /&gt;
* merchant’s server only supports TLS 1.3 (Barion uses 1.2 for checking this file)&lt;br /&gt;
* merchant has some form of bot/scraping protection enabled, which filters out requests that has a non-browser shaped or missing User-Agent header&lt;br /&gt;
&lt;br /&gt;
If a merchant reaches out about a domain association file problem, you can check these issues via:&lt;br /&gt;
&lt;br /&gt;
* first opening the domain association file on their site from a browser and checking the response&lt;br /&gt;
* and if that didn’t bring any results, running the script “Test-ApplePayDomainAssociation.ps1” found in the DeveloperScripts repo&lt;br /&gt;
** run this script in Powershell 5.1&lt;br /&gt;
** you can run the script locally, but for more reliable results, use one of the prod-web machines via the help of operators (so the network environment and TLS capabilities match production)&lt;br /&gt;
&lt;br /&gt;
== Contact ==&lt;br /&gt;
George Maroufidis &amp;lt;gmaroufidis@apple.com&amp;gt;&lt;br /&gt;
&lt;br /&gt;
George Maroufidis |  Pay eCommerce EMEIA | OneBattersea Power Station, London, SW11 8BZ, United Kingdom | iPhone: +44 7591 916 527&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
* Apple Pay Marketing Guidelines&lt;br /&gt;
* Human Interface Guidelines&lt;br /&gt;
&lt;br /&gt;
== Reference ==&lt;br /&gt;
&lt;br /&gt;
* Configuring the environment&lt;br /&gt;
* Apple Pay on the web&lt;br /&gt;
* PaymentToken&lt;br /&gt;
* Sandbox&lt;br /&gt;
&amp;lt;blockquote&amp;gt;This article is about directly integrating the Apple Pay button in your webshop.&lt;br /&gt;
&lt;br /&gt;
If you simply want to display Apple Pay as a payment option in the Barion Smart Gateway, no further configuration is necessary; pass &amp;quot;ApplePay&amp;quot; in [[FundingSources|the FundingSources array]] when preparing a payment.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
The appeal of Apple Pay is that it requires only two actions from the customer: selecting the ‘Pay with Apple Pay’ button, and confirming the payment with Touch ID or Face ID.&lt;br /&gt;
&lt;br /&gt;
Another advantage to your Barion shop’s payment workflow is that customers aren’t navigated away from your checkout page when using Apple Pay.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;prerequisites&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=IMPORTANT|text=You do not need to register an Apple Developer Account! Should you need an Apple Merchant Id, use the PublicId (guid) of your shop!|color=#FF7A3D}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;access to and being able to modify both your webshop’s front-end and back-end code&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;your webshop using HTTPS (having a TLS 1.2 or higher certificate installed) for all its pages that include the Apple Pay button&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Barion Wallet with an approved Barion shop&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;the Barion shop complies with [https://developer.apple.com/apple-pay/acceptable-use-guidelines-for-websites/ Apple’s acceptable use guidelines], including not selling prohibited products or services&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;Note that Apple’s policies regarding acceptable products and services are more limiting than those of Barion.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;It may happen that even though Barion approves your Barion shop to sell a certain item, you will not be allowed to display the Apple Pay button as a payment option for customers to pay for that item.&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;an account in the Barion Wallet for each of the currencies that you’d like to accept using Apple Pay&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Limitations ==&lt;br /&gt;
&lt;br /&gt;
* you can’t yet tokenize your customer’s card details when using the Apple Pay button, so [[Token payment 3D Secure|recurring payments]] aren’t available&lt;br /&gt;
* Barion currently only supports Apple Pay button on the web, and not on native iOS apps&lt;br /&gt;
* regardless of the integration detailed here, the Apple Pay button will only be displayed to your customers if they comply with Apple’s requirements:&lt;br /&gt;
** they’re using [https://support.apple.com/en-us/102896 an Apple Pay-compatible device]&lt;br /&gt;
** they’re viewing your webshop using a browser that supports Apple Pay&lt;br /&gt;
** they’re located [https://support.apple.com/en-us/102775 in a country or region where Apple Pay is available]&lt;br /&gt;
== Steps ==&lt;br /&gt;
=== Setting up your Apple prerequisites ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;When using Barion’s Apple Pay API endpoints, Barion gives you [https://developer.apple.com/support/app-account/ an Apple developer account], and registers [https://developer.apple.com/documentation/applepaywebmerchantregistrationapi/registering_with_apple_pay_and_applying_to_use_the_api a Merchant ID], [https://help.apple.com/developer-account/#/devb2e62b839?sub=devf31990e3f Payment Processing Certificate], and [https://help.apple.com/developer-account/#/dev1731126fb Merchant Identity Certificate] for you as a subsidiary of Barion’s Apple Pay credentials.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
Verify and register your webshop’s domain name or names:&lt;br /&gt;
&lt;br /&gt;
# Log in to your Barion Wallet, and go to your Barion shop’s Shops&amp;amp;gt;Actions&amp;amp;gt;Settings screen.&lt;br /&gt;
# Click the “Manage Apple Pay settings”, and then “Download domain verification file” to save the verification file for your shop’s domain.&lt;br /&gt;
# Save the domain verification file that you downloaded in the &amp;lt;code&amp;gt;/.well-known&amp;lt;/code&amp;gt; directory of all the sites that your specified domains use, making sure of the following:&lt;br /&gt;
#* the file should send the &amp;lt;code&amp;gt;&amp;lt;mimeMap fileExtension=&amp;quot;.&amp;quot; mimeType=&amp;quot;application/json&amp;quot; /&amp;gt;&amp;lt;/code&amp;gt; MIME data;&lt;br /&gt;
#* the file must be accessible externally, and not be password-protected, or behind a proxy or redirect;&lt;br /&gt;
#* the sites must be served over HTTPS.&lt;br /&gt;
# Enter all the domains that you’d like to use Apple Pay on (into whose root you’ve downloaded the domain verification file) in the text box provided, then click “Save”.&lt;br /&gt;
&lt;br /&gt;
=== Configuring and displaying the Apple Pay button ===&lt;br /&gt;
&lt;br /&gt;
=== Configuring and displaying the Apple Pay button ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol style=&amp;quot;list-style-type: decimal;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Load the button script into your checkout page by adding the following script tag inside the page head:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;html&amp;quot;&amp;gt;&amp;lt;script crossorigin src=&amp;quot;https://applepay.cdn-apple.com/jsapi/1.latest/apple-pay-sdk.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Always load the always-current &amp;lt;code&amp;gt;1.latest&amp;lt;/code&amp;gt; path instead of a pinned version, and keep the &amp;lt;code&amp;gt;crossorigin&amp;lt;/code&amp;gt; attribute — it is required for the native &amp;lt;code&amp;gt;&amp;amp;lt;apple-pay-button&amp;amp;gt;&amp;lt;/code&amp;gt; element and for the cross-browser behaviour (native in WebKit, QR code hand-off on other desktop browsers) to work correctly.&amp;lt;/blockquote&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;This script makes an ApplePaySession available to your site front-end, among other things.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;ol start=&amp;quot;2&amp;quot; style=&amp;quot;list-style-type: decimal;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Add the &amp;lt;code&amp;gt;apple-pay-button&amp;lt;/code&amp;gt; custom element (for example, &amp;lt;code&amp;gt;&amp;amp;lt;apple-pay-button id=&amp;quot;apple-pay-button&amp;quot; buttonstyle=&amp;quot;black&amp;quot; type=&amp;quot;plain&amp;quot;&amp;amp;gt;&amp;amp;lt;/apple-pay-button&amp;amp;gt;&amp;lt;/code&amp;gt;) to your checkout page. The official SDK renders this element natively — you no longer need to write your own CSS to display it.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=IMPORTANT|text=The &amp;amp;lt;apple-pay-button&amp;amp;gt; element&#039;s size can&#039;t be set with ordinary CSS height/border-radius properties — its internal shadow-DOM content won&#039;t follow them. Use the dedicated CSS custom properties instead: --apple-pay-button-height and --apple-pay-button-border-radius.|color=#FF7A3D}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;css&amp;quot;&amp;gt;apple-pay-button {&lt;br /&gt;
  --apple-pay-button-height: 48px;&lt;br /&gt;
  --apple-pay-button-border-radius: 8px;&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Start a new ApplePaySession when the checkout page loads:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;  const request = {&lt;br /&gt;
    countryCode: &#039;US&#039;,&lt;br /&gt;
    currencyCode: &#039;USD&#039;,&lt;br /&gt;
    supportedNetworks: [&#039;visa&#039;, &#039;masterCard&#039;, &#039;discover&#039;],&lt;br /&gt;
    merchantCapabilities: [&#039;supports3DS&#039;],&lt;br /&gt;
    total: { label: &#039;Your Merchant Name&#039;, amount: &#039;10.00&#039; }&lt;br /&gt;
  }&lt;br /&gt;
  const applePlaySession = new ApplePaySession(3, request);&lt;br /&gt;
&lt;br /&gt;
  // add an isSessionCanceled boolean to easily be able to cancel the session if your user abandons the in-progress payment process&lt;br /&gt;
  var isSessionCanceled = false;&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&amp;lt;blockquote&amp;gt;The merchant may supply the shipping and billing contact information directly, or request it when starting the ApplePaySession by including the [https://developer.apple.com/documentation/applepayontheweb/applepaypaymentrequest/requiredshippingcontactfields requiredShippingContactFields]  and [https://developer.apple.com/documentation/applepayontheweb/applepaypaymentrequest/requiredbillingcontactfields requiredBillingContactFields] properties in the payment request. More about the Apple Pay payment request [https://developer.apple.com/documentation/applepayontheweb/applepaypaymentrequest here].&amp;lt;/blockquote&amp;gt;&amp;lt;ol start=&amp;quot;4&amp;quot; style=&amp;quot;list-style-type: decimal;&amp;quot;&amp;gt;&amp;lt;li&amp;gt;&lt;br /&gt;
    &amp;lt;p&amp;gt;Make sure to only display the Apple Pay button to users who can use it, by have your webshop’s checkout pages do&lt;br /&gt;
      the following when they load:&amp;lt;/p&amp;gt;&lt;br /&gt;
    &amp;lt;p&amp;gt;Call [https://developer.apple.com/documentation/applepayontheweb/applepaysession/canmakepayments &amp;lt;code&amp;gt;ApplePaySession.canMakePayments()&amp;lt;/code&amp;gt;] to check, in a single simple boolean call, whether Apple Pay is available at all on the customer&#039;s device/browser — this is the method needed to decide whether to show the button.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;p&amp;gt;If you additionally need detailed status about a specific merchant and the customer&#039;s stored cards, use [https://developer.apple.com/documentation/applepayontheweb/applepaysession/applepaycapabilities &amp;lt;code&amp;gt;applePaySession.applePayCapabilities()&amp;lt;/code&amp;gt;], passing it your Barion shop’s public Id as the merchantId parameter.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;blockquote&amp;gt;&amp;lt;code&amp;gt;applePaySession.canMakePaymentsWithActiveCard&amp;lt;/code&amp;gt; is &#039;&#039;&#039;deprecated&#039;&#039;&#039; by Apple — use &amp;lt;code&amp;gt;applePayCapabilities&amp;lt;/code&amp;gt; instead for that detailed check.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;p&amp;gt;If Apple can verify your Barion shop as a registered Apple Pay provider, the detailed check reports the following:&amp;lt;/p&amp;gt;&lt;br /&gt;
    &amp;lt;ul&amp;gt;&lt;br /&gt;
      &amp;lt;li&amp;gt;that your customer&#039;s device is capable of using Apple Pay&amp;lt;/li&amp;gt;&lt;br /&gt;
      &amp;lt;li&amp;gt;that Apple Pay is enabled on your customer&#039;s device, and&amp;lt;/li&amp;gt;&lt;br /&gt;
      &amp;lt;li&amp;gt;that the customer has the details of at least one active and web payment-eligible bank card stored in their Apple&lt;br /&gt;
        Pay wallet.&amp;lt;/li&amp;gt;&lt;br /&gt;
    &amp;lt;/ul&amp;gt;&lt;br /&gt;
  &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;Handle [https://developer.apple.com/documentation/apple_pay_on_the_web/paymentcredentialstatus the &amp;lt;code&amp;gt;PaymentCredentialStatus&amp;lt;/code&amp;gt; object] that the method returns to make a decision about displaying the&lt;br /&gt;
        Apple Pay button.&lt;br /&gt;
  &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Handling payments ===&lt;br /&gt;
&lt;br /&gt;
Set up your webshop to perform these steps each time a user selects the Apple Pay button.&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=IMPORTANT|text=The &amp;amp;lt;apple-pay-button&amp;amp;gt; element does not dispatch a standard bubbling DOM click event, so addEventListener / jQuery .on(&#039;click&#039;, ...) (whether bound to the element or to a container around it) will not fire. Bind your click handler directly to the element&#039;s onclick property instead.|color=#FF7A3D}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;document.getElementById(&#039;apple-pay-button&#039;).onclick = function (event) {&lt;br /&gt;
    // start your ApplePaySession here&lt;br /&gt;
};&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol style=&amp;quot;list-style-type: decimal;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Set up an event handler for [https://developer.apple.com/documentation/apple_pay_on_the_web/applepaysession/1778021-onvalidatemerchant &amp;lt;code&amp;gt;ApplePaySession.onvalidatemerchant&amp;lt;/code&amp;gt;] that notifies your site&#039;s back-end, and passes it the event response.&amp;lt;/p&amp;gt;&amp;lt;blockquote&amp;gt;Don&#039;t call the ValidateSession Barion API endpoint directly from the browser, as this could expose your Barion shop&#039;s POSKey.&amp;lt;/blockquote&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Have your site&#039;s back-end call [[ApplePay-ValidateSession|the ValidateSession Barion API endpoint]], passing it the &amp;lt;code&amp;gt;onvalidatemerchant&amp;lt;/code&amp;gt; event’s &amp;lt;code&amp;gt;ValidationUrl&amp;lt;/code&amp;gt; attribute.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;async function validateApplePaySession(POSKey, SessionRequestUrl, ShopUrl) {&lt;br /&gt;
  const url = &amp;quot;https://api.test.barion.com/v2/ApplePay/ValidateSession&amp;quot;;&lt;br /&gt;
  const data = {&lt;br /&gt;
    POSKey,&lt;br /&gt;
    SessionRequestUrl,&lt;br /&gt;
    ShopUrl,&lt;br /&gt;
  };&lt;br /&gt;
&lt;br /&gt;
  try {&lt;br /&gt;
    const response = await fetch(url, {&lt;br /&gt;
      method: &amp;quot;POST&amp;quot;,&lt;br /&gt;
      headers: {&lt;br /&gt;
        &amp;quot;Content-Type&amp;quot;: &amp;quot;application/json&amp;quot;,&lt;br /&gt;
      },&lt;br /&gt;
      body: JSON.stringify(data),&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
    if (!response.ok) {&lt;br /&gt;
      throw new Error(`Error: ${response.status} ${response.statusText}`);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    const result = await response.json();&lt;br /&gt;
    return result;&lt;br /&gt;
  } catch (error) {&lt;br /&gt;
    // handle the error according to your business logic&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
applePaySession.onvalidatemerchant = async function (event) {&lt;br /&gt;
  const validationResult = await validateApplePaySession(POSKey, event.validationURL, ShopUrl);&lt;br /&gt;
  &lt;br /&gt;
  applePaySession.completeMerchantValidation(validationResult.ApplePaySessionResponse);&lt;br /&gt;
};&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;This event is triggered when the Apple Pay payment sheet is displayed to the customer.&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Set up an event handler for [https://developer.apple.com/documentation/apple_pay_on_the_web/applepaysession/1778020-onpaymentauthorized &amp;lt;code&amp;gt;ApplePaySession.onpaymentauthorized&amp;lt;/code&amp;gt;]&amp;lt;/p&amp;gt;&amp;lt;blockquote&amp;gt;Don&#039;t call the StartPaymentWithAppleToken Barion API endpoint directly from the browser, as this could expose your Barion shop&#039;s POSKey.&amp;lt;/blockquote&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;that calls the [[ApplePay-StartPaymentWithAppleToken|StartPaymentWithAppleToken Barion API endpoint]], passing it the event’s following attributes:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;token&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;shippingContact&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;billingContact&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note that &amp;lt;code&amp;gt;StartPaymentWithAppleToken&amp;lt;/code&amp;gt; is actually a specialized version of [[Payment-Start-v2|the payment/start API endpoint]], and so will also require all the usual parameters that you’d pass to that endpoint.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
async function startApplePayPayment(&lt;br /&gt;
  POSKey,&lt;br /&gt;
  ShippingContact,&lt;br /&gt;
  BillingContact,&lt;br /&gt;
  Token,&lt;br /&gt;
  /** include other required and optional Payment/Start params */&lt;br /&gt;
  PaymentStartProperties&lt;br /&gt;
) {&lt;br /&gt;
  const url =&lt;br /&gt;
    &amp;quot;https://api.test.barion.com/v2/ApplePay/StartPaymentWithAppleToken&amp;quot;;&lt;br /&gt;
  const data = {&lt;br /&gt;
    POSKey,&lt;br /&gt;
    ShippingContact,&lt;br /&gt;
    BillingContact,&lt;br /&gt;
    Token,&lt;br /&gt;
    ...PaymentStartProperties,&lt;br /&gt;
  };&lt;br /&gt;
&lt;br /&gt;
  try {&lt;br /&gt;
    const response = await fetch(url, {&lt;br /&gt;
      method: &amp;quot;POST&amp;quot;,&lt;br /&gt;
      headers: {&lt;br /&gt;
        &amp;quot;Content-Type&amp;quot;: &amp;quot;application/json&amp;quot;,&lt;br /&gt;
      },&lt;br /&gt;
      body: JSON.stringify(data),&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
    if (!response.ok) {&lt;br /&gt;
      throw new Error(`Error: ${response.status} ${response.statusText}`);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    const result = await response.json();&lt;br /&gt;
    return result;&lt;br /&gt;
  } catch (error) {&lt;br /&gt;
    // handle the error according to your business logic&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
const PaymentStartProperties = {&lt;br /&gt;
  PaymentType: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
applePaySession.onpaymentauthorized = function (event) {&lt;br /&gt;
  startApplePayPayment(&lt;br /&gt;
    POSKey,&lt;br /&gt;
    event.paymentInfo.shippingContent,&lt;br /&gt;
    event.paymentInfo.billingContact,&lt;br /&gt;
    event.paymentInfo.Token,&lt;br /&gt;
    PaymentStartProperties&lt;br /&gt;
  );&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;This event is triggered when the customer has authorized the Apple Pay payment using their Touch ID or Face ID.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Set up an event handler for &amp;lt;code&amp;gt;oncancel&amp;lt;/code&amp;gt; to implement your business logic for when the user abandons the Apple Pay payment.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Make sure that your event handler indicates that the session is canceled so the ApplePaySession’s &amp;lt;code&amp;gt;completePayment&amp;lt;/code&amp;gt; method doesn’t get executed.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;  applePaySession.oncancel = function (event) {&lt;br /&gt;
    // your oncancel business logic&lt;br /&gt;
&lt;br /&gt;
    isSessionCanceled = true;&lt;br /&gt;
  };&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Call [https://developer.apple.com/documentation/apple_pay_on_the_web/applepaysession/1778001-begin ApplePaySession.begin] to kick off the payment process.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;  applePaySession.begin();&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;This starts the merchant validation process that results in &amp;lt;code&amp;gt;ApplePaySession.onvalidatemerchant&amp;lt;/code&amp;gt; being triggered.&amp;lt;/blockquote&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Testing your implementation ===&lt;br /&gt;
&lt;br /&gt;
The following steps are needed in order to test your implementation:&lt;br /&gt;
# request access by sending an email to devsupport@barion.com!&lt;br /&gt;
# include an email address, that has no Apple Id yet&lt;br /&gt;
# we will register &amp;amp; connect it to our test account&lt;br /&gt;
# after that, you will be able to [https://developer.apple.com/apple-pay/sandbox-testing/ use Apple&#039;s test cards]&lt;br /&gt;
&lt;br /&gt;
== Related links ==&lt;br /&gt;
&lt;br /&gt;
[[ApplePay-ValidateSession|ValidateSession API endpoint]]&lt;br /&gt;
&lt;br /&gt;
[[ApplePay-StartPaymentWithAppleToken|StartPaymentWithAppleToken API endpoint]]&lt;/div&gt;</summary>
		<author><name>Salamongy@barion.dev</name></author>
	</entry>
	<entry>
		<id>https://docs.barion.com/index.php?title=Apple_Pay&amp;diff=4940</id>
		<title>Apple Pay</title>
		<link rel="alternate" type="text/html" href="https://docs.barion.com/index.php?title=Apple_Pay&amp;diff=4940"/>
		<updated>2026-09-03T06:56:21Z</updated>

		<summary type="html">&lt;p&gt;Salamongy@barion.dev: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{PageTitle|title=Apple Pay integration}}&lt;br /&gt;
{{TableOfContents}}&lt;br /&gt;
&lt;br /&gt;
Apple Pay is a wallet solution created by Apple for Apple customers. It is only accessible in the Apple ecosystem. You can use it with your iPhone, iWatch or with your desktop/laptop Macintosh computer. When it comes to Barion there are two different ways to use this payment option:&lt;br /&gt;
&lt;br /&gt;
* on the Barion Smart Gateway (called hosted mode)&lt;br /&gt;
* in their webshop if they integrate the so-called integrated mode&lt;br /&gt;
&lt;br /&gt;
The customer who wants to pay with Apple Pay Wallet must have an Apple device that supports authentication. This could be&lt;br /&gt;
&lt;br /&gt;
* an iPhone,&lt;br /&gt;
* a modern MacBook with fingerprint authentication or&lt;br /&gt;
* an older MacBook with a paired iPhone&lt;br /&gt;
&lt;br /&gt;
=== Browser support ===&lt;br /&gt;
Apple Pay behaves differently depending on the customer&#039;s browser:&amp;lt;blockquote&amp;gt;&lt;br /&gt;
* In Safari, and in any browser built on Apple&#039;s WebKit engine (Chrome, Firefox, or Edge on iOS), the button works natively, and the customer confirms the payment with Touch ID or Face ID.&lt;br /&gt;
* In other desktop browsers that can&#039;t run Apple Pay directly (for example Chrome, Firefox, or Edge on Windows), Apple&#039;s SDK automatically shows a QR code that the customer scans with their iPhone&#039;s Camera app (requires &#039;&#039;&#039;iOS 18 or later&#039;&#039;&#039;) to complete the payment there.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;Furthermore, the customer must fill out their home address and their contact information in their Apple Pay wallet as well. Without this, they won&#039;t be able to use their card in their Apple Wallet. This can be done even during the payment process.&lt;br /&gt;
&lt;br /&gt;
This feature is listed as an available payment method on the shop&#039;s admin site&lt;br /&gt;
&lt;br /&gt;
In case it is switched off the shop won&#039;t be able to display it as a funding source. This won&#039;t produce any error message, the Apple Pay option just won&#039;t be visible.&lt;br /&gt;
&lt;br /&gt;
=== Hosted mode ===&lt;br /&gt;
This is the &amp;quot;out of the box&amp;quot; mode that is available on the Barion Smart Gateway. It works in every browser described in the &#039;&#039;&#039;Browser support&#039;&#039;&#039; section above — natively in &#039;&#039;&#039;Safari&#039;&#039;&#039; and other WebKit-based browsers, and via the QR code hand-off in other desktop browsers.&lt;br /&gt;
&lt;br /&gt;
If the customer selects the Apple Pay accordion, the Apple Pay button will be visible.&lt;br /&gt;
&lt;br /&gt;
Once the customer clicks the Pay button the Apple Pay screen is displayed. This screen is actually controlled by the device, we don&#039;t have any control over it.&lt;br /&gt;
&lt;br /&gt;
On this screen, the customer may change the used credit card, the home address, or the e-mail address. These are all required to pay via Apple Pay. Once the customer approves the transaction everything continues as with a normal card would.&lt;br /&gt;
&lt;br /&gt;
=== Integrated mode ===&lt;br /&gt;
In integrated mode (called processor mode in Apple documentation) the webshop owner puts the Apple Pay button in their webshop and does not need to redirect the customer to the Barion Smart Gateway. This feature requires custom development from the webshop owner. The shop has to implement the Apple Pay button (instead of just relying on our gateway). To do this, they have to read through [[Apple Pay|this documentation]].&lt;br /&gt;
&lt;br /&gt;
The Apple Pay button can be displayed anywhere on the webshop. For example, on our demomerchant site is next to the Google Pay button.&lt;br /&gt;
&lt;br /&gt;
This integration requires a developer and is beneficial for shops that want to provide their customer a faster payment experience (since there is no need to redirect them to our gateway).&lt;br /&gt;
&lt;br /&gt;
To enable the button on the merchant&#039;s website the website has to be registered at Apple services. To help with this task we created a setting screen in our system. This setting page is available from the shop&#039;s setting page. (The one accessible by the owner)&lt;br /&gt;
&lt;br /&gt;
On this page, the owner has to input all the domains that the shop is using for the Apple Pay button. In addition to this the owner also has to upload a domain verification file to its domain.&lt;br /&gt;
&lt;br /&gt;
=== After payment ===&lt;br /&gt;
After the successful payment, the customer receives the usual confirmation letter, however, the bank card is clearly flagged, so the customer is aware that the payment was funded with a card from their Apple Wallet.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Warning:&#039;&#039;&#039; The card number displayed here is not the real card number. Apple creates a fake card number to protect the real card, so we are only aware of the fake number.&lt;br /&gt;
&lt;br /&gt;
= Technical implementation =&lt;br /&gt;
&lt;br /&gt;
== Merchants ==&lt;br /&gt;
The production and non-production environments use different merchants to keep the processing private key secret. Barion has two registered merchants at Apple Pay:&lt;br /&gt;
&lt;br /&gt;
* merchant.com.barion.applepay (used in the production environment)&lt;br /&gt;
* merchant.com.barion.test.applepay (used in non-production environments)&lt;br /&gt;
&lt;br /&gt;
This means the certificate installations, domain validations, and registrations must be completed separately in every environment. All necessary files and certificates are in a separate folder here: &#039;&#039;R:\Development\Sensitive\ApplePay\Merchants&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Certificates for production environment are handled by the Operator team.&lt;br /&gt;
&lt;br /&gt;
== Certificates ==&lt;br /&gt;
Apple Pay certificates for the Dev|Demo environments are here: &#039;&#039;R:\Development\Sensitive\ApplePay\Merchants&#039;&#039;. They were created by the operators, use the following page to create the Apple Pay merchant ID and certificates, and verify the domains: Configuring the environment&lt;br /&gt;
&lt;br /&gt;
There are two certificate files with different purposes. The &#039;&#039;merchant&#039;&#039; certificate is to validate and create Apple Pay sessions and the &#039;&#039;processor&#039;&#039; certificate is to decrypt the payload. Each of the certificates has to contain a private key. The preferred format is P12.&lt;br /&gt;
&lt;br /&gt;
The merchant certificate has to be installed on the Windows certificate store, the application will use it from the Personal container.&lt;br /&gt;
&lt;br /&gt;
From the processing certificate we need the private key only, to retrieve it use the following OpenSSL (3.2.1+ version required) command:&lt;br /&gt;
&lt;br /&gt;
After the PEM file is created, the content of the file should be saved into a text file. This text file is used in the configuration file(ApplePay.ProcessingPrivateKeyPath):&lt;br /&gt;
&lt;br /&gt;
== Changing of the certificates ==&lt;br /&gt;
Certificates can be obtained from Apple. Apple can only handle one certificate at a time, when the new certificate is enabled, the old one is automatically revoked. Since this process takes about 15-45 minutes to complete, it is advised to do it in a low-traffic period.&lt;br /&gt;
&lt;br /&gt;
Steps:&lt;br /&gt;
&lt;br /&gt;
# Obtain the new certificates from the Apple Developer Portal&lt;br /&gt;
# Generate the private key for the certificate as described in the previous point&lt;br /&gt;
# Update the appropriate config files (Secure, Api, Admin, Tools.QuedTaskInstaller as of 2023.04.21.) with the new certificate thumbprint and private key&lt;br /&gt;
# Enable the new certificates on the Apple Developer Portal&lt;br /&gt;
# Deploy the new configs to our servers (since the old certificates are revoked, and the new onew take about 15-45 minutes for the certificates to go live on Apple&#039;s side, there will be a downtime of about 15-45 minutes, during this time, ApplePay payments will fail)&lt;br /&gt;
# Done :)&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
Apple Pay on the web can be tested with Apple devices. The minimum OS versions are:&lt;br /&gt;
&lt;br /&gt;
* macOS 10.14.4&lt;br /&gt;
* iOS 12.2&lt;br /&gt;
&lt;br /&gt;
There are some example message here: &#039;&#039;R:\Development\Sensitive\ApplePay\Sample messages&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
These messages can be posted via Postman using the following API endpoint:&lt;br /&gt;
&lt;br /&gt;
Use the WalletMessage object in the CardInformation object to post the Apple Pay payload.&lt;br /&gt;
&lt;br /&gt;
To test the new cross-browser QR code hand-off (for customers on desktop non-Safari browsers), you need an iPhone running &#039;&#039;&#039;iOS 18 or later&#039;&#039;&#039; — this is a separate, newer requirement from the general &amp;quot;iOS 12.2&amp;quot; minimum above, which only covers using Apple Pay natively in &#039;&#039;&#039;Safari&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
MacOS is not enough to use Apple Pay. To use Apple Pay on MacOS you should configure Handoff function on the devices, follow this to set up the devices properly. This Handoff requirement applies to &#039;&#039;&#039;Safari&#039;&#039;&#039; on macOS. Non-Safari desktop browsers (including Chrome or Firefox on macOS) don&#039;t need Handoff configured at all — they use the QR code hand-off flow described above instead.&lt;br /&gt;
&lt;br /&gt;
You can test which certificate is used to encrypt the payment data with this command:&lt;br /&gt;
&lt;br /&gt;
The 2023_proc_Certificates.p12 should be the new certificate!&lt;br /&gt;
&lt;br /&gt;
The output of the above script should be the same as that of PaymentData.Header.PublicKeyHash&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting domain association errors ==&lt;br /&gt;
Some common pitfalls with domain association files can be found below.&lt;br /&gt;
&lt;br /&gt;
* domain association file cannot be reached without authentication&lt;br /&gt;
* response doesn’t contain “Content-Type” header with value “application/json”&lt;br /&gt;
* merchant’s server only supports TLS 1.3 (Barion uses 1.2 for checking this file)&lt;br /&gt;
* merchant has some form of bot/scraping protection enabled, which filters out requests that has a non-browser shaped or missing User-Agent header&lt;br /&gt;
&lt;br /&gt;
If a merchant reaches out about a domain association file problem, you can check these issues via:&lt;br /&gt;
&lt;br /&gt;
* first opening the domain association file on their site from a browser and checking the response&lt;br /&gt;
* and if that didn’t bring any results, running the script “Test-ApplePayDomainAssociation.ps1” found in the DeveloperScripts repo&lt;br /&gt;
** run this script in Powershell 5.1&lt;br /&gt;
** you can run the script locally, but for more reliable results, use one of the prod-web machines via the help of operators (so the network environment and TLS capabilities match production)&lt;br /&gt;
&lt;br /&gt;
== Contact ==&lt;br /&gt;
George Maroufidis &amp;lt;gmaroufidis@apple.com&amp;gt;&lt;br /&gt;
&lt;br /&gt;
George Maroufidis |  Pay eCommerce EMEIA | OneBattersea Power Station, London, SW11 8BZ, United Kingdom | iPhone: +44 7591 916 527&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
* Apple Pay Marketing Guidelines&lt;br /&gt;
* Human Interface Guidelines&lt;br /&gt;
&lt;br /&gt;
== Reference ==&lt;br /&gt;
&lt;br /&gt;
* Configuring the environment&lt;br /&gt;
* Apple Pay on the web&lt;br /&gt;
* PaymentToken&lt;br /&gt;
* Sandbox&lt;br /&gt;
&amp;lt;blockquote&amp;gt;This article is about directly integrating the Apple Pay button in your webshop.&lt;br /&gt;
&lt;br /&gt;
If you simply want to display Apple Pay as a payment option in the Barion Smart Gateway, no further configuration is necessary; pass &amp;quot;ApplePay&amp;quot; in [[FundingSources|the FundingSources array]] when preparing a payment.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
The appeal of Apple Pay is that it requires only two actions from the customer: selecting the ‘Pay with Apple Pay’ button, and confirming the payment with Touch ID or Face ID.&lt;br /&gt;
&lt;br /&gt;
Another advantage to your Barion shop’s payment workflow is that customers aren’t navigated away from your checkout page when using Apple Pay.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;prerequisites&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=IMPORTANT|text=You do not need to register an Apple Developer Account! Should you need an Apple Merchant Id, use the PublicId (guid) of your shop!|color=#FF7A3D}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;access to and being able to modify both your webshop’s front-end and back-end code&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;your webshop using HTTPS (having a TLS 1.2 or higher certificate installed) for all its pages that include the Apple Pay button&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Barion Wallet with an approved Barion shop&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;the Barion shop complies with [https://developer.apple.com/apple-pay/acceptable-use-guidelines-for-websites/ Apple’s acceptable use guidelines], including not selling prohibited products or services&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;Note that Apple’s policies regarding acceptable products and services are more limiting than those of Barion.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;It may happen that even though Barion approves your Barion shop to sell a certain item, you will not be allowed to display the Apple Pay button as a payment option for customers to pay for that item.&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;an account in the Barion Wallet for each of the currencies that you’d like to accept using Apple Pay&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Limitations ==&lt;br /&gt;
&lt;br /&gt;
* you can’t yet tokenize your customer’s card details when using the Apple Pay button, so [[Token payment 3D Secure|recurring payments]] aren’t available&lt;br /&gt;
* Barion currently only supports Apple Pay button on the web, and not on native iOS apps&lt;br /&gt;
* regardless of the integration detailed here, the Apple Pay button will only be displayed to your customers if they comply with Apple’s requirements:&lt;br /&gt;
** they’re using [https://support.apple.com/en-us/102896 an Apple Pay-compatible device]&lt;br /&gt;
** they’re viewing your webshop using a browser that supports Apple Pay&lt;br /&gt;
** they’re located [https://support.apple.com/en-us/102775 in a country or region where Apple Pay is available]&lt;br /&gt;
== Steps ==&lt;br /&gt;
=== Setting up your Apple prerequisites ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;When using Barion’s Apple Pay API endpoints, Barion gives you [https://developer.apple.com/support/app-account/ an Apple developer account], and registers [https://developer.apple.com/documentation/applepaywebmerchantregistrationapi/registering_with_apple_pay_and_applying_to_use_the_api a Merchant ID], [https://help.apple.com/developer-account/#/devb2e62b839?sub=devf31990e3f Payment Processing Certificate], and [https://help.apple.com/developer-account/#/dev1731126fb Merchant Identity Certificate] for you as a subsidiary of Barion’s Apple Pay credentials.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
Verify and register your webshop’s domain name or names:&lt;br /&gt;
&lt;br /&gt;
# Log in to your Barion Wallet, and go to your Barion shop’s Shops&amp;amp;gt;Actions&amp;amp;gt;Settings screen.&lt;br /&gt;
# Click the “Manage Apple Pay settings”, and then “Download domain verification file” to save the verification file for your shop’s domain.&lt;br /&gt;
# Save the domain verification file that you downloaded in the &amp;lt;code&amp;gt;/.well-known&amp;lt;/code&amp;gt; directory of all the sites that your specified domains use, making sure of the following:&lt;br /&gt;
#* the file should send the &amp;lt;code&amp;gt;&amp;lt;mimeMap fileExtension=&amp;quot;.&amp;quot; mimeType=&amp;quot;application/json&amp;quot; /&amp;gt;&amp;lt;/code&amp;gt; MIME data;&lt;br /&gt;
#* the file must be accessible externally, and not be password-protected, or behind a proxy or redirect;&lt;br /&gt;
#* the sites must be served over HTTPS.&lt;br /&gt;
# Enter all the domains that you’d like to use Apple Pay on (into whose root you’ve downloaded the domain verification file) in the text box provided, then click “Save”.&lt;br /&gt;
&lt;br /&gt;
=== Configuring and displaying the Apple Pay button ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol style=&amp;quot;list-style-type: decimal;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Load the button script into your checkout page by adding the following script tag inside the page head:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;html&amp;quot;&amp;gt;&amp;lt;script crossorigin src=&amp;quot;https://applepay.cdn-apple.com/jsapi/1.latest/apple-pay-sdk.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;This script makes an ApplePaySession available to your site front-end, among other things.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;ol start=&amp;quot;2&amp;quot; style=&amp;quot;list-style-type: decimal;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Add the &amp;lt;code&amp;gt;apple-pay-button&amp;lt;/code&amp;gt; custom element (for example, &amp;lt;code&amp;gt;&amp;amp;lt;apple-pay-button id=&amp;quot;apple-pay-button&amp;quot; buttonstyle=&amp;quot;black&amp;quot; type=&amp;quot;plain&amp;quot;&amp;amp;gt;&amp;amp;lt;/apple-pay-button&amp;amp;gt;&amp;lt;/code&amp;gt;) to your checkout page. The official SDK renders this element natively — you no longer need to write your own CSS to display it.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=IMPORTANT|text=The &amp;amp;lt;apple-pay-button&amp;amp;gt; element&#039;s size can&#039;t be set with ordinary CSS height/border-radius properties — its internal shadow-DOM content won&#039;t follow them. Use the dedicated CSS custom properties instead: --apple-pay-button-height and --apple-pay-button-border-radius.|color=#FF7A3D}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;css&amp;quot;&amp;gt;apple-pay-button {&lt;br /&gt;
  --apple-pay-button-height: 48px;&lt;br /&gt;
  --apple-pay-button-border-radius: 8px;&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Start a new ApplePaySession when the checkout page loads:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;  const request = {&lt;br /&gt;
    countryCode: &#039;US&#039;,&lt;br /&gt;
    currencyCode: &#039;USD&#039;,&lt;br /&gt;
    supportedNetworks: [&#039;visa&#039;, &#039;masterCard&#039;, &#039;discover&#039;],&lt;br /&gt;
    merchantCapabilities: [&#039;supports3DS&#039;],&lt;br /&gt;
    total: { label: &#039;Your Merchant Name&#039;, amount: &#039;10.00&#039; }&lt;br /&gt;
  }&lt;br /&gt;
  const applePlaySession = new ApplePaySession(3, request);&lt;br /&gt;
&lt;br /&gt;
  // add an isSessionCanceled boolean to easily be able to cancel the session if your user abandons the in-progress payment process&lt;br /&gt;
  var isSessionCanceled = false;&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&amp;lt;blockquote&amp;gt;The merchant may supply the shipping and billing contact information directly, or request it when starting the ApplePaySession by including the [https://developer.apple.com/documentation/applepayontheweb/applepaypaymentrequest/requiredshippingcontactfields requiredShippingContactFields]  and [https://developer.apple.com/documentation/applepayontheweb/applepaypaymentrequest/requiredbillingcontactfields requiredBillingContactFields] properties in the payment request. More about the Apple Pay payment request [https://developer.apple.com/documentation/applepayontheweb/applepaypaymentrequest here].&amp;lt;/blockquote&amp;gt;&amp;lt;ol start=&amp;quot;4&amp;quot; style=&amp;quot;list-style-type: decimal;&amp;quot;&amp;gt;&amp;lt;li&amp;gt;&lt;br /&gt;
    &amp;lt;p&amp;gt;Make sure to only display the Apple Pay button to users who can use it, by have your webshop’s checkout pages do&lt;br /&gt;
      the following when they load:&amp;lt;/p&amp;gt;&lt;br /&gt;
    &amp;lt;p&amp;gt;Call [https://developer.apple.com/documentation/applepayontheweb/applepaysession/canmakepayments &amp;lt;code&amp;gt;ApplePaySession.canMakePayments()&amp;lt;/code&amp;gt;] to check, in a single simple boolean call, whether Apple Pay is available at all on the customer&#039;s device/browser — this is the method needed to decide whether to show the button.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;p&amp;gt;If you additionally need detailed status about a specific merchant and the customer&#039;s stored cards, use [https://developer.apple.com/documentation/applepayontheweb/applepaysession/applepaycapabilities &amp;lt;code&amp;gt;applePaySession.applePayCapabilities()&amp;lt;/code&amp;gt;], passing it your Barion shop’s public Id as the merchantId parameter.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;blockquote&amp;gt;&amp;lt;code&amp;gt;applePaySession.canMakePaymentsWithActiveCard&amp;lt;/code&amp;gt; is &#039;&#039;&#039;deprecated&#039;&#039;&#039; by Apple — use &amp;lt;code&amp;gt;applePayCapabilities&amp;lt;/code&amp;gt; instead for that detailed check.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;p&amp;gt;If Apple can verify your Barion shop as a registered Apple Pay provider, the detailed check reports the following:&amp;lt;/p&amp;gt;&lt;br /&gt;
    &amp;lt;ul&amp;gt;&lt;br /&gt;
      &amp;lt;li&amp;gt;that your customer&#039;s device is capable of using Apple Pay&amp;lt;/li&amp;gt;&lt;br /&gt;
      &amp;lt;li&amp;gt;that Apple Pay is enabled on your customer&#039;s device, and&amp;lt;/li&amp;gt;&lt;br /&gt;
      &amp;lt;li&amp;gt;that the customer has the details of at least one active and web payment-eligible bank card stored in their Apple&lt;br /&gt;
        Pay wallet.&amp;lt;/li&amp;gt;&lt;br /&gt;
    &amp;lt;/ul&amp;gt;&lt;br /&gt;
  &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;Handle [https://developer.apple.com/documentation/apple_pay_on_the_web/paymentcredentialstatus the &amp;lt;code&amp;gt;PaymentCredentialStatus&amp;lt;/code&amp;gt; object] that the method returns to make a decision about displaying the&lt;br /&gt;
        Apple Pay button.&lt;br /&gt;
  &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Handling payments ===&lt;br /&gt;
&lt;br /&gt;
Set up your webshop to perform these steps each time a user selects the Apple Pay button.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol style=&amp;quot;list-style-type: decimal;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Set up an event handler for [https://developer.apple.com/documentation/apple_pay_on_the_web/applepaysession/1778021-onvalidatemerchant &amp;lt;code&amp;gt;ApplePaySession.onvalidatemerchant&amp;lt;/code&amp;gt;] that notifies your site&#039;s back-end, and passes it the event response.&amp;lt;/p&amp;gt;&amp;lt;blockquote&amp;gt;Don&#039;t call the ValidateSession Barion API endpoint directly from the browser, as this could expose your Barion shop&#039;s POSKey.&amp;lt;/blockquote&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Have your site&#039;s back-end call [[ApplePay-ValidateSession|the ValidateSession Barion API endpoint]], passing it the &amp;lt;code&amp;gt;onvalidatemerchant&amp;lt;/code&amp;gt; event’s &amp;lt;code&amp;gt;ValidationUrl&amp;lt;/code&amp;gt; attribute.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;async function validateApplePaySession(POSKey, SessionRequestUrl, ShopUrl) {&lt;br /&gt;
  const url = &amp;quot;https://api.test.barion.com/v2/ApplePay/ValidateSession&amp;quot;;&lt;br /&gt;
  const data = {&lt;br /&gt;
    POSKey,&lt;br /&gt;
    SessionRequestUrl,&lt;br /&gt;
    ShopUrl,&lt;br /&gt;
  };&lt;br /&gt;
&lt;br /&gt;
  try {&lt;br /&gt;
    const response = await fetch(url, {&lt;br /&gt;
      method: &amp;quot;POST&amp;quot;,&lt;br /&gt;
      headers: {&lt;br /&gt;
        &amp;quot;Content-Type&amp;quot;: &amp;quot;application/json&amp;quot;,&lt;br /&gt;
      },&lt;br /&gt;
      body: JSON.stringify(data),&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
    if (!response.ok) {&lt;br /&gt;
      throw new Error(`Error: ${response.status} ${response.statusText}`);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    const result = await response.json();&lt;br /&gt;
    return result;&lt;br /&gt;
  } catch (error) {&lt;br /&gt;
    // handle the error according to your business logic&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
applePaySession.onvalidatemerchant = async function (event) {&lt;br /&gt;
  const validationResult = await validateApplePaySession(POSKey, event.validationURL, ShopUrl);&lt;br /&gt;
  &lt;br /&gt;
  applePaySession.completeMerchantValidation(validationResult.ApplePaySessionResponse);&lt;br /&gt;
};&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;This event is triggered when the Apple Pay payment sheet is displayed to the customer.&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Set up an event handler for [https://developer.apple.com/documentation/apple_pay_on_the_web/applepaysession/1778020-onpaymentauthorized &amp;lt;code&amp;gt;ApplePaySession.onpaymentauthorized&amp;lt;/code&amp;gt;]&amp;lt;/p&amp;gt;&amp;lt;blockquote&amp;gt;Don&#039;t call the StartPaymentWithAppleToken Barion API endpoint directly from the browser, as this could expose your Barion shop&#039;s POSKey.&amp;lt;/blockquote&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;that calls the [[ApplePay-StartPaymentWithAppleToken|StartPaymentWithAppleToken Barion API endpoint]], passing it the event’s following attributes:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;token&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;shippingContact&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;billingContact&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note that &amp;lt;code&amp;gt;StartPaymentWithAppleToken&amp;lt;/code&amp;gt; is actually a specialized version of [[Payment-Start-v2|the payment/start API endpoint]], and so will also require all the usual parameters that you’d pass to that endpoint.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
async function startApplePayPayment(&lt;br /&gt;
  POSKey,&lt;br /&gt;
  ShippingContact,&lt;br /&gt;
  BillingContact,&lt;br /&gt;
  Token,&lt;br /&gt;
  /** include other required and optional Payment/Start params */&lt;br /&gt;
  PaymentStartProperties&lt;br /&gt;
) {&lt;br /&gt;
  const url =&lt;br /&gt;
    &amp;quot;https://api.test.barion.com/v2/ApplePay/StartPaymentWithAppleToken&amp;quot;;&lt;br /&gt;
  const data = {&lt;br /&gt;
    POSKey,&lt;br /&gt;
    ShippingContact,&lt;br /&gt;
    BillingContact,&lt;br /&gt;
    Token,&lt;br /&gt;
    ...PaymentStartProperties,&lt;br /&gt;
  };&lt;br /&gt;
&lt;br /&gt;
  try {&lt;br /&gt;
    const response = await fetch(url, {&lt;br /&gt;
      method: &amp;quot;POST&amp;quot;,&lt;br /&gt;
      headers: {&lt;br /&gt;
        &amp;quot;Content-Type&amp;quot;: &amp;quot;application/json&amp;quot;,&lt;br /&gt;
      },&lt;br /&gt;
      body: JSON.stringify(data),&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
    if (!response.ok) {&lt;br /&gt;
      throw new Error(`Error: ${response.status} ${response.statusText}`);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    const result = await response.json();&lt;br /&gt;
    return result;&lt;br /&gt;
  } catch (error) {&lt;br /&gt;
    // handle the error according to your business logic&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
const PaymentStartProperties = {&lt;br /&gt;
  PaymentType: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
applePaySession.onpaymentauthorized = function (event) {&lt;br /&gt;
  startApplePayPayment(&lt;br /&gt;
    POSKey,&lt;br /&gt;
    event.paymentInfo.shippingContent,&lt;br /&gt;
    event.paymentInfo.billingContact,&lt;br /&gt;
    event.paymentInfo.Token,&lt;br /&gt;
    PaymentStartProperties&lt;br /&gt;
  );&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;This event is triggered when the customer has authorized the Apple Pay payment using their Touch ID or Face ID.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Set up an event handler for &amp;lt;code&amp;gt;oncancel&amp;lt;/code&amp;gt; to implement your business logic for when the user abandons the Apple Pay payment.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Make sure that your event handler indicates that the session is canceled so the ApplePaySession’s &amp;lt;code&amp;gt;completePayment&amp;lt;/code&amp;gt; method doesn’t get executed.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;  applePaySession.oncancel = function (event) {&lt;br /&gt;
    // your oncancel business logic&lt;br /&gt;
&lt;br /&gt;
    isSessionCanceled = true;&lt;br /&gt;
  };&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Call [https://developer.apple.com/documentation/apple_pay_on_the_web/applepaysession/1778001-begin ApplePaySession.begin] to kick off the payment process.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;  applePaySession.begin();&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;This starts the merchant validation process that results in &amp;lt;code&amp;gt;ApplePaySession.onvalidatemerchant&amp;lt;/code&amp;gt; being triggered.&amp;lt;/blockquote&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Testing your implementation ===&lt;br /&gt;
&lt;br /&gt;
The following steps are needed in order to test your implementation:&lt;br /&gt;
# request access by sending an email to devsupport@barion.com!&lt;br /&gt;
# include an email address, that has no Apple Id yet&lt;br /&gt;
# we will register &amp;amp; connect it to our test account&lt;br /&gt;
# after that, you will be able to [https://developer.apple.com/apple-pay/sandbox-testing/ use Apple&#039;s test cards]&lt;br /&gt;
&lt;br /&gt;
== Related links ==&lt;br /&gt;
&lt;br /&gt;
[[ApplePay-ValidateSession|ValidateSession API endpoint]]&lt;br /&gt;
&lt;br /&gt;
[[ApplePay-StartPaymentWithAppleToken|StartPaymentWithAppleToken API endpoint]]&lt;/div&gt;</summary>
		<author><name>Salamongy@barion.dev</name></author>
	</entry>
	<entry>
		<id>https://docs.barion.com/index.php?title=Apple_Pay&amp;diff=4939</id>
		<title>Apple Pay</title>
		<link rel="alternate" type="text/html" href="https://docs.barion.com/index.php?title=Apple_Pay&amp;diff=4939"/>
		<updated>2026-09-03T06:29:20Z</updated>

		<summary type="html">&lt;p&gt;Salamongy@barion.dev: New Apple Pay SDK  script update&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{PageTitle|title=Apple Pay integration}}&lt;br /&gt;
{{TableOfContents}}&lt;br /&gt;
&lt;br /&gt;
Apple Pay is a wallet solution created by Apple for Apple customers. It is only accessible in the Apple ecosystem. You can use it with your iPhone, iWatch or with your desktop/laptop Macintosh computer. When it comes to Barion there are two different ways to use this payment option:&lt;br /&gt;
&lt;br /&gt;
* on the Barion Smart Gateway (called hosted mode)&lt;br /&gt;
* in their webshop if they integrate the so-called integrated mode&lt;br /&gt;
&lt;br /&gt;
The customer who wants to pay with Apple Pay Wallet must have an Apple device that supports authentication. This could be&lt;br /&gt;
&lt;br /&gt;
* an iPhone,&lt;br /&gt;
* a modern MacBook with fingerprint authentication or&lt;br /&gt;
* an older MacBook with a paired iPhone&lt;br /&gt;
&lt;br /&gt;
=== Browser support ===&lt;br /&gt;
Apple Pay behaves differently depending on the customer&#039;s browser:&amp;lt;blockquote&amp;gt;&lt;br /&gt;
* In Safari, and in any browser built on Apple&#039;s WebKit engine (Chrome, Firefox, or Edge on iOS), the button works natively, and the customer confirms the payment with Touch ID or Face ID.&lt;br /&gt;
* In other desktop browsers that can&#039;t run Apple Pay directly (for example Chrome, Firefox, or Edge on Windows), Apple&#039;s SDK automatically shows a QR code that the customer scans with their iPhone&#039;s Camera app (requires &#039;&#039;&#039;iOS 18 or later&#039;&#039;&#039;) to complete the payment there.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;Furthermore, the customer must fill out their home address and their contact information in their Apple Pay wallet as well. Without this, they won&#039;t be able to use their card in their Apple Wallet. This can be done even during the payment process.&lt;br /&gt;
&lt;br /&gt;
This feature is listed as an available payment method on the shop&#039;s admin site&lt;br /&gt;
&lt;br /&gt;
In case it is switched off the shop won&#039;t be able to display it as a funding source. This won&#039;t produce any error message, the Apple Pay option just won&#039;t be visible.&lt;br /&gt;
&lt;br /&gt;
=== Hosted mode ===&lt;br /&gt;
This is the &amp;quot;out of the box&amp;quot; mode that is available on the Barion Smart Gateway. It works in every browser described in the &#039;&#039;&#039;Browser support&#039;&#039;&#039; section above — natively in &#039;&#039;&#039;Safari&#039;&#039;&#039; and other WebKit-based browsers, and via the QR code hand-off in other desktop browsers.&lt;br /&gt;
&lt;br /&gt;
If the customer selects the Apple Pay accordion, the Apple Pay button will be visible.&lt;br /&gt;
&lt;br /&gt;
Once the customer clicks the Pay button the Apple Pay screen is displayed. This screen is actually controlled by the device, we don&#039;t have any control over it.&lt;br /&gt;
&lt;br /&gt;
On this screen, the customer may change the used credit card, the home address, or the e-mail address. These are all required to pay via Apple Pay. Once the customer approves the transaction everything continues as with a normal card would.&lt;br /&gt;
&lt;br /&gt;
=== Integrated mode ===&lt;br /&gt;
In integrated mode (called processor mode in Apple documentation) the webshop owner puts the Apple Pay button in their webshop and does not need to redirect the customer to the Barion Smart Gateway. This feature requires custom development from the webshop owner. The shop has to implement the Apple Pay button (instead of just relying on our gateway). To do this, they have to read through [[Apple Pay|this documentation]].&lt;br /&gt;
&lt;br /&gt;
The Apple Pay button can be displayed anywhere on the webshop. For example, on our demomerchant site is next to the Google Pay button.&lt;br /&gt;
&lt;br /&gt;
This integration requires a developer and is beneficial for shops that want to provide their customer a faster payment experience (since there is no need to redirect them to our gateway).&lt;br /&gt;
&lt;br /&gt;
To enable the button on the merchant&#039;s website the website has to be registered at Apple services. To help with this task we created a setting screen in our system. This setting page is available from the shop&#039;s setting page. (The one accessible by the owner)&lt;br /&gt;
&lt;br /&gt;
On this page, the owner has to input all the domains that the shop is using for the Apple Pay button. In addition to this the owner also has to upload a domain verification file to its domain.&lt;br /&gt;
&lt;br /&gt;
=== After payment ===&lt;br /&gt;
After the successful payment, the customer receives the usual confirmation letter, however, the bank card is clearly flagged, so the customer is aware that the payment was funded with a card from their Apple Wallet.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Warning:&#039;&#039;&#039; The card number displayed here is not the real card number. Apple creates a fake card number to protect the real card, so we are only aware of the fake number.&lt;br /&gt;
&lt;br /&gt;
= Technical implementation =&lt;br /&gt;
&lt;br /&gt;
== Merchants ==&lt;br /&gt;
The production and non-production environments use different merchants to keep the processing private key secret. Barion has two registered merchants at Apple Pay:&lt;br /&gt;
&lt;br /&gt;
* merchant.com.barion.applepay (used in the production environment)&lt;br /&gt;
* merchant.com.barion.test.applepay (used in non-production environments)&lt;br /&gt;
&lt;br /&gt;
This means the certificate installations, domain validations, and registrations must be completed separately in every environment. All necessary files and certificates are in a separate folder here: &#039;&#039;R:\Development\Sensitive\ApplePay\Merchants&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Certificates for production environment are handled by the Operator team.&lt;br /&gt;
&lt;br /&gt;
== Certificates ==&lt;br /&gt;
Apple Pay certificates for the Dev|Demo environments are here: &#039;&#039;R:\Development\Sensitive\ApplePay\Merchants&#039;&#039;. They were created by the operators, use the following page to create the Apple Pay merchant ID and certificates, and verify the domains: Configuring the environment&lt;br /&gt;
&lt;br /&gt;
There are two certificate files with different purposes. The &#039;&#039;merchant&#039;&#039; certificate is to validate and create Apple Pay sessions and the &#039;&#039;processor&#039;&#039; certificate is to decrypt the payload. Each of the certificates has to contain a private key. The preferred format is P12.&lt;br /&gt;
&lt;br /&gt;
The merchant certificate has to be installed on the Windows certificate store, the application will use it from the Personal container.&lt;br /&gt;
&lt;br /&gt;
From the processing certificate we need the private key only, to retrieve it use the following OpenSSL (3.2.1+ version required) command:&lt;br /&gt;
&lt;br /&gt;
After the PEM file is created, the content of the file should be saved into a text file. This text file is used in the configuration file(ApplePay.ProcessingPrivateKeyPath):&lt;br /&gt;
&lt;br /&gt;
== Changing of the certificates ==&lt;br /&gt;
Certificates can be obtained from Apple. Apple can only handle one certificate at a time, when the new certificate is enabled, the old one is automatically revoked. Since this process takes about 15-45 minutes to complete, it is advised to do it in a low-traffic period.&lt;br /&gt;
&lt;br /&gt;
Steps:&lt;br /&gt;
&lt;br /&gt;
# Obtain the new certificates from the Apple Developer Portal&lt;br /&gt;
# Generate the private key for the certificate as described in the previous point&lt;br /&gt;
# Update the appropriate config files (Secure, Api, Admin, Tools.QuedTaskInstaller as of 2023.04.21.) with the new certificate thumbprint and private key&lt;br /&gt;
# Enable the new certificates on the Apple Developer Portal&lt;br /&gt;
# Deploy the new configs to our servers (since the old certificates are revoked, and the new onew take about 15-45 minutes for the certificates to go live on Apple&#039;s side, there will be a downtime of about 15-45 minutes, during this time, ApplePay payments will fail)&lt;br /&gt;
# Done :)&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
Apple Pay on the web can be tested with Apple devices. The minimum OS versions are:&lt;br /&gt;
&lt;br /&gt;
* macOS 10.14.4&lt;br /&gt;
* iOS 12.2&lt;br /&gt;
&lt;br /&gt;
There are some example message here: &#039;&#039;R:\Development\Sensitive\ApplePay\Sample messages&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
These messages can be posted via Postman using the following API endpoint:&lt;br /&gt;
&lt;br /&gt;
Use the WalletMessage object in the CardInformation object to post the Apple Pay payload.&lt;br /&gt;
&lt;br /&gt;
To test the new cross-browser QR code hand-off (for customers on desktop non-Safari browsers), you need an iPhone running &#039;&#039;&#039;iOS 18 or later&#039;&#039;&#039; — this is a separate, newer requirement from the general &amp;quot;iOS 12.2&amp;quot; minimum above, which only covers using Apple Pay natively in &#039;&#039;&#039;Safari&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
MacOS is not enough to use Apple Pay. To use Apple Pay on MacOS you should configure Handoff function on the devices, follow this to set up the devices properly. This Handoff requirement applies to &#039;&#039;&#039;Safari&#039;&#039;&#039; on macOS. Non-Safari desktop browsers (including Chrome or Firefox on macOS) don&#039;t need Handoff configured at all — they use the QR code hand-off flow described above instead.&lt;br /&gt;
&lt;br /&gt;
You can test which certificate is used to encrypt the payment data with this command:&lt;br /&gt;
&lt;br /&gt;
The 2023_proc_Certificates.p12 should be the new certificate!&lt;br /&gt;
&lt;br /&gt;
The output of the above script should be the same as that of PaymentData.Header.PublicKeyHash&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting domain association errors ==&lt;br /&gt;
Some common pitfalls with domain association files can be found below.&lt;br /&gt;
&lt;br /&gt;
* domain association file cannot be reached without authentication&lt;br /&gt;
* response doesn’t contain “Content-Type” header with value “application/json”&lt;br /&gt;
* merchant’s server only supports TLS 1.3 (Barion uses 1.2 for checking this file)&lt;br /&gt;
* merchant has some form of bot/scraping protection enabled, which filters out requests that has a non-browser shaped or missing User-Agent header&lt;br /&gt;
&lt;br /&gt;
If a merchant reaches out about a domain association file problem, you can check these issues via:&lt;br /&gt;
&lt;br /&gt;
* first opening the domain association file on their site from a browser and checking the response&lt;br /&gt;
* and if that didn’t bring any results, running the script “Test-ApplePayDomainAssociation.ps1” found in the DeveloperScripts repo&lt;br /&gt;
** run this script in Powershell 5.1&lt;br /&gt;
** you can run the script locally, but for more reliable results, use one of the prod-web machines via the help of operators (so the network environment and TLS capabilities match production)&lt;br /&gt;
&lt;br /&gt;
== Contact ==&lt;br /&gt;
George Maroufidis &amp;lt;gmaroufidis@apple.com&amp;gt;&lt;br /&gt;
&lt;br /&gt;
George Maroufidis |  Pay eCommerce EMEIA | OneBattersea Power Station, London, SW11 8BZ, United Kingdom | iPhone: +44 7591 916 527&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
* Apple Pay Marketing Guidelines&lt;br /&gt;
* Human Interface Guidelines&lt;br /&gt;
&lt;br /&gt;
== Reference ==&lt;br /&gt;
&lt;br /&gt;
* Configuring the environment&lt;br /&gt;
* Apple Pay on the web&lt;br /&gt;
* PaymentToken&lt;br /&gt;
* Sandbox&lt;br /&gt;
&amp;lt;blockquote&amp;gt;This article is about directly integrating the Apple Pay button in your webshop.&lt;br /&gt;
&lt;br /&gt;
If you simply want to display Apple Pay as a payment option in the Barion Smart Gateway, no further configuration is necessary; pass &amp;quot;ApplePay&amp;quot; in [[FundingSources|the FundingSources array]] when preparing a payment.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
The appeal of Apple Pay is that it requires only two actions from the customer: selecting the ‘Pay with Apple Pay’ button, and confirming the payment with Touch ID or Face ID.&lt;br /&gt;
&lt;br /&gt;
Another advantage to your Barion shop’s payment workflow is that customers aren’t navigated away from your checkout page when using Apple Pay.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;prerequisites&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=IMPORTANT|text=You do not need to register an Apple Developer Account! Should you need an Apple Merchant Id, use the PublicId (guid) of your shop!|color=#FF7A3D}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;access to and being able to modify both your webshop’s front-end and back-end code&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;your webshop using HTTPS (having a TLS 1.2 or higher certificate installed) for all its pages that include the Apple Pay button&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Barion Wallet with an approved Barion shop&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;the Barion shop complies with [https://developer.apple.com/apple-pay/acceptable-use-guidelines-for-websites/ Apple’s acceptable use guidelines], including not selling prohibited products or services&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;Note that Apple’s policies regarding acceptable products and services are more limiting than those of Barion.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;It may happen that even though Barion approves your Barion shop to sell a certain item, you will not be allowed to display the Apple Pay button as a payment option for customers to pay for that item.&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;an account in the Barion Wallet for each of the currencies that you’d like to accept using Apple Pay&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Limitations ==&lt;br /&gt;
&lt;br /&gt;
* you can’t yet tokenize your customer’s card details when using the Apple Pay button, so [[Token payment 3D Secure|recurring payments]] aren’t available&lt;br /&gt;
* Barion currently only supports Apple Pay button on the web, and not on native iOS apps&lt;br /&gt;
* regardless of the integration detailed here, the Apple Pay button will only be displayed to your customers if they comply with Apple’s requirements:&lt;br /&gt;
** they’re using [https://support.apple.com/en-us/102896 an Apple Pay-compatible device]&lt;br /&gt;
** they’re viewing your webshop using a browser that supports Apple Pay&lt;br /&gt;
** they’re located [https://support.apple.com/en-us/102775 in a country or region where Apple Pay is available]&lt;br /&gt;
== Steps ==&lt;br /&gt;
=== Setting up your Apple prerequisites ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;When using Barion’s Apple Pay API endpoints, Barion gives you [https://developer.apple.com/support/app-account/ an Apple developer account], and registers [https://developer.apple.com/documentation/applepaywebmerchantregistrationapi/registering_with_apple_pay_and_applying_to_use_the_api a Merchant ID], [https://help.apple.com/developer-account/#/devb2e62b839?sub=devf31990e3f Payment Processing Certificate], and [https://help.apple.com/developer-account/#/dev1731126fb Merchant Identity Certificate] for you as a subsidiary of Barion’s Apple Pay credentials.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
Verify and register your webshop’s domain name or names:&lt;br /&gt;
&lt;br /&gt;
# Log in to your Barion Wallet, and go to your Barion shop’s Shops&amp;amp;gt;Actions&amp;amp;gt;Settings screen.&lt;br /&gt;
# Click the “Manage Apple Pay settings”, and then “Download domain verification file” to save the verification file for your shop’s domain.&lt;br /&gt;
# Save the domain verification file that you downloaded in the &amp;lt;code&amp;gt;/.well-known&amp;lt;/code&amp;gt; directory of all the sites that your specified domains use, making sure of the following:&lt;br /&gt;
#* the file should send the &amp;lt;code&amp;gt;&amp;lt;mimeMap fileExtension=&amp;quot;.&amp;quot; mimeType=&amp;quot;application/json&amp;quot; /&amp;gt;&amp;lt;/code&amp;gt; MIME data;&lt;br /&gt;
#* the file must be accessible externally, and not be password-protected, or behind a proxy or redirect;&lt;br /&gt;
#* the sites must be served over HTTPS.&lt;br /&gt;
# Enter all the domains that you’d like to use Apple Pay on (into whose root you’ve downloaded the domain verification file) in the text box provided, then click “Save”.&lt;br /&gt;
&lt;br /&gt;
=== Configuring and displaying the Apple Pay button ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol style=&amp;quot;list-style-type: decimal;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Load the button script into your checkout page by adding the following script tag inside the page head:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;html&amp;quot;&amp;gt;&amp;lt;script crossorigin src=&amp;quot;https://applepay.cdn-apple.com/jsapi/1.latest/apple-pay-sdk.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;This script makes an ApplePaySession available to your site front-end, among other things.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;ol start=&amp;quot;2&amp;quot; style=&amp;quot;list-style-type: decimal;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Add the &amp;lt;code&amp;gt;apple-pay-button&amp;lt;/code&amp;gt; element (for example, &amp;lt;code&amp;gt;&amp;amp;lt;div id=&amp;quot;apple-pay-button&amp;quot;&amp;amp;gt;&amp;amp;lt;/div&amp;amp;gt;&amp;lt;/code&amp;gt;) to your checkout page, [https://developer.apple.com/documentation/apple_pay_on_the_web/displaying_apple_pay_buttons_using_css and use the CSS included in the button script to display it].&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Start a new ApplePaySession when the checkout page loads:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;  const request = {&lt;br /&gt;
    countryCode: &#039;US&#039;,&lt;br /&gt;
    currencyCode: &#039;USD&#039;,&lt;br /&gt;
    supportedNetworks: [&#039;visa&#039;, &#039;masterCard&#039;, &#039;discover&#039;],&lt;br /&gt;
    merchantCapabilities: [&#039;supports3DS&#039;],&lt;br /&gt;
    total: { label: &#039;Your Merchant Name&#039;, amount: &#039;10.00&#039; }&lt;br /&gt;
  }&lt;br /&gt;
  const applePlaySession = new ApplePaySession(3, request);&lt;br /&gt;
&lt;br /&gt;
  // add an isSessionCanceled boolean to easily be able to cancel the session if your user abandons the in-progress payment process&lt;br /&gt;
  var isSessionCanceled = false;&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&amp;lt;blockquote&amp;gt;The merchant may supply the shipping and billing contact information directly, or request it when starting the ApplePaySession by including the [https://developer.apple.com/documentation/applepayontheweb/applepaypaymentrequest/requiredshippingcontactfields requiredShippingContactFields]  and [https://developer.apple.com/documentation/applepayontheweb/applepaypaymentrequest/requiredbillingcontactfields requiredBillingContactFields] properties in the payment request. More about the Apple Pay payment request [https://developer.apple.com/documentation/applepayontheweb/applepaypaymentrequest here].&amp;lt;/blockquote&amp;gt;&amp;lt;ol start=&amp;quot;2&amp;quot; style=&amp;quot;list-style-type: decimal;&amp;quot;&amp;gt;&amp;lt;li&amp;gt;&lt;br /&gt;
    &amp;lt;p&amp;gt;Make sure to only display the Apple Pay button to users who can use it, by have your webshop’s checkout pages do&lt;br /&gt;
      the following when they load:&amp;lt;/p&amp;gt;&lt;br /&gt;
    &amp;lt;p&amp;gt;Call the [https://developer.apple.com/documentation/applepayontheweb/applepaysession/canmakepaymentswithactivecard applePaySession.canMakePaymentsWithActiveCard] or [https://developer.apple.com/documentation/applepayontheweb/applepaysession/applepaycapabilities applePaySession.applePayCapabilities] method, passing it your Barion shop’s public Id as the merchantId parameter.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;p&amp;gt;If Apple can verify your Barion shop as a registered Apple Pay provider, the method checks the following:&amp;lt;/p&amp;gt;&lt;br /&gt;
    &amp;lt;ul&amp;gt;&lt;br /&gt;
      &amp;lt;li&amp;gt;that your customer&#039;s device is capable of using Apple Pay&amp;lt;/li&amp;gt;&lt;br /&gt;
      &amp;lt;li&amp;gt;that Apple Pay is enabled on your customer&#039;s device, and&amp;lt;/li&amp;gt;&lt;br /&gt;
      &amp;lt;li&amp;gt;that the customer has the details of at least one active and web payment-eligible bank card stored in their Apple&lt;br /&gt;
        Pay wallet.&amp;lt;/li&amp;gt;&lt;br /&gt;
    &amp;lt;/ul&amp;gt;&lt;br /&gt;
  &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;Handle [https://developer.apple.com/documentation/apple_pay_on_the_web/paymentcredentialstatus the &amp;lt;code&amp;gt;PaymentCredentialStatus&amp;lt;/code&amp;gt; object] that the method returns to make a decision about displaying the&lt;br /&gt;
        Apple Pay button.&lt;br /&gt;
  &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Handling payments ===&lt;br /&gt;
&lt;br /&gt;
Set up your webshop to perform these steps each time a user selects the Apple Pay button.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol style=&amp;quot;list-style-type: decimal;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Set up an event handler for [https://developer.apple.com/documentation/apple_pay_on_the_web/applepaysession/1778021-onvalidatemerchant &amp;lt;code&amp;gt;ApplePaySession.onvalidatemerchant&amp;lt;/code&amp;gt;] that notifies your site&#039;s back-end, and passes it the event response.&amp;lt;/p&amp;gt;&amp;lt;blockquote&amp;gt;Don&#039;t call the ValidateSession Barion API endpoint directly from the browser, as this could expose your Barion shop&#039;s POSKey.&amp;lt;/blockquote&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Have your site&#039;s back-end call [[ApplePay-ValidateSession|the ValidateSession Barion API endpoint]], passing it the &amp;lt;code&amp;gt;onvalidatemerchant&amp;lt;/code&amp;gt; event’s &amp;lt;code&amp;gt;ValidationUrl&amp;lt;/code&amp;gt; attribute.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;async function validateApplePaySession(POSKey, SessionRequestUrl, ShopUrl) {&lt;br /&gt;
  const url = &amp;quot;https://api.test.barion.com/v2/ApplePay/ValidateSession&amp;quot;;&lt;br /&gt;
  const data = {&lt;br /&gt;
    POSKey,&lt;br /&gt;
    SessionRequestUrl,&lt;br /&gt;
    ShopUrl,&lt;br /&gt;
  };&lt;br /&gt;
&lt;br /&gt;
  try {&lt;br /&gt;
    const response = await fetch(url, {&lt;br /&gt;
      method: &amp;quot;POST&amp;quot;,&lt;br /&gt;
      headers: {&lt;br /&gt;
        &amp;quot;Content-Type&amp;quot;: &amp;quot;application/json&amp;quot;,&lt;br /&gt;
      },&lt;br /&gt;
      body: JSON.stringify(data),&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
    if (!response.ok) {&lt;br /&gt;
      throw new Error(`Error: ${response.status} ${response.statusText}`);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    const result = await response.json();&lt;br /&gt;
    return result;&lt;br /&gt;
  } catch (error) {&lt;br /&gt;
    // handle the error according to your business logic&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
applePaySession.onvalidatemerchant = async function (event) {&lt;br /&gt;
  const validationResult = await validateApplePaySession(POSKey, event.validationURL, ShopUrl);&lt;br /&gt;
  &lt;br /&gt;
  applePaySession.completeMerchantValidation(validationResult.ApplePaySessionResponse);&lt;br /&gt;
};&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;This event is triggered when the Apple Pay payment sheet is displayed to the customer.&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Set up an event handler for [https://developer.apple.com/documentation/apple_pay_on_the_web/applepaysession/1778020-onpaymentauthorized &amp;lt;code&amp;gt;ApplePaySession.onpaymentauthorized&amp;lt;/code&amp;gt;]&amp;lt;/p&amp;gt;&amp;lt;blockquote&amp;gt;Don&#039;t call the StartPaymentWithAppleToken Barion API endpoint directly from the browser, as this could expose your Barion shop&#039;s POSKey.&amp;lt;/blockquote&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;that calls the [[ApplePay-StartPaymentWithAppleToken|StartPaymentWithAppleToken Barion API endpoint]], passing it the event’s following attributes:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;token&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;shippingContact&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;billingContact&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note that &amp;lt;code&amp;gt;StartPaymentWithAppleToken&amp;lt;/code&amp;gt; is actually a specialized version of [[Payment-Start-v2|the payment/start API endpoint]], and so will also require all the usual parameters that you’d pass to that endpoint.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
async function startApplePayPayment(&lt;br /&gt;
  POSKey,&lt;br /&gt;
  ShippingContact,&lt;br /&gt;
  BillingContact,&lt;br /&gt;
  Token,&lt;br /&gt;
  /** include other required and optional Payment/Start params */&lt;br /&gt;
  PaymentStartProperties&lt;br /&gt;
) {&lt;br /&gt;
  const url =&lt;br /&gt;
    &amp;quot;https://api.test.barion.com/v2/ApplePay/StartPaymentWithAppleToken&amp;quot;;&lt;br /&gt;
  const data = {&lt;br /&gt;
    POSKey,&lt;br /&gt;
    ShippingContact,&lt;br /&gt;
    BillingContact,&lt;br /&gt;
    Token,&lt;br /&gt;
    ...PaymentStartProperties,&lt;br /&gt;
  };&lt;br /&gt;
&lt;br /&gt;
  try {&lt;br /&gt;
    const response = await fetch(url, {&lt;br /&gt;
      method: &amp;quot;POST&amp;quot;,&lt;br /&gt;
      headers: {&lt;br /&gt;
        &amp;quot;Content-Type&amp;quot;: &amp;quot;application/json&amp;quot;,&lt;br /&gt;
      },&lt;br /&gt;
      body: JSON.stringify(data),&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
    if (!response.ok) {&lt;br /&gt;
      throw new Error(`Error: ${response.status} ${response.statusText}`);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    const result = await response.json();&lt;br /&gt;
    return result;&lt;br /&gt;
  } catch (error) {&lt;br /&gt;
    // handle the error according to your business logic&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
const PaymentStartProperties = {&lt;br /&gt;
  PaymentType: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
applePaySession.onpaymentauthorized = function (event) {&lt;br /&gt;
  startApplePayPayment(&lt;br /&gt;
    POSKey,&lt;br /&gt;
    event.paymentInfo.shippingContent,&lt;br /&gt;
    event.paymentInfo.billingContact,&lt;br /&gt;
    event.paymentInfo.Token,&lt;br /&gt;
    PaymentStartProperties&lt;br /&gt;
  );&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;This event is triggered when the customer has authorized the Apple Pay payment using their Touch ID or Face ID.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Set up an event handler for &amp;lt;code&amp;gt;oncancel&amp;lt;/code&amp;gt; to implement your business logic for when the user abandons the Apple Pay payment.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Make sure that your event handler indicates that the session is canceled so the ApplePaySession’s &amp;lt;code&amp;gt;completePayment&amp;lt;/code&amp;gt; method doesn’t get executed.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;  applePaySession.oncancel = function (event) {&lt;br /&gt;
    // your oncancel business logic&lt;br /&gt;
&lt;br /&gt;
    isSessionCanceled = true;&lt;br /&gt;
  };&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Call [https://developer.apple.com/documentation/apple_pay_on_the_web/applepaysession/1778001-begin ApplePaySession.begin] to kick off the payment process.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;  applePaySession.begin();&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;This starts the merchant validation process that results in &amp;lt;code&amp;gt;ApplePaySession.onvalidatemerchant&amp;lt;/code&amp;gt; being triggered.&amp;lt;/blockquote&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Testing your implementation ===&lt;br /&gt;
&lt;br /&gt;
The following steps are needed in order to test your implementation:&lt;br /&gt;
# request access by sending an email to devsupport@barion.com!&lt;br /&gt;
# include an email address, that has no Apple Id yet&lt;br /&gt;
# we will register &amp;amp; connect it to our test account&lt;br /&gt;
# after that, you will be able to [https://developer.apple.com/apple-pay/sandbox-testing/ use Apple&#039;s test cards]&lt;br /&gt;
&lt;br /&gt;
== Related links ==&lt;br /&gt;
&lt;br /&gt;
[[ApplePay-ValidateSession|ValidateSession API endpoint]]&lt;br /&gt;
&lt;br /&gt;
[[ApplePay-StartPaymentWithAppleToken|StartPaymentWithAppleToken API endpoint]]&lt;/div&gt;</summary>
		<author><name>Salamongy@barion.dev</name></author>
	</entry>
	<entry>
		<id>https://docs.barion.com/index.php?title=Apple_Pay&amp;diff=4938</id>
		<title>Apple Pay</title>
		<link rel="alternate" type="text/html" href="https://docs.barion.com/index.php?title=Apple_Pay&amp;diff=4938"/>
		<updated>2026-09-03T06:11:26Z</updated>

		<summary type="html">&lt;p&gt;Salamongy@barion.dev: new Apple Pay SDK&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{PageTitle|title=Apple Pay integration}}&lt;br /&gt;
{{TableOfContents}}&lt;br /&gt;
&lt;br /&gt;
Apple Pay is a wallet solution created by Apple for Apple customers. It is only accessible in the Apple ecosystem. You can use it with your iPhone, iWatch or with your desktop/laptop Macintosh computer. When it comes to Barion there are two different ways to use this payment option:&lt;br /&gt;
&lt;br /&gt;
* on the Barion Smart Gateway (called hosted mode)&lt;br /&gt;
* in their webshop if they integrate the so-called integrated mode&lt;br /&gt;
&lt;br /&gt;
The customer who wants to pay with Apple Pay Wallet must have an Apple device that supports authentication. This could be&lt;br /&gt;
&lt;br /&gt;
* an iPhone,&lt;br /&gt;
* a modern MacBook with fingerprint authentication or&lt;br /&gt;
* an older MacBook with a paired iPhone&lt;br /&gt;
&lt;br /&gt;
=== Browser support ===&lt;br /&gt;
Apple Pay behaves differently depending on the customer&#039;s browser:&amp;lt;blockquote&amp;gt;&lt;br /&gt;
* In Safari, and in any browser built on Apple&#039;s WebKit engine (Chrome, Firefox, or Edge on iOS), the button works natively, and the customer confirms the payment with Touch ID or Face ID.&lt;br /&gt;
* In other desktop browsers that can&#039;t run Apple Pay directly (for example Chrome, Firefox, or Edge on Windows), Apple&#039;s SDK automatically shows a QR code that the customer scans with their iPhone&#039;s Camera app (requires &#039;&#039;&#039;iOS 18 or later&#039;&#039;&#039;) to complete the payment there.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;Furthermore, the customer must fill out their home address and their contact information in their Apple Pay wallet as well. Without this, they won&#039;t be able to use their card in their Apple Wallet. This can be done even during the payment process.&lt;br /&gt;
&lt;br /&gt;
This feature is listed as an available payment method on the shop&#039;s admin site&lt;br /&gt;
&lt;br /&gt;
In case it is switched off the shop won&#039;t be able to display it as a funding source. This won&#039;t produce any error message, the Apple Pay option just won&#039;t be visible.&lt;br /&gt;
&lt;br /&gt;
=== Hosted mode ===&lt;br /&gt;
This is the &amp;quot;out of the box&amp;quot; mode that is available on the Barion Smart Gateway. It works in every browser described in the &#039;&#039;&#039;Browser support&#039;&#039;&#039; section above — natively in &#039;&#039;&#039;Safari&#039;&#039;&#039; and other WebKit-based browsers, and via the QR code hand-off in other desktop browsers.&lt;br /&gt;
&lt;br /&gt;
If the customer selects the Apple Pay accordion, the Apple Pay button will be visible.&lt;br /&gt;
&lt;br /&gt;
Once the customer clicks the Pay button the Apple Pay screen is displayed. This screen is actually controlled by the device, we don&#039;t have any control over it.&lt;br /&gt;
&lt;br /&gt;
On this screen, the customer may change the used credit card, the home address, or the e-mail address. These are all required to pay via Apple Pay. Once the customer approves the transaction everything continues as with a normal card would.&lt;br /&gt;
&lt;br /&gt;
=== Integrated mode ===&lt;br /&gt;
In integrated mode (called processor mode in Apple documentation) the webshop owner puts the Apple Pay button in their webshop and does not need to redirect the customer to the Barion Smart Gateway. This feature requires custom development from the webshop owner. The shop has to implement the Apple Pay button (instead of just relying on our gateway). To do this, they have to read through [[Apple Pay|this documentation]].&lt;br /&gt;
&lt;br /&gt;
The Apple Pay button can be displayed anywhere on the webshop. For example, on our demomerchant site is next to the Google Pay button.&lt;br /&gt;
&lt;br /&gt;
This integration requires a developer and is beneficial for shops that want to provide their customer a faster payment experience (since there is no need to redirect them to our gateway).&lt;br /&gt;
&lt;br /&gt;
To enable the button on the merchant&#039;s website the website has to be registered at Apple services. To help with this task we created a setting screen in our system. This setting page is available from the shop&#039;s setting page. (The one accessible by the owner)&lt;br /&gt;
&lt;br /&gt;
On this page, the owner has to input all the domains that the shop is using for the Apple Pay button. In addition to this the owner also has to upload a domain verification file to its domain.&lt;br /&gt;
&lt;br /&gt;
=== After payment ===&lt;br /&gt;
After the successful payment, the customer receives the usual confirmation letter, however, the bank card is clearly flagged, so the customer is aware that the payment was funded with a card from their Apple Wallet.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Warning:&#039;&#039;&#039; The card number displayed here is not the real card number. Apple creates a fake card number to protect the real card, so we are only aware of the fake number.&lt;br /&gt;
&lt;br /&gt;
= Technical implementation =&lt;br /&gt;
&lt;br /&gt;
== Merchants ==&lt;br /&gt;
The production and non-production environments use different merchants to keep the processing private key secret. Barion has two registered merchants at Apple Pay:&lt;br /&gt;
&lt;br /&gt;
* merchant.com.barion.applepay (used in the production environment)&lt;br /&gt;
* merchant.com.barion.test.applepay (used in non-production environments)&lt;br /&gt;
&lt;br /&gt;
This means the certificate installations, domain validations, and registrations must be completed separately in every environment. All necessary files and certificates are in a separate folder here: &#039;&#039;R:\Development\Sensitive\ApplePay\Merchants&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Certificates for production environment are handled by the Operator team.&lt;br /&gt;
&lt;br /&gt;
== Certificates ==&lt;br /&gt;
Apple Pay certificates for the Dev|Demo environments are here: &#039;&#039;R:\Development\Sensitive\ApplePay\Merchants&#039;&#039;. They were created by the operators, use the following page to create the Apple Pay merchant ID and certificates, and verify the domains: Configuring the environment&lt;br /&gt;
&lt;br /&gt;
There are two certificate files with different purposes. The &#039;&#039;merchant&#039;&#039; certificate is to validate and create Apple Pay sessions and the &#039;&#039;processor&#039;&#039; certificate is to decrypt the payload. Each of the certificates has to contain a private key. The preferred format is P12.&lt;br /&gt;
&lt;br /&gt;
The merchant certificate has to be installed on the Windows certificate store, the application will use it from the Personal container.&lt;br /&gt;
&lt;br /&gt;
From the processing certificate we need the private key only, to retrieve it use the following OpenSSL (3.2.1+ version required) command:&lt;br /&gt;
&lt;br /&gt;
After the PEM file is created, the content of the file should be saved into a text file. This text file is used in the configuration file(ApplePay.ProcessingPrivateKeyPath):&lt;br /&gt;
&lt;br /&gt;
== Changing of the certificates ==&lt;br /&gt;
Certificates can be obtained from Apple. Apple can only handle one certificate at a time, when the new certificate is enabled, the old one is automatically revoked. Since this process takes about 15-45 minutes to complete, it is advised to do it in a low-traffic period.&lt;br /&gt;
&lt;br /&gt;
Steps:&lt;br /&gt;
&lt;br /&gt;
# Obtain the new certificates from the Apple Developer Portal&lt;br /&gt;
# Generate the private key for the certificate as described in the previous point&lt;br /&gt;
# Update the appropriate config files (Secure, Api, Admin, Tools.QuedTaskInstaller as of 2023.04.21.) with the new certificate thumbprint and private key&lt;br /&gt;
# Enable the new certificates on the Apple Developer Portal&lt;br /&gt;
# Deploy the new configs to our servers (since the old certificates are revoked, and the new onew take about 15-45 minutes for the certificates to go live on Apple&#039;s side, there will be a downtime of about 15-45 minutes, during this time, ApplePay payments will fail)&lt;br /&gt;
# Done :)&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
Apple Pay on the web can be tested with Apple devices. The minimum OS versions are:&lt;br /&gt;
&lt;br /&gt;
* macOS 10.14.4&lt;br /&gt;
* iOS 12.2&lt;br /&gt;
&lt;br /&gt;
There are some example message here: &#039;&#039;R:\Development\Sensitive\ApplePay\Sample messages&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
These messages can be posted via Postman using the following API endpoint:&lt;br /&gt;
&lt;br /&gt;
Use the WalletMessage object in the CardInformation object to post the Apple Pay payload.&lt;br /&gt;
&lt;br /&gt;
To test the new cross-browser QR code hand-off (for customers on desktop non-Safari browsers), you need an iPhone running &#039;&#039;&#039;iOS 18 or later&#039;&#039;&#039; — this is a separate, newer requirement from the general &amp;quot;iOS 12.2&amp;quot; minimum above, which only covers using Apple Pay natively in &#039;&#039;&#039;Safari&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
MacOS is not enough to use Apple Pay. To use Apple Pay on MacOS you should configure Handoff function on the devices, follow this to set up the devices properly. This Handoff requirement applies to &#039;&#039;&#039;Safari&#039;&#039;&#039; on macOS. Non-Safari desktop browsers (including Chrome or Firefox on macOS) don&#039;t need Handoff configured at all — they use the QR code hand-off flow described above instead.&lt;br /&gt;
&lt;br /&gt;
You can test which certificate is used to encrypt the payment data with this command:&lt;br /&gt;
&lt;br /&gt;
The 2023_proc_Certificates.p12 should be the new certificate!&lt;br /&gt;
&lt;br /&gt;
The output of the above script should be the same as that of PaymentData.Header.PublicKeyHash&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting domain association errors ==&lt;br /&gt;
Some common pitfalls with domain association files can be found below.&lt;br /&gt;
&lt;br /&gt;
* domain association file cannot be reached without authentication&lt;br /&gt;
* response doesn’t contain “Content-Type” header with value “application/json”&lt;br /&gt;
* merchant’s server only supports TLS 1.3 (Barion uses 1.2 for checking this file)&lt;br /&gt;
* merchant has some form of bot/scraping protection enabled, which filters out requests that has a non-browser shaped or missing User-Agent header&lt;br /&gt;
&lt;br /&gt;
If a merchant reaches out about a domain association file problem, you can check these issues via:&lt;br /&gt;
&lt;br /&gt;
* first opening the domain association file on their site from a browser and checking the response&lt;br /&gt;
* and if that didn’t bring any results, running the script “Test-ApplePayDomainAssociation.ps1” found in the DeveloperScripts repo&lt;br /&gt;
** run this script in Powershell 5.1&lt;br /&gt;
** you can run the script locally, but for more reliable results, use one of the prod-web machines via the help of operators (so the network environment and TLS capabilities match production)&lt;br /&gt;
&lt;br /&gt;
== Contact ==&lt;br /&gt;
George Maroufidis &amp;lt;gmaroufidis@apple.com&amp;gt;&lt;br /&gt;
&lt;br /&gt;
George Maroufidis |  Pay eCommerce EMEIA | OneBattersea Power Station, London, SW11 8BZ, United Kingdom | iPhone: +44 7591 916 527&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
* Apple Pay Marketing Guidelines&lt;br /&gt;
* Human Interface Guidelines&lt;br /&gt;
&lt;br /&gt;
== Reference ==&lt;br /&gt;
&lt;br /&gt;
* Configuring the environment&lt;br /&gt;
* Apple Pay on the web&lt;br /&gt;
* PaymentToken&lt;br /&gt;
* Sandbox&lt;br /&gt;
&amp;lt;blockquote&amp;gt;This article is about directly integrating the Apple Pay button in your webshop.&lt;br /&gt;
&lt;br /&gt;
If you simply want to display Apple Pay as a payment option in the Barion Smart Gateway, no further configuration is necessary; pass &amp;quot;ApplePay&amp;quot; in [[FundingSources|the FundingSources array]] when preparing a payment.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
The appeal of Apple Pay is that it requires only two actions from the customer: selecting the ‘Pay with Apple Pay’ button, and confirming the payment with Touch ID or Face ID.&lt;br /&gt;
&lt;br /&gt;
Another advantage to your Barion shop’s payment workflow is that customers aren’t navigated away from your checkout page when using Apple Pay.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;prerequisites&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=IMPORTANT|text=You do not need to register an Apple Developer Account! Should you need an Apple Merchant Id, use the PublicId (guid) of your shop!|color=#FF7A3D}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;access to and being able to modify both your webshop’s front-end and back-end code&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;your webshop using HTTPS (having a TLS 1.2 or higher certificate installed) for all its pages that include the Apple Pay button&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Barion Wallet with an approved Barion shop&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;the Barion shop complies with [https://developer.apple.com/apple-pay/acceptable-use-guidelines-for-websites/ Apple’s acceptable use guidelines], including not selling prohibited products or services&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;Note that Apple’s policies regarding acceptable products and services are more limiting than those of Barion.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;It may happen that even though Barion approves your Barion shop to sell a certain item, you will not be allowed to display the Apple Pay button as a payment option for customers to pay for that item.&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;an account in the Barion Wallet for each of the currencies that you’d like to accept using Apple Pay&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Limitations ==&lt;br /&gt;
&lt;br /&gt;
* you can’t yet tokenize your customer’s card details when using the Apple Pay button, so [[Token payment 3D Secure|recurring payments]] aren’t available&lt;br /&gt;
* Barion currently only supports Apple Pay button on the web, and not on native iOS apps&lt;br /&gt;
* regardless of the integration detailed here, the Apple Pay button will only be displayed to your customers if they comply with Apple’s requirements:&lt;br /&gt;
** they’re using [https://support.apple.com/en-us/102896 an Apple Pay-compatible device]&lt;br /&gt;
** they’re viewing your webshop using a browser that supports Apple Pay&lt;br /&gt;
** they’re located [https://support.apple.com/en-us/102775 in a country or region where Apple Pay is available]&lt;br /&gt;
== Steps ==&lt;br /&gt;
=== Setting up your Apple prerequisites ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;When using Barion’s Apple Pay API endpoints, Barion gives you [https://developer.apple.com/support/app-account/ an Apple developer account], and registers [https://developer.apple.com/documentation/applepaywebmerchantregistrationapi/registering_with_apple_pay_and_applying_to_use_the_api a Merchant ID], [https://help.apple.com/developer-account/#/devb2e62b839?sub=devf31990e3f Payment Processing Certificate], and [https://help.apple.com/developer-account/#/dev1731126fb Merchant Identity Certificate] for you as a subsidiary of Barion’s Apple Pay credentials.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
Verify and register your webshop’s domain name or names:&lt;br /&gt;
&lt;br /&gt;
# Log in to your Barion Wallet, and go to your Barion shop’s Shops&amp;amp;gt;Actions&amp;amp;gt;Settings screen.&lt;br /&gt;
# Click the “Manage Apple Pay settings”, and then “Download domain verification file” to save the verification file for your shop’s domain.&lt;br /&gt;
# Save the domain verification file that you downloaded in the &amp;lt;code&amp;gt;/.well-known&amp;lt;/code&amp;gt; directory of all the sites that your specified domains use, making sure of the following:&lt;br /&gt;
#* the file should send the &amp;lt;code&amp;gt;&amp;lt;mimeMap fileExtension=&amp;quot;.&amp;quot; mimeType=&amp;quot;application/json&amp;quot; /&amp;gt;&amp;lt;/code&amp;gt; MIME data;&lt;br /&gt;
#* the file must be accessible externally, and not be password-protected, or behind a proxy or redirect;&lt;br /&gt;
#* the sites must be served over HTTPS.&lt;br /&gt;
# Enter all the domains that you’d like to use Apple Pay on (into whose root you’ve downloaded the domain verification file) in the text box provided, then click “Save”.&lt;br /&gt;
&lt;br /&gt;
=== Configuring and displaying the Apple Pay button ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol style=&amp;quot;list-style-type: decimal;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Load the button script into your checkout page by adding the following script tag inside the page head:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;html&amp;quot;&amp;gt;&amp;lt;script src=&amp;quot;https://applepay.cdn-apple.com/jsapi/v1.1.0/apple-pay-sdk.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;This script makes an ApplePaySession available to your site front-end, among other things.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;ol start=&amp;quot;2&amp;quot; style=&amp;quot;list-style-type: decimal;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Add the &amp;lt;code&amp;gt;apple-pay-button&amp;lt;/code&amp;gt; element (for example, &amp;lt;code&amp;gt;&amp;amp;lt;div id=&amp;quot;apple-pay-button&amp;quot;&amp;amp;gt;&amp;amp;lt;/div&amp;amp;gt;&amp;lt;/code&amp;gt;) to your checkout page, [https://developer.apple.com/documentation/apple_pay_on_the_web/displaying_apple_pay_buttons_using_css and use the CSS included in the button script to display it].&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Start a new ApplePaySession when the checkout page loads:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;  const request = {&lt;br /&gt;
    countryCode: &#039;US&#039;,&lt;br /&gt;
    currencyCode: &#039;USD&#039;,&lt;br /&gt;
    supportedNetworks: [&#039;visa&#039;, &#039;masterCard&#039;, &#039;discover&#039;],&lt;br /&gt;
    merchantCapabilities: [&#039;supports3DS&#039;],&lt;br /&gt;
    total: { label: &#039;Your Merchant Name&#039;, amount: &#039;10.00&#039; }&lt;br /&gt;
  }&lt;br /&gt;
  const applePlaySession = new ApplePaySession(3, request);&lt;br /&gt;
&lt;br /&gt;
  // add an isSessionCanceled boolean to easily be able to cancel the session if your user abandons the in-progress payment process&lt;br /&gt;
  var isSessionCanceled = false;&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&amp;lt;blockquote&amp;gt;The merchant may supply the shipping and billing contact information directly, or request it when starting the ApplePaySession by including the [https://developer.apple.com/documentation/applepayontheweb/applepaypaymentrequest/requiredshippingcontactfields requiredShippingContactFields]  and [https://developer.apple.com/documentation/applepayontheweb/applepaypaymentrequest/requiredbillingcontactfields requiredBillingContactFields] properties in the payment request. More about the Apple Pay payment request [https://developer.apple.com/documentation/applepayontheweb/applepaypaymentrequest here].&amp;lt;/blockquote&amp;gt;&amp;lt;ol start=&amp;quot;2&amp;quot; style=&amp;quot;list-style-type: decimal;&amp;quot;&amp;gt;&amp;lt;li&amp;gt;&lt;br /&gt;
    &amp;lt;p&amp;gt;Make sure to only display the Apple Pay button to users who can use it, by have your webshop’s checkout pages do&lt;br /&gt;
      the following when they load:&amp;lt;/p&amp;gt;&lt;br /&gt;
    &amp;lt;p&amp;gt;Call the [https://developer.apple.com/documentation/applepayontheweb/applepaysession/canmakepaymentswithactivecard applePaySession.canMakePaymentsWithActiveCard] or [https://developer.apple.com/documentation/applepayontheweb/applepaysession/applepaycapabilities applePaySession.applePayCapabilities] method, passing it your Barion shop’s public Id as the merchantId parameter.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;p&amp;gt;If Apple can verify your Barion shop as a registered Apple Pay provider, the method checks the following:&amp;lt;/p&amp;gt;&lt;br /&gt;
    &amp;lt;ul&amp;gt;&lt;br /&gt;
      &amp;lt;li&amp;gt;that your customer&#039;s device is capable of using Apple Pay&amp;lt;/li&amp;gt;&lt;br /&gt;
      &amp;lt;li&amp;gt;that Apple Pay is enabled on your customer&#039;s device, and&amp;lt;/li&amp;gt;&lt;br /&gt;
      &amp;lt;li&amp;gt;that the customer has the details of at least one active and web payment-eligible bank card stored in their Apple&lt;br /&gt;
        Pay wallet.&amp;lt;/li&amp;gt;&lt;br /&gt;
    &amp;lt;/ul&amp;gt;&lt;br /&gt;
  &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;Handle [https://developer.apple.com/documentation/apple_pay_on_the_web/paymentcredentialstatus the &amp;lt;code&amp;gt;PaymentCredentialStatus&amp;lt;/code&amp;gt; object] that the method returns to make a decision about displaying the&lt;br /&gt;
        Apple Pay button.&lt;br /&gt;
  &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Handling payments ===&lt;br /&gt;
&lt;br /&gt;
Set up your webshop to perform these steps each time a user selects the Apple Pay button.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol style=&amp;quot;list-style-type: decimal;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Set up an event handler for [https://developer.apple.com/documentation/apple_pay_on_the_web/applepaysession/1778021-onvalidatemerchant &amp;lt;code&amp;gt;ApplePaySession.onvalidatemerchant&amp;lt;/code&amp;gt;] that notifies your site&#039;s back-end, and passes it the event response.&amp;lt;/p&amp;gt;&amp;lt;blockquote&amp;gt;Don&#039;t call the ValidateSession Barion API endpoint directly from the browser, as this could expose your Barion shop&#039;s POSKey.&amp;lt;/blockquote&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Have your site&#039;s back-end call [[ApplePay-ValidateSession|the ValidateSession Barion API endpoint]], passing it the &amp;lt;code&amp;gt;onvalidatemerchant&amp;lt;/code&amp;gt; event’s &amp;lt;code&amp;gt;ValidationUrl&amp;lt;/code&amp;gt; attribute.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;async function validateApplePaySession(POSKey, SessionRequestUrl, ShopUrl) {&lt;br /&gt;
  const url = &amp;quot;https://api.test.barion.com/v2/ApplePay/ValidateSession&amp;quot;;&lt;br /&gt;
  const data = {&lt;br /&gt;
    POSKey,&lt;br /&gt;
    SessionRequestUrl,&lt;br /&gt;
    ShopUrl,&lt;br /&gt;
  };&lt;br /&gt;
&lt;br /&gt;
  try {&lt;br /&gt;
    const response = await fetch(url, {&lt;br /&gt;
      method: &amp;quot;POST&amp;quot;,&lt;br /&gt;
      headers: {&lt;br /&gt;
        &amp;quot;Content-Type&amp;quot;: &amp;quot;application/json&amp;quot;,&lt;br /&gt;
      },&lt;br /&gt;
      body: JSON.stringify(data),&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
    if (!response.ok) {&lt;br /&gt;
      throw new Error(`Error: ${response.status} ${response.statusText}`);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    const result = await response.json();&lt;br /&gt;
    return result;&lt;br /&gt;
  } catch (error) {&lt;br /&gt;
    // handle the error according to your business logic&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
applePaySession.onvalidatemerchant = async function (event) {&lt;br /&gt;
  const validationResult = await validateApplePaySession(POSKey, event.validationURL, ShopUrl);&lt;br /&gt;
  &lt;br /&gt;
  applePaySession.completeMerchantValidation(validationResult.ApplePaySessionResponse);&lt;br /&gt;
};&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;This event is triggered when the Apple Pay payment sheet is displayed to the customer.&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Set up an event handler for [https://developer.apple.com/documentation/apple_pay_on_the_web/applepaysession/1778020-onpaymentauthorized &amp;lt;code&amp;gt;ApplePaySession.onpaymentauthorized&amp;lt;/code&amp;gt;]&amp;lt;/p&amp;gt;&amp;lt;blockquote&amp;gt;Don&#039;t call the StartPaymentWithAppleToken Barion API endpoint directly from the browser, as this could expose your Barion shop&#039;s POSKey.&amp;lt;/blockquote&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;that calls the [[ApplePay-StartPaymentWithAppleToken|StartPaymentWithAppleToken Barion API endpoint]], passing it the event’s following attributes:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;token&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;shippingContact&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;billingContact&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note that &amp;lt;code&amp;gt;StartPaymentWithAppleToken&amp;lt;/code&amp;gt; is actually a specialized version of [[Payment-Start-v2|the payment/start API endpoint]], and so will also require all the usual parameters that you’d pass to that endpoint.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
async function startApplePayPayment(&lt;br /&gt;
  POSKey,&lt;br /&gt;
  ShippingContact,&lt;br /&gt;
  BillingContact,&lt;br /&gt;
  Token,&lt;br /&gt;
  /** include other required and optional Payment/Start params */&lt;br /&gt;
  PaymentStartProperties&lt;br /&gt;
) {&lt;br /&gt;
  const url =&lt;br /&gt;
    &amp;quot;https://api.test.barion.com/v2/ApplePay/StartPaymentWithAppleToken&amp;quot;;&lt;br /&gt;
  const data = {&lt;br /&gt;
    POSKey,&lt;br /&gt;
    ShippingContact,&lt;br /&gt;
    BillingContact,&lt;br /&gt;
    Token,&lt;br /&gt;
    ...PaymentStartProperties,&lt;br /&gt;
  };&lt;br /&gt;
&lt;br /&gt;
  try {&lt;br /&gt;
    const response = await fetch(url, {&lt;br /&gt;
      method: &amp;quot;POST&amp;quot;,&lt;br /&gt;
      headers: {&lt;br /&gt;
        &amp;quot;Content-Type&amp;quot;: &amp;quot;application/json&amp;quot;,&lt;br /&gt;
      },&lt;br /&gt;
      body: JSON.stringify(data),&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
    if (!response.ok) {&lt;br /&gt;
      throw new Error(`Error: ${response.status} ${response.statusText}`);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    const result = await response.json();&lt;br /&gt;
    return result;&lt;br /&gt;
  } catch (error) {&lt;br /&gt;
    // handle the error according to your business logic&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
const PaymentStartProperties = {&lt;br /&gt;
  PaymentType: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
applePaySession.onpaymentauthorized = function (event) {&lt;br /&gt;
  startApplePayPayment(&lt;br /&gt;
    POSKey,&lt;br /&gt;
    event.paymentInfo.shippingContent,&lt;br /&gt;
    event.paymentInfo.billingContact,&lt;br /&gt;
    event.paymentInfo.Token,&lt;br /&gt;
    PaymentStartProperties&lt;br /&gt;
  );&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;This event is triggered when the customer has authorized the Apple Pay payment using their Touch ID or Face ID.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Set up an event handler for &amp;lt;code&amp;gt;oncancel&amp;lt;/code&amp;gt; to implement your business logic for when the user abandons the Apple Pay payment.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Make sure that your event handler indicates that the session is canceled so the ApplePaySession’s &amp;lt;code&amp;gt;completePayment&amp;lt;/code&amp;gt; method doesn’t get executed.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;  applePaySession.oncancel = function (event) {&lt;br /&gt;
    // your oncancel business logic&lt;br /&gt;
&lt;br /&gt;
    isSessionCanceled = true;&lt;br /&gt;
  };&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Call [https://developer.apple.com/documentation/apple_pay_on_the_web/applepaysession/1778001-begin ApplePaySession.begin] to kick off the payment process.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;  applePaySession.begin();&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;This starts the merchant validation process that results in &amp;lt;code&amp;gt;ApplePaySession.onvalidatemerchant&amp;lt;/code&amp;gt; being triggered.&amp;lt;/blockquote&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Testing your implementation ===&lt;br /&gt;
&lt;br /&gt;
The following steps are needed in order to test your implementation:&lt;br /&gt;
# request access by sending an email to devsupport@barion.com!&lt;br /&gt;
# include an email address, that has no Apple Id yet&lt;br /&gt;
# we will register &amp;amp; connect it to our test account&lt;br /&gt;
# after that, you will be able to [https://developer.apple.com/apple-pay/sandbox-testing/ use Apple&#039;s test cards]&lt;br /&gt;
&lt;br /&gt;
== Related links ==&lt;br /&gt;
&lt;br /&gt;
[[ApplePay-ValidateSession|ValidateSession API endpoint]]&lt;br /&gt;
&lt;br /&gt;
[[ApplePay-StartPaymentWithAppleToken|StartPaymentWithAppleToken API endpoint]]&lt;/div&gt;</summary>
		<author><name>Salamongy@barion.dev</name></author>
	</entry>
</feed>