ProBuy Logo
PB

ProBuy Docs

Version 1.0

Postman Collection Guide

The ProBuy Postman Collection provides a comprehensive set of pre-configured API requests to help you test and develop your integration quickly. Import the collection and start testing all ProBuy API endpoints immediately.

Download and Import

Step 1: Download Postman

If you haven't already, download and install Postman:

Download Postman

Postman is available for Windows, macOS, and Linux. The collection works with Postman v10.0+

Download Postman

Step 1.5: Download ProBuy Collection Files

Download the ProBuy Postman collection and environment files:

Step 2: Import Collection

Import the ProBuy collection into Postman:

  1. 1. Open Postman
  2. 2. Click the "Import" button in the top-left
  3. 3. Drag and drop the downloaded probuy-api-collection.json file
  4. 4. Click "Import"
  5. 5. The collection will appear in your workspace

Step 3: Import Environments

Import environment files for sandbox and production:

  1. 1. Click "Import" in Postman again
  2. 2. Import probuy-sandbox-environment.json for testing
  3. 3. Import probuy-production-environment.json for live use
  4. 4. Both environments will appear in the environment dropdown (top-right)

Environment Configuration

Configure Sandbox Environment

Set up your sandbox environment for testing:

1. Click the environment dropdown (top-right)
2. Select "ProBuy Sandbox (Development)"
3. Click the eye icon to view/edit variables
4. Update these variables:
Variable Name | Value to Update
--------------------- | ---------------------------------
api_token | YOUR_SANDBOX_API_TOKEN (get from supplier portal)
merchant_success_url | https://yourstore.com/payment/success
merchant_failure_url | https://yourstore.com/payment/failure
merchant_cancel_url | https://yourstore.com/payment/cancel
webhook_url | https://webhook.site/YOUR_UNIQUE_URL (for testing)
Pre-configured values (no changes needed):
- base_url: https://sandboxapi.probuy.dev
- supplier_portal: https://sandboxsupplier.probuy.dev

Configure Production Environment

Variable Name | Value to Update
--------------------- | ---------------------------------
api_token | YOUR_PRODUCTION_API_TOKEN (get from supplier portal)
merchant_success_url | https://yourstore.com/payment/success
merchant_failure_url | https://yourstore.com/payment/failure
merchant_cancel_url | https://yourstore.com/payment/cancel
webhook_url | https://yourserver.com/webhooks/probuy
Pre-configured values (no changes needed):
- base_url: https://api.probuy.me
- supplier_portal: https://supplier.probuy.me
- company_portal: https://company.probuy.me

Collection Structure

The collection is organized into logical folders:

📁 1. Authentication

  • • Get API Token
  • • Refresh Token
  • • Validate Token

📁 2. Checkout Management

  • • Create Checkout Session
  • • Get Checkout Details
  • • Update Checkout
  • • Cancel Checkout
  • • List Checkouts

📁 3. Order Management

  • • Get Order Details
  • • List Orders
  • • Update Order Status
  • • Add Order Note

📁 4. Payments & Refunds

  • • Capture Payment
  • • Refund Payment (Full)
  • • Refund Payment (Partial)
  • • Get Refund Details
  • • List Refunds

📁 5. Customer Management

  • • Get Customer Details
  • • Check Eligibility
  • • Get Customer Orders
  • • Get Installment Schedule

📁 6. Webhooks

  • • Register Webhook
  • • List Webhooks
  • • Test Webhook
  • • Delete Webhook
  • • Webhook Verification Example

📁 7. Analytics & Reporting

  • • Get Transaction Summary
  • • Get Revenue Report
  • • Export Transactions
  • • Get Settlement Details

Common API Requests

1. Create Checkout Session

The most common request - creating a new checkout session:

POST {{base_url}}/checkout
Authorization: Bearer {{api_token}}
Content-Type: application/json
{
"orderReferenceId": "ORD-{{$timestamp}}",
"orderNumber": "ORDER-12345",
"currency": "SAR",
"totalAmount": 1500.00,
"taxAmount": 225.00,
"consumer": {
"email": "[email protected]",
"firstName": "Ahmed",
"lastName": "Al-Saud",
"phoneNumber": "+966501234567"
},
"billingAddress": {
"line1": "123 King Fahd Road",
"city": "Riyadh",
"state": "Riyadh Province",
"postalCode": "12345",
"countryCode": "SA"
},
"items": [
{
"name": "Test Product",
"sku": "TEST-001",
"quantity": 1,
"unitPrice": 1500.00,
"totalAmount": 1500.00
}
],
"countryCode": "SA",
"merchantUrls": {
"successUrl": "{{merchant_success_url}}",
"failureUrl": "{{merchant_failure_url}}",
"cancelUrl": "{{merchant_cancel_url}}",
"webhookUrl": "{{webhook_url}}"
}
}
Tests (Pre-written in collection):
pm.test("Status code is 201", function () {
pm.response.to.have.status(201);
});
pm.test("Response has checkoutId", function () {
var jsonData = pm.response.json();
pm.expect(jsonData.checkoutId).to.exist;
pm.environment.set("checkout_id", jsonData.checkoutId);
});

2. Get Checkout Details

GET {{base_url}}/checkout/{{checkout_id}}
Authorization: Bearer {{api_token}}
Tests:
pm.test("Status code is 200", function () {
pm.response.to.have.status(200);
});
pm.test("Checkout has valid status", function () {
var jsonData = pm.response.json();
pm.expect(jsonData.status).to.be.oneOf([
"pending", "approved", "declined", "cancelled", "expired"
]);
});

3. Check Customer Eligibility

POST {{base_url}}/eligibility/check
Authorization: Bearer {{api_token}}
Content-Type: application/json
{
"consumer": {
"email": "[email protected]",
"phoneNumber": "+966501234567"
},
"amount": 1500.00,
"currency": "SAR",
"countryCode": "SA"
}
Tests:
pm.test("Eligibility check returns eligible status", function () {
var jsonData = pm.response.json();
pm.expect(jsonData.eligible).to.be.a('boolean');
pm.expect(jsonData.maxAmount).to.be.a('number');
});

4. Process Refund

POST {{base_url}}/checkout/{{checkout_id}}/refund
Authorization: Bearer {{api_token}}
Content-Type: application/json
{
"amount": 500.00,
"reason": "Customer requested partial refund",
"refundType": "partial"
}
Tests:
pm.test("Refund created successfully", function () {
pm.response.to.have.status(201);
var jsonData = pm.response.json();
pm.expect(jsonData.refundId).to.exist;
pm.environment.set("refund_id", jsonData.refundId);
});

Running Tests

Run Individual Request

  1. 1. Select a request from the collection
  2. 2. Review the request body and parameters
  3. 3. Click "Send"
  4. 4. View response in the lower panel
  5. 5. Check "Test Results" tab for validation

Run Entire Collection

Use Collection Runner to execute all requests sequentially:

1. Click "..." next to collection name
2. Select "Run collection"
3. Configure runner:
- Select environment (ProBuy Sandbox)
- Choose iterations: 1
- Delay: 1000ms between requests
4. Click "Run ProBuy API Collection"
5. View test results and pass/fail status

Automated Testing with Newman

Run the collection from command line using Newman:

# Install Newman
npm install -g newman
# Run collection
newman run probuy-collection.json \
-e probuy-sandbox-environment.json \
--reporters cli,html \
--reporter-html-export ./test-results.html
# Run with specific folder
newman run probuy-collection.json \
-e probuy-sandbox-environment.json \
--folder "Checkout Management"
# Run in CI/CD pipeline
newman run probuy-collection.json \
-e probuy-sandbox-environment.json \
--bail \
--reporters cli,junit \
--reporter-junit-export ./junit-results.xml

Pre-Request Scripts

The collection includes helpful pre-request scripts:

// Generate unique order reference
pm.environment.set("order_reference_id", "ORD-" + Date.now());
// Generate random customer email
pm.environment.set("test_email",
"test-" + Date.now() + "@test.probuy.dev"
);
// Set current timestamp
pm.environment.set("timestamp", new Date().toISOString());
// Calculate tax (15%)
const subtotal = pm.variables.get("subtotal");
const taxAmount = subtotal * 0.15;
pm.environment.set("tax_amount", taxAmount);
pm.environment.set("total_amount", subtotal + taxAmount);

Environment Variables Reference

Variable
base_url
Description
API base URL
Example
https://sandbox-api.probuy.dev/v1
Variable
api_token
Description
Your API authentication token
Example
sk_test_abc123...
Variable
checkout_id
Description
Auto-set from create checkout response
Example
chk_abc123def456
Variable
order_id
Description
Auto-set from order responses
Example
ord_xyz789
Variable
refund_id
Description
Auto-set from refund responses
Example
ref_123abc

Webhook Testing

Test webhook integration using Postman Mock Server or webhook.site:

Using webhook.site

  1. 1. Visit webhook.site
  2. 2. Copy your unique URL
  3. 3. Set it in Postman: webhook_url variable
  4. 4. Create a checkout with this webhook URL
  5. 5. Complete checkout flow
  6. 6. View webhook payload on webhook.site

Webhook Verification Script

// Webhook signature verification (add to test script)
const crypto = require('crypto');
pm.test("Webhook signature is valid", function () {
const signature = pm.request.headers.get('X-ProBuy-Signature');
const body = pm.request.body.raw;
const secret = pm.environment.get('webhook_secret');
const expectedSignature = 'sha256=' +
crypto.createHmac('sha256', secret)
.update(body)
.digest('hex');
pm.expect(signature).to.equal(expectedSignature);
});

Troubleshooting

401 Unauthorized Error

Solutions:

  • • Verify api_token is set correctly in environment
  • • Check token hasn't expired
  • • Ensure using correct environment (sandbox vs production)
  • • Token should start with sk_test_ (sandbox) or sk_live_ (production)

Variables not resolved

Check:

  • • Environment is selected (top-right dropdown)
  • • Variable names match exactly (case-sensitive)
  • • Variables exist in current environment
  • • Check variable scope (environment vs collection vs global)

Test failures

Debug steps:

  • • Check "Test Results" tab for specific failures
  • • Review response body for error messages
  • • Verify request body matches expected format
  • • Check Postman Console (View > Show Postman Console)

Best Practices

Use Sandbox First

Always test with sandbox environment before switching to production. Sandbox uses test data and doesn't process real payments.

Save Your Work

Save modified requests in your own workspace. Fork the collection to keep it separate from future updates.

Use Collection Variables

Store frequently used values as variables. This makes requests easier to maintain and update.

Review Responses

Always review full response bodies. They contain valuable debugging information and show actual data structures.

Document Custom Requests

Add descriptions to custom requests. Future you (and your team) will thank you.

Support

Collection Support

Issues with the Postman collection

Email: [email protected]
GitHub: Report Issues
Response: Within 4 hours

Resources

Additional documentation

Next Steps