PGecom
  • 🚀Introduction
  • đŸŽ¯Guides
    • Getting authenticated
  • 📚Concepts
    • Sandbox Environment
  • 🧑‍đŸ’ģAPI Endpoint
    • Ecommerce
      • đŸ›ī¸Shop
        • GetShopById
        • CreateShop
      • 👔Product
        • ProductSchema
        • GetProductById
        • GetProductBySlug
        • CreateNewProduct
      • 🛒Checkout
        • CreateCheckoutSession
      • Form
        • GetFormById
      • Invoice
        • GetInvoiceById
    • Wordpress Plugin
    • Chrome Extension
    • GiftCards
      • â„šī¸Gift Card Schema
      • ✅List giftcards
      • â˜‘ī¸Order a gift card
      • â˜‘ī¸Get giftcard
      • â˜‘ī¸Rates
    • Send rewards
      • â„šī¸Rewards Schema
      • â˜‘ī¸Send rewards
    • Withdraw
      • â„šī¸Withdraw Schema
      • â˜‘ī¸Process Withdraw
      • â˜‘ī¸Rates
    • Radar
      • â„šī¸Radar Schema
      • â˜‘ī¸Check for Fraudster
    • Top Up
      • â„šī¸Topup Schema
      • â˜‘ī¸Estimate
      • â˜‘ī¸Send
    • Payment
      • Mon Cash
        • CreateMonCashPayment
        • VerifyMonCashPayment
        • WithdrawToMonCashEstimate
        • WithdrawFundsToMonCash
      • PG Pay
        • ConfigurePGPay
        • CreatePGPayPayment
        • VerifyPGPaymentWithToken
        • VerifyPGPaymentWithOrderId
    • Deprecated
      • Card Holder
        • â„šī¸Card Holder Schema
        • â˜‘ī¸Update
      • Card
        • â„šī¸Card Schema
        • ✅Retrieve a single card
        • ✅List cards
        • â˜‘ī¸Create a card
        • â˜‘ī¸Create Customer
  • 🎓Resources
    • Support
    • Production Access
Powered by GitBook
On this page

Was this helpful?

  1. API Endpoint
  2. Ecommerce
  3. Product

CreateNewProduct

This endpoint is there to create new product

POST https://sandbox.pgecom.com/api/v1/product

Headers

Name
Type
Description

Authorization*

String

Bearer {{token}}

Request Body

Name
Type
Description

shopId*

String

The id of the shop

name*

String

Name of the product

price*

Number

The current price of the product

description*

String

Product description

mainImageUrl

String

The main image url

comparePrice

Number

Discount price of the product

costPerItem

Number

The amount of cost per item

inventory

Number

Quantity of products in stock

productType

String

Type of products (physical, digital, service)

status

String

Product status (draft, active, archived)

{
    "name": "Hair",
    "shopId": "0a40d129-0728-4b10-b32e-117abd6938c3",
    "description": "This is another fantastic product. I am looking forward to doing it here",
    "price": 50,
    "productType": "digital",
    "comparePrice": 0,
    "inventory": 20,
    "costPerItem": 0,
    "status": "draft",
    "mainImageUrl": "",
    "id": "0ee6defd-2210-47f6-b624-07f79396ca2a",
    "slug": "hair",
    "isFeatured": false,
    "isContinueSellingOutStock": false,
    "published": false,
    "vendor": "facebook",
    "userID": "5f56dfa3-a415-4818-8275-44fc63ece3fd"
}
{
    "message": "\"shopId\" is required",
    "status": 500
}
{
    "message": "Too many requests, please try again later.",
    "status": 429
}
{
    "message": "Token needs to be provided",
    "status": 401
}

{
    "message": "Shop with id 0a40d129-0728-b10-b32e-117abd6938c3 not found"
}

const axios = require('axios');
let data = {
    "name": "Hair",
    "shopId": "0a40d129-0728-4b10-b32e-117abd6938c3",
    "description": "This is another fantastic product. I am looking forward to doing it here",
    "id": "aa97f0b3-c13d-437d-8d06-d46f0f65a48b",
    "price": "50",
    "productType": "digital",
    "comparePrice": 0,
    "inventory": "20",
    "costPerItem": 0,
    "status": "draft",
    "mainImageUrl": ""
}
let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://sandbox.pgecom.com/api/v1/merchant/product',
  headers: { },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});
import http.client

conn = http.client.HTTPSConnection("https://sandbox.pgecom.com")
payload = {
    "name": "Hair",
    "shopId": "0a40d129-0728-4b10-b32e-117abd6938c3",
    "description": "This is another fantastic product. I am looking forward to doing it here",
    "id": "aa97f0b3-c13d-437d-8d06-d46f0f65a48b",
    "price": "50",
    "productType": "digital",
    "comparePrice": 0,
    "inventory": "20",
    "costPerItem": 0,
    "status": "draft",
    "mainImageUrl": ""
}
headers = {}
conn.request("POST", "/api/v1/merchant/product", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
require "uri"
require "net/http"

url = URI("https://sandbox.pgecom.com/api/v1/merchant/product")

http = Net::HTTP.new(url.host, url.port);
request = Net::HTTP::Post.new(url)
request.body = {
    "name": "Hair",
    "shopId": "0a40d129-0728-4b10-b32e-117abd6938c3",
    "description": "This is another fantastic product. I am looking forward to doing it here",
    "id": "aa97f0b3-c13d-437d-8d06-d46f0f65a48b",
    "price": "50",
    "productType": "digital",
    "comparePrice": 0,
    "inventory": "20",
    "costPerItem": 0,
    "status": "draft",
    "mainImageUrl": ""
}
response = http.request(request)
puts response.read_body
<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('https://sandbox.pgecom.com/api/v1/merchant/product');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
  'follow_redirects' => TRUE
));
$request->setBody({
    "name": "Hair",
    "shopId": "0a40d129-0728-4b10-b32e-117abd6938c3",
    "description": "This is another fantastic product. I am looking forward to doing it here",
    "id": "aa97f0b3-c13d-437d-8d06-d46f0f65a48b",
    "price": "50",
    "productType": "digital",
    "comparePrice": 0,
    "inventory": "20",
    "costPerItem": 0,
    "status": "draft",
    "mainImageUrl": ""
})
try {
  $response = $request->send();
  if ($response->getStatus() == 200) {
    echo $response->getBody();
  }
  else {
    echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
    $response->getReasonPhrase();
  }
}
catch(HTTP_Request2_Exception $e) {
  echo 'Error: ' . $e->getMessage();
}
curl --location 'https://sandbox.pgecom.com/api/v1/merchant/product' \
--data '{
    "name": "Hair",
    "shopId": "0a40d129-0728-4b10-b32e-117abd6938c3",
    "description": "This is another fantastic product. I am looking forward to doing it here",
    "price": "50",
    "productType": "digital",
    "comparePrice": 0,
    "inventory": "20",
    "costPerItem": 0,
    "status": "draft",
    "mainImageUrl": ""
}'
PreviousGetProductBySlugNextCheckout

Last updated 5 months ago

Was this helpful?

🧑‍đŸ’ģ
👔