Skip to content

    Charge payments

    Charge payment

    When you ship the order to your customer, make sure to charge the payment in order to receive the funds from Nexi Group.

    By default, our system does not automatically charge/capture the amount which has been reserved. Depending on your business model, you should decide on the way how to handle this process. It is our recommendation to do the setup for immediate charge/capture.

    Immediate charge/capture setup

    A payment can be:

    • fully charged (default)
    • partially charged if needed
    • reserve and release partial amount if needed

    Note that it is not possible to charge an amount that exceeds the original order. The system will tell when you exceed the limit. Below is the server code to charge a payment:

    Charge payment

    <?php
    
    $secretKey = "<YOUR_SECRET_API_KEY>";
    $paymentId = "<YOUR_PAYMENT_ID>";

    Enable safe retries by using an idempotency key when creating charges. Read more about retries and idempotency keys in the API reference.

    Full charge

    A full charge only requires you to specify the full amount to be charged, like this:

    Charge payment fully

    payload.json
    {
        "amount": 5500
    }

    Partial charge

    If you instead want to do a partial charge, you need to specify the order items that you charge for. A partial charge is typically used when you only ship a subset of the items ordered, or if you decide to lower the price of the items. Regardless, you always need to specify a new order so that the registered order of the payment aligns with the charge.

    Charge payment partially

    payload.json
    {
        "amount": 2750,
        "orderItems": [
          {

    Charge and release the remaining amount

    When doing a partial charge, it is possible to specify that the remaining reserved amount should be released back to the customer. This can be done by using the flag finalCharge in the charge request. If this is not specified the amount will be released back to the customer when the reservation normally is voided (usually 7 days from the initial reservation).

    Example

    A customer has bought 3 items where only 2 are in stock and will be delivered. To release the remaining reserved amount, simply include the items and amount that should be charged and include the flag finalCharge set to true in the charge request:

    Charge and release remaining amount

    payload.json
    ```
    {
        "amount": 2750,
        "orderItems": [

    You can subscribe to the following webhook events to track charges associated with a payment:

    Was this helpful?

    What was your feeling about it?