Ptop Payment Gateway API

Official Enterprise Integration & Compliance Manual

1. Executive Summary (API v3)

Ptop API v3 provides enterprise-grade payment processing capabilities including transaction creation, webhook-based confirmation, HMAC signature verification, transaction status queries, and secure merchant wallet payouts. This version introduces strict separation between server-to-server notifications and customer redirection to ensure reliability and integrity.

2. API Base URLs

EnvironmentEndpoint
LivePOST https://ptop.me/api/v3/payment
SandboxPOST https://ptop.me/api/test/v3/payment

3. Transaction Creation

FieldTypeDescription
website_idstringMerchant identifier
secret_keystringPrivate authentication key
amountnumberMinimum 1 USD
currencystringUSD only
productstringProduct/service name
order_idstringMerchant order reference
webhook_urlurlServer callback endpoint
success_urlurlCustomer redirect after success
fail_urlurlCustomer redirect after cancellation

Example Request

{
 "website_id": "your-id",
 "secret_key": "your-secret",
 "amount": 100.00,
 "currency": "USD",
 "product": "Premium Plan",
 "order_id": "ORD-1001",
 "webhook_url": "https://merchant.com/webhook",
 "success_url": "https://merchant.com/success",
 "fail_url": "https://merchant.com/fail"
}

Example Response

{
 "success": true,
 "transaction_id": "a93kd82hda",
 "payment_url": "https://ptop.me/api/v3/payment/a93kd82hda"
}

Response Code Matrix

HTTP CodeMeaning
200Request successful
400Validation error
401Unauthorized – Invalid credentials
403Signature mismatch
500Internal server error

4. Webhook Delivery Specification

Ptop sends server-to-server POST requests to webhook_url upon transaction update. Your server must return HTTP 200 OK within 10 seconds.

Retry Policy

If no 200 OK is received, Ptop retries delivery up to 3 times with exponential backoff.

Success Payload

{
 "success": true,
 "transaction_id": "a93kd82hda",
 "order_id": "ORD-1001",
 "message": "Payment done",
 "signature": "HMAC_SIGNATURE"
}

5. Signature Verification (HMAC-SHA256)

You MUST hash the RAW request body exactly as received using your the_signature key.

$rawBody = file_get_contents('php://input');
$calculatedSignature = hash_hmac('sha256', $rawBody, $the_signature);

if (!hash_equals($calculatedSignature, $_POST['signature'])) {
 http_response_code(403);
 exit('Invalid signature');
}

6. Payment Status Check

POST https://ptop.me/api/v3/payment-check

Request

{
 "website_id": "your-id",
 "secret_key": "your-secret",
 "transaction_id": "a93kd82hda"
}

Response

{
 "status": 1,
 "amount": 100.00
}
Status CodeDescription
0Pending
1Paid
2Cancelled

7. Merchant Payout API

POST https://ptop.me/api/api-payout

Sends funds from your merchant wallet to a Ptop user. Payouts are executed instantly: there is no pending state and no approval step from the merchant panel.

Request Fields

FieldTypeDescription
website_idstringMerchant identifier
secret_keystringPrivate authentication key
reviverEmailemailEmail of the receiver's Ptop account
amountnumberMinimum 0.01 USD
signaturestringHMAC-SHA256, lowercase hex (see below)
sendingTrxstringYour unique payout reference, max 6 characters. Used for idempotency and status checks.

Data Concatenation (Exact String to Hash)

website_id|secret_key|reviverEmail|amount

Signature Generation

The key is the Signature Key (the_signature) from your merchant panel, not the secret_key.

$data = $website_id . '|' . $secret_key . '|' . $reviverEmail . '|' . $amount;
$signature = hash_hmac('sha256', $data, $the_signature);

Amount Format in the Signature (Important)

When amount is sent as a JSON number, Ptop signs its shortest form: trailing zeros after the decimal point are removed. A zero in the middle stays. Sign the amount in this form, or you will get 403 Signature mismatch.

amount sent (JSON number)Value to sign
2 or 2.002
2.502.5
2.012.01
1.051.05
200.00200

If you send amount as a JSON string (e.g. "2.00"), it is signed exactly as sent (2.00). In all cases, the value you sign must match the value you send.

// PHP: shortest form of the amount
$amountForSignature = rtrim(rtrim(number_format($amount, 2, '.', ''), '0'), '.');

// JavaScript: String() already gives the shortest form
const amountForSignature = String(2.50); // "2.5"

Example Request

{
 "website_id": "w123456",
 "secret_key": "secxyz890",
 "reviverEmail": "client@email.com",
 "amount": 50,
 "signature": "generated_signature",
 "sendingTrx": "A1X9T3"
}

String to hash for this example: w123456|secxyz890|client@email.com|50

Success Response (HTTP 200)

{
 "status": "success",
 "message": "Payment sent successfully.",
 "sendingTrx": "A1X9T3",
 "trx": "api-A9ARVD6JEPD5",
 "amount": 50
}

HTTP 200 with "status": "success" means the funds were moved to the receiver. The payout is final. Do not pay it again manually. Any other response means the payout was not executed and no funds were deducted.

Response Code Matrix

HTTP CodemessageMeaning
200Payment sent successfully.Payout completed
422Validation failed.Invalid fields, or Duplicate request detected (sendingTrx already used)
401Unauthorized or sandbox credentials used.Invalid credentials
403Signature mismatch. Untrusted origin.Wrong signature (check key and amount format)
403Insufficient balance.Not enough funds in your merchant wallet
404Receiver user not found.No Ptop account with this reviverEmail
500Internal server error.Check the status with Payout Status Check before retrying

Timeouts and Retries

If you get no response (timeout), do not pay manually. Call Payout Status Check with the same sendingTrx, or resend the payout with the same sendingTrx: if the first request was executed, you will get 422 Duplicate request detected.

8. Payout Status Check

POST https://ptop.me/api/payout-check

Returns the status of a payout by its sendingTrx. You can only query payouts sent from your own merchant account.

Request

{
 "website_id": "your-id",
 "secret_key": "your-secret",
 "sendingTrx": "A1X9T3"
}

Response – Completed (HTTP 200)

{
 "status": "completed",
 "sendingTrx": "A1X9T3",
 "trx": "api-A9ARVD6JEPD5",
 "amount": 50,
 "currency": "USD",
 "reviverEmail": "client@email.com",
 "created_at": "2026-12-02T06:15:04+00:00",
 "message": "Payout completed."
}

Response – Not Executed (HTTP 404)

{
 "status": "not_found",
 "sendingTrx": "A1X9T3",
 "message": "No payout found for this sendingTrx. It was not executed."
}
HTTP CodestatusMeaning
200completedPayout done. Funds moved to the receiver.
404not_foundPayout not executed. No funds deducted. Safe to retry with the same sendingTrx.
401errorInvalid credentials
422errorValidation failed

created_at is in UTC. Times in the Ptop panel are shown in the platform's local time.

9. Security & Compliance

  • HTTPS is mandatory for all endpoints.
  • IP whitelisting is recommended.
  • All webhooks are signed using HMAC-SHA256.
  • Idempotency enforced via sendingTrx (max 6 characters, unique per payout).
  • Secret keys must never be exposed client-side.

10. Enterprise Support

api_support@ptop.me