{"title":"Decrypt Apple Pay tokens","category":"default","creationDate":1732628520,"content":"<p>An Apple Pay token contains encrypted data of a transaction performed with Apple Pay. Apple Pay tokens enable you to securely pass the data of your shoppers to a payment service provider, like Adyen.<\/p>\n<h2>Choose a decryption method<\/h2>\n<p>If you are <a href=\"https:\/\/docs.adyen.com\/get-started-with-adyen\/adyen-glossary\/#pci-compliance\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" class=\"external-link no-image\">PCI-compliant<\/a> you have a choice of letting Adyen handle the token decryption, or handling it on your own.<\/p>\n<p>Only handle the token decryption on your own in advanced setup scenarios, like when you have to submit Merchant Plug-In (MPI) data in an Apple Pay request.<\/p>\n<p>A benefit of handling the decryption on your own is that the auditing of transactions becomes easier with the availability of transaction data like shopper names.<\/p>\n<p>If you are not PCI-compliant you must let Adyen handle the decryption.<\/p>\n<h2>Let Adyen handle the decryption<\/h2>\n<h3>In-app<\/h3>\n<p>After initiating the Apple Pay payment on your mobile application, you receive a callback that includes a <code>PKPayment<\/code>. This includes <code>paymentData<\/code>, a stringified version of the payment token. You need to submit this data in your <a href=\"#step-2-submit-the-api-request1\">payment request to Adyen<\/a>.<\/p>\n<ol>\n<li>\n<p>Stringify the paymentData from the token <span id=\"step-1-stringify-the-paymentdata-from-the-token\"   ><\/span><\/p>\n<p>When the request is completed, you receive a <a href=\"https:\/\/developer.apple.com\/documentation\/passkit\/pkpayment?changes=latest_ma_8&amp;language=objc\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" class=\"external-link no-image\">PKPayment<\/a> which contains <code>paymentData<\/code>. Apple Pay returns more data than we need for authorization, for example a shipping address, but only the <code>paymentData<\/code> is necessary for authorization.<\/p>\n<p>Convert the <code>paymentData<\/code> to a String:<\/p>\n<pre><code class=\"language-swift\">func paymentAuthorizationViewController(_ controller: PKPaymentAuthorizationViewController, didAuthorizePayment payment: PKPayment, completion: @escaping (PKPaymentAuthorizationStatus) -&gt; Void) {\nlet token = payment.token.paymentData.base64EncodedString()\n}<\/code><\/pre>\n<\/li>\n<li>\n<p><span id=\"step-2-submit-the-api-request1\"   >Submit the API request  <\/span><\/p>\n<p>Include the encoded token from step 1 as the value of <code>applePayToken<\/code> in the <code>paymentMethod<\/code> object of your  <a href=\"https:\/\/docs.adyen.com\/api-explorer\/Checkout\/latest\/post\/payments\" class=\"codeLabel  external-link no-image\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">\/payments<\/a> request:<\/p>\n<div data-component-wrapper=\"code-sample\">\n<code-sample :title=\"''\" :id=\"'apple-pay-onweb-api'\" :code-data=\"[{&quot;language&quot;:&quot;bash&quot;,&quot;tabTitle&quot;:&quot;curl&quot;,&quot;content&quot;:&quot;curl https:\\\/\\\/checkout-test.adyen.com\\\/v72\\\/payments \\\\\\n-H 'x-api-key: ADYEN_API_KEY' \\\\\\n-H 'content-type: application\\\/json' \\\\\\n-d '{\\n    \\&quot;amount\\&quot;: {\\n    \\&quot;currency\\&quot;: \\&quot;EUR\\&quot;,\\n    \\&quot;value\\&quot;: 2000\\n    },\\n    \\&quot;reference\\&quot;: \\&quot;YOUR_REFERENCE\\&quot;,\\n    \\&quot;paymentMethod\\&quot;: {\\n    \\&quot;type\\&quot;: \\&quot;applepay\\&quot;,\\n    \\&quot;applePayToken\\&quot;: \\&quot;VNRWtuNlNEWkRCSm1xWndjMDFFbktkQU...\\&quot;\\n    },\\n    \\&quot;returnUrl\\&quot;: \\&quot;https:\\\/\\\/your-company.example.com\\\/...\\&quot;,\\n    \\&quot;merchantAccount\\&quot;: \\&quot;ADYEN_MERCHANT_ACCOUNT\\&quot;\\n    }'&quot;},{&quot;language&quot;:&quot;java&quot;,&quot;tabTitle&quot;:&quot;Java&quot;,&quot;content&quot;:&quot;\\\/\\\/ Adyen Java API Library v27.0.0\\nimport com.adyen.Client;\\nimport com.adyen.enums.Environment;\\nimport com.adyen.model.checkout.*;\\nimport java.time.OffsetDateTime;\\nimport java.util.*;\\nimport com.adyen.model.RequestOptions;\\nimport com.adyen.service.checkout.*;\\n\\n\\\/\\\/ For the live environment, additionally include your liveEndpointUrlPrefix.\\nClient client = new Client(\\&quot;ADYEN_API_KEY\\&quot;, Environment.TEST);\\n\\n\\\/\\\/ Create the request object(s)\\nAmount amount = new Amount()\\n  .currency(\\&quot;EUR\\&quot;)\\n  .value(2000L);\\n\\nApplePayDetails applePayDetails = new ApplePayDetails()\\n  .applePayToken(\\&quot;VNRWtuNlNEWkRCSm1xWndjMDFFbktkQU...\\&quot;)\\n  .type(ApplePayDetails.TypeEnum.APPLEPAY);\\n\\nPaymentRequest paymentRequest = new PaymentRequest()\\n  .reference(\\&quot;YOUR_REFERENCE\\&quot;)\\n  .amount(amount)\\n  .merchantAccount(\\&quot;ADYEN_MERCHANT_ACCOUNT\\&quot;)\\n  .paymentMethod(new CheckoutPaymentMethod(applePayDetails))\\n  .returnUrl(\\&quot;https:\\\/\\\/your-company.example.com\\\/...\\&quot;);\\n\\n\\\/\\\/ Send the request\\nPaymentsApi service = new PaymentsApi(client);\\nPaymentResponse response = service.payments(paymentRequest, new RequestOptions().idempotencyKey(\\&quot;UUID\\&quot;));&quot;},{&quot;language&quot;:&quot;php&quot;,&quot;tabTitle&quot;:&quot;PHP&quot;,&quot;content&quot;:&quot;\\\/\\\/ Adyen PHP API Library v19.0.0\\nuse Adyen\\\\Client;\\nuse Adyen\\\\Environment;\\nuse Adyen\\\\Model\\\\Checkout\\\\Amount;\\nuse Adyen\\\\Model\\\\Checkout\\\\CheckoutPaymentMethod;\\nuse Adyen\\\\Model\\\\Checkout\\\\PaymentRequest;\\nuse Adyen\\\\Service\\\\Checkout\\\\PaymentsApi;\\n\\n$client = new Client();\\n$client-&gt;setXApiKey(\\&quot;ADYEN_API_KEY\\&quot;);\\n\\\/\\\/ For the live environment, additionally include your liveEndpointUrlPrefix.\\n$client-&gt;setEnvironment(Environment::TEST);\\n\\n\\n\\\/\\\/ Create the request object(s)\\n$amount = new Amount();\\n$amount\\n  -&gt;setCurrency(\\&quot;EUR\\&quot;)\\n  -&gt;setValue(2000);\\n\\n$checkoutPaymentMethod = new CheckoutPaymentMethod();\\n$checkoutPaymentMethod\\n  -&gt;setApplePayToken(\\&quot;VNRWtuNlNEWkRCSm1xWndjMDFFbktkQU...\\&quot;)\\n  -&gt;setType(\\&quot;applepay\\&quot;);\\n\\n$paymentRequest = new PaymentRequest();\\n$paymentRequest\\n  -&gt;setReference(\\&quot;YOUR_REFERENCE\\&quot;)\\n  -&gt;setAmount($amount)\\n  -&gt;setMerchantAccount(\\&quot;ADYEN_MERCHANT_ACCOUNT\\&quot;)\\n  -&gt;setPaymentMethod($checkoutPaymentMethod)\\n  -&gt;setReturnUrl(\\&quot;https:\\\/\\\/your-company.example.com\\\/...\\&quot;);\\n\\n$requestOptions['idempotencyKey'] = 'UUID';\\n\\n\\\/\\\/ Send the request\\n$service = new PaymentsApi($client);\\n$response = $service-&gt;payments($paymentRequest, $requestOptions);&quot;},{&quot;language&quot;:&quot;cs&quot;,&quot;tabTitle&quot;:&quot;C#&quot;,&quot;content&quot;:&quot;\\\/\\\/ Adyen .net API Library v17.0.0\\nusing Adyen;\\nusing Environment = Adyen.Model.Environment;\\nusing Adyen.Model;\\nusing Adyen.Model.Checkout;\\nusing Adyen.Service.Checkout;\\n\\n\\\/\\\/ For the live environment, additionally include your liveEndpointUrlPrefix.\\nvar config = new Config()\\n{\\n    XApiKey = \\&quot;ADYEN_API_KEY\\&quot;,\\n    Environment = Environment.Test\\n};\\nvar client = new Client(config);\\n\\n\\\/\\\/ Create the request object(s)\\nAmount amount = new Amount\\n{\\n  Currency = \\&quot;EUR\\&quot;,\\n  Value = 2000\\n};\\n\\nApplePayDetails applePayDetails = new ApplePayDetails\\n{\\n  ApplePayToken = \\&quot;VNRWtuNlNEWkRCSm1xWndjMDFFbktkQU...\\&quot;,\\n  Type = ApplePayDetails.TypeEnum.Applepay\\n};\\n\\nPaymentRequest paymentRequest = new PaymentRequest\\n{\\n  Reference = \\&quot;YOUR_REFERENCE\\&quot;,\\n  Amount = amount,\\n  MerchantAccount = \\&quot;ADYEN_MERCHANT_ACCOUNT\\&quot;,\\n  PaymentMethod = new CheckoutPaymentMethod(applePayDetails),\\n  ReturnUrl = \\&quot;https:\\\/\\\/your-company.example.com\\\/...\\&quot;\\n};\\n\\n\\\/\\\/ Send the request\\nvar service = new PaymentsService(client);\\nvar response = service.Payments(paymentRequest, requestOptions: new RequestOptions { IdempotencyKey = \\&quot;UUID\\&quot;});&quot;},{&quot;language&quot;:&quot;js&quot;,&quot;tabTitle&quot;:&quot;NodeJS (JavaScript)&quot;,&quot;content&quot;:&quot;\\\/\\\/ Adyen Node API Library v18.0.0\\n\\\/\\\/ Require the parts of the module you want to use\\nconst { Client, CheckoutAPI } = require('@adyen\\\/api-library');\\n\\\/\\\/ Initialize the client object\\n\\\/\\\/ For the live environment, additionally include your liveEndpointUrlPrefix.\\nconst client = new Client({apiKey: \\&quot;ADYEN_API_KEY\\&quot;, environment: \\&quot;TEST\\&quot;});\\n\\n\\\/\\\/ Create the request object(s)\\nconst paymentRequest = {\\n  amount: {\\n    currency: \\&quot;EUR\\&quot;,\\n    value: 2000\\n  },\\n  reference: \\&quot;YOUR_REFERENCE\\&quot;,\\n  paymentMethod: {\\n    type: \\&quot;applepay\\&quot;,\\n    applePayToken: \\&quot;VNRWtuNlNEWkRCSm1xWndjMDFFbktkQU...\\&quot;\\n  },\\n  returnUrl: \\&quot;https:\\\/\\\/your-company.example.com\\\/...\\&quot;,\\n  merchantAccount: \\&quot;ADYEN_MERCHANT_ACCOUNT\\&quot;\\n}\\n\\n\\\/\\\/ Send the request\\nconst checkoutAPI = new CheckoutAPI(client);\\nconst response = checkoutAPI.PaymentsApi.payments(paymentRequest, { idempotencyKey: \\&quot;UUID\\&quot; });&quot;},{&quot;language&quot;:&quot;go&quot;,&quot;tabTitle&quot;:&quot;Go&quot;,&quot;content&quot;:&quot;\\\/\\\/ Adyen Go API Library v10.4.0\\nimport (\\n  \\&quot;context\\&quot;\\n  \\&quot;github.com\\\/adyen\\\/adyen-go-api-library\\\/v9\\\/src\\\/common\\&quot;\\n  \\&quot;github.com\\\/adyen\\\/adyen-go-api-library\\\/v9\\\/src\\\/adyen\\&quot;\\n  \\&quot;github.com\\\/adyen\\\/adyen-go-api-library\\\/v9\\\/src\\\/checkout\\&quot;\\n)\\n\\\/\\\/ For the live environment, additionally include your liveEndpointUrlPrefix.\\nclient := adyen.NewClient(&amp;common.Config{\\n  ApiKey:      \\&quot;ADYEN_API_KEY\\&quot;,\\n  Environment: common.TestEnv,\\n})\\n\\n\\\/\\\/ Create the request object(s)\\namount := checkout.Amount{\\n  Currency: \\&quot;EUR\\&quot;,\\n  Value: 2000,\\n}\\n\\napplePayDetails := checkout.ApplePayDetails{\\n  ApplePayToken: \\&quot;VNRWtuNlNEWkRCSm1xWndjMDFFbktkQU...\\&quot;,\\n  Type: common.PtrString(\\&quot;applepay\\&quot;),\\n}\\n\\npaymentRequest := checkout.PaymentRequest{\\n  Reference: \\&quot;YOUR_REFERENCE\\&quot;,\\n  Amount: amount,\\n  MerchantAccount: \\&quot;ADYEN_MERCHANT_ACCOUNT\\&quot;,\\n  PaymentMethod: checkout.ApplePayDetailsAsCheckoutPaymentMethod(&amp;applePayDetails),\\n  ReturnUrl: \\&quot;https:\\\/\\\/your-company.example.com\\\/...\\&quot;,\\n}\\n\\n\\\/\\\/ Send the request\\nservice := client.Checkout()\\nreq := service.PaymentsApi.PaymentsInput().IdempotencyKey(\\&quot;UUID\\&quot;).PaymentRequest(paymentRequest)\\nres, httpRes, err := service.PaymentsApi.Payments(context.Background(), req)&quot;},{&quot;language&quot;:&quot;py&quot;,&quot;tabTitle&quot;:&quot;Python&quot;,&quot;content&quot;:&quot;# Adyen Python API Library v12.5.1\\nimport Adyen\\n\\nadyen = Adyen.Adyen()\\nadyen.client.xapikey = \\&quot;ADYEN_API_KEY\\&quot;\\n# For the live environment, additionally include your liveEndpointUrlPrefix.\\nadyen.client.platform = \\&quot;test\\&quot; # The environment to use library in.\\n\\n# Create the request object(s)\\njson_request = {\\n  \\&quot;amount\\&quot;: {\\n    \\&quot;currency\\&quot;: \\&quot;EUR\\&quot;,\\n    \\&quot;value\\&quot;: 2000\\n  },\\n  \\&quot;reference\\&quot;: \\&quot;YOUR_REFERENCE\\&quot;,\\n  \\&quot;paymentMethod\\&quot;: {\\n    \\&quot;type\\&quot;: \\&quot;applepay\\&quot;,\\n    \\&quot;applePayToken\\&quot;: \\&quot;VNRWtuNlNEWkRCSm1xWndjMDFFbktkQU...\\&quot;\\n  },\\n  \\&quot;returnUrl\\&quot;: \\&quot;https:\\\/\\\/your-company.example.com\\\/...\\&quot;,\\n  \\&quot;merchantAccount\\&quot;: \\&quot;ADYEN_MERCHANT_ACCOUNT\\&quot;\\n}\\n\\n# Send the request\\nresult = adyen.checkout.payments_api.payments(request=json_request, idempotency_key=\\&quot;UUID\\&quot;)&quot;},{&quot;language&quot;:&quot;rb&quot;,&quot;tabTitle&quot;:&quot;Ruby&quot;,&quot;content&quot;:&quot;# Adyen Ruby API Library v9.5.1\\nrequire \\&quot;adyen-ruby-api-library\\&quot;\\n\\nadyen = Adyen::Client.new\\nadyen.api_key = 'ADYEN_API_KEY'\\n# For the live environment, additionally include your liveEndpointUrlPrefix.\\nadyen.env = :test # Set to \\&quot;live\\&quot; for live environment\\n\\n# Create the request object(s)\\nrequest_body = {\\n  :amount =&gt; {\\n    :currency =&gt; 'EUR',\\n    :value =&gt; 2000\\n  },\\n  :reference =&gt; 'YOUR_REFERENCE',\\n  :paymentMethod =&gt; {\\n    :type =&gt; 'applepay',\\n    :applePayToken =&gt; 'VNRWtuNlNEWkRCSm1xWndjMDFFbktkQU...'\\n  },\\n  :returnUrl =&gt; 'https:\\\/\\\/your-company.example.com\\\/...',\\n  :merchantAccount =&gt; 'ADYEN_MERCHANT_ACCOUNT'\\n}\\n\\n# Send the request\\nresult = adyen.checkout.payments_api.payments(request_body, headers: { 'Idempotency-Key' =&gt; 'UUID' })&quot;},{&quot;language&quot;:&quot;ts&quot;,&quot;tabTitle&quot;:&quot;NodeJS (TypeScript)&quot;,&quot;content&quot;:&quot;\\\/\\\/ Adyen Node API Library v18.0.0\\n\\\/\\\/ Require the parts of the module you want to use\\nimport { Client, CheckoutAPI, Types } from \\&quot;@adyen\\\/api-library\\&quot;;\\n\\\/\\\/ Initialize the client object\\n\\\/\\\/ For the live environment, additionally include your liveEndpointUrlPrefix.\\nconst client = new Client({apiKey: \\&quot;ADYEN_API_KEY\\&quot;, environment: \\&quot;TEST\\&quot;});\\n\\n\\\/\\\/ Create the request object(s)\\nconst amount: Types.checkout.Amount = {\\n  currency: \\&quot;EUR\\&quot;,\\n  value: 2000\\n};\\n\\nconst applePayDetails: Types.checkout.ApplePayDetails = {\\n  applePayToken: \\&quot;VNRWtuNlNEWkRCSm1xWndjMDFFbktkQU...\\&quot;,\\n  type: Types.checkout.ApplePayDetails.TypeEnum.Applepay\\n};\\n\\nconst paymentRequest: Types.checkout.PaymentRequest = {\\n  reference: \\&quot;YOUR_REFERENCE\\&quot;,\\n  amount: amount,\\n  merchantAccount: \\&quot;ADYEN_MERCHANT_ACCOUNT\\&quot;,\\n  paymentMethod: applePayDetails,\\n  returnUrl: \\&quot;https:\\\/\\\/your-company.example.com\\\/...\\&quot;\\n};\\n\\n\\\/\\\/ Send the request\\nconst checkoutAPI = new CheckoutAPI(client);\\nconst response = checkoutAPI.PaymentsApi.payments(paymentRequest, { idempotencyKey: \\&quot;UUID\\&quot; });&quot;}]\" :enable-copy-link-to-code-block=\"true\" :code-sample-card-size=\"'fullsize'\"><\/code-sample>\n<\/div>\n<\/li>\n<\/ol>\n<h3>Web<\/h3>\n<p>After initiating the Apple Pay payment on your website you receive a token in the <a href=\"https:\/\/developer.apple.com\/documentation\/apple_pay_on_the_web\/applepaysession\/1778020-onpaymentauthorized\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" class=\"external-link no-image\">onPaymentAuthorized<\/a> event.<\/p>\n<p>Retrieve the <code>paymentData<\/code> from the token and convert it to a string. Pass this to your server, and then submit it in a <code>\/payments<\/code> request to Adyen.<\/p>\n<ol>\n<li>\n<p>Stringify the paymentData from the token<\/p>\n<p>Apple Pay returns more data than we need for authorization, for example a shipping address, but only the <code>PaymentData<\/code> is necessary for authorization. Take this data from the token and convert the JSON to a String and base64-encoded:<\/p>\n<pre><code class=\"language-js\">session.onpaymentauthorized = function(event) {\nvar token = btoa(JSON.stringify(event.payment.token.paymentData));\n};<\/code><\/pre>\n<\/li>\n<li>\n<p>Submit the API request<\/p>\n<p>Include the encoded token from step 1 as the value of <code>applePayToken<\/code> in the <code>paymentMethod<\/code> object of your  <a href=\"https:\/\/docs.adyen.com\/api-explorer\/Checkout\/latest\/post\/payments\" class=\"codeLabel  external-link no-image\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">\/payments<\/a> request:<\/p>\n<div data-component-wrapper=\"code-sample\">\n<code-sample :title=\"''\" :id=\"'apple-pay-inapp-api'\" :code-data=\"[{&quot;language&quot;:&quot;bash&quot;,&quot;tabTitle&quot;:&quot;curl&quot;,&quot;content&quot;:&quot;curl https:\\\/\\\/checkout-test.adyen.com\\\/v72\\\/payments \\\\\\n-H 'x-api-key: ADYEN_API_KEY' \\\\\\n-H 'content-type: application\\\/json' \\\\\\n-d '{\\n      \\&quot;amount\\&quot;: {\\n        \\&quot;currency\\&quot;: \\&quot;USD\\&quot;,\\n        \\&quot;value\\&quot;: 1000\\n      },\\n      \\&quot;reference\\&quot;: \\&quot;Your order number\\&quot;,\\n      \\&quot;paymentMethod\\&quot;: {\\n        \\&quot;type\\&quot;: \\&quot;applepay\\&quot;,\\n        \\&quot;applePayToken\\&quot;: \\&quot;{hint:token from step 1}VNRWtuNlNEWkRCSm1xWndjMDFFbktkQU...{\\\/hint}\\&quot;\\n      },\\n      \\&quot;returnUrl\\&quot;: \\&quot;https:\\\/\\\/your-company.example.com\\\/...\\&quot;,\\n      \\&quot;merchantAccount\\&quot;: \\&quot;ADYEN_MERCHANT_ACCOUNT\\&quot;\\n    }'&quot;},{&quot;language&quot;:&quot;java&quot;,&quot;tabTitle&quot;:&quot;Java&quot;,&quot;content&quot;:&quot;\\\/\\\/ Adyen Java API Library v27.0.0\\nimport com.adyen.Client;\\nimport com.adyen.enums.Environment;\\nimport com.adyen.model.checkout.*;\\nimport java.time.OffsetDateTime;\\nimport java.util.*;\\nimport com.adyen.model.RequestOptions;\\nimport com.adyen.service.checkout.*;\\n\\n\\\/\\\/ For the live environment, additionally include your liveEndpointUrlPrefix.\\nClient client = new Client(\\&quot;ADYEN_API_KEY\\&quot;, Environment.TEST);\\n\\n\\\/\\\/ Create the request object(s)\\nAmount amount = new Amount()\\n  .currency(\\&quot;USD\\&quot;)\\n  .value(1000L);\\n\\nApplePayDetails applePayDetails = new ApplePayDetails()\\n  .applePayToken(\\&quot;VNRWtuNlNEWkRCSm1xWndjMDFFbktkQU...\\&quot;)\\n  .type(ApplePayDetails.TypeEnum.APPLEPAY);\\n\\nPaymentRequest paymentRequest = new PaymentRequest()\\n  .reference(\\&quot;Your order number\\&quot;)\\n  .amount(amount)\\n  .merchantAccount(\\&quot;ADYEN_MERCHANT_ACCOUNT\\&quot;)\\n  .paymentMethod(new CheckoutPaymentMethod(applePayDetails))\\n  .returnUrl(\\&quot;https:\\\/\\\/your-company.example.com\\\/...\\&quot;);\\n\\n\\\/\\\/ Send the request\\nPaymentsApi service = new PaymentsApi(client);\\nPaymentResponse response = service.payments(paymentRequest, new RequestOptions().idempotencyKey(\\&quot;UUID\\&quot;));&quot;},{&quot;language&quot;:&quot;php&quot;,&quot;tabTitle&quot;:&quot;PHP&quot;,&quot;content&quot;:&quot;\\\/\\\/ Adyen PHP API Library v19.0.0\\nuse Adyen\\\\Client;\\nuse Adyen\\\\Environment;\\nuse Adyen\\\\Model\\\\Checkout\\\\Amount;\\nuse Adyen\\\\Model\\\\Checkout\\\\CheckoutPaymentMethod;\\nuse Adyen\\\\Model\\\\Checkout\\\\PaymentRequest;\\nuse Adyen\\\\Service\\\\Checkout\\\\PaymentsApi;\\n\\n$client = new Client();\\n$client-&gt;setXApiKey(\\&quot;ADYEN_API_KEY\\&quot;);\\n\\\/\\\/ For the live environment, additionally include your liveEndpointUrlPrefix.\\n$client-&gt;setEnvironment(Environment::TEST);\\n\\n\\n\\\/\\\/ Create the request object(s)\\n$amount = new Amount();\\n$amount\\n  -&gt;setCurrency(\\&quot;USD\\&quot;)\\n  -&gt;setValue(1000);\\n\\n$checkoutPaymentMethod = new CheckoutPaymentMethod();\\n$checkoutPaymentMethod\\n  -&gt;setApplePayToken(\\&quot;VNRWtuNlNEWkRCSm1xWndjMDFFbktkQU...\\&quot;)\\n  -&gt;setType(\\&quot;applepay\\&quot;);\\n\\n$paymentRequest = new PaymentRequest();\\n$paymentRequest\\n  -&gt;setReference(\\&quot;Your order number\\&quot;)\\n  -&gt;setAmount($amount)\\n  -&gt;setMerchantAccount(\\&quot;ADYEN_MERCHANT_ACCOUNT\\&quot;)\\n  -&gt;setPaymentMethod($checkoutPaymentMethod)\\n  -&gt;setReturnUrl(\\&quot;https:\\\/\\\/your-company.example.com\\\/...\\&quot;);\\n\\n$requestOptions['idempotencyKey'] = 'UUID';\\n\\n\\\/\\\/ Send the request\\n$service = new PaymentsApi($client);\\n$response = $service-&gt;payments($paymentRequest, $requestOptions);&quot;},{&quot;language&quot;:&quot;cs&quot;,&quot;tabTitle&quot;:&quot;C#&quot;,&quot;content&quot;:&quot;\\\/\\\/ Adyen .net API Library v17.0.0\\nusing Adyen;\\nusing Environment = Adyen.Model.Environment;\\nusing Adyen.Model;\\nusing Adyen.Model.Checkout;\\nusing Adyen.Service.Checkout;\\n\\n\\\/\\\/ For the live environment, additionally include your liveEndpointUrlPrefix.\\nvar config = new Config()\\n{\\n    XApiKey = \\&quot;ADYEN_API_KEY\\&quot;,\\n    Environment = Environment.Test\\n};\\nvar client = new Client(config);\\n\\n\\\/\\\/ Create the request object(s)\\nAmount amount = new Amount\\n{\\n  Currency = \\&quot;USD\\&quot;,\\n  Value = 1000\\n};\\n\\nApplePayDetails applePayDetails = new ApplePayDetails\\n{\\n  ApplePayToken = \\&quot;VNRWtuNlNEWkRCSm1xWndjMDFFbktkQU...\\&quot;,\\n  Type = ApplePayDetails.TypeEnum.Applepay\\n};\\n\\nPaymentRequest paymentRequest = new PaymentRequest\\n{\\n  Reference = \\&quot;Your order number\\&quot;,\\n  Amount = amount,\\n  MerchantAccount = \\&quot;ADYEN_MERCHANT_ACCOUNT\\&quot;,\\n  PaymentMethod = new CheckoutPaymentMethod(applePayDetails),\\n  ReturnUrl = \\&quot;https:\\\/\\\/your-company.example.com\\\/...\\&quot;\\n};\\n\\n\\\/\\\/ Send the request\\nvar service = new PaymentsService(client);\\nvar response = service.Payments(paymentRequest, requestOptions: new RequestOptions { IdempotencyKey = \\&quot;UUID\\&quot;});&quot;},{&quot;language&quot;:&quot;js&quot;,&quot;tabTitle&quot;:&quot;NodeJS (JavaScript)&quot;,&quot;content&quot;:&quot;\\\/\\\/ Adyen Node API Library v18.0.0\\n\\\/\\\/ Require the parts of the module you want to use\\nconst { Client, CheckoutAPI } = require('@adyen\\\/api-library');\\n\\\/\\\/ Initialize the client object\\n\\\/\\\/ For the live environment, additionally include your liveEndpointUrlPrefix.\\nconst client = new Client({apiKey: \\&quot;ADYEN_API_KEY\\&quot;, environment: \\&quot;TEST\\&quot;});\\n\\n\\\/\\\/ Create the request object(s)\\nconst paymentRequest = {\\n  amount: {\\n    currency: \\&quot;USD\\&quot;,\\n    value: 1000\\n  },\\n  reference: \\&quot;Your order number\\&quot;,\\n  paymentMethod: {\\n    type: \\&quot;applepay\\&quot;,\\n    applePayToken: \\&quot;VNRWtuNlNEWkRCSm1xWndjMDFFbktkQU...\\&quot;\\n  },\\n  returnUrl: \\&quot;https:\\\/\\\/your-company.example.com\\\/...\\&quot;,\\n  merchantAccount: \\&quot;ADYEN_MERCHANT_ACCOUNT\\&quot;\\n}\\n\\n\\\/\\\/ Send the request\\nconst checkoutAPI = new CheckoutAPI(client);\\nconst response = checkoutAPI.PaymentsApi.payments(paymentRequest, { idempotencyKey: \\&quot;UUID\\&quot; });&quot;},{&quot;language&quot;:&quot;go&quot;,&quot;tabTitle&quot;:&quot;Go&quot;,&quot;content&quot;:&quot;\\\/\\\/ Adyen Go API Library v10.4.0\\nimport (\\n  \\&quot;context\\&quot;\\n  \\&quot;github.com\\\/adyen\\\/adyen-go-api-library\\\/v9\\\/src\\\/common\\&quot;\\n  \\&quot;github.com\\\/adyen\\\/adyen-go-api-library\\\/v9\\\/src\\\/adyen\\&quot;\\n  \\&quot;github.com\\\/adyen\\\/adyen-go-api-library\\\/v9\\\/src\\\/checkout\\&quot;\\n)\\n\\\/\\\/ For the live environment, additionally include your liveEndpointUrlPrefix.\\nclient := adyen.NewClient(&amp;common.Config{\\n  ApiKey:      \\&quot;ADYEN_API_KEY\\&quot;,\\n  Environment: common.TestEnv,\\n})\\n\\n\\\/\\\/ Create the request object(s)\\namount := checkout.Amount{\\n  Currency: \\&quot;USD\\&quot;,\\n  Value: 1000,\\n}\\n\\napplePayDetails := checkout.ApplePayDetails{\\n  ApplePayToken: \\&quot;VNRWtuNlNEWkRCSm1xWndjMDFFbktkQU...\\&quot;,\\n  Type: common.PtrString(\\&quot;applepay\\&quot;),\\n}\\n\\npaymentRequest := checkout.PaymentRequest{\\n  Reference: \\&quot;Your order number\\&quot;,\\n  Amount: amount,\\n  MerchantAccount: \\&quot;ADYEN_MERCHANT_ACCOUNT\\&quot;,\\n  PaymentMethod: checkout.ApplePayDetailsAsCheckoutPaymentMethod(&amp;applePayDetails),\\n  ReturnUrl: \\&quot;https:\\\/\\\/your-company.example.com\\\/...\\&quot;,\\n}\\n\\n\\\/\\\/ Send the request\\nservice := client.Checkout()\\nreq := service.PaymentsApi.PaymentsInput().IdempotencyKey(\\&quot;UUID\\&quot;).PaymentRequest(paymentRequest)\\nres, httpRes, err := service.PaymentsApi.Payments(context.Background(), req)&quot;},{&quot;language&quot;:&quot;py&quot;,&quot;tabTitle&quot;:&quot;Python&quot;,&quot;content&quot;:&quot;# Adyen Python API Library v12.5.1\\nimport Adyen\\n\\nadyen = Adyen.Adyen()\\nadyen.client.xapikey = \\&quot;ADYEN_API_KEY\\&quot;\\n# For the live environment, additionally include your liveEndpointUrlPrefix.\\nadyen.client.platform = \\&quot;test\\&quot; # The environment to use library in.\\n\\n# Create the request object(s)\\njson_request = {\\n  \\&quot;amount\\&quot;: {\\n    \\&quot;currency\\&quot;: \\&quot;USD\\&quot;,\\n    \\&quot;value\\&quot;: 1000\\n  },\\n  \\&quot;reference\\&quot;: \\&quot;Your order number\\&quot;,\\n  \\&quot;paymentMethod\\&quot;: {\\n    \\&quot;type\\&quot;: \\&quot;applepay\\&quot;,\\n    \\&quot;applePayToken\\&quot;: \\&quot;VNRWtuNlNEWkRCSm1xWndjMDFFbktkQU...\\&quot;\\n  },\\n  \\&quot;returnUrl\\&quot;: \\&quot;https:\\\/\\\/your-company.example.com\\\/...\\&quot;,\\n  \\&quot;merchantAccount\\&quot;: \\&quot;ADYEN_MERCHANT_ACCOUNT\\&quot;\\n}\\n\\n# Send the request\\nresult = adyen.checkout.payments_api.payments(request=json_request, idempotency_key=\\&quot;UUID\\&quot;)&quot;},{&quot;language&quot;:&quot;rb&quot;,&quot;tabTitle&quot;:&quot;Ruby&quot;,&quot;content&quot;:&quot;# Adyen Ruby API Library v9.5.1\\nrequire \\&quot;adyen-ruby-api-library\\&quot;\\n\\nadyen = Adyen::Client.new\\nadyen.api_key = 'ADYEN_API_KEY'\\n# For the live environment, additionally include your liveEndpointUrlPrefix.\\nadyen.env = :test # Set to \\&quot;live\\&quot; for live environment\\n\\n# Create the request object(s)\\nrequest_body = {\\n  :amount =&gt; {\\n    :currency =&gt; 'USD',\\n    :value =&gt; 1000\\n  },\\n  :reference =&gt; 'Your order number',\\n  :paymentMethod =&gt; {\\n    :type =&gt; 'applepay',\\n    :applePayToken =&gt; 'VNRWtuNlNEWkRCSm1xWndjMDFFbktkQU...'\\n  },\\n  :returnUrl =&gt; 'https:\\\/\\\/your-company.example.com\\\/...',\\n  :merchantAccount =&gt; 'ADYEN_MERCHANT_ACCOUNT'\\n}\\n\\n# Send the request\\nresult = adyen.checkout.payments_api.payments(request_body, headers: { 'Idempotency-Key' =&gt; 'UUID' })&quot;},{&quot;language&quot;:&quot;ts&quot;,&quot;tabTitle&quot;:&quot;NodeJS (TypeScript)&quot;,&quot;content&quot;:&quot;\\\/\\\/ Adyen Node API Library v18.0.0\\n\\\/\\\/ Require the parts of the module you want to use\\nimport { Client, CheckoutAPI, Types } from \\&quot;@adyen\\\/api-library\\&quot;;\\n\\\/\\\/ Initialize the client object\\n\\\/\\\/ For the live environment, additionally include your liveEndpointUrlPrefix.\\nconst client = new Client({apiKey: \\&quot;ADYEN_API_KEY\\&quot;, environment: \\&quot;TEST\\&quot;});\\n\\n\\\/\\\/ Create the request object(s)\\nconst amount: Types.checkout.Amount = {\\n  currency: \\&quot;USD\\&quot;,\\n  value: 1000\\n};\\n\\nconst applePayDetails: Types.checkout.ApplePayDetails = {\\n  applePayToken: \\&quot;VNRWtuNlNEWkRCSm1xWndjMDFFbktkQU...\\&quot;,\\n  type: Types.checkout.ApplePayDetails.TypeEnum.Applepay\\n};\\n\\nconst paymentRequest: Types.checkout.PaymentRequest = {\\n  reference: \\&quot;Your order number\\&quot;,\\n  amount: amount,\\n  merchantAccount: \\&quot;ADYEN_MERCHANT_ACCOUNT\\&quot;,\\n  paymentMethod: applePayDetails,\\n  returnUrl: \\&quot;https:\\\/\\\/your-company.example.com\\\/...\\&quot;\\n};\\n\\n\\\/\\\/ Send the request\\nconst checkoutAPI = new CheckoutAPI(client);\\nconst response = checkoutAPI.PaymentsApi.payments(paymentRequest, { idempotencyKey: \\&quot;UUID\\&quot; });&quot;}]\" :enable-copy-link-to-code-block=\"true\" :code-sample-card-size=\"'fullsize'\"><\/code-sample>\n<\/div>\n<\/li>\n<\/ol>\n<h2>Handle the decryption on your own<\/h2>\n<h3>Requirements<\/h3>\n<p>To decrypt Apple Pay tokens on your own, you must:<\/p>\n<ul>\n<li>Have an <a href=\"https:\/\/developer.apple.com\/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" class=\"external-link no-image\">Apple Developer account<\/a> that is associated with either the <a href=\"https:\/\/developer.apple.com\/programs\/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" class=\"external-link no-image\">Apple Developer Program<\/a>, or the <a href=\"https:\/\/developer.apple.com\/programs\/enterprise\/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" class=\"external-link no-image\">Apple Developer Enterprise Program<\/a>.<\/li>\n<li>Use your own Apple Pay certificate.<\/li>\n<li>Be PCI-compliant to handle unencrypted card details.<\/li>\n<li>Have an API-only integration.<\/li>\n<\/ul>\n<h3>Decryption process<\/h3>\n<div class=\"sc-notice info\"><div>\n<p>Verify the Apple Pay certificate before proceeding to token decryption.<\/p>\n<\/div><\/div>\n<p>To decrypt Apple Pay tokens, follow the <a href=\"https:\/\/developer.apple.com\/documentation\/passkit\/apple_pay\/payment_token_format_reference#\/\/apple_ref\/doc\/uid\/TP40014929-CH8-SW1\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" class=\"external-link no-image\">detailed steps as outlined on the Apple developer portal<\/a>.<\/p>\n<p>Overview:<\/p>\n<ol>\n<li>Use the value of publicKeyHash to determine which merchant public key Apple used, and then retrieve the corresponding merchant public key certificate and private key.<\/li>\n<li>Restore the symmetric key.<\/li>\n<li>Use the symmetric key to decrypt the value of the data key.<\/li>\n<li>Confirm that you have not already credited this payment by verifying that no payment with the same <code>transactionId<\/code> shows as processed.<\/li>\n<li>Verify the original transaction details of the Apple Pay payment request.<\/li>\n<li>Use the decrypted payment data to process the payment. See the API reference section below for details.<\/li>\n<\/ol>\n<h3>API reference<\/h3>\n<p>The parameters listed in this section are specific to using decrypted Apple Pay tokens. For descriptions of other parameters go to  <a href=\"https:\/\/docs.adyen.com\/api-explorer\/Checkout\/latest\/post\/payments\" class=\"codeLabel  external-link no-image\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">\/payments<\/a>.<\/p>\n<p>There are two types of transactions, namely customer initiated and merchant initiated transactions, each with a specific set of parameters.<\/p>\n\n<div id=\"tab6WnAF\">\n    <div data-component-wrapper=\"tabs\">\n        <tabs\n                        :items=\"[{&quot;title&quot;:&quot;Customer initiated transaction&quot;,&quot;content&quot;:&quot;\\n&lt;table&gt;\\n&lt;thead&gt;\\n&lt;tr&gt;\\n&lt;th&gt;Parameter name&lt;\\\/th&gt;\\n&lt;th&gt;Required&lt;\\\/th&gt;\\n&lt;th&gt;Description&lt;\\\/th&gt;\\n&lt;\\\/tr&gt;\\n&lt;\\\/thead&gt;\\n&lt;tbody&gt;\\n&lt;tr&gt;\\n&lt;td&gt; &lt;a href=\\&quot;https:\\\/\\\/docs.adyen.com\\\/api-explorer\\\/Checkout\\\/latest\\\/post\\\/payments#request-paymentMethod-CardDetails-expiryMonth\\&quot; class=\\&quot;codeLabel  external-link no-image\\&quot; target=\\&quot;_blank\\&quot; rel=\\&quot;nofollow noopener noreferrer\\&quot;&gt;paymentMethod.expiryMonth&lt;\\\/a&gt;&lt;\\\/td&gt;\\n&lt;td&gt;&lt;img title=\\&quot;-white_check_mark-\\&quot; alt=\\&quot;-white_check_mark-\\&quot; class=\\&quot;smileys\\&quot; src=\\&quot;\\\/user\\\/data\\\/smileys\\\/emoji\\\/white_check_mark.png\\&quot; \\\/&gt;&lt;\\\/td&gt;\\n&lt;td&gt;Use the &lt;span translate=\\&quot;no\\&quot;&gt;&lt;strong&gt;applicationExpirationDate&lt;\\\/strong&gt;&lt;\\\/span&gt; value contained in the Apple Pay token.&lt;\\\/td&gt;\\n&lt;\\\/tr&gt;\\n&lt;tr&gt;\\n&lt;td&gt; &lt;a href=\\&quot;https:\\\/\\\/docs.adyen.com\\\/api-explorer\\\/Checkout\\\/latest\\\/post\\\/payments#request-paymentMethod-CardDetails-expiryYear\\&quot; class=\\&quot;codeLabel  external-link no-image\\&quot; target=\\&quot;_blank\\&quot; rel=\\&quot;nofollow noopener noreferrer\\&quot;&gt;paymentMethod.expiryYear&lt;\\\/a&gt;&lt;\\\/td&gt;\\n&lt;td&gt;&lt;img title=\\&quot;-white_check_mark-\\&quot; alt=\\&quot;-white_check_mark-\\&quot; class=\\&quot;smileys\\&quot; src=\\&quot;\\\/user\\\/data\\\/smileys\\\/emoji\\\/white_check_mark.png\\&quot; \\\/&gt;&lt;\\\/td&gt;\\n&lt;td&gt;Use the &lt;span translate=\\&quot;no\\&quot;&gt;&lt;strong&gt;applicationExpirationDate&lt;\\\/strong&gt;&lt;\\\/span&gt; value contained in the Apple Pay token.&lt;\\\/td&gt;\\n&lt;\\\/tr&gt;\\n&lt;tr&gt;\\n&lt;td&gt; &lt;a href=\\&quot;https:\\\/\\\/docs.adyen.com\\\/api-explorer\\\/Checkout\\\/latest\\\/post\\\/payments#request-paymentMethod-CardDetails-holderName\\&quot; class=\\&quot;codeLabel  external-link no-image\\&quot; target=\\&quot;_blank\\&quot; rel=\\&quot;nofollow noopener noreferrer\\&quot;&gt;paymentMethod.holderName&lt;\\\/a&gt;&lt;\\\/td&gt;\\n&lt;td&gt;&lt;img title=\\&quot;-white_check_mark-\\&quot; alt=\\&quot;-white_check_mark-\\&quot; class=\\&quot;smileys\\&quot; src=\\&quot;\\\/user\\\/data\\\/smileys\\\/emoji\\\/white_check_mark.png\\&quot; \\\/&gt;&lt;\\\/td&gt;\\n&lt;td&gt;Use the &lt;span translate=\\&quot;no\\&quot;&gt;&lt;strong&gt;cardholderName&lt;\\\/strong&gt;&lt;\\\/span&gt; value contained in the Apple Pay token.&lt;\\\/td&gt;\\n&lt;\\\/tr&gt;\\n&lt;tr&gt;\\n&lt;td&gt; &lt;a href=\\&quot;https:\\\/\\\/docs.adyen.com\\\/api-explorer\\\/Checkout\\\/latest\\\/post\\\/payments#request-paymentMethod-CardDetails-number\\&quot; class=\\&quot;codeLabel  external-link no-image\\&quot; target=\\&quot;_blank\\&quot; rel=\\&quot;nofollow noopener noreferrer\\&quot;&gt;paymentMethod.number&lt;\\\/a&gt;&lt;\\\/td&gt;\\n&lt;td&gt;&lt;img title=\\&quot;-white_check_mark-\\&quot; alt=\\&quot;-white_check_mark-\\&quot; class=\\&quot;smileys\\&quot; src=\\&quot;\\\/user\\\/data\\\/smileys\\\/emoji\\\/white_check_mark.png\\&quot; \\\/&gt;&lt;\\\/td&gt;\\n&lt;td&gt;Use the &lt;span translate=\\&quot;no\\&quot;&gt;&lt;strong&gt;applicationPrimaryAccountNumber&lt;\\\/strong&gt;&lt;\\\/span&gt; value contained in the Apple Pay token.&lt;\\\/td&gt;\\n&lt;\\\/tr&gt;\\n&lt;tr&gt;\\n&lt;td&gt; &lt;a href=\\&quot;https:\\\/\\\/docs.adyen.com\\\/api-explorer\\\/Checkout\\\/latest\\\/post\\\/payments#request-paymentMethod-CardDetails-brand\\&quot; class=\\&quot;codeLabel  external-link no-image\\&quot; target=\\&quot;_blank\\&quot; rel=\\&quot;nofollow noopener noreferrer\\&quot;&gt;paymentMethod.brand&lt;\\\/a&gt;&lt;\\\/td&gt;\\n&lt;td&gt;&lt;\\\/td&gt;\\n&lt;td&gt;This field is relevant for reconciliation.&lt;\\\/td&gt;\\n&lt;\\\/tr&gt;\\n&lt;tr&gt;\\n&lt;td&gt; &lt;a href=\\&quot;https:\\\/\\\/docs.adyen.com\\\/api-explorer\\\/Checkout\\\/latest\\\/post\\\/payments#request-mpiData-authenticationResponse\\&quot; class=\\&quot;codeLabel  external-link no-image\\&quot; target=\\&quot;_blank\\&quot; rel=\\&quot;nofollow noopener noreferrer\\&quot;&gt;mpiData.authenticationResponse&lt;\\\/a&gt;&lt;\\\/td&gt;\\n&lt;td&gt;&lt;img title=\\&quot;-white_check_mark-\\&quot; alt=\\&quot;-white_check_mark-\\&quot; class=\\&quot;smileys\\&quot; src=\\&quot;\\\/user\\\/data\\\/smileys\\\/emoji\\\/white_check_mark.png\\&quot; \\\/&gt;&lt;\\\/td&gt;\\n&lt;td&gt;Set to \\&quot;&lt;span translate=\\&quot;no\\&quot;&gt;&lt;strong&gt;Y&lt;\\\/strong&gt;&lt;\\\/span&gt;\\&quot;.&lt;\\\/td&gt;\\n&lt;\\\/tr&gt;\\n&lt;tr&gt;\\n&lt;td&gt; &lt;a href=\\&quot;https:\\\/\\\/docs.adyen.com\\\/api-explorer\\\/Checkout\\\/latest\\\/post\\\/payments#request-mpiData-cavv\\&quot; class=\\&quot;codeLabel  external-link no-image\\&quot; target=\\&quot;_blank\\&quot; rel=\\&quot;nofollow noopener noreferrer\\&quot;&gt;mpiData.cavv&lt;\\\/a&gt;&lt;\\\/td&gt;\\n&lt;td&gt;&lt;img title=\\&quot;-white_check_mark-\\&quot; alt=\\&quot;-white_check_mark-\\&quot; class=\\&quot;smileys\\&quot; src=\\&quot;\\\/user\\\/data\\\/smileys\\\/emoji\\\/white_check_mark.png\\&quot; \\\/&gt;&lt;\\\/td&gt;\\n&lt;td&gt;Use the &lt;span translate=\\&quot;no\\&quot;&gt;&lt;strong&gt;onlinePaymentCryptogram&lt;\\\/strong&gt;&lt;\\\/span&gt; value contained in the Apple Pay token.&lt;\\\/td&gt;\\n&lt;\\\/tr&gt;\\n&lt;tr&gt;\\n&lt;td&gt; &lt;a href=\\&quot;https:\\\/\\\/docs.adyen.com\\\/api-explorer\\\/Checkout\\\/latest\\\/post\\\/payments#request-mpiData-directoryResponse\\&quot; class=\\&quot;codeLabel  external-link no-image\\&quot; target=\\&quot;_blank\\&quot; rel=\\&quot;nofollow noopener noreferrer\\&quot;&gt;mpiData.directoryResponse&lt;\\\/a&gt;&lt;\\\/td&gt;\\n&lt;td&gt;&lt;img title=\\&quot;-white_check_mark-\\&quot; alt=\\&quot;-white_check_mark-\\&quot; class=\\&quot;smileys\\&quot; src=\\&quot;\\\/user\\\/data\\\/smileys\\\/emoji\\\/white_check_mark.png\\&quot; \\\/&gt;&lt;\\\/td&gt;\\n&lt;td&gt;Set to \\&quot;&lt;span translate=\\&quot;no\\&quot;&gt;&lt;strong&gt;Y&lt;\\\/strong&gt;&lt;\\\/span&gt;\\&quot;.&lt;\\\/td&gt;\\n&lt;\\\/tr&gt;\\n&lt;tr&gt;\\n&lt;td&gt; &lt;a href=\\&quot;https:\\\/\\\/docs.adyen.com\\\/api-explorer\\\/Checkout\\\/latest\\\/post\\\/payments#request-mpiData-eci\\&quot; class=\\&quot;codeLabel  external-link no-image\\&quot; target=\\&quot;_blank\\&quot; rel=\\&quot;nofollow noopener noreferrer\\&quot;&gt;mpiData.eci&lt;\\\/a&gt;&lt;\\\/td&gt;\\n&lt;td&gt;&lt;img title=\\&quot;-white_check_mark-\\&quot; alt=\\&quot;-white_check_mark-\\&quot; class=\\&quot;smileys\\&quot; src=\\&quot;\\\/user\\\/data\\\/smileys\\\/emoji\\\/white_check_mark.png\\&quot; \\\/&gt;&lt;\\\/td&gt;\\n&lt;td&gt;Use the &lt;span translate=\\&quot;no\\&quot;&gt;&lt;strong&gt;eciIndicator&lt;\\\/strong&gt;&lt;\\\/span&gt; value contained in the Apple Pay token. If you do not receive the &lt;code&gt;eciIndicator&lt;\\\/code&gt; variable in the Apple Pay token, you can omit this parameter from the request.&lt;\\\/td&gt;\\n&lt;\\\/tr&gt;\\n&lt;\\\/tbody&gt;\\n&lt;\\\/table&gt;\\n&lt;pre&gt;&lt;code class=\\&quot;language-curl\\&quot;&gt;curl https:\\\/\\\/checkout-test.adyen.com\\\/v72\\\/payments \\\\\\n-H &#039;x-api-key: ADYEN_API_KEY&#039; \\\\\\n-H &#039;content-type: application\\\/json&#039; \\\\\\n-d &#039;{\\n    \\&quot;amount\\&quot;: {\\n            \\&quot;currency\\&quot;: \\&quot;USD\\&quot;,\\n            \\&quot;value\\&quot;: 1000\\n        },\\n    \\&quot;reference\\&quot;: \\&quot;Your order number\\&quot;,\\n    \\&quot;paymentMethod\\&quot;: {\\n            \\&quot;type\\&quot;: \\&quot;scheme\\&quot;,\\n            \\&quot;brand\\&quot;: \\&quot;applepay\\&quot;,\\n            \\&quot;number\\&quot;: \\&quot;************1234\\&quot;,\\n            \\&quot;expiryMonth\\&quot;: \\&quot;12\\&quot;,\\n            \\&quot;expiryYear\\&quot;: \\&quot;24\\&quot;,\\n            \\&quot;holderName\\&quot;: \\&quot;ApplePay\\&quot;\\n        },\\n    \\&quot;mpiData\\&quot;: {\\n            \\&quot;authenticationResponse\\&quot;: \\&quot;Y\\&quot;,\\n            \\&quot;cavv\\&quot;: \\&quot;II67QpgqW\\\/llYxZSBACWojEBhgA=\\&quot;,\\n            \\&quot;directoryResponse\\&quot;: \\&quot;Y\\&quot;,\\n            \\&quot;eci\\&quot;: \\&quot;07\\&quot;\\n        },\\n    \\&quot;returnUrl\\&quot;: \\&quot;https:\\\/\\\/your-company.example.com\\\/...\\&quot;,\\n    \\&quot;merchantAccount\\&quot;: \\&quot;YOUR_MERCHANT_ACCOUNT\\&quot;\\n}&#039;&lt;\\\/code&gt;&lt;\\\/pre&gt;\\n&quot;,&quot;altTitle&quot;:null,&quot;oldTabId&quot;:&quot;customer_initiated_transaction_0_1&quot;,&quot;relation&quot;:&quot;&quot;},{&quot;title&quot;:&quot;Merchant initiated transaction&quot;,&quot;content&quot;:&quot;\\n&lt;table&gt;\\n&lt;thead&gt;\\n&lt;tr&gt;\\n&lt;th&gt;Parameter name&lt;\\\/th&gt;\\n&lt;th&gt;Required&lt;\\\/th&gt;\\n&lt;th&gt;Description&lt;\\\/th&gt;\\n&lt;\\\/tr&gt;\\n&lt;\\\/thead&gt;\\n&lt;tbody&gt;\\n&lt;tr&gt;\\n&lt;td&gt; &lt;a href=\\&quot;https:\\\/\\\/docs.adyen.com\\\/api-explorer\\\/Checkout\\\/latest\\\/post\\\/payments#request-paymentMethod-CardDetails-expiryMonth\\&quot; class=\\&quot;codeLabel  external-link no-image\\&quot; target=\\&quot;_blank\\&quot; rel=\\&quot;nofollow noopener noreferrer\\&quot;&gt;paymentMethod.expiryMonth&lt;\\\/a&gt;&lt;\\\/td&gt;\\n&lt;td&gt;&lt;img title=\\&quot;-white_check_mark-\\&quot; alt=\\&quot;-white_check_mark-\\&quot; class=\\&quot;smileys\\&quot; src=\\&quot;\\\/user\\\/data\\\/smileys\\\/emoji\\\/white_check_mark.png\\&quot; \\\/&gt;&lt;\\\/td&gt;\\n&lt;td&gt;Use the &lt;span translate=\\&quot;no\\&quot;&gt;&lt;strong&gt;applicationExpirationDate&lt;\\\/strong&gt;&lt;\\\/span&gt; value contained in the Apple Pay token.&lt;\\\/td&gt;\\n&lt;\\\/tr&gt;\\n&lt;tr&gt;\\n&lt;td&gt; &lt;a href=\\&quot;https:\\\/\\\/docs.adyen.com\\\/api-explorer\\\/Checkout\\\/latest\\\/post\\\/payments#request-paymentMethod-CardDetails-expiryYear\\&quot; class=\\&quot;codeLabel  external-link no-image\\&quot; target=\\&quot;_blank\\&quot; rel=\\&quot;nofollow noopener noreferrer\\&quot;&gt;paymentMethod.expiryYear&lt;\\\/a&gt;&lt;\\\/td&gt;\\n&lt;td&gt;&lt;img title=\\&quot;-white_check_mark-\\&quot; alt=\\&quot;-white_check_mark-\\&quot; class=\\&quot;smileys\\&quot; src=\\&quot;\\\/user\\\/data\\\/smileys\\\/emoji\\\/white_check_mark.png\\&quot; \\\/&gt;&lt;\\\/td&gt;\\n&lt;td&gt;Use the &lt;span translate=\\&quot;no\\&quot;&gt;&lt;strong&gt;applicationExpirationDate&lt;\\\/strong&gt;&lt;\\\/span&gt; value contained in the Apple Pay token.&lt;\\\/td&gt;\\n&lt;\\\/tr&gt;\\n&lt;tr&gt;\\n&lt;td&gt; &lt;a href=\\&quot;https:\\\/\\\/docs.adyen.com\\\/api-explorer\\\/Checkout\\\/latest\\\/post\\\/payments#request-paymentMethod-CardDetails-holderName\\&quot; class=\\&quot;codeLabel  external-link no-image\\&quot; target=\\&quot;_blank\\&quot; rel=\\&quot;nofollow noopener noreferrer\\&quot;&gt;paymentMethod.holderName&lt;\\\/a&gt;&lt;\\\/td&gt;\\n&lt;td&gt;&lt;img title=\\&quot;-white_check_mark-\\&quot; alt=\\&quot;-white_check_mark-\\&quot; class=\\&quot;smileys\\&quot; src=\\&quot;\\\/user\\\/data\\\/smileys\\\/emoji\\\/white_check_mark.png\\&quot; \\\/&gt;&lt;\\\/td&gt;\\n&lt;td&gt;Use the &lt;span translate=\\&quot;no\\&quot;&gt;&lt;strong&gt;cardholderName&lt;\\\/strong&gt;&lt;\\\/span&gt; value contained in the Apple Pay token.&lt;\\\/td&gt;\\n&lt;\\\/tr&gt;\\n&lt;tr&gt;\\n&lt;td&gt; &lt;a href=\\&quot;https:\\\/\\\/docs.adyen.com\\\/api-explorer\\\/Checkout\\\/latest\\\/post\\\/payments#request-paymentMethod-CardDetails-number\\&quot; class=\\&quot;codeLabel  external-link no-image\\&quot; target=\\&quot;_blank\\&quot; rel=\\&quot;nofollow noopener noreferrer\\&quot;&gt;paymentMethod.number&lt;\\\/a&gt;&lt;\\\/td&gt;\\n&lt;td&gt;&lt;img title=\\&quot;-white_check_mark-\\&quot; alt=\\&quot;-white_check_mark-\\&quot; class=\\&quot;smileys\\&quot; src=\\&quot;\\\/user\\\/data\\\/smileys\\\/emoji\\\/white_check_mark.png\\&quot; \\\/&gt;&lt;\\\/td&gt;\\n&lt;td&gt;Use the &lt;span translate=\\&quot;no\\&quot;&gt;&lt;strong&gt;applicationPrimaryAccountNumber&lt;\\\/strong&gt;&lt;\\\/span&gt; value contained in the Apple Pay token.&lt;\\\/td&gt;\\n&lt;\\\/tr&gt;\\n&lt;tr&gt;\\n&lt;td&gt; &lt;a href=\\&quot;https:\\\/\\\/docs.adyen.com\\\/api-explorer\\\/Checkout\\\/latest\\\/post\\\/payments#request-paymentMethod-CardDetails-brand\\&quot; class=\\&quot;codeLabel  external-link no-image\\&quot; target=\\&quot;_blank\\&quot; rel=\\&quot;nofollow noopener noreferrer\\&quot;&gt;paymentMethod.brand&lt;\\\/a&gt;&lt;\\\/td&gt;\\n&lt;td&gt;&lt;\\\/td&gt;\\n&lt;td&gt;This field is relevant for reconciliation.&lt;\\\/td&gt;\\n&lt;\\\/tr&gt;\\n&lt;\\\/tbody&gt;\\n&lt;\\\/table&gt;\\n&lt;pre&gt;&lt;code class=\\&quot;language-curl\\&quot;&gt;curl https:\\\/\\\/checkout-test.adyen.com\\\/v72\\\/payments \\\\\\n-H &#039;x-api-key: ADYEN_API_KEY&#039; \\\\\\n-H &#039;content-type: application\\\/json&#039; \\\\\\n-d &#039;{\\n    \\&quot;reference\\&quot; : \\&quot;MY_REFERENCE\\&quot;,\\n    \\&quot;merchantOrderReference\\&quot; : \\&quot;MY_ORDER_REFERENCE\\&quot;,\\n    \\&quot;amount\\&quot; : {\\n            \\&quot;currency\\&quot; : \\&quot;EUR\\&quot;,\\n            \\&quot;value\\&quot; : \\&quot;50000\\&quot;\\n        },\\n    \\&quot;merchantAccount\\&quot; : \\&quot;ADYEN_MERCHANT_ACCOUNT\\&quot;,\\n    \\&quot;recurringProcessingModel\\&quot; : \\&quot;Subscription\\&quot;,\\n    \\&quot;paymentMethod\\&quot; : {\\n            \\&quot;number\\&quot; : \\&quot;************1234\\&quot;,\\n            \\&quot;expiryMonth\\&quot; : \\&quot;12\\&quot;,\\n            \\&quot;expiryYear\\&quot; : \\&quot;2024\\&quot;,\\n            \\&quot;type\\&quot; : \\&quot;scheme\\&quot;,\\n            \\&quot;brand\\&quot; : \\&quot;applepay\\&quot;\\n        },\\n    \\&quot;shopperInteraction\\&quot; : \\&quot;ContAuth\\&quot;,\\n    \\&quot;shopperIP\\&quot; : \\&quot;1.1.1.1\\&quot;,\\n    \\&quot;additionalData\\&quot; : {\\n            \\&quot;networkTxReference\\&quot; : \\&quot;ABCDEF0GH1234\\&quot;\\n        },\\n    \\&quot;billingAddress\\&quot; : {\\n            \\&quot;country\\&quot; : \\&quot;DE\\&quot;,\\n            \\&quot;city\\&quot; : \\&quot;Berlin\\&quot;,\\n            \\&quot;street\\&quot; : \\&quot;Friedrichstr.\\&quot;,\\n            \\&quot;houseNumberOrName\\&quot; : \\&quot;63\\&quot;,\\n            \\&quot;postalCode\\&quot; : \\&quot;10117\\&quot;\\n        }\\n}&#039;\\n&lt;\\\/code&gt;&lt;\\\/pre&gt;\\n&quot;,&quot;altTitle&quot;:null,&quot;oldTabId&quot;:&quot;merchant_initiated_transaction_1_2&quot;,&quot;relation&quot;:&quot;&quot;}]\"\n            :should-update-when-url-changes='false'>\n        <\/tabs>\n    <\/div>\n<\/div>\n","url":"https:\/\/docs.adyen.com\/pt\/payment-methods\/apple-pay\/api-only\/apple-pay-token-decryption","articleFields":{"description":"Learn how to decrypt Apple Pay tokens.","id":"42833055","type":"page","_expandable":{"operations":""},"status":"current","feedback_component":true,"filters_component":false,"decision_tree":"[]","page_id":"0fa4a123-946b-4388-8e17-b21be741566e","last_edit_on":"26-11-2024 14:42"},"algolia":{"url":"https:\/\/docs.adyen.com\/pt\/payment-methods\/apple-pay\/api-only\/apple-pay-token-decryption","title":"Decrypt Apple Pay tokens","content":"An Apple Pay token contains encrypted data of a transaction performed with Apple Pay. Apple Pay tokens enable you to securely pass the data of your shoppers to a payment service provider, like Adyen.\nChoose a decryption method\nIf you are PCI-compliant you have a choice of letting Adyen handle the token decryption, or handling it on your own.\nOnly handle the token decryption on your own in advanced setup scenarios, like when you have to submit Merchant Plug-In (MPI) data in an Apple Pay request.\nA benefit of handling the decryption on your own is that the auditing of transactions becomes easier with the availability of transaction data like shopper names.\nIf you are not PCI-compliant you must let Adyen handle the decryption.\nLet Adyen handle the decryption\nIn-app\nAfter initiating the Apple Pay payment on your mobile application, you receive a callback that includes a PKPayment. This includes paymentData, a stringified version of the payment token. You need to submit this data in your payment request to Adyen.\n\n\nStringify the paymentData from the token \nWhen the request is completed, you receive a PKPayment which contains paymentData. Apple Pay returns more data than we need for authorization, for example a shipping address, but only the paymentData is necessary for authorization.\nConvert the paymentData to a String:\nfunc paymentAuthorizationViewController(_ controller: PKPaymentAuthorizationViewController, didAuthorizePayment payment: PKPayment, completion: @escaping (PKPaymentAuthorizationStatus) -&gt; Void) {\nlet token = payment.token.paymentData.base64EncodedString()\n}\n\n\nSubmit the API request  \nInclude the encoded token from step 1 as the value of applePayToken in the paymentMethod object of your  \/payments request:\n\n\n\n\n\nWeb\nAfter initiating the Apple Pay payment on your website you receive a token in the onPaymentAuthorized event.\nRetrieve the paymentData from the token and convert it to a string. Pass this to your server, and then submit it in a \/payments request to Adyen.\n\n\nStringify the paymentData from the token\nApple Pay returns more data than we need for authorization, for example a shipping address, but only the PaymentData is necessary for authorization. Take this data from the token and convert the JSON to a String and base64-encoded:\nsession.onpaymentauthorized = function(event) {\nvar token = btoa(JSON.stringify(event.payment.token.paymentData));\n};\n\n\nSubmit the API request\nInclude the encoded token from step 1 as the value of applePayToken in the paymentMethod object of your  \/payments request:\n\n\n\n\n\nHandle the decryption on your own\nRequirements\nTo decrypt Apple Pay tokens on your own, you must:\n\nHave an Apple Developer account that is associated with either the Apple Developer Program, or the Apple Developer Enterprise Program.\nUse your own Apple Pay certificate.\nBe PCI-compliant to handle unencrypted card details.\nHave an API-only integration.\n\nDecryption process\n\nVerify the Apple Pay certificate before proceeding to token decryption.\n\nTo decrypt Apple Pay tokens, follow the detailed steps as outlined on the Apple developer portal.\nOverview:\n\nUse the value of publicKeyHash to determine which merchant public key Apple used, and then retrieve the corresponding merchant public key certificate and private key.\nRestore the symmetric key.\nUse the symmetric key to decrypt the value of the data key.\nConfirm that you have not already credited this payment by verifying that no payment with the same transactionId shows as processed.\nVerify the original transaction details of the Apple Pay payment request.\nUse the decrypted payment data to process the payment. See the API reference section below for details.\n\nAPI reference\nThe parameters listed in this section are specific to using decrypted Apple Pay tokens. For descriptions of other parameters go to  \/payments.\nThere are two types of transactions, namely customer initiated and merchant initiated transactions, each with a specific set of parameters.\n\n\n    \n        \n        \n    \n\n","type":"page","locale":"pt","boost":16,"hierarchy":{"lvl0":"Home","lvl1":"Payment methods","lvl2":"Apple Pay","lvl3":"Apple Pay for API only","lvl4":"Decrypt Apple Pay tokens"},"hierarchy_url":{"lvl0":"https:\/\/docs.adyen.com\/pt","lvl1":"https:\/\/docs.adyen.com\/pt\/payment-methods","lvl2":"https:\/\/docs.adyen.com\/pt\/payment-methods\/apple-pay","lvl3":"https:\/\/docs.adyen.com\/pt\/payment-methods\/apple-pay\/api-only","lvl4":"\/pt\/payment-methods\/apple-pay\/api-only\/apple-pay-token-decryption"},"levels":5,"category":"Payment method","category_color":"green","tags":["Decrypt","Apple","tokens"]},"articleFiles":{"apple-pay-inapp-api.js":"<p alt=\"\">apple-pay-inapp-api.js<\/p>","apple-pay-onweb-api.js":"<p alt=\"\">apple-pay-onweb-api.js<\/p>"}}
