Skip to content

Payments

A Payment represents an attempt to collect money from your customer.

POST/v1/payments

Create a new payment

Create a Payment

Creates a new payment and returns a checkout URL.

Request Body

ParameterTypeRequiredDescription
amountintegerAmount in cents (e.g., 1000 = RM 10.00)
currencystringThree-letter ISO currency code. Default: MYR
descriptionstringPayment description (max 255 chars)
success_urlstringURL to redirect on success
cancel_urlstringURL to redirect on cancellation
callback_urlstringWebhook URL for this payment
metadataobjectCustom key-value pairs (max 10 keys)

Example Request

bash
curl https://api.salamgateway.com/v1/payments \
  -H "Authorization: Bearer sk_live_xxx" \
  -H "Content-Type: application/json" \
  -d '{
    "amount": 10000,
    "description": "Order #1234",
    "success_url": "https://example.com/success",
    "cancel_url": "https://example.com/cancel"
  }'
typescript
const salam = new Salam({ apiKey: 'sk_live_xxx' });

const payment = await salam.payments.create({
  amount: 10000,
  description: 'Order #1234',
  success_url: 'https://example.com/success',
  cancel_url: 'https://example.com/cancel',
});
javascript
const salam = new SalamJS('pk_live_xxx');

const payment = await salam.payments.create({
  amount: 10000,
  description: 'Order #1234',
  success_url: 'https://example.com/success',
  cancel_url: 'https://example.com/cancel',
});

Response

json
{
  "id": "pay_abc123xyz",
  "object": "payment",
  "amount": 10000,
  "currency": "MYR",
  "status": "pending",
  "description": "Order #1234",
  "redirect_url": "https://checkout.salamgateway.com/pay/pay_abc123xyz",
  "success_url": "https://example.com/success",
  "cancel_url": "https://example.com/cancel",
  "expires_at": "2024-01-15T12:00:00Z",
  "created_at": "2024-01-15T11:30:00Z"
}

GET/v1/payments/:id

Retrieve a payment

Retrieve a Payment

Retrieves the details of an existing payment.

Path Parameters

ParameterDescription
idThe payment ID

Example

bash
curl https://api.salamgateway.com/v1/payments/pay_abc123 \
  -H "Authorization: Bearer sk_live_xxx"
typescript
const payment = await salam.payments.retrieve('pay_abc123');
javascript
const payment = await salam.payments.retrieve('pay_abc123');

Response

json
{
  "id": "pay_abc123xyz",
  "object": "payment",
  "amount": 10000,
  "currency": "MYR",
  "status": "captured",
  "description": "Order #1234",
  "payment_method": "fpx",
  "payment_method_details": {
    "bank": "Maybank2U",
    "bank_code": "MB2U0227"
  },
  "captured": true,
  "captured_at": "2024-01-15T11:35:00Z",
  "success_url": "https://example.com/success",
  "cancel_url": "https://example.com/cancel",
  "metadata": {},
  "created_at": "2024-01-15T11:30:00Z"
}

GET/v1/payments

List all payments

List Payments

Returns a paginated list of payments.

Query Parameters

ParameterDescription
statusFilter by status: pending, authorized, captured, failed, cancelled
fromStart date (ISO 8601)
toEnd date (ISO 8601)
pagePage number (default: 1)
limitItems per page (default: 20, max: 100)

Example

bash
curl "https://api.salamgateway.com/v1/payments?status=captured&limit=10" \
  -H "Authorization: Bearer sk_live_xxx"
typescript
const payments = await salam.payments.list({
  status: 'captured',
  limit: 10,
});

Response

json
{
  "data": [
    {
      "id": "pay_abc123",
      "object": "payment",
      "amount": 10000,
      "currency": "MYR",
      "status": "captured",
      "created_at": "2024-01-15T11:30:00Z"
    }
  ],
  "meta": {
    "total": 150,
    "page": 1,
    "limit": 10,
    "totalPages": 15
  }
}

POST/v1/payments/:id/capture

Capture an authorized payment

Capture a Payment

Captures an authorized payment.

Path Parameters

ParameterDescription
idThe payment ID

Request Body

ParameterTypeDescription
amountintegerOptional partial capture amount

Example

bash
curl https://api.salamgateway.com/v1/payments/pay_abc123/capture \
  -X POST \
  -H "Authorization: Bearer sk_live_xxx" \
  -H "Content-Type: application/json" \
  -d '{}'
typescript
const payment = await salam.payments.capture('pay_abc123');

POST/v1/payments/:id/void

Void an authorized payment

Void a Payment

Voids an authorized payment that has not been captured.

Path Parameters

ParameterDescription
idThe payment ID

Example

bash
curl https://api.salamgateway.com/v1/payments/pay_abc123/void \
  -X POST \
  -H "Authorization: Bearer sk_live_xxx"
typescript
const payment = await salam.payments.void('pay_abc123');

Payment Object

Attributes

AttributeTypeDescription
idstringUnique payment identifier
objectstringAlways "payment"
amountintegerAmount in cents
currencystringThree-letter ISO currency code
statusstringPayment status
descriptionstringPayment description
payment_methodstringPayment method used (fpx, card)
payment_method_detailsobjectDetails about the payment method
capturedbooleanWhether the payment has been captured
captured_atstringTimestamp when captured
refundedbooleanWhether the payment has been refunded
refunded_amountintegerAmount refunded in cents
metadataobjectCustom metadata
created_atstringCreation timestamp
updated_atstringLast update timestamp

Payment Status

StatusDescription
pendingPayment created, awaiting customer action
authorizedPayment authorized but not captured
capturedPayment captured successfully
failedPayment failed
cancelledPayment cancelled by customer or merchant
expiredPayment expired without completion

Released under the MIT License.