Integrate using server-side-only integration
Accept payments with your custom-created payment form
Overview
If you want to manage the appearance and operation of your payment form, you can build your own UI on the client side and connect it with the Unzer API on the server side.
If you are building the custom payment form, you can integrate all the payment methods provided by Unzer.
Before you begin
Check the basic integration requirements.
How it works
To integrate a payment method using UI components, you need to perform steps both on the client and the server side.
- Implement the payment form - provide all the necessary fields to gather information required for the specific payment method. Using collected payment information you will create a payment type resource.
- Next, use the ID of the newly created payment type to make a payment using one of the supported server-side technologies (Direct API integration, PHP SDK integration, Java SDK integration). For some payment methods, you must forwarding the customer to an external page.
- After payment is made you should check its status on the server side and display the result to the customer on the client side.
- You can perform more operations on the server side once the payment has been made — a common example would be canceling the payment.
Step 1: Implement the payment form
Depending on the payment method you should provide all the fields required to complete the payment. Below you can see an example for card payment containing credit card number, expiry date, and CVC fields.
Parameter | Type | Description |
---|---|---|
number (required) | string | The card number. |
expiryDate (required) | string | The card expiration date, in the MM/YY format. |
cvc | string | The card verification code. |
cardHolder | string | The cardholder’s name. |
email | string | The email of the cardholder |
Create a Payment Type resource
After payment form submission you need to create a payment type resource for the chosen payment method. The response of the created type will contain an ID, this is later referred to as typeId
. You will need this typeId
to perform the transaction.
POST https://api.unzer.com/v1/payments/charges
{
"number" : "4444333322221111",
"expiryDate" : "04/25",
"cvc": "123",
"3ds": "false",
"cardHolder": "Max Mustermann"
}
// get the 'number', 'expiryDate' and 'cvc' from your payment form.
$unzer = new Unzer($privateKey);
$card = new Card($cardNumber, $expiryDate);
$card->setCvc($cvc)
->setCardHolder('Max Mustermann');
$card = $unzer->createPaymentType($card);
// get the 'number', 'expiryDate' and 'cvc' from your payment form.
Unzer Unzer = new Unzer("s-priv-xxxxxxxxxx");
Card card = new Card(cardNumber, expiryDate);
card.setCvc(cvc);
card.setCardHolder("Max Mustermann");
card = unzer.createPaymentType(card);
For a reference of all payment type creation calls, please refer to the API reference.
Next steps
The next steps are the same as for the UI components integration. Check Integrate using UI components from step 2 onwards.