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 | object_id | 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. |
barcode | string | Barcode number ( |
created_at | datetime | UTC datetime of source creation in ISO 8601 format ( |
currency | currency | Currency for source as three-letter ISO 4217 code. |
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 ( |
references | references | Reference information about the payment ( |
scannable_code | string | 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. Value can be one of the following (depending on account and country):
See installments for allowed values. |
zero_interest_installments | boolean | Whether merchant absorbs the interest for installment payments ( |
Example
-
JSON Response
{ "object": "source", "id": "src_test_no1t4tnemucod0e51mo", "livemode": false, "location": "/sources/src_test_no1t4tnemucod0e51mo", "created_at": "2019-12-31T12:59:59Z", "type": "barcode_alipay", "flow": "offline", "amount": 12345, "currency": "THB", "mobile_number": null, "phone_number": null, "references": null, "name": null, "email": null, "barcode": "1234567890", "store_id": "store_1", "store_name": "store 1", "terminal_id": "POS-01", "installment_term": null, "zero_interest_installments": null, "scannable_code": null }
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 | currency | (required) Currency for source as three-letter ISO 4217 code. |
type | string | (required) Payment source type. Value can be one of the following (depending on account and country):
See installments for allowed values. |
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 ( |
name | string | (optional, but conditionally required) Payer name ( |
phone_number | string | (optional, but conditionally required) Payer phone number ( |
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) Whether merchant absorbs the interest for installment payments ( |
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_56bywcp7sk1qselsyqb' source = omise.Source.create( amount=100000, currency='thb', type='bill_payment_tesco_lotus' )
source, createSource := &omise.Source{}, &operations.CreateSource{ Amount: 100000, Currency: "thb", Type: "bill_payment_tesco_lotus", } if e := client.Do(source, createSource); e != nil { log.Fatalln(e) } log.Printf("created source: %#v\n", source)
Retrieve a source
- GET https://api.omise.co/sources/{id}Returns the source matching :id
. Note: this verb accepts only secret key authentication.
Example
-
Retrieve a source with a secret key
- curl
curl https://api.omise.co/sources/src_test_5g5in1we65199wlsyji \ -u $OMISE_SECRET_KEY: