Source API
Create and retrieve payment sources. Sources are methods for accepting payments through non-credit-card channels (including Alipay, convenience store, internet banking and installment payments).
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 |
amount | integer | Source amount in smallest unit of source currency |
bank | string | Bank ( |
barcode | string | Barcode number ( |
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 ( |
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:
|
receipt_amount | integer | Receipt amount ( |
references | object | Reference information about the payment ( |
scannable_code | barcode | Barcode object |
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 |
items | items | Item containing details of item ( |
shipping | address | Address Shipping address ( |
billing | address | Address Billing address |
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 ( |
string | (optional, but conditionally required) Payer email address ( |
|
installment_term | integer | (optional, but conditionally required) Installment term in months. See installments for allowed values ( |
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:
|
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 ( |
items | items | (optional, but conditionally required) Items for payment source ( |
shipping | shipping | (optional, but conditionally required) Shipping address for payment source ( |
billing | billing | (optional) Billing address 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:
Item
- POSTThe following parameters for item of the source.
Request Parameters
Name | Type | Description |
---|---|---|
amount | integer | (optional, but conditionally required) Selling price of the item in smallest unit of |
sku | string | (optional, but conditionally required) Sku/product id of the item ( |
name | string | (optional, but conditionally required) Name of the item ( |
quantity | integer | (optional, but conditionally required) Quantity of the item ( |
category | string | (optional) Category of the item |
brand | string | (optional) Brand of the item |
item_uri | string | (optional) Uri of the item |
image_uri | string | (optional) Image uri of the item |
Address
- POSTThe following parameters for shipping and billing address of the source.
Request Parameters
Name | Type | Description |
---|---|---|
country | string | Address country as two-letter ISO 3166 code |
city | string | Address city |
postal_code | string | Address postal code |
state | string | Address state |
street1 | string | Address street #1 |
street2 | string | (optional) Address street #2 |