Interaction Guide for RMA and RMA Items

Below you will find a walkthrough for quickly generating an RMA and attaching RMA items to it.

1. Create the RMA

An RMA requires two pieces of information: the Order ID and a Refund Action. We will use Order 65 as our order and “storecredit” as our refund action for this example. We add them as parameters to our CURL command as such:

curl -k -X POST 'https://api.gudtech.com/customer/rma/create~1.json' \
    -H 'Content-Type: application/json' \
    -H 'apikey: YOUR_APIKEY_GOES_HERE' \
    -d '{"records": [{ "order_id" : 65, "refund_action": "storecredit" }] }'

Note that we can pass in a list of records above to create multiple RMAs in a single API call.

The command will return a list of records, each with an ID pertaining to the newly created RMA:

{
 "success":1,
 "records":[
            {
              "shipping_amt":"",
              "subtotal_amt":"",
              "product_amt":"",
              "status":"incomplete",
              "refund_amt":"",
              "date_created":"2015-10-27T10:56:44-0700",
              "order_id":"65",
              "tax_amt":"",
              "refund_action":"storecredit",
              "notes":null,
              "discount_amt":"",
              "id":"115"
            }
           ]
}

We’ve successfully created RMA 115. We will use this ID to add RMA Items in the next step.

2. Fetch Aspirational RMA Items

Use the RMA.Item.Fetch action with the with_all_oitems flag to fetch aspirational RMA Items. These are the order items that we plan on basing our new RMA items from. For this we invoke another CURL command, using the ID from the results above in our parameters:

curl -k -X POST 'https://api.gudtech.com/customer/rma/item/fetch~1.json' \
    -H 'Content-Type: application/json' \
    -H 'apikey: YOUR_APIKEY_GOES_HERE' \
    -d '{ "rma_id" : "115", "with_all_oitems":"true"}'

Which returns the single RMA item that corresponds to the order:

{
 "success": 1,
 "records": [
             { 
              "do_refund": "no",
              "sku": "Sku 123",
              "returned_quantity": 0,
              "restocking_fee": null,
              "ship_quantity": "1",
              "give_shipping_amt": null,
              "restock_actor_id": "3",
              "id": "oi-86",
              "unit_price": "75.00",
              "item_type": "ship",
              "rma_item_id": null,
              "sku_id": "40",
              "do_shipping": "no",
              "restock_actor_name": "Testoria",
              "do_restock": "no"
              "order_item_id": "86",
              "component": 0,
              "attributes": [],
              "product_name": "Product 123"
             }
            ]
}

We will use the ID field from each order item record to update the corresponding RMA item. The IDs returned will be prefixed with ‘oi-’ when the “with_all_oitems” flag is set. In any case, the ID value of these records will correspond to the same RMA Item when we use it for updating.

3. Update Aspirational RMA Items to Create Real RMA Items

Please note: Without this update step, the RMA Item will not be created, even if the fetch command returned records.

Suppose we want to set the restock, refund, shipping and quantity values of our returned record. We will use ID ‘oi-86’ in conjunction with the RMA ID 115 to update/create an RMA Item in this next CURL command (note that rma_id is required for this command):

curl -k -X POST 'https://api.gudtech.com/customer/rma/item/update~1.json' \
    -H 'Content-Type: application/json' \
    -H 'apikey: YOUR_APIKEY_GOES_HERE' \
    -d '{ "rma_id" : "115", "records" : [{"id":"oi-86","quantity":"123","do_restock":"local","do_refund":"yes","do_shipping":"no"}] }'

It returns the updated record:

{
 "success": 1,
 "records": [
             { 
              "do_refund": "local",
              "sku": "Sku 123",
              "status": "active",
              "returned_quantity": 0,
              "restocking_fee": "",
              "reason_name": "",
              "ship_quantity": 1,
              "give_shipping_amt": "",
              "restock_actor_id": "3",
              "id": "53",
              "item_shipping_amt": "",
              "unit_price": "75.00",
              "item_type": "ship",
              "rma_id": "115",
              "rma_item_id": "53",
              "quantity": "123",
              "sku_id": "40",
              "do_shipping": "no",
              "restock_actor_name": "Testoria",
              "do_restock": "no",
              "order_item_id": "86",
              "component": 0,
              "reason_id": null,
              "attributes": [],
              "product_name": "Product 123"
             }
            ]
}

4. Complete the RMA

The API creates an RMA of Status: Incomplete so as to give the user a chance to accurately represent its contents. Now that we have updated our items, we can change the status of our new RMA:

curl -k -X POST 'https://api.gudtech.com/customer/rma/update~1.json' \
    -H 'Content-Type: application/json' \
    -H 'apikey: YOUR_APIKEY_GOES_HERE' \
    -d '{ "records" : [{"id":"115", "status":"complete"}] }'

Which will return the updated record id:

{"success":1,"records":[{"id":"115"}]}
Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.
Powered by Zendesk