# Processing payments Important This page describes a necessary step in the **[direct API integration](/developer-portal/direct-integration-landing)** process. It assumes the previous **[checkout integration](/developer-portal/checkout-integration)** step has been completed. If you are using an e-commerce platform such as Magento, Woocommerce or Salesforce, this section is not relevant to your integration of April. With the initial stage of integration complete, you are now ready to configure the customer payment process. Follow these steps to enable functional payment processing. Workflow diagrams of the payment process can be found in the **[technical diagrams](/developer-portal/technical-diagrams#full-payment)** documentation page. ## Step 1 - Retrieving the payment token from customer payments When a customer makes a payment through the April checkout, the system will generate a **payment token** which you can use to actualise a transaction. Customers opting to pay now can select the Card payment option and will be asked to enter their card details. Customers opting to use the Pay in instalments option will be asked to enter their card details, verify their phone number and email address, and finally accept the terms and conditions. In both cases, these actions will generate a payment token. If you have not enabled the “Pay Now” or “Submit Payment Plan” options in the `AprilCheckout.render()` method, you can instead initiate these checks using the `AprilCheckout.submit()` method. If you have added a “Place Order” button to your checkout, it can check if the payment token has been generated already and call `AprilCheckout.submit()` if it hasn’t. `AprilCheckout.submit()` will then process the required details and return the paymentToken via the `paymentToken` callback. Once you have the payment token, pass this to your backend server to initiate the next steps. ## Step 2 - Creating an order When a customer completes the checkout process, an order with April will need to be created. Use the following POST request made from your backend server to the [Create Order](/openapi/april-public/orders/createorder) API endpoint. ## Step 3 - Completing a payment process Once an order has been created you will receive an order identifier (starting with `ordr_`). To complete the transaction and receive your money, make a `POST` request from your backend server with your secret API key to the [Pay Order](/openapi/april-public/orders/payorder) API endpoint using the order identifier and payment token. ```http request POST https://api.au.meetapril.io/orders/ordr_YuceOqGnzB6DXse8/pay Authorization: Bearer YOUR_CREDENTIALS Accept: application/json Content-Type: application/json { "PayByCard": { "paymentTokenId": "ptkn_YucebqEqox6brME1" } } ``` ```json { "transactionId": "tran_YvrnkXYqUW-2JsB1", "transactionStatus": "paid", "amount": 60000, "currency": "AUD", "payType": "payinfull" } ``` If the payment is successful, you will receive a response with the `transactionId` and the `transactionStatus`. If the payment is unsuccessful, you will get a response like below: ```json { "statusCode": 400, "errorCode": "do_not_honor", "message": "Error encountered trying to process this transaction with the payment gateway", "tracer": "329473b4-9e66-4354-aae4-a2170826c289", "detail": "Declined - Do Not Honour", "errorTypeDescription": "The server is unable to process the request due to client error. Most common reasons are a malformed request syntax or values." } ``` The API documentation details all the `errorCode`'s your integration should be prepared to handle. Additional information is provided in [Handling errors and payment actions](/developer-portal/error-handling). ## Step 4 - Initiating a refund To initiate a refund for a successful transaction, create a refund with April with the following `PATCH` request made from your backend server with your merchant secret key or markeplace API key to the [Update Transaction](/openapi/april-public/transactions/updatetransaction) API endpoint. ```http request PATCH https://api.au.meetapril.io/transactions/tran_YvrnkXYqUW-2JsB1 Authorization: Bearer MERCHANT_SECRET_KEY Accept: application/json Content-Type: application/json { "CreateRefund": { "refundAmount": 45000 } } ``` ## What's next? Important The integration is not yet finished. These next steps must be completed to gain full functionality. **[Handling errors and payment actions](/developer-portal/error-handling)** correctly to ensure payments are processed correctly. If you have not yet finished the first stage of integration, return to the **[checkout integration](/developer-portal/checkout-integration)** page. Visit the **[testing](/developer-portal/testing)** documentation page to confirm the integration is fully functional. Return to the initial **[direct API integration](/developer-portal/direct-integration-landing)** landing page. br br **[Return to documentation home](/).**