REST API
Documentation
- Nederlands
- English
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.
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/example?id=" + order.Id,
Billing = new PrintApi.Input.Checkout.BillingInfo
{
Address = 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 |
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.
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;
}