Update Product
Change or modify a product or service.
This method triggers the Product Updated webhook. This webhook contains the same information as the response.
product
ID of the product.
active
Indicates whether the product is currently available for purchase.
true
attributes
Array of up to 5 alphanumeric strings defined by the merchant. Each string defines the key in a key-value pair in the
attributes
object in the correspondingsku
objects.
name
The name of the product or service that is displayed to the customer.
package_dimensions
Describes the physical size and weight of the product. Relevant when
type
is goods. Contains the following fields:height
length
weight
width
These fields are represented as numbers, but it is the responsibility of the merchant to define and interpret the relevant units of length and weight.
statement_descriptor
A text description that appears in the customer's invoice. Limited to 22 characters. Relevant when
type
is service.
unit_label
A label that represents units of this product, such as seats, on customers’ invoices. Relevant when
type
is service.
Code Samples
.NET
using System; using System.Text.Json; namespace RapydApiRequestSample { class Program { static void Main(string[] args) { try { string product = "product_0d9dc6be69c769560fe913f3b086d8ca"; var metadata = new { merchant_defined = true }; string attributes = new string[] { "color", "armrest", "cover" }; var package_dimensions = new Object[] { new { height = 10 }, new { length = 20 }, new { weight = 100 }, new { width = 40 }, }; string result = RapydApiRequestSample.Utilities.MakeRequest("POST", $"/v1/products/{product}", 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 = { name: 'Gamers Red Chair' }; const result = await makeRequest( 'POST', '/v1/products/product_5d11e30104e3b802c44a08a434aef729', 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 = [ "name" => "Gamer's Red Chair", "statement_descriptor" => "", ]; try { $object = make_request('post', '/v1/products/product_cc7ca57655ce8bc3149d318662b3b8bd', $body); var_dump($object); } catch(Exception $e) { echo "Error: $e"; } ?>
Python
from pprint import pprint from utilities import make_request product = { "name": "Gamer's Red Chair", "attributes": [ "color", "armrest", "cover" ], "metadata": { "merchant_defined": True }, "package_dimensions": { "height": 10, "length": 20, "weight": 100, "width": 40 } } result = make_request(method='post', path='/v1/products/product_0d9dc6be69c769560fe913f3b086d8ca', body=product) pprint(result)
/v1/products/:product
Update Product
curl -X post https://sandboxapi.rapyd.net/v1/products/product_0d9dc6be69c769560fe913f3b086d8ca -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 '{ "name": "Gamer's Red Chair", "attributes": [ "color", "armrest", "cover" ], "metadata": { "merchant_defined": true }, "package_dimensions": { "height": 10, "length": 20, "weight": 100, "width": 40 }, "statement_descriptor": "", "unit_label": "" } '
{ "status": { "error_code": "", "status": "SUCCESS", "message": "", "response_code": "", "operation_id": "039ee3bd-48c9-43ec-8706-6578962f14bb" }, "data": { "id": "product_0d9dc6be69c769560fe913f3b086d8ca", "active": true, "attributes": [ "armrest", "color", "cover" ], "created_at": 1592299157, "description": "The ultimate in comfort for the dedicated gamer.", "metadata": { "merchant_defined": true }, "name": "Gamer's Red Chair", "package_dimensions": { "height": 10, "length": 20, "weight": 100, "width": 40 }, "shippable": true, "skus": [], "statement_descriptor": "", "type": "goods", "unit_label": "", "updated_at": 1592300812 }