API integration
Alternatively, if you do not wish to embed the Order Management widget in your site, you can integrate Nemuru's Order API for the same purpose: handling an order after the customer has completed the purchase and the order is confirmed.
As some lenders might take a few moments to review the capture/refund request to eventually confirm it, Nemuru proposes an asynchronous, server-side communication between the merchant and Nemuru. That is, the merchant initiates the capture or refund, indicating the items of the order to be captured or returned, and Nemuru processes the request with the corresponding lender. As soon as Nemuru receives the confirmation from the lender, Nemuru sends a server notification to the merchant with the details of the corresponding action.
However, it is possible to avoid asynchronies (awaiting the server notification) by instructing Nemuru to initiate and process the capture/refund transactionally with the lender. In order to do so, make sure to include the transactional
field set to true
in your request.
Check the following diagrams to better understand the sequence of requests:
Capture
Transactional flow
(1) The merchant retrieves the order details in order to get the item IDs, which will be needed when initiating the capture.
(1R) Nemuru returns the order with status code 200.
(2) The merchant initiates the capture by sending a request to Nemuru, indicating which items are to be captured and that the capture needs to be processed transactionally with the lender.
(3) Nemuru sends the capture request to the lender, so the latter can validate and confirm it.
(3R) The lender confirms the capture to Nemuru.
(2R) Nemuru responds with status 201 Created, letting the merchant know that the capture request has been successfully confirmed by the lender.
Asynchronous flow
(1) The merchant retrieves the order details in order to get the item IDs, which will be needed when initiating the capture.
(1R) Nemuru returns the order with status code 200.
(2) The merchant initiates the capture by sending a request to Nemuru, indicating which items are to be captured.
(2R) Nemuru responds with status 201 Created, letting the merchant know that the capture request has been successfully initiated.
(3) Nemuru sends the capture request to the lender, so the latter can validate and confirm it.
(3R) The lender confirms the capture to Nemuru.
(4) Nemuru notifies you (the merchant) that the capture is confirmed by the lender (POST
notification). The body of the request includes the order_id
and additional parameters passed when creating the order, plus the event order_capture_created
value.
(4R) Nemuru expects the merchant to respond to the request (4) with status code 200.
Refund
Transactional flow
(1) The merchant retrieves the order details in order to get the item IDs, which will be needed when initiating the refund.
(1R) Nemuru returns the order with status code 200.
(2) The merchant initiates the refund by sending a request to Nemuru, indicating which items are to be refunded and that the refund needs to be processed transactionally with the lender.
(3) Nemuru sends the refund request to the lender, so the latter can validate and confirm it.
(3R) The lender confirms the refund to Nemuru.
(2R) Nemuru responds with status 201 Created, letting the merchant know that the refund request has been successfully confirmed by the lender.
Asynchronous flow
(1) The merchant retrieves the order details in order to get the item IDs, which will be needed when initiating the refund.
(1R) Nemuru returns the order with status code 200.
(2) The merchant initiates the refund by sending a request to Nemuru, indicating which items are to be refunded.
(2R) Nemuru responds with status 201 Created, letting the merchant know that the refund request has been successfully initiated.
(3) Nemuru sends the refund request to the lender, so the latter can validate and confirm it.
(3R) The lender confirms the refund to Nemuru.
(4) Nemuru notifies you (the merchant) that the refund is confirmed by the lender (POST
notification). The body of the request includes the order_id
and additional parameters passed when creating the order, plus the event order_refund_created
value.
(4R) Nemuru expects the merchant to respond to the request (4) with status code 200.