REST API

Documentation


Payment

Print API offers two different ways to pay for orders. If you have your own payment system, you can choose to periodically receive an invoice. In that case, you can skip this step.

Read more about the payment methods in our FAQ.
Optional Payment links

To generate a payment link for an order, simply POST the payment details to the set-up URL of the order. You can obtain this set-up URL in the HTTP response when placing the order. Pricing can be configured per product from your account.

// $order = $api->post('/orders', ...);

$setupUrl = $order->checkout->setupUrl;
$checkout = $api->post($setupUrl, get_checkout_setup($order));

echo $checkout->paymentUrl; // redirect your user here

function get_checkout_setup($order)
{             
    return array(
        'returnUrl' => 'http://localhost/example?order_id=' . $order->id,
        'billing' => array(
            'address' => array(
                'name' => 'Print API',
                'line1' => 'Osloweg 75',
                'postCode' => '9700 GE',
                'city' => 'Groningen',
                'country' => 'NL'
            )
        )
    );
}
Special fields:
Name Details
"returnUrl" The URL where your user will return after payment
address["country"] A ISO 3166-1 alpha 2 country code

If your user completes or cancels the payment, they will be redirected to the returnUrl you supplied in the POST. On that page, you can request the payment status from the API, as shown in the example below. If the payment was not completed, the paymentUrl remains available for up to 24 hours.

// Sample script for your return URL:
            
$id = urlencode($_GET['order_id']);
$order = $api->get('/orders/' . $id);

switch ($order->checkout->status) {

    case 'Successful':
        echo 'Thanks for your order!';
        break;

    case 'Open':
        echo 'Payment was not completed. Please try again. <br />';
        echo $order->checkout->paymentUrl;
        break;

    case 'Cancelled':
        echo 'The payment has expired.';
        break;
}
Print API also has webhooks to automatically notify your server of status changes. More on that in the next step!
Next