How to perform a payment
This section shows how to perform a payment.
Request body
Request body
{ "initialAmount": 100, "currency": "EUR", "product": "paypal", "async": { "successUrl": "https://myshop.com/success/", "failureUrl": "https://myshop.com/fail/", "cancelUrl": "https://myshop.com/cancel/" }, "merchantOrderId": "#0000000001", "description": "Order at myshop.com", "customer": "Customer-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" }
PayPal Debit Payment Body -JSON Format
Parameter | Mandatory | Description |
---|---|---|
initialAmount | mandatory | Amount as smallest currency unit e.g 100€ will be result in amount = 10000 |
currency | mandatory | Currency code according to ISO 4217 |
product | mandatory | Payment product (method) to be used for this order |
async | mandatory* | Mandatory for asynchronous payment products like PayPal |
merchantOrderId | optional | The order id from your system/shop |
description | optional | The description from your system/shop of this order |
customer | mandatory | The customer id which will be used to process this order |
PayPal Debit Payment Body - async - JSON Format
Parameter | Mandatory | Description |
---|---|---|
successUrl | mandatory | In case of a successful order the customer will be redirected to the given URL |
failureUrl | mandatory | In case of a failed order the customer will be redirected to the given URL |
cancelUrl | mandatory | In case of a cancellation by the customer, the customer will be redirected to the given URL |
Find more information on potential body parameters in our API reference.
Send request with curl
Send the request via curl - line breaks for readability
curl --user MerchantID:APIKey \ -H "Content-Type: application/json" -X POST \ -d '{"initialAmount": 100,"currency": "EUR","product": "paypal","async": \ { \ "successUrl": "https://myshop.com/success/", \ "failureUrl": "https://myshop.com/fail/", \ "cancelUrl": "https://myshop.com/cancel/"}, \ "merchantOrderId": "#0000000001", \ "description": "Order at myshop.com", \ "customer": "Customer-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" \ }' \ https://apitest.payengine.de/v1/orders/debit/
curl command - descriptions
We will now touch on every part of this command.
--user MerchantID:APIKey Curl Option for HTTP basic access authentication.
-H "Content-Type: application/json" content-type header "application/json" for our API.
-X POST We want the request to be a HTTP POST.
-d '{"initialAmount": 100,"currency": "EUR","product": "paypal","async": {"successUrl": "https://myshop.com/success/","failureUrl": "https://myshop.com/fail/","cancelUrl": "https://myshop.com/cancel/"},"merchantOrderId": "#0000000001","description": "Order at myshop.com","customer": "Customer-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}' The body for our request in JSON format.
https://apitest.payengine.de/v1/orders/debit/ The orders debit endpoint of our API (Test in this case).
curl command - response
If the Request was successful we should get a response that looks like this:
Response
{ "createdAt": 1502092403541, "modifiedAt": 1502092403557, "merchantId": "Merchant-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "terms": null, "privacy": null, "orderId": "xxxxxxxxx", "merchantOrderId": "#0000000001", "paymentProviderTransactionId": null, "description": "Order at myshop.com", "statementDescription": null, "initialAmount": 100, "preauthorizedAmount": 0, "capturedAmount": 0, "refundedAmount": 0, "canceledAmount": 0, "currency": "EUR", "basket": [], "customer": { "createdAt": 1501757581860, "modifiedAt": 1501757581860, "email": "jane@doe.com", "merchantCustomerId": "xyz", "customerId": "Customer-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "addresses": [], "personas": [], "paymentInstruments": [ { "paymentInstrumentId": "PaymentInstrument-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "merchantPaymentInstrumentId": null, "attributes": null, "encrypted": false, "origin": "paypal", "type": "paypal", "recurring": false, "createdAt": 1502092403535, "modifiedAt": 1502092403535 } ] }, "persona": null, "billingAddress": null, "shippingAddress": null, "ipAddress": null, "paymentInstrument": { "paymentInstrumentId": "PaymentInstrument-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "merchantPaymentInstrumentId": null, "attributes": null, "encrypted": false, "origin": "paypal", "type": "paypal", "recurring": false, "createdAt": 1502092403535, "modifiedAt": 1502092403535 }, "transactions": [ { "createdAt": 1502092403555, "modifiedAt": 1502092403555, "type": "DEBIT", "transactionId": "DebitTransaction-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "description": "Order at myshop.com", "initialAmount": 100, "refundedAmount": 0, "currency": "EUR", "status": "PENDING", "order": "xxxxxxxxx", "parentTransaction": null, "transactions": null, "basket": [] } ], "status": "OPEN", "channel": "ECOM", "source": null, "settled": null, "settlementDate": null, "allowedProducts": [], "product": "paypal", "transactionType": "DEBIT", "meta": null, "async": null, "redirectUrl": "https://apitest.payengine.de/order/paypal/1.0/redirect/Order-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" }
Find more information in our API reference.