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. Payment
  3. PG Pay

CreatePGPayPayment

Create a pg pay a checkout session

Create a pg pay payment request

POST https://sandbox.pgecom.com/api/pgpay/token

Request Body

Name
Type
Description

userID*

String

The receiver that's going to receive the funds

amount*

Number

currency

String

We currently only accept htg or usd as currency

orderId

String

Your orderId for internal reference, if not provided, one is creating for you

phone

String

Customer's phone number to autocomplete in the form

description

String

Description of the transaction

successUrl

String

Success url to redirect to when payment is complete

errorUrl

String

Error url to redirect to if payment fails

customerEmail

String

Customer email

customerFirstName

String

Customer first name

customerLastName

String

Customer last name

metadata

Object

Additional data to retrieve when fetching order

isChatEnabled

Boolean

Will disable the pgecom live chat support on the pgpay checkout flow

paymentMethods

Array[String]

You can pass a list of payment methods that you want to enable (ex. pgpay, moncash, crypto)

webhookUrl

string

This can be sent inside the metadata data as metadata.webhookUrl or directly in the payload. This will receive post a request with the following values when the transaction is complete - orderId - status - transactionId - currency - token

{
    "amount": 0.91,
    "userID": "f725076f-ade0-4912-bc86-db1681700d91",
    "id": "41412be3-01fd-488a-a279-cadbe171b5e5",
    "orderId": "41412be3-01fd-488a-a279-cadbe171b5e5",
    "paymentMethod": "pgpay",
    "paymentStatus": "pending",
    "status": "pending",
    "deliveryMethod": "instant",
    "transactionType": "pgpay_deposit",
    "quantity": 1,
    "phone": "+50934748112",
    "gourdes": 55,
    "customerId": "e66d2dac-e514-42b7-8490-de3972709d7e",
    "successUrl": "https://pgecom.com",
    "currency": "htg",
    "sender": "info@pgecom.com",
    "metadata": {
        "is_matched": false,
        "gender": "female",
        "app_name": "Match.com",
        "webhookUrl": "https://webhook.site/40adf10b-9352-4d20-b23a-17d4f1a32a9f",
        "customerEmail": "info@pgecom.com",
        "isProd": false,
        "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJvcmRlcklkIjoiNDE0MTJiZTMtMDFmZC00ODhhLWEyNzktY2FkYmUxNzFiNWU1IiwiaWF0IjoxNzEzNDU5MjE2LCJleHAiOjE3MTM0NjI4MTZ9.-LqeTBDi1vOT1giyOLfnQ5hrpmrtrKbWxB_SqvZD5mU",
        "paymentMethods": [
            "moncash",
            "pgpay"
        ],
        "isChatEnabled": false,
        "pgPayMerchantName": "PGecom",
        "customerFirstName": "",
        "customerLastName": "",
        "returnUrl": "https://sandbox.pgecom.com/payment/pgpay/eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJvcmRlcklkIjoiNDE0MTJiZTMtMDFmZC00ODhhLWEyNzktY2FkYmUxNzFiNWU1IiwiaWF0IjoxNzEzNDU5MjE2LCJleHAiOjE3MTM0NjI4MTZ9.-LqeTBDi1vOT1giyOLfnQ5hrpmrtrKbWxB_SqvZD5mU?merchantName=PGecom&amount=55"
    },
    "platform": "pgrewards",
    "redirectUrl": "http://localhost:3002/payment/pgpay/eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJvcmRlcklkIjoiNDE0MTJiZTMtMDFmZC00ODhhLWEyNzktY2FkYmUxNzFiNWU1IiwiaWF0IjoxNzEzNDU5MjE2LCJleHAiOjE3MTM0NjI4MTZ9.-LqeTBDi1vOT1giyOLfnQ5hrpmrtrKbWxB_SqvZD5mU?merchantName=PGecom&amount=55",
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJvcmRlcklkIjoiNDE0MTJiZTMtMDFmZC00ODhhLWEyNzktY2FkYmUxNzFiNWU1IiwiaWF0IjoxNzEzNDU5MjE2LCJleHAiOjE3MTM0NjI4MTZ9.-LqeTBDi1vOT1giyOLfnQ5hrpmrtrKbWxB_SqvZD5mU"
}
{
    "message": "Order ID 8db0fd57-5494-45d2-8ede-f045ffbd85b9 already exist, please create a new order id",
    "status": 400
}
const axios = require('axios');
let data = {
    "amount": 25,
    "userID": "5f56dfa3-a415-4818-8275-44fc63ece3fd",
    "customerEmail": "info@pgecom.com",
    "customerFirstName": "Esterling",
    "customerLastName": "Accime",
    "successUrl": "/success",
    "errorUrl": "/error"
}

let config = {
  method: 'post',
  url: 'https://sandbox.pgecom.com/api/pgpay/token',
  headers: { },
  data : data
};

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

url = "https://sandbox.pgecom.com/api/pgpay/token"

payload = {
    "amount": 25,
    "userID": "5f56dfa3-a415-4818-8275-44fc63ece3fd",
    "customerEmail": "info@pgecom.com",
    "customerFirstName": "Esterling",
    "customerLastName": "Accime",
    "successUrl": "/success",
    "errorUrl": "/error"
}
headers = {}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)
require "uri"
require "net/http"

url = URI("https://sandbox.pgecom.com/api/pgpay/token")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request.body = {
    "amount": 25,
    "userID": "5f56dfa3-a415-4818-8275-44fc63ece3fd",
    "customerEmail": "info@pgecom.com",
    "customerFirstName": "Esterling",
    "customerLastName": "Accime",
    "successUrl": "/success",
    "errorUrl": "/error"
}
response = https.request(request)
puts response.read_body
<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('https://sandbox.pgecom.com/api/pgpay/token');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
  'follow_redirects' => TRUE
));
$request->setBody({
    "amount": 25,
    "userID": "5f56dfa3-a415-4818-8275-44fc63ece3fd",
    "customerEmail": "info@pgecom.com",
    "customerFirstName": "Esterling",
    "customerLastName": "Accime",
    "successUrl": "/success",
    "errorUrl": "/error"
});
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/pgpay/token' \
--data-raw '{
    "amount": 25,
    "userID": "5f56dfa3-a415-4818-8275-44fc63ece3fd",
    "customerEmail": "info@pgecom.com",
    "customerFirstName": "Esterling",
    "customerLastName": "Accime",
    "successUrl": "/success",
    "errorUrl": "/error"
}'

PreviousConfigurePGPayNextVerifyPGPaymentWithToken

Last updated 11 months ago

Was this helpful?

Amount to charge the customer. Learn more about our fees via this

🧑‍đŸ’ģ
link