Skip to main content

Documentation

Create a Return Against an Order

Make a return against an order. The maximum amount of the return is the amount of the order.

Note

It is the responsibility of the merchant to validate the quantity of the items in the return against the quantity of the items in the order.

This method triggers the following webhooks:

    • order

    • ID of the return. String starting with orre_.

  • items

  • Array of objects that describe the goods.

Code Samples
    • .NET

      • using System;
        using System.Text.Json;
        
        namespace RapydApiRequestSample
        {
            class Program
            {
                static void Main(string[] args)
                {
                    try
                    {
                        var items = new Object[]
                        {
                            new
                            {
                                parent = "sku_97f432994f033bd722486ab22fe242d2",
                                amount = 10,
                                type = "sku",
                                quantity = 1,
                            },
                        };
        
                        string order = "order_20bdf9df5841e57ba80e0a68085871ea";
        
                        var requestObj = new
                        {
                            items,
                        };
        
                        string request = JsonSerializer.Serialize(requestObj);
        
                        string result = RapydApiRequestSample.Utilities.MakeRequest("POST", $"/v1/orders/{order}/returns", 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 = {
              items: [
                {
                  parent: 'sku_97f432994f033bd722486ab22fe242d2',
                  amount: '10',
                  type: 'sku',
                  quantity: '1'
                }
              ]
            };
            const result = await makeRequest(
              'POST',
              '/v1/orders/order_20bdf9df5841e57ba80e0a68085871ea/returns',
              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 = [
            "items" =>  array(
                array(
                    "parent" =>  "sku_97f432994f033bd722486ab22fe242d2",
                    "amount" =>  10,
                    "type" =>  "sku",
                    "quantity" =>  1
                )
            ),
        ];
        
        try {
            $object = make_request('post', '/v1/orders/order_20bdf9df5841e57ba80e0a68085871ea/returns', $body);
            var_dump($object);
        } catch(Exception $e) {
            echo "Error =>  $e";
        }
        ?>
    • Python

      • from pprint import pprint
        
        from utilities import make_request
        
        order = {
            "items": [
                {
                    "parent": "sku_97f432994f033bd722486ab22fe242d2",
                    "amount": "10",
                    "type": "sku",
                    "quantity": "1"
                }
            ]
        }
        result = make_request(method='post',
                              path='/v1/orders/order_20bdf9df5841e57ba80e0a68085871ea/returns',
                              body=order)
        pprint(result)
  • /v1/orders/{order}/returns

  • Create a Return Against an Order

  • curl -X post
    https://sandboxapi.rapyd.net/v1/orders/order_ad4cea80c36e3469330c82c44a7b0362/returns
    -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 '{
        "items": [
            {
                "parent": "sku_7e7818cd3cb7c33c194bc278b5c51c88",
                "amount": "10",
                "type": "sku",
                "quantity": "1"
            }
        ]
    }
    '
    
  • {
        "status": {
            "error_code": "",
            "status": "SUCCESS",
            "message": "",
            "response_code": "",
            "operation_id": "21eb3f25-3033-45e4-8137-11287e1a05b7"
        },
        "data": {
            "id": "orre_1bf55355a9334d702be0309e00e75ad4",
            "amount": 5,
            "created": 1597758667,
            "currency": "USD",
            "items": [
                {
                    "amount": 5,
                    "currency": "USD",
                    "description": 0,
                    "parent": "sku_7e7818cd3cb7c33c194bc278b5c51c88",
                    "quantity": 1,
                    "type": "sku"
                }
            ],
            "order": "order_ad4cea80c36e3469330c82c44a7b0362",
            "refund": "refund_2dbd966149fc1c92c273ef6e9ac0fb21"
        }
    }