Source API
ในการรับชำระเงินผ่านช่องทางใดๆ ที่นอกเหนือจากบัตรเครดิตและบัตรเดบิต ให้ทำการสร้าง source ของรายการนั้นๆ ก่อนแล้วจึงนำ source ไปสร้างรายการรับชำระเงิน
Attributes
Name | Type | Description |
---|---|---|
object | string | The string |
id | string | The source identifier matching |
livemode | boolean | Whether this is a live ( |
location | string | API path to retrieve the current |
absorption_type | string | Which entity absorbs interest for installment payments. One of |
amount | integer | Source amount in smallest unit of source currency |
bank | string | Bank ( |
barcode | string | Barcode number ( |
billing | object | Billing address. See source creation parameters for more details. |
charge_status | string | Status of charge created using this source (if any). Value is one of allowed |
created_at | string | UTC datetime of source creation in ISO 8601 format ( |
currency | string | Currency for source as three-letter ISO 4217 code |
discounts | array | Discounts ( |
string | Payer email address ( |
|
flow | string | The payment flow payers need to go through to complete the payment. One of
|
installment_term | integer | Installment term in months. See installments for allowed values ( |
ip | string | IP address provided to Opn Payments at source creation. May be IPv4 or IPv6. |
items | array | Information about items included in the order. See source creation parameters for more details. |
mobile_number | string | Payer phone number ( |
name | string | Payer name ( |
phone_number | string | Payer phone number ( |
platform_type | string | Platform from which payer is making a payment. One of WEB, IOS, or ANDROID. |
promotion_code | string | The code that grants access to special offers or discounts provided by the service provider. |
provider_references | object | Denotes the transaction references for payments made. The following payment methods return transaction references:
This object returns |
receipt_amount | integer | Receipt amount ( |
references | object | Reference information about the payment ( |
scannable_code | barcode | Barcode object |
shipping | object | Shipping address. See source creation parameters for more details. |
store_id | string | Store ID for payment source ( |
store_name | string | Store name for payment source ( |
terminal_id | string | Terminal ID for payment source ( |
type | string | Payment source type |
zero_interest_installments | boolean | Whether merchant absorbs the interest for installment payments; must match value in associated charge ( |
Example
-
JSON Response
{ "object": "source", "id": "src_test_no1t4tnemucod0e51mo", "livemode": false, "location": "/sources/src_test_no1t4tnemucod0e51mo", "amount": 12345, "barcode": "1234567890", "bank": null, "created_at": "2019-12-31T12:59:59Z", "currency": "THB", "email": null, "flow": "offline", "installment_term": null, "absorption_type": null, "name": null, "mobile_number": null, "phone_number": null, "platform_type": null, "scannable_code": null, "billing": null, "shipping": null, "items": [], "references": null, "store_id": "store_1", "store_name": "store 1", "terminal_id": "POS-01", "type": "barcode_alipay", "zero_interest_installments": null, "charge_status": "unknown", "receipt_amount": null, "discounts": [] }
Create a source
- POST https://api.omise.co/sourcesCreates and returns a new source. Note: this verb accepts both public and secret key authentication. Sources can also be created and charged directly using the Charge API.
Request Parameters
Name | Type | Description |
---|---|---|
amount | integer | (required) Source amount in smallest unit of source currency |
currency | string | (required) Currency for source as three-letter ISO 4217 code |
type | string | (required, one of: |
bank | string | (optional, but conditionally required) Bank ( |
barcode | string | (optional, but conditionally required) Barcode number ( |
billing | object | (optional) Billing address
|
string | (optional, but conditionally required) Payer email address ( |
|
installment_term | integer | (optional, but conditionally required) Installment term in months. See installments for allowed values ( |
ip | string | (optional) IP address provided to Opn Payments at source creation. May be IPv4 or IPv6. |
items | array | (optional) Information about items included in the order. Array of objects with the following attributes:
|
mobile_number | string | (optional, but conditionally required) Payer phone number ( |
name | string | (optional, but conditionally required) Payer name ( |
platform_type | string | (optional, but conditionally required) Platform from which payer is making a payment. One of WEB, IOS, or ANDROID:
The following payment methods support
|
promotion_code | string | (optional) The code that grants access to special offers or discounts provided by the service provider. |
shipping | object | (optional) Shipping address
|
store_id | string | (optional, but conditionally required) Store ID for payment source ( |
store_name | string | (optional, but conditionally required) Store name for payment source ( |
terminal_id | string | (optional, but conditionally required) Terminal ID for payment source ( |
zero_interest_installments | boolean | (optional, one of: |
Example
-
Create a source with a public key
- Omise.js
- Android SDK
- iOS SDK
- curl
- php
- node.js
- java
- python
- go
Omise.setPublicKey("OMISE_PUBLIC_KEY"); Omise.createSource("internet_banking_bbl", { "amount": 12345, "currency": "THB" }, function(statusCode, response) { console.log(response["id"]) });
private val client = Client("pkey_test_123") val request = Source.CreateSourceRequestBuilder(25000L, "thb", SourceType.InternetBanking.Bbl).build() client.send(request, object: RequestListener<Source>{ override fun onRequestSucceed(model: Source) { // you created a source } override fun onRequestFailed(throwable: Throwable) { // something bad happened } })
let paymentInformation = PaymentInformation.internetBanking(.bbl) let sourceParameter = CreateSourceParameter( paymentInformation: paymentInformation, amount: amount, currency: currency ) let request = Request<Source>(parameter: sourceParameter) let requestTask = client.requestTask(with: request, completionHandler: completionHandler) requestTask.resume()
curl https://api.omise.co/sources \ -u $OMISE_PUBLIC_KEY: \ -d "amount=100000" \ -d "currency=THB" \ -d "type=bill_payment_tesco_lotus"
<?php $source = OmiseSource::create(array( 'amount' => 100000, 'currency' => 'thb', 'type' => 'bill_payment_tesco_lotus' ));
'use strict'; exports.__esModule = true; var omise = require('../index')({ 'publicKey': 'pkey_test_56bywcp7sk1qselsyqb' }); var source = { 'type': 'internet_banking_bbl', 'amount': 500000, 'currency': 'thb' }; omise.sources.create(source).then(function(resSource) { console.log(`created source: ${resSource.id}`); }).catch(function(err) { console.log(err); });
Client client = new Client("pkey_test_56bywcp7sk1qselsyqb"); Source source = client.sources().create(new Source.Create() .type(SourceType.InternetBankingScb) .amount(10000) .currency("thb")); System.out.println("created source: " + source.getId());
import omise omise.api_secret = "skey_test_no1t4tnemucod0e51mo" omise.api_version = "2017-11-02" source = omise.Source.create( amount=100000, currency="thb", type="bill_payment_tesco_lotus" )
client, _ := omise.NewClient( "pkey_test_no1t4tnemucod0e51mo", "skey_test_no1t4tnemucod0e51mo", ) result := &omise.Source{} err := client.Do(result, &operations.CreateSource{ Amount: 100000, Currency: "thb", Type: "bill_payment_tesco_lotus", }) if err != nil { log.Fatalln(err) } log.Println(result)
Retrieve a source
- GET https://api.omise.co/sources/{id}Returns the source matching :id
. This verb accepts both secret and public key authentication.
Example
-
Retrieve a source with a secret key
- curl
curl https://api.omise.co/sources/src_test_5g5in1we65199wlsyji \ -u $OMISE_SECRET_KEY: