Create a Source
Create a payment source for alternative payment methods. Sources enable customers to pay via PromptPay QR codes, mobile banking, internet banking, installments, and more.
API Credentials
Request Parametersโ
Required - 3 fieldsRequired Parameters
`amount`INTEGER(required)
Amount in smallest currency unit (satangs for THB, cents for USD, yen for JPY). For example, 100000 satangs = 1,000 THB.
`currency`STRING(required)
ISO 4217 three-letter currency code in lowercase. Must match the payment method type.
`type`STRING(required)
Payment method type. Different types support different currencies.
Recommended - 2 fieldsRecommended Parameters
Additional - 10 fieldsAdditional Parameters
Responsesโ
200
Successful transactionSource created successfully. The response includes payment-specific data like QR codes or redirect URLs.
Common response fields:
id- Source ID (src_*) to use when creating a chargetype- Payment method typeflow- Payment flow: offline (QR code), redirect (web), or app_redirect (mobile app)amount- Source amount in smallest currency unitcurrency- Currency codescannable_code- QR code data for QR-based paymentscharge_status- Status of any charge created with this source
400
Bad requestRequest validation failed. Check the error message for details.
Common causes:
- Missing required fields (
amount,currency,type) - Invalid currency for payment type (e.g., SGD for PromptPay)
- Missing type-specific required fields (e.g., installment_term for installments)
- Invalid payment type
401
UnauthorizedAuthentication failed. Invalid or missing API key.
Common causes:
- Missing Authorization header
- Invalid public key
- Using secret key instead of public key
- Incorrect HTTP Basic Auth format
422
Unprocessable entityRequest validation failed due to business logic constraints.
Common causes:
- Amount below minimum for payment type
- Amount above maximum for payment type
- Payment type not enabled for your account
- Invalid installment term for selected bank
Code samplesโ
- cURL
- Ruby
- Python
- Node.js
- PHP
- Java
- C#
- Go
curl https://api.omise.co/sources \
-u pkey_test_5xuy4w91xqz7d1w9u0t: \
-d "amount=100000" \
-d "currency=thb" \
-d "type=promptpay"
require 'omise'
Omise.api_key = 'pkey_test_5xuy4w91xqz7d1w9u0t'
source = Omise::Source.create({
amount: 100000,
currency: 'thb',
type: 'promptpay'
})
import omise
omise.api_public = 'pkey_test_5xuy4w91xqz7d1w9u0t'
source = omise.Source.create(
amount=100000,
currency='thb',
type='promptpay'
)
const omise = require('omise')({
publicKey: 'pkey_test_5xuy4w91xqz7d1w9u0t'
});
const source = await omise.sources.create({
amount: 100000,
currency: 'thb',
type: 'promptpay'
});
<?php
define('OMISE_PUBLIC_KEY', 'pkey_test_5xuy4w91xqz7d1w9u0t');
$source = OmiseSource::create([
'amount' => 100000,
'currency' => 'thb',
'type' => 'promptpay'
]);
Client client = new Client.Builder()
.publicKey("pkey_test_5xuy4w91xqz7d1w9u0t")
.build();
Source source = client.sources().create()
.amount(100000L)
.currency("thb")
.type("promptpay")
.send();
var client = new Client("pkey_test_5xuy4w91xqz7d1w9u0t");
var source = await client.Sources.Create(new CreateSourceRequest
{
Amount = 100000,
Currency = "thb",
Type = "promptpay"
});
client, _ := omise.NewClient(
"pkey_test_5xuy4w91xqz7d1w9u0t",
"",
)
source, _ := client.Sources().Create(&operations.CreateSource{
Amount: 100000,
Currency: "thb",
Type: "promptpay",
})
Error and result codesโ
Common Error Codesโ
| Code | Description | Resolution |
|---|---|---|
bad_request | Missing or invalid parameters | Check all required fields are provided |
authentication_failure | Invalid API key | Verify your public key is correct |
currency_not_supported | Currency not supported for payment type | Check payment type supports your currency |
amount_too_low | Amount below minimum | Check minimum amount for payment type |
amount_too_high | Amount exceeds maximum | Check maximum amount for payment type |
payment_method_not_allowed | Payment type not enabled | Contact Omise to enable payment method |
Source Flow Typesโ
| Flow | Description |
|---|---|
offline | Customer scans QR code (PromptPay, Alipay) |
redirect | Customer redirected to web page (Internet Banking) |
app_redirect | Customer redirected to mobile app (Mobile Banking) |
Try it outโ
Required - 3 fields
Recommended - 2 fields
Additional - 10 fields