Accept Apple Pay with UI components
Overview
Use the Unzer UI v2 component to add the Unzer Apple Pay payment method to your checkout page.
- See the list of prerequisites for Accepting Apple Pay Payments through the Unzer payment system here: Apple Pay Prerequisites
Legacy integration
This page describes the most recent integration of the UI Components, introduced in Jan 2025. For the Legacy integration guide go here.
Using Apple Pay
Apple Pay guidelines
Before you can use Apple Pay as a payment method, you must make sure that your website or app complies with all of the guidelines specified by Apple.
Apple Pay version compatibility
You can accept payments using Apple Pay with the Unzer API. Our code examples use version 6 to provide a good mix of compatibility with most of the Apple devices and the data that you can request from a customer to process orders.
Apple Pay - Good to know
Here are some things that you should keep in mind when implementing Apple Pay in your application:
- The
domainNameparameter from the merchant validation step must be the same as validated for the Apple developer account. - Apple Pay is only available on supported Apple devices. See the full list of supported devices here: Supported devices
- If you are integrating for mobile devices, please read the Guidelines for mobile integrations.
Before you begin
Before you begin- Check the basic integration requirements.
- Familiarize yourself with general guide on integrating using UI components.
Step 1: Add UI components v2 to your payment pageclient side
Step 1: Add UI components v2 to your payment page [client side]First, you need to initiate our UI components v2 library and add the needed payment type component to your payment page.
Initiate UI Components - Apple Pay
Initiate UI Components v2 - Apple PayLoad the Unzer JS script
Load the Unzer JS scriptInclude the Unzer JS script on your website. This will load all the Unzer custom UI components with unzer- prefixed. For example, <unzer-paylater-invoice>.
Make sure to always include the script directly from the Unzer domain https://static-v2.unzer.com.
<script
type="module"
src="https://static-v2.unzer.com/v2/ui-components/index.js"
></script>
To make your website load faster, import the unzer script at the bottom of your HTML document.
Make sure to import the script as type=“module”.
To learn which URLs must be added to the allowlist for Unzer UI components in your content security policy, please refer to Content security policy section.
It is a good practice to put your website in loading state until the Unzer script is loaded, and the UI components are ready to use.
// Make sure initially your application is in loading state
// until all Unzer components are loaded
Promise.all([
customElements.whenDefined("unzer-payment"),
// Probably add any other Unzer components used here. For example:
// customElements.whenDefined("unzer-paylater-invoice"),
]).then(() => {
// Hide the loading state and proceed with next steps
}).catch((error) => {
// Handle any error that might occur during the
// loading process and initialization
});
UI setup and configuration
UI setup and configurationTo securely collect payment data from your customer, you need to add the <unzer-payment> component, inside which you insert the needed payment type components.
<unzer-checkout> element.
This will provide automatic handling for enabling/disabling the submit button depending on the current status,
and showing/hiding of brand icons.<unzer-payment
id="unzer-payment"
publicKey="s-pub-xyz"
locale="de-DE">
<!-- ... Here you will need to add the Unzer payment type tag, so the form UI elements will be inserted -->
<!-- e.g <unzer-paylater-invoice></unzer-paylater-invoice> -->
</unzer-payment>
<unzer-checkout id='unzer-checkout'>
<button type="submit" id="yourPaymentButtonId">Pay</button>
</unzer-checkout>
Following parameters need to be passed.
| Parameter | Type | Description | Default value |
|---|---|---|---|
publicKey (required) | String | The merchant public key. | - |
locale | String | The used locale. For more information on supported locales, see Localization. | Browser user defined locale. |
Customer Data APIs
The <unzer-payment> component exposes public APIs to programmatically access and manage customer data. These APIs enable multi-step checkout flows where customer information and payment are on separate steps.
Use case: Update customer details during checkout, pre-populate forms, or retrieve customer data before final submission.
Read APIs
The following methods return or check customer data:
| Method | Return Type | Description |
|---|---|---|
getCustomerData() | Object | Returns all customer data in PAPI format including personal info, addresses, and metadata (customerId, id, phone, language). |
getValidationErrors() | Object | Returns current validation errors as key-value pairs. Only includes fields with errors. Returns empty object {} if no errors. |
isCustomerValid() | Boolean | Checks if all customer data is valid. Returns true if valid, false if validation errors exist. |
Write APIs
The following methods update or clear customer data:
| Method | Parameters | Description |
|---|---|---|
setCustomerData(data) | data: Object in PAPI format | Pre-populates the entire customer form with provided data. Replaces all existing data. |
updateCustomerData(data) | data: Object in PAPI format | Partially updates customer data. Fields not included in the update are preserved. Useful for updating individual fields without affecting others. |
clearCustomerData() | - | Resets the customer form to empty state. Clears all personal info, addresses, and company data. |
Customer Settings Parameter
To render an empty customer form with a specific customer type (B2C or B2B), use the customerSettings parameter:
// Render empty B2B form (shows company fields)
unzerPayment.setCustomerData({ customerSettings: { type: 'B2B' } });
// Render empty B2C form (shows personal fields) - or omit for default B2C
unzerPayment.setCustomerData({ customerSettings: { type: 'B2C' } });
Valid values:
'B2C'- Individual customer (default if nothing is passed)'B2B'- Business customer
customerSettings.typeonly supports'B2C'and'B2B'- use this to pre-set the form type without pre-populating data- Default behavior: If no
customerSettingsis provided, the form defaults to B2C
All customer data APIs use the PAPI (Payment API) format. The data structure matches the customer resource format from the Unzer API. Fields like
customerId and id can be added or retrieved through these APIs.Example: Multi-step checkout
// Get reference to unzer-payment component
const unzerPayment = document.getElementById('unzer-payment');
// Pre-populate customer data on page load (e.g., from previous session)
const existingCustomerData = {
salutation: 'mr',
firstname: 'John',
lastname: 'Doe',
email: 'john.doe@example.com',
mobile: {
prefix: '+49',
phone: '1234567890'
},
billingAddress: {
firstname: 'John',
lastname: 'Doe',
street: 'Main Street 1',
zip: '12345',
city: 'Berlin',
country: 'DE'
},
shippingAddress: {
firstname: 'John',
lastname: 'Doe',
street: 'Shipping Street 2',
zip: '54321',
city: 'Munich',
country: 'DE'
}
};
unzerPayment.setCustomerData(existingCustomerData);
// Update only specific fields (other fields are preserved)
unzerPayment.updateCustomerData({
email: 'newemail@example.com',
mobile: {
prefix: '+49',
phone: '9876543210'
}
});
// Check if customer data is valid before proceeding to payment
if (unzerPayment.isCustomerValid()) {
const customerData = unzerPayment.getCustomerData();
console.log('Customer data is valid:', customerData);
// Proceed to payment step
} else {
const errors = unzerPayment.getValidationErrors();
console.log('Validation errors:', errors);
// Show errors to user: e.g., {email: "Invalid email format", mobile: "Phone number is required"}
}
// Clear customer form (e.g., on logout or form reset)
unzerPayment.clearCustomerData();
To implement a customer form, check customer UI components page for details.
Customized checkout flow - Apple Pay
Customized checkout flow - Apple PayTo simplify the integration, you can use the <unzer-checkout> custom web component. This tag encapsulates core functionality needed to manage the checkout process efficiently.
<unzer-checkout> should be used with a checkout button as its immediate child.<unzer-checkout id='unzer-checkout'>
<button type="submit">Pay</button>
</unzer-checkout>
Apple Pay integration without Unzer checkout component
If you prefer to implement your own logic, you can decide not to include the <unzer-checkout> component.
In this mode, <unzer-checkout> will trigger a callback function, allowing you to implement your own logic and criteria for managing the button state. You can provide an onPaymentAuthorizedCallback function in the configuration, which lets you implement custom logic to approve or reject the payment by calling approve or reject based on your requirements.
<unzer-payment
id="unzer-payment"
publicKey="{{PUBLIC_KEY}}"
locale="de-DE">
<unzer-apple-pay></unzer-apple-pay>
</unzer-payment>
Promise.all([
customElements.whenDefined("unzer-payment"),
customElements.whenDefined("unzer-apple-pay"),
]).then(() => {
const unzerPayment = document.getElementById('unzer-payment');
const applePayPaymentRequest = {
countryCode: 'DE',
currencyCode: 'EUR',
supportedNetworks: ['visa', 'mastercard'],
merchantCapabilities: ['supports3DS'],
total: { label: 'Unzer GmbH', amount: '12.99' },
lineItems: [
{
"label": "Subtotal",
"type": "final",
"amount": "10.00"
},
{
"label": "Free Shipping",
"amount": "0.00",
"type": "final"
},
{
"label": "Estimated Tax",
"amount": "2.99",
"type": "final"
}
],
onPaymentAuthorizedCallback: async (paymentData, approve, reject) => {
// Implement your business logic validation here
// You can perform additional checks on paymentData before proceeding
if (requirementsNotMet) {
reject();
// Implement user notification for rejection reason
return;
}
const response = await unzerPayment.submit();
// Perform any necessary response validation
// ...
// Handle the payment response and update UI accordingly
// This step is required to proceed with the payment flow
if (response.submitResponse.success) {
approve();
} else {
reject();
}
},
};
unzerPayment.setApplePayData(applePayPaymentRequest);
}).catch((error) => {
// Handle initialization errors
console.error('Failed to initialize Apple Pay:', error);
});
Step 2: Add Apple Pay to your project
First you need to insert the Unzer Apple Pay element <unzer-apple-pay> inside the <unzer-payment>.
<unzer-payment
id="unzer-payment"
publicKey="s-pub-xyz"
locale="de-DE">
<unzer-apple-pay></unzer-apple-pay>
</unzer-payment>
<unzer-checkout id='unzer-checkout'></unzer-checkout>
Create an Apple Pay payment requestclient side
First you need to set-up an ApplePayPaymentRequest. For more information, see Apple Pay Demo - Create a Payment Request.
const applePayPaymentRequest = {
countryCode: 'DE',
currencyCode: 'EUR',
supportedNetworks: ['visa', 'mastercard'],
merchantCapabilities: ['supports3DS'],
total: { label: 'Unzer GmbH', amount: '12.99' },
lineItems: [
{
"label": "Subtotal",
"type": "final",
"amount": "10.00"
},
{
"label": "Free Shipping",
"amount": "0.00",
"type": "final"
},
{
"label": "Estimated Tax",
"amount": "2.99",
"type": "final"
}
],
};
The created payment request can then be used to create the ApplePaySession.
Start the Apple Pay sessionclient side
By calling the setApplePayData method with the valid session object containing all required information you created above, the Apple Pay session will be started. After the session is started, the browser invokes the onvalidatemerchant handler, which will fetch a merchant session from the server, and the merchant validation process is started. The browser then displays the payment sheet.
// This will provide a default onvalidatemerchant implementation
unzerPaymentElement.setApplePayData(applePayPaymentRequest);
<unzer-payment
id="unzer-payment"
publicKey="s-pub-xyz"
locale="de-DE"
>
<unzer-apple-pay></unzer-apple-pay>
</unzer-payment>
const unzerPaymentElement = document.getElementById('unzer-payment');
unzerPaymentElement.setApplePayData(applePayPaymentRequest);
Authorize the payment and create payment type resource
After the customer authenticates the payment via Touch ID, Face ID or passcode, the customer and payment data are automatically submitted. You will then need to query the unzer-checkout element and handle the response inside its onPaymentSubmit event listener.
The following code example shows how to read customer and payment data from the response.
// Make sure that this code is executed after the elements are rendered
const unzerCheckout = document.getElementById('unzer-checkout');
unzerCheckout.onPaymentSubmit = (response) => {
if (response.submitResponse && response.customerResponse) {
if (response.customerResponse.success) {
// Optional: Only in case a new customer is created in the frontend.
const customerId = response.customerResponse.data.id;
}
if (response.submitResponse.success) {
const paymentTypeId = response.submitResponse.data.id;
}
// Submit all IDs to your server-side integration to perform the payment transaction.
}
};
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/html">
<head>
<meta charset="utf-8" />
<title>Apple Pay Payment</title>
<script>
Promise.all([
customElements.whenDefined("unzer-payment"),
]).then(() => {
const unzerPaymentElement = document.getElementById('unzer-payment');
const applePayPaymentRequest = {
countryCode: 'DE',
currencyCode: 'EUR',
supportedNetworks: ['visa', 'mastercard'],
merchantCapabilities: ['supports3DS'],
total: { label: 'Unzer GmbH', amount: '12.99' },
lineItems: [
{
"label": "Subtotal",
"type": "final",
"amount": "10.00"
},
{
"label": "Free Shipping",
"amount": "0.00",
"type": "final"
},
{
"label": "Estimated Tax",
"amount": "2.99",
"type": "final"
}
],
};
unzerPaymentElement.setApplePayData(applePayPaymentRequest);
}).catch((error) => {
// Handle any error that might occur during the
// loading process and initialization
});
// Make sure that this code is executed after the elements are rendered
const unzerCheckout = document.getElementById('unzer-checkout');
unzerCheckout.onPaymentSubmit = (response) => {
if (response.submitResponse && response.customerResponse) {
if (response.customerResponse.success) {
// Optional: Only in case a new customer is created in the frontend.
const customerId = response.customerResponse.data.id;
}
if (response.submitResponse.success) {
const paymentTypeId = response.submitResponse.data.id;
}
// Submit all IDs to your server-side integration to perform the payment transaction.
}
};
</script>
<script
type="module"
src="https://static-v2.unzer.com/v2/ui-components/index.js"
></script>
</head>
<body>
<unzer-payment
id="unzer-payment"
publicKey="{{PUBLIC_KEY}}"
locale="de-DE"
>
<unzer-apple-pay></unzer-apple-pay>
</unzer-payment>
<unzer-checkout id='unzer-checkout'></unzer-checkout>
</body>
</html>
Express Checkoutclient side
You can integrate Apple Pay as express checkout utilizing Apple Pay JS API. It allows you to collect address data from the customer and to update costs based on selected shipping methods. You can find examples of how to collect the customer’s address data and update costs based on the shipping method below.
To access the created Apple Pay session, you can add the initApplePaySession callback to your applePayPaymentRequest. This callback allows you to interact with the Apple Pay session when it’s initialized.
// ... For previously created applePayPaymentRequest object.
// Additionally add the initApplePaySession callback.
applePayPaymentRequest.initApplePaySession = (applePaySession) => {
const session = applePaySession;
},
There are other event handlers that you might need to implement to customize the checkout experience we are not covering in our documentation. Please refer to the Apple Pay documentation ApplePayPaymentRequest page.
For more information about the ApplePaySession object and events you can react on, see the Apple Pay documentation ApplePaySession page.
Collect Customer Address data
To collect the customer address data, you can set the requiredShippingContactFields and requiredBillingContactFields
properties when creating the ApplePayPaymentRequest object.
That way you can get the Address data from the onpaymentauthorized event handler after the authorization of the
payment.
Add these properties to your ApplePayPaymentRequest object as described in section Create an Apple Pay payment request and Session.
let applePayPaymentRequest = {
// ... previously set properties.
// Set the requiredShippingContactFields and requiredBillingContactFields properties
requiredShippingContactFields: ['postalAddress', 'name', 'email', 'phone'],
requiredBillingContactFields: ['postalAddress', 'name', 'email', 'phone'],
};
onpaymentauthorized event handler, you can get the shippingContact and billingContact properties from
the payment object to store the customer address data for your order.// ... previously created session object (ApplePaySession).
session.onpaymentauthorized = function(event) {
// The event will contain the data you need to pass to our server-side integration to actually charge the customers card
let paymentData = event.payment.token.paymentData;
let shippingContact = event.payment.shippingContact; // Store the shipping contact data for express checkout
let billingContact = event.payment.billingContact; // Store the billing contact data for express checkout
// Process the payment...
}
// Add additional event handler functions ...
Update costs based or shipping methods
You can update the costs based on the customer’s shipping method.
You need to provide available shipping methods and the total cost for each shipping method in the shippingMethods
property of the ApplePayPaymentRequest object.
To update the costs based on the customer’s shipping method, you can use the shippingMethodSelected event handler.
This event is called when the customer selects a shipping method.
// ... For previously created applePayPaymentRequest object.
// Additionally set the shippingMethods.
applePayPaymentRequest.shippingMethods = [
{
"label": "Free Shipping",
"detail": "Arrives in 5 to 7 days",
"amount": "0.00",
"identifier": "free"
},
{
"label": "Express Shipping",
"detail": "Arrives in 1 to 2 days",
"amount": "5.99",
"identifier": "express"
}
];
// ... previously created session object (ApplePaySession).
// Set onshippingmethodselected event handler
session.onshippingmethodselected = function(event) {
// Recalculate the total amount based on the shipping method selected.
let shippingMethod = event.shippingMethod;
let subTotal = parseFloat("12.99"); // Price of order items.
let newCost = subTotal + parseFloat(shippingMethod.amount); // Adding shipping costs.
let updateObject = {
newTotal: {
"label": "Unzer GmbH",
"type": "final",
"amount": newCost.toString()
},
newLineItems: [
{
"label": "Bag Subtotal",
"type": "final",
"amount": "10.00"
},
{
"label": shippingMethod.label,
"type": "final",
"amount": shippingMethod.amount
}
]
};
session.completeShippingMethodSelection(updateObject);
}
// ... Add additional event handler functions.
Provide a Payment Authorized Endpointserver side
After the customer has authorized the payment via the Apple Pay overlay (Face ID, Touch ID or device passcode), Safari
will return an object (encrypted Apple Pay token) with data which you need to create the Apple Pay payment type on the
Unzer API. The Unzer payment type will be needed to perform the actual transaction. For this you should provide a
backend controller to accept the typeId from your frontend. This controller returns the result of the API
authorization because Apple Pay uses this to display the result to the customer.
As an example you can have a look at this RequestMapping:
$jsonData = json_decode(file_get_contents('php://input'), false);
$typeId = $jsonData->typeId;
// Catch API errors, write the message to your log and show the ClientMessage to the client.
$response = ['transactionStatus' => 'error'];
try {
// Create an Unzer object using your private key and register a debug handler if you want to.
$unzer = new Unzer('s-priv-xxxxxxxxxxxxxx');
// -> Here you can place the Charge or Authorize call as shown in Step 3 <-
// E.g $transaction = $unzer->performCharge(...);
// Or $transaction = $unzer->performAuthorize(...);
$response['transactionStatus'] = 'pending';
if ($transaction->isSuccess()) {
$response['transactionStatus'] = 'success';
}
} catch (UnzerApiException $e) {
$merchantMessage = $e->getMerchantMessage();
$clientMessage = $e->getClientMessage();
} catch (RuntimeException $e) {
$merchantMessage = $e->getMessage();
}
echo json_encode($response);
String paymentTypeId = getApplePayPaymentTypeIdFromFrontend();
Unzer unzer = new Unzer("s-priv-xxxxxxxxxx");
boolean authStatus = false;
Applepay applepay = unzer.fetchPaymentType(paymentTypeId);
try {
// -> Here you can place the Charge or Authorize call as shown in Step 3 <-
// E.g Charge charge = unzer.charge(...);
// Or Authorize authorize = unzer.authorize(...);
// Set the authStatus based on the resulting Status of the Payment-Transaction
// The functions `charge.getStatus()` or `authorize.getStatus()` will return the `Status-Enum` (`SUCCESS`, `PENDING`, `ERROR`)
if(charge.getStatus().equals(AbstractTransaction.Status.SUCCESS))
{
authStatus = true;
}
} catch (Exception ex) {
log.error(ex.getMessage());
}
return authStatus;
Step 3: Make a paymentserver side
Make a charge transaction
Make a charge or authorize transaction with the Applepay resource that you created earlier. With a successful charge transaction, money is transferred from the customer to the merchant and a payment resource is created. In case of the authorize transaction, it can be charged after the authorization is successful.
POST https://dev-api.unzer.com/v1/payments/charges
Body:
{
"amount" : "49.99",
"currency" : "EUR",
"returnUrl": "http://example.org",
"resources" : {
"typeId" : "s-apl-xxxxxxxxxxxx"
}
}
$unzer = new Unzer('s-priv-xxxxxxxxxx');
$applePay = $unzer->fetchPaymentType('s-apl-xxxxxxxxxxx');
$charge = $applePay->charge(49.99, 'EUR', 'https://www.my-shop-url.de/returnhandler');
Unzer unzer = new Unzer("s-priv-xxxxxxxxxx");
Charge charge = unzer.charge(BigDecimal.valueOf(49.99), Currency.getInstance("EUR"), "s-apl-wqmqea8qkpqy", new URL("https://www.my-shop-url.de/returnhandler"));
The response looks similar to the following example:
{
"id": "s-chg-1",
"isSuccess": true,
"isPending": false,
"isError": false,
"redirectUrl": "",
"message": {
"code": "COR.000.100.112",
"merchant": "Request successfully processed in 'Merchant in Connector Test Mode'",
"customer": "Your payments have been successfully processed in sandbox mode."
},
"amount": "49.9900",
"currency": "EUR",
"returnUrl": "http://example.org",
"date": "2021-05-14 16:01:24",
"resources": {
"paymentId": "s-pay-xxxxxxx",
"traceId": "c6dc23c6fe91a3e1129da83ebd29deb0",
"typeId": "s-apl-xxxxxxxxxxxx"
},
"paymentReference": "",
"processing": {
"uniqueId": "31HA07BC810C911B825D119A51F5A57C",
"shortId": "4849.3448.4721",
"traceId": "c6dc23c6fe91a3e1129da83ebd29deb0"
}
}
Step 4: Check status of the paymentserver side
Step 3: Check status of the payment [server side]Once the customer is redirected to the returnUrl, you can fetch the payment details from the API, by using the resources.paymentId from the charge response above to handle the payment according to its status. If the status of the payment is completed, the payment process has been finished successfully and can be considered as paid. Check all possible payment states here.
GET https://api.unzer.com/v1/payments/{payment_ID}
{
"id": "s-pay-222305",
"state": {
"id": 1,
"name": "completed"
},
"amount": {
"total": "49.9900",
"charged": "49.9900",
"canceled": "0.0000",
"remaining": "0.0000"
},
"currency": "EUR",
"orderId": "",
"invoiceId": "",
"resources": {
"customerId": "",
"paymentId": "s-pay-222305",
"basketId": "",
"metadataId": "",
"payPageId": "",
"traceId": "70ddf3152a798c554d9751a6d77812ae",
"typeId": "s-apl-wqmqea8qkpqy"
},
"transactions": [
{
"date": "2021-05-10 00:51:03",
"type": "charge",
"status": "success",
"url": "https://api.unzer.com/v1/payments/s-pay-222305/charges/s-chg-1",
"amount": "49.9900"
}
]
}
Step 5: Display the payment resultclient side
Step 4: Display the payment result [client side]Use the information from the Check status of the payment step to display the payment result to your customer.
This can be the success or error page of your shop. If something went wrong, you can use the client message from the API response and show it to the customer.
Manage paymentserver side
For more details on managing Apple Pay payments, such as refunding them, see Manage Apple Pay payments.
Notifications
NotificationsWe recommend subscribing to the payment event to receive notifications about any changes to the payment resource. As soon as the event is triggered you should fetch the payment and update the order status in your shop according to its status.
{
"event":"payment.pending",
"publicKey":"s-pub-xxxxxxxxxx",
"retrieveUrl":"https://api.unzer.com/v1/payments/s-pay-774",
"paymentId":"s-pay-774"
}
For more details on implementing webhooks to receive notifications, see Notifications page.
Error handling
Error handlingAll requests to the API can result in an error that should be handled. Refer to the Error handling guide to learn more about Unzer API (and other) errors and handling them.
Hands-on example
The following example contains a sample integration.
Select Edit in JSFiddle to try out the checkout component for yourself. Just replace the publicKey="INSERT YOUR SANDBOX PUBLIC KEY" with your sandbox public key and then select Run.
You can find your sandbox keys in Unzer Insights.
Once you submit the payment, you can view the payment ID in the console of the browser. For example, --- success paymentId s-pit-00naqzqml7ex.
<script
type="module"
src="https://static-v2.unzer.com/v2/ui-components/index.js"
></script>
<div class="box">
<!-- id: Unique HTML identifier for the payment component. -->
<!-- publicKey: Merchant public key provided by Unzer. Replace with your own Unzer public key. -->
<!-- locale: Defines the language of the payment component interface and error messages(e.g., "de-DE" for German, "en-EN" for English). If not set, defaults to browser language. -->
<unzer-payment
id="unzer-payment"
publicKey="INSERT YOUR SANDBOX PUBLIC KEY"
locale="de-DE"
>
<unzer-apple-pay></unzer-apple-pay>
</unzer-payment>
<div class="pay-button">
<unzer-checkout id="unzer-checkout"
><button type="submit" id="yourPaymentButtonId">
Pay
</button></unzer-checkout
>
</div>
</div>
Promise.all([customElements.whenDefined('unzer-payment')]).then(() => {
const unzerPaymentElement = document.getElementById("unzer-payment");
const applePayPaymentRequest = {
countryCode: "DE",
currencyCode: "EUR",
supportedNetworks: ["visa", "mastercard"],
merchantCapabilities: ["supports3DS"],
total: {
label: "Unzer GmbH",
amount: "12.99"
},
lineItems: [{
label: "Subtotal",
type: "final",
amount: "10.00"
}, {
label: "Free Shipping",
amount: "0.00",
type: "final"
}, {
label: "Estimated Tax",
amount: "2.99",
type: "final"
}]
};
unzerPaymentElement.setApplePayData(applePayPaymentRequest);
const unzerCheckout = document.getElementById('unzer-checkout');
unzerCheckout.onPaymentSubmit = (response) => {
if (response.submitResponse && response.submitResponse.success) {
/* Submit the ID of the created payment type resource to your server side integration to perform the payment transaction. */
const paymentId = response.submitResponse.data.id;
console.log("--- success paymentId", paymentId);
} else {
/* Handle resource creation error */ }
};
}).catch((error) => {
/* Handle loading and initialization error */
console.log("--- initialization error", error);
});
:root {
/* Font family */
--unzer-font: SFMono;
/* Brand color */
--unzer-brand-color: #ee1818;
/* Main text color */
--unzer-text-color: #f19316;
/* Background Color */
--unzer-background-color: #6a9472;
/* Link color */
--unzer-link-color: #1330ef;
/* Corner radius in pixels */
--unzer-corner-radius: 0;
/* Enables or disables shadows (1 or 0) */
--unzer-shadows: 1;
}
.box {
/* Changes the box width */
max-width: 300px;
/* Sets horizontal alignment */
margin: auto;
}
.pay-button {
/* Makes the button container full width and centers its content horizontally */
width: 100%;
display: flex;
justify-content: center;
margin-top: 8px;
}
#yourPaymentButtonId {
/* Button background color */
background: #2986e2;
/* Button text color */
color: #fff;
/* Removes border */
border: none;
/* Makes button corners fully rounded */
border-radius: 24px;
/* Button padding */
padding: 10px 32px;
/* Button font size */
font-size: 1rem;
/* Button font weight */
font-weight: 600;
/* Button font family */
font-family: 'Segoe UI', 'Arial', 'Helvetica Neue', 'sans-serif';
/* Shows pointer cursor on hover */
cursor: pointer;
/* Removes outline on focus */
outline: none;
/* Minimum button width */
min-width: 100px;
/* Minimum button height */
min-height: 40px;
/* Makes the button respect width/height and allows centering in flex */
display: inline-block;
}
#yourPaymentButtonId:hover {
/* Button background color on hover */
background: #1565c0;
}
Test & go live
Test & go liveYou should always test your integration before going live. First perform test transactions using test data. Next, check against Integration checklist and Go-live checklist to make sure the integration is complete and you’re ready to go live.
