Update an Order
Change or modify an order.
You can make the following changes:
When
status
is created:coupon
,metadata
ortax_percent
fields.When
status
is pending, paid, or fulfilled:metadata
orstatus
fields.
When the customer completes a payment, the merchant must change the status
from pending to paid.
This method triggers the Order Updated Webhook. This webhook contains the same information as the response.
Code Samples
.NET
using System; using System.Text.Json; namespace RapydApiRequestSample { class Program { static void Main(string[] args) { try { string order = "order_20bdf9df5841e57ba80e0a68085871ea"; var metadata = new { merchant_defined = true }; var requestObj = new { metadata, tax_percent = 13.5, }; string request = JsonSerializer.Serialize(requestObj); string result = RapydApiRequestSample.Utilities.MakeRequest("POST", $"/v1/orders/{order}", request); Console.WriteLine(result); } catch (Exception e) { Console.WriteLine("Error completing request: " + e.Message); } } } }
JavaScript
const makeRequest = require('<path-to-your-utility-file>/utilities').makeRequest; async function main() { try { const body = { metadata: { number: 1 } }; const result = await makeRequest( 'POST', '/v1/orders/order_20bdf9df5841e57ba80e0a68085871ea', body ); console.log(result); } catch (error) { console.error('Error completing request', error); } }
PHP
<?php $path = $_SERVER['DOCUMENT_ROOT']; $path .= "/<path-to-your-utility-file>/utilities.php"; include($path); $body = [ "tax_percent" => 13.5 ]; try { $object = make_request('post', '/v1/orders/order_20bdf9df5841e57ba80e0a68085871ea', $body); var_dump($object); } catch(Exception $e) { echo "Error: $e"; } ?>
Python
from pprint import pprint from utilities import make_request order = { "metadata": { "merchant_defined": True }, "tax_percent": 13.5 } result = make_request(method='post', path='/v1/orders/order_20bdf9df5841e57ba80e0a68085871ea', body=order) pprint(result)
/v1/orders/:order
Tax Percent
curl -X post https://sandboxapi.rapyd.net/v1/orders/order_90c6a004eb51af10ad8521de4d984a22 -H 'access_key: your-access-key-here' -H 'Content-Type: application/json' -H 'idempotency: your-idempotency-parameter-here' -H 'salt: your-random-string-here' -H 'signature: your-calculated-signature-here' -H 'timestamp: your-unix-timestamp-here' -d '{ "metadata": { "merchant_defined": true }, "tax_percent": 15, "coupon": "" } '
{ "status": { "error_code": "", "status": "SUCCESS", "message": "", "response_code": "", "operation_id": "c737c893-5c3a-4e52-b850-4189e350a736" }, "data": { "id": "order_90c6a004eb51af10ad8521de4d984a22", "amount": 471.5, "amount_returned": 0, "payment": null, "created": 1596103588, "customer": "cus_bb2efee62c0179f563f0d29ba5001051", "currency": "USD", "email": "johndoe@rapyd.net", "external_coupon_code": "", "items": [ { "amount": 10, "currency": "USD", "description": "Shipping", "parent": "", "quantity": 1, "type": "shipping" }, { "amount": 200, "currency": "USD", "description": "Deluxe Gamer's Chair", "parent": "sku_46976a7be5c29d2b2073059877751419", "quantity": 2, "type": "sku" }, { "amount": 61.5, "currency": "USD", "description": "15% tax on total order", "parent": "", "quantity": 0, "type": "tax" } ], "metadata": { "merchant_defined": true }, "returns": [], "shipping_address": { "id": "address_9eb6deb646a279dbdc423f07fa4121ba", "name": "John Doe", "line_1": "", "line_2": "", "line_3": "", "city": "Anytown", "state": "NY", "country": "US", "zip": "12345", "phone_number": "12125559999", "metadata": { "merchant_defined": true }, "canton": "", "district": "", "created_at": 1596103588 }, "status": "created", "status_transitions": { "canceled": 0, "fulfilled": 0, "paid": 0, "returned": 0, "pending": 0, "partial": 0 }, "updated": 1596103988, "upstream_id": "GZC12345", "tax_percent": 15 } }
Status
// Request URL: POST https://sandboxapi.rapyd.net/v1/orders/order_fc5bbe669e7ab546a0f705fe9b90817a // Message body: { "status": "paid" }
{ "status": { "error_code": "", "status": "SUCCESS", "message": "", "response_code": "", "operation_id": "e954d9a6-eaeb-41da-8b87-77c72363d6cd" }, "data": { "id": "order_fc5bbe669e7ab546a0f705fe9b90817a", "amount": 410, "amount_returned": 0, "payment": null, "created": 1636980756, "customer": "cus_8d73840a409c849a0f715ee2fc114410", "currency": "USD", "email": "johndoe@rapyd.net", "external_coupon_code": "", "items": [ { "amount": 200, "currency": "USD", "description": "Deluxe Gamer's Chair", "parent": "sku_8d345036a8520fa7e31d396b97502b19", "quantity": 2, "type": "sku" }, { "amount": 10, "currency": "USD", "description": "Shipping", "parent": "", "quantity": 1, "type": "shipping" } ], "metadata": { "merchant_defined": true }, "returns": [], "shipping_address": { "id": "address_43bd104eac45bcfcf3dc41d125b8c0d9", "name": "John Doe", "line_1": "", "line_2": "", "line_3": "", "city": "Anytown", "state": "NY", "country": "US", "zip": "12345", "phone_number": "12125559999", "metadata": { "merchant_defined": true }, "canton": "", "district": "", "created_at": 1636980756 }, "status": "paid", "status_transitions": { "canceled": 0, "fulfilled": 0, "paid": 1637068431, "returned": 0, "pending": 1637053897, "partial": 0 }, "updated": 1637068431, "upstream_id": "GZC12345", "tax_percent": 0 } }