alt

Important information

Please be advised that there will be a scheduled downtime across our API network on November 05 and November 07, 2024. For more information, visit our platform status portal.:
- Scheduled maintenance on November 5, 2024
- Scheduled maintenance on November 7, 2024

Unzer

Manage Klarna payment

Manage Klarna payments for your customers

After a successful authorize transaction, you can partially or fully charge a payment. You can also make a partial or full refund on the charge transaction later.

For a full reference of managing payments, go to relevant server-side integration documentation page: Manage API resources (direct API calls), Manage API resources (PHP SDK), or Manage API resources (Java SDK).

Full charge

Once you ship the goods to your customer, make a charge transaction. After this, Klarna informs the customer regarding the payment details, like the amount due and where to make the payment.

POST: https://api.unzer.com/v1/payments/s-pay-101/charges

{
}
$unzer = new Unzer('s-priv-xxxxxxxxxx');
$charge = $unzer->performChargeOnPayment('s-pay-101', new Charge());
Unzer unzer = new Unzer("s-priv-xxxxxxxxxx");
Charge charge = unzer.chargeAuthorization("s-pay-101");

The response looks similar to the following example:

{
    "id": "s-chg-1",
    "isSuccess": true,
    "isPending": false,
    "isError": false,
    "card3ds": false,
    "redirectUrl": "",
    "message": {
        "code": "COR.000.000.000",
        "merchant": "Transaction succeeded",
        "customer": "Your payments have been successfully processed."
    },
    "amount": "105.9500",
    "currency": "EUR",
    "date": "2022-09-05 12:47:44",
    "resources": {
        "customerId": "s-cst-6c8fe4e63bf9",
        "paymentId": "s-pay-173",
        "basketId": "s-bsk-7e772dd4266b",
        "metadataId": "",
        "payPageId": "",
        "traceId": "58e301db625ca471f3c8b9b78863ecda",
        "typeId": "s-kla-gixitbjxdm5c"
    },
    "additionalTransactionData": {
        "shipping": {
            "deliveryTrackingId": "00340434286851877897",
            "deliveryService": "DHL",
            "returnTrackingId": "00340412345487812345"
        }
    },
    "orderId": "order-1662381951790-517",
    "paymentReference": "",
    "processing": {
        "uniqueId": "eb51f52d-f803-4025-a09a-0499a20786ea",
        "shortId": "3493.0801.6897",
        "traceId": "58e301db625ca471f3c8b9b78863ecda"
    }
}

Provide shipping information

To track the customer’s order, you can provide shipping information in your charges request.

Shipping information can be provided in the following fields:

ParameterTypeDescription
deliveryTrackingId (optional)stringTracking ID of the selected delivery service provider for the delivery to the customer.
returnTrackingId (optional)stringTracking ID of the selected delivery service provider if the customer is returning goods to you.
deliveryService (optional)stringDelivery service provider used for ship the goods to your customer (such as, DHL, UPS, and Hermes)
POST: https://api.unzer.com/v1/payments/s-pay-101/charges
{
    "amount": "50",
    "additionalTransactionData": {
        "shipping": {
          "deliveryTrackingId": "00340434286851877897",
           "returnTrackingId": "00123434286851877897",
          "deliveryService": "DHL"
        }
}
$unzer = new Unzer('s-priv-xxxxxxxxxx');

$shipping = (new ShippingData())
    ->setDeliveryTrackingId('00340434286851877897')
    ->setReturnTrackingId('00123434286851877897')
    ->setDeliveryService('DHL');

$charge = new Charge();
$charge->setShipping($shipping);

$unzer->performChargeOnPayment('s-pay-101', $charge);
Unzer unzer = new Unzer("s-priv-xxxxxxxxxx");

AdditionalTransactionData additionalTransactionData = new AdditionalTransactionData()
        .setShipping(new ShippingTransactionData()
                .setDeliveryTrackingId("00340434286851877897")
                .setReturnTrackingId("00123434286851877897")
                .setDeliveryService("DHL")
        );

Charge charge = new Charge()
        .setAmount(BigDecimal.valueOf(500.5))
        .setCurrency(Currency.getInstance("EUR"))
        .setReturnUrl(unsafeUrl("https://unzer.com"))
        .setPaymentId("s-pay-101")
        .setAdditionalTransactionData(additionalTransactionData);

unzer.chargeAuthorization(charge);

Partial charge

If you ship an order in multiple steps, you can make make a partial charge for each part you want to ship.

POST: https://api.unzer.com/v1/payments/s-pay-101/charges

{
  "amount" : "50"
}
$unzer = new Unzer('s-priv-xxxxxxxxxx');
$charge = new Charge(50);

$unzer->performChargeOnPayment('s-pay-101', $charge);
Unzer unzer = new Unzer("s-priv-xxxxxxxxxx");
Charge charge = unzer.chargeAuthorization("s-pay-101", BigDecimal.valueOf(50.0));

The response looks similar to the following example:

{
    "id": "s-chg-1",
    "isSuccess": true,
    "isPending": false,
    "isError": false,
    "card3ds": false,
    "message": {
        "code": "COR.000.000.000",
        "merchant": "Transaction succeeded",
        "customer": "Your payments have been successfully processed."
    },
    "amount": "50.0000",
    "currency": "EUR",
    "date": "2022-09-07 07:50:05",
    "resources": {
        "customerId": "s-cst-fd71259f772e",
        "paymentId": "s-pay-178",
        "basketId": "s-bsk-6a2a6a016c5d",
        "metadataId": "",
        "payPageId": "",
        "traceId": "e174d228870b0d28ee7bed9c8e6b9448",
        "typeId": "s-kla-c4smukjmblo6"
    },
    "orderId": "order-1662536943915-994",
    "paymentReference": "",
    "processing": {
        "uniqueId": "fac72ce4-2d37-473a-a0c6-90a81b8586d5",
        "shortId": "3542.6775.3793",
        "traceId": "e174d228870b0d28ee7bed9c8e6b9448"
    }
}

Cancel before charge (reversal)

If the customer cancels an order completely before you ship the goods or if the goods are not available in stock, you must cancel the order by initializing a reversal.

icon
If the customer is not cancelling the order completely, you don’t need a reversal transaction. Only charge the remaining items as soon as you ship them.
POST: https://api.unzer.com/v1/payments/s-pay-101/authorize/cancels

{
}
$unzer = new Unzer('s-priv-xxxxxxxxxx');
$cancel = $unzer->cancelAuthorizedPayment('s-pay-101');
Unzer unzer = new Unzer("s-priv-xxxxxxxxxx");
Cancel cancel = unzer.cancelAuthorization("s-pay-101");

The response looks similar to the following example:

{
    "id": "s-cnl-1",
    "isSuccess": true,
    "isPending": false,
    "isError": false,
    "card3ds": false,
    "message": {
        "code": "COR.000.000.000",
        "merchant": "Transaction succeeded",
        "customer": "Your payments have been successfully processed."
    },
    "amount": "105.9500",
    "currency": "EUR",
    "date": "2022-09-07 06:27:15",
    "resources": {
        "customerId": "s-cst-aca01e999567",
        "paymentId": "s-pay-177",
        "basketId": "s-bsk-b3ecac2d3f40",
        "metadataId": "",
        "payPageId": "",
        "traceId": "0bab5a0c7e25dd10c8c9d761cf32239d",
        "typeId": "s-kla-yzqihi0vk22c"
    },
    "orderId": "order-1662465734746-967",
    "paymentReference": "",
    "processing": {
        "uniqueId": "b07c9031-b918-4267-9a0f-28fdb9a69324",
        "shortId": "3519.8907.0240",
        "traceId": "0bab5a0c7e25dd10c8c9d761cf32239d"
    }
}

Cancel after charge (refund)

In case you already charged a payment for an order that the customer wants to cancel/return, you can refund it up to the charged amount. To do this you have to make a cancels transaction on the respective paymentId.

POST: https://api.unzer.com/v1/payments/s-pay-101/charges/cancels

{
  "amount" : "105.95"
}
$unzer = new Unzer('s-priv-xxxxxxxxxx');
$cancel = $unzer->cancelChargedPayment('s-pay-101', new Cancellation(105.95));
Unzer unzer = new Unzer("s-priv-xxxxxxxxxx");
Cancel cancel = unzer.cancelCharge("s-pay-101", BigDecimal.valueOf(10.0));

The response looks similar to the following example:

{
    "id": "s-cnl-1",
    "isSuccess": true,
    "isPending": false,
    "isError": false,
    "card3ds": false,
    "message": {
        "code": "COR.000.000.000",
        "merchant": "Transaction succeeded",
        "customer": "Your payments have been successfully processed."
    },
    "amount": "105.9500",
    "currency": "EUR",
    "date": "2022-09-07 08:03:32",
    "resources": {
        "customerId": "s-cst-9529d7bb0a01",
        "paymentId": "s-pay-179",
        "basketId": "s-bsk-8814e569e6ed",
        "metadataId": "",
        "payPageId": "",
        "traceId": "15926308bc5bfc020de083b206f300ab",
        "typeId": "s-kla-oiebatzvtewm"
    },
    "orderId": "order-1662537504002-624",
    "paymentReference": "",
    "processing": {
        "uniqueId": "7d87d4b7-f8d4-4cbd-b0e1-255cbc695f71",
        "shortId": "3542.8567.5456",
        "traceId": "15926308bc5bfc020de083b206f300ab"
    }
}
icon
The charges initialized after the authorize are actual payments and can be refunded by canceling them.