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.

// var order = await client.Orders.PostAsync(...);

var checkout = await client.Checkout.PostAsync(order, _getCheckoutData(order));

Console.WriteLine(checkout.PaymentUrl); // redirect your user here
private PrintApi.Input.Checkout _getCheckoutData(PrintApi.Output.Order order)
{
    return new PrintApi.Input.Checkout
    {
        ReturnUrl = "http://localhost/voorbeeld?id=" + order.Id,
        BillingAddress = new PrintApi.Input.Address
        {
            Name = "John Doe",
            Line1 = "Osloweg 75",
            PostCode = "9700 GE",
            City = "Groningen",
            Country = Country.NL
        }
    };
}
Special fields:
Name Details
"returnUrl" The URL where your user will return after payment
billingAddress["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.

var order = await client.Orders.GetAsync(id);

switch (order.Checkout.Status)
{
    case PaymentStatus.Successful:
        Console.WriteLine("Thanks for your order!");
        break;

    case PaymentStatus.Open:
        Console.WriteLine("Payment was not completed. Please try again.");
        Console.WriteLine(order.Checkout.PaymentUrl);
        break;

    case PaymentStatus.Cancelled:
        Console.WriteLine("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