Skip to content

    Managing payments with Payment API

    This guide is for developers who want to charge and manage payments programmatically using the Payment API.

    Complexity: Medium
    Coding: Yes (Backend)
    Platform:

    Overview

    Whenever your customer buys something on your site, a new payment is created in Checkout. New payments require your action:

    • When you ship the order, make sure to charge the payment in order to receive the funds from Nexi Group.
    • If the order is canceled by the customer, make sure to cancel the payment in order to release the reservation on the customer's payment card.
    • If you have already charged your customer and need to compensate your customer for a returned order etc, you can refund the charge.
    • If your customer has placed an order with multiple items, the amount is reserved. However, if some of the items from the order is out of stock, you can release the reserved amount after with split capture.

    Payments can be managed in Checkout Portal or programmatically through the Payment API. The guide Manage payment describes how to use Checkout Portal to manage payments while this guide shows you how to use the Payment API.

    Retrieve payment details

    The Payment API allows you to fetch details about a payment registered in Checkout.

    First, load your checkout page and go through the checkout flow so that a new payment is created in Checkout. You will need the payment identifier in subsequent requests, so be sure to save the paymentId returned from the create payment method or collect the new payment identifier using webhooks with the payment.created event.

    See the integration guide for more information about creating a new payment object.

    Once you have the new paymentId, you can query the Payment API for the payment details associated with the new payment:

    Retrieve payment details

    <?php
    
    $curl = curl_init();

    As always, remember to replace the text <YOUR_SECRET_API_KEY> and any other parameters within <...>. You can find your integration keys in Checkout Portal.

    Was this helpful?

    What was your feeling about it?