Charges
Charge an amount.
If your API key is in sandbox mode, customer’s account will not actually be debited, and merchant’s account is not actually credited.
Charge triggers a payment transaction from the customer to the merchant.
There are two options to charge a payment:
- Direct charge
- Charge after authorization
Direct charge
A direct charge is triggered by calling /payments/charges with an amount, a currency, a transaction’s description, and a reference to a payment type. Find all of the details in the documentation API reference.
Direct charge will directly debit customer’s account without any reservation.
Charge after authorization
You can also carry out a two-step procedure in which you first reserve a payment for a customer payment type using an authorization call and then carry out settlement for the authorization. To settle an authorization, you must specify the payment ID or the order ID in the URL.
curl https://api.unzer.com/v1/payments/s-pay-1/charges -X POST \
-u s-priv-xxxxxxxxxx: \
-d amount=1.00
-d paymentReference=Test charge transaction
{
"amount": 50,
"paymentReference": "Test charge transaction"
}
You can call charge with or without an amount. If you do not specify an amount, the full authorization amount will be charged. You can also define description during calling charge. Find more details in the API reference.
It is possible to charge several times per authorization. This is used if you deliver some goods to customers and only want to invoice the delivered goods.
In case you charge multi-times. Please consider total charge request amount cannot be exceed authorized amount. Otherwise, an error will be thrown.
Payment types supporting charge
Not every payment type supports charge. Check the following table to see which payment type does support charge:
Payment method | Supports charge |
---|---|
/types/card | yes (Direct charge & Charge after authorization) |
/types/invoice | yes (Direct charge) |
/types/invoice-secured | yes (Direct charge) |
/types/paypal | yes (Direct charge & Charge after authorization) |
/types/prepayment | yes (Direct charge) |
/types/sepa-direct-debit | yes (Direct charge) |
/types/sepa-direct-debit-secured | yes (Direct charge) |
/types/giropay | yes (Direct charge) |
/types/przelewy24 | yes (Direct charge) |
/types/eps | yes (Direct charge) |
/types/sofort | yes (Direct charge) |
/types/ideal | yes (Direct charge) |
/types/pis | yes (Direct charge) |
/types/bancontact | yes (Direct charge) |
Request Response
Charge transactions are described in the API reference.
Success response example
{
"id": "s-chg-1",
"isSuccess": true,
"isPending": false,
"isError": false,
"message": {
"code": "COR.000.100.112",
"customer": "Request successfully processed in 'Merchant in Connector Test Mode'"
},
"amount": "100.0000",
"currency": "EUR",
"returnUrl": "https://www.unzer.com",
"paymentReference": "Test charge transaction",
"date": "2018-09-13 21:27:16",
"resources": {
"customerId": "",
"paymentId": "s-pay-2",
"basketId": "",
"metadataId": "",
"typeId": "s-crd-fm7tifzkqewy"
},
"processing": {
"uniqueId": "31HA07BC8179DC97ADB61081D525202A",
"shortId": "4008.0043.6848",
"3dsecure": false //card only
}
}
Pending response example
{
"id": "s-chg-1",
"isSuccess": false,
"isPending": true,
"isError": false,
"redirectUrl": "https://payment.unzer.com/v1/redirect/3ds/s-VrcZgTnEEnem",
"message": {
"code": "COR.000.200.000",
"customer": "Transaction pending"
},
"amount": "6.0000",
"currency": "EUR",
"returnUrl": "https://google.com.vn",
"date": "2018-11-30 03:05:39",
"resources": {
"customerId": "",
"paymentId": "s-pay-1227",
"basketId": "",
"metadataId": "",
"typeId": "s-crd-oiwm8rlbezhk"
},
"processing": {
"uniqueId": "31HA07BC815F7DC727FB1B2C017287F9",
"shortId": "4074.7353.9832"
}
}
A direct charge call returns a payment ID and the charge ID 1, since only one direct charge per payment is possible.
The parameters isSuccess, isPending, isError indicate the result of the payment. Only one of these three can be true.
Status parameter | Description |
---|---|
isSuccess | The charge call was executed successfully. |
isPending | The charge call may returns a RedirectUrl. The customer must be redirected to the RedirectUrl so that the customer can complete the payment. The payment method determines whether a charge call can enter the pending state.. |
isError | Something went wrong. You’ll also find a news section that describes in more detail what the trouble was. |
Name | Format | Description |
---|---|---|
id | string | ID of this charge transaction |
isSuccess | string | If the transaction was successful, the value is set to true. |
isPending | string | If the transaction is pending, the value is set to true. E.g. if a redirect to an external system is required. |
isError | string | If an error occurs, this value is set to true. |
redirectUrl | string | If customer’s confirmation is required, a redirect URL will be returned. Customer needs to be redirected to this URL and proceed the confirmation. |
message | object | |
message.code | string | Every error returns a unique id. |
message.customer | string | Error message for your customer translated into the customer language. |
message.merchant | string | Error message for you. This message appears always in English. |
amount | string | The amount to be authorized on the specified account. The amount is rounded depending on the respective currency. |
currency | string(3) | ISO currency code: For a list of possible codes, see: Amounts and Currencies |
returnUrl | string | Some payment methods require the customer to leave the merchant application. This URL is used to bring the customer back to the application. |
paymentReference | string | Transaction description. |
date | date | Timestamp of this transaction. |
resources | object | |
resources.customerId | string | Customer ID used for this transaction. |
resource.basketId | string | Basket ID used for this transaction. |
resource.metadataId | string | Meta data ID used for this transaction. |
resources.paymentId | string | ID of the payment. |
resources.typeId | string | ID of the types Resource that is to be used for this transaction. |
processing | object | |
processing.uniqueId | string | Unique id of the payment system used. |
processing.shortId | string | User-friendly reference ID of the payment system. |
processing.iban | string | Iban of the merchant in case of prepayment or invoice. In case of direct debit, this value contains the customer IBAN. |
processing.bic | string | Bic of the merchant for prepayment or invoice. In the case of a direct debit, this value contains the customer BIC. |
processing.identification | string | This value returns the descriptor for invoice and prepayment. |
processing.creatorId | string | This value returns your creditor id. |
processing.3dsecure | boolean | Indicate a 3ds transaction (card payment type only). |