### List Example (Cards) Source: https://docs.omise.co/api-pagination This example demonstrates how to use pagination parameters to retrieve a list of cards for a customer. The same parameters apply to other list APIs. ```APIDOC ## GET /customers/{customer_id}/cards ### Description Retrieves a paginated list of cards associated with a customer. ### Method GET ### Endpoint `/customers/{customer_id}/cards` ### Parameters #### Query Parameters - **from** (iso8601) - Optional - The UTC date and time limiting the beginning of returned records. - **to** (iso8601) - Optional - The UTC date and time limiting the end of returned records. - **offset** (integer) - Optional - The offset of the first record returned. How many records should be skipped from the beginning? - **limit** (integer) - Optional - The maximum amount of records returned. Maximum: 100. - **order** (string) - Optional - The order of the list returned. i.e., `chronological` (from earliest to latest), `reverse_chronological` (from latest to earliest). ### Request Example ```bash curl https://api.omise.co/customers/cust_test_4xs68oo1vgalgffzsyw/cards \ -X GET \ -u skey_test_4xs68olyuul9lmmp375: \ -d "from=2014-10-20T00:00:00Z" \ -d "to=2014-10-25T00:00:00Z" \ -d "offset=1" \ -d "limit=5" ``` ### Response #### Success Response (200) - **object** (string) - The string `list`. - **from** (datetime, iso8601) - The UTC date and time limiting the beginning of returned records. - **to** (datetime, iso8601) - The UTC date and time limiting the end of returned records. - **offset** (integer) - The offset of the first record returned. - **limit** (integer) - The maximum amount of records returned. - **total** (integer) - Total amount of records between `from` and `to`. - **data** (array) - Array of returned objects (charges, cards, ...). #### Response Example ```json { "object": "list", "from": "2014-10-20T00:00:00Z", "to": "2014-10-25T00:00:00Z", "offset": 1, "limit": 5, "total": 2, "data": [ { "object": "card", "id": "card_test_4xs68on6y9b4teqliza", "livemode": false, "location": "/customers/cust_test_4xs68oo1vgalgffzsyw/cards/card_4xs68on6y9b4teqliza", "country": "", "city": "Bangkok", "postal_code": "10310", "financing": "", "last_digits": 4242, "brand": "Visa", "expiration_month": 10, "expiration_year": 2018, "fingerprint": "uBNb5Z5J6firoMoDo80jEc1X/QucKQ4SCu80kP9U0gE=", "name": "Somchai Prasert", "created": "2014-10-20T04:47:15Z" } ] } ``` ``` -------------------------------- ### List API Pagination Example Source: https://docs.omise.co/api-pagination?selected_country=japan This example demonstrates how to paginate a list of customer cards using various optional parameters like from, to, offset, and limit. ```APIDOC ## GET /customers/{customer_id}/cards ### Description Retrieves a paginated list of cards associated with a specific customer. ### Method GET ### Endpoint /customers/{customer_id}/cards ### Parameters #### Query Parameters - **from** (datetime, iso8601) - Optional - The UTC date and time limiting the beginning of returned records. - **to** (datetime, iso8601) - Optional - The UTC date and time limiting the end of returned records. - **offset** (integer) - Optional - The offset of the first record returned. Skips a specified number of records. - **limit** (integer) - Optional, maximum: 100 - The maximum amount of records to return. - **order** (string) - Optional, default: chronological - The order of the list returned (`chronological` or `reverse_chronological`). ### Request Example ``` curl https://api.omise.co/customers/cust_test_4xs68oo1vgalgffzsyw/cards \ -X GET \ -u skey_test_4xs68olyuul9lmmp375: \ -d "from=2014-10-20T00:00:00Z" \ -d "to=2014-10-25T00:00:00Z" \ -d "offset=1" \ -d "limit=5" ``` ### Response #### Success Response (200) - **object** (string) - The string `list`. - **from** (datetime, iso8601) - The UTC date and time limiting the beginning of returned records. - **to** (datetime, iso8601) - The UTC date and time limiting the end of returned records. - **offset** (integer) - The offset of the first record returned. - **limit** (integer) - The maximum amount of records returned. - **total** (integer) - Total amount of records between `from` and `to`. - **data** (array) - Array of returned card objects. #### Response Example ```json { "object": "list", "from": "2014-10-20T00:00:00Z", "to": "2014-10-25T00:00:00Z", "offset": 1, "limit": 5, "total": 2, "data": [ { "object": "card", "id": "card_test_4xs68on6y9b4teqliza", "livemode": false, "location": "/customers/cust_test_4xs68oo1vgalgffzsyw/cards/card_4xs68on6y9b4teqliza", "country": "", "city": "Bangkok", "postal_code": "10310", "financing": "", "last_digits": 4242, "brand": "Visa", "expiration_month": 10, "expiration_year": 2018, "fingerprint": "uBNb5Z5J6firoMoDo80jEc1X/QucKQ4SCu80kP9U0gE=", "name": "Somchai Prasert", "created": "2014-10-20T04:47:15Z" } ] } ``` ``` -------------------------------- ### List All Charges using Go Source: https://docs.omise.co/charges-api Use the Omise Go SDK to list charges. This example demonstrates client initialization and making a list charges request with custom parameters. ```go client, _ := omise.NewClient( "pkey_test_no1t4tnemucod0e51mo", "skey_test_no1t4tnemucod0e51mo", ) result := &omise.ChargeList{} err := client.Do(result, &operations.ListCharges{ operations.List{ Limit: 100, From: time.Now().Add(-1 * time.Hour), }, }) if err != nil { log.Fatalln(err) } log.Println(result) ``` -------------------------------- ### Create an Installment Payment charge Source: https://docs.omise.co/api/charges This section provides an example for creating an Installment Payment charge using cURL. ```APIDOC ## POST /charges ### Description Creates a charge with an installment payment source. ### Method POST ### Endpoint https://api.omise.co/charges ### Parameters #### Request Body - **description** (string) - Optional - A description for the charge. - **amount** (integer) - Required - The amount to charge. - **currency** (string) - Required - The currency of the charge (e.g., 'THB'). - **return_uri** (string) - Required - The URI to redirect the user to after payment. - **source[type]** (string) - Required - The type of payment source, set to 'installment_kbank' for KBank installment. - **source[installment_term]** (integer) - Required - The number of installments. ### Request Example ```json { "description": "Charge with source", "amount": 500000, "currency": "THB", "return_uri": "https://www.omise.co/example_return_uri", "source": { "type": "installment_kbank", "installment_term": 4 } } ``` ### Response #### Success Response (200) - **id** (string) - The unique identifier for the charge. - **status** (string) - The current status of the charge. #### Response Example ```json { "id": "chrg_test_67890", "status": "pending" } ``` ``` -------------------------------- ### Create Token and Charge with Java Source: https://docs.omise.co/api/charges This Java example shows how to first create a token using card details and then use that token to create a charge. It utilizes the Omise Java client. ```java Request tokenRequest = new Token.CreateRequestBuilder() .card(new Card.Create() .name("John Doe") .number("4242424242424242") .securityCode("123") .expiration(10, 2020)) .build(); Token token = client.sendRequest(tokenRequest); System.out.printf("Created token: " + token.getId()); Request createChargeRequest = new Charge.CreateRequestBuilder() .amount(100000) .currency("THB") .card(token.getId()) .build(); Charge charge = client().sendRequest(createChargeRequest); System.out.printf("Created charge: %s", charge.getId()); ``` -------------------------------- ### Installment Payment Source Response Object Source: https://docs.omise.co/installment-payments This is an example of the JSON response received after successfully creating an installment payment source. The 'id' attribute is crucial for subsequent charge creation. ```json { "object": "source", "id": "src_test_5xk6wi5sno7ar7p3zcv", "livemode": false, "location": "/sources/src_test_5xk6wi5sno7ar7p3zcv", "amount": 400000, "barcode": null, "bank": null, "created_at": "2023-10-26T06:03:05Z", "currency": "THB", "email": null, "flow": "redirect", "installment_term": 4, "ip": null, "absorption_type": "customer", "name": null, "mobile_number": null, "phone_number": null, "platform_type": null, "scannable_code": null, "billing": null, "shipping": null, "items": [], "references": null, "provider_references": null, "store_id": null, "store_name": null, "terminal_id": null, "type": "installment_kbank", "zero_interest_installments": false, "charge_status": "unknown", "receipt_amount": null, "discounts": [] } ``` -------------------------------- ### Create Source Source: https://docs.omise.co/source-api This section provides examples of how to create a source using different SDKs and the direct API. It demonstrates the process for various payment types and includes optional parameters that can be used during source creation. ```APIDOC ## Create Source ### Description Creates a payment source that can be used to authorize a payment. This is the first step in the payment process, allowing users to select their preferred payment method. ### Method POST ### Endpoint /sources ### Parameters #### Query Parameters - **promotion_code** (string) - Optional - The code that grants access to special offers or discounts provided by the service provider. - **qr_settings** (object) - Optional - A configuration object that customizes the format and appearance of the response QR code (`type=promptpay`). * `image_type` (string) - The image format for the QR code. Supported formats: jpeg, png, and svg. - **shipping** (object) - Optional - Shipping address. * `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. - **store_id** (string) - Optional, but conditionally required - Store ID for payment source (`type=barcode_alipay`). - **store_name** (string) - Optional, but conditionally required - Store name for payment source (`type=barcode_alipay`). - **supplier_id** (string) - Optional - TBD. - **terminal_id** (string) - Optional, but conditionally required - Terminal ID for payment source (`type=barcode_alipay`). - **zero_interest_installments** (boolean) - Optional, one of: `true`, `false` - Whether merchant absorbs the interest for installment payments; must match value in associated charge (`type=installment_*`). ### Request Example ```json { "amount": 12345, "currency": "THB", "type": "internet_banking_bbl" } ``` ### Response #### Success Response (200) - **id** (string) - The unique identifier for the created source. - **amount** (number) - The amount of the transaction. - **currency** (string) - The currency of the transaction. - **type** (string) - The type of the source (e.g., `internet_banking_bbl`). - **status** (string) - The current status of the source (e.g., `pending`, `consumed`). #### Response Example ```json { "id": "src_1234567890abcdef", "amount": 12345, "currency": "THB", "type": "internet_banking_bbl", "status": "pending" } ``` ``` -------------------------------- ### Create Source and Charge with Customer Paying Interest Source: https://docs.omise.co/installment-payments Use this example to explicitly set `zero_interest_installments` to `false`, ensuring the customer pays any applicable installment interest. ```curl curl https://api.omise.co/charges \ -u $OMISE_SECRET_KEY: \ -d "amount=400000" \ -d "currency=THB" \ -d "return_uri=http://example.com/orders/345678/complete" \ -d "zero_interest_installments=false" \ -d "source[type]=installment_kbank" \ -d "source[installment_term]=4" ``` -------------------------------- ### List All Charges (Go) Source: https://docs.omise.co/api/charges Use the Omise Go SDK to list charges. This example demonstrates setting a limit and a time range for the query. ```go client, _ := omise.NewClient( "pkey_test_no1t4tnemucod0e51mo", "skey_test_no1t4tnemucod0e51mo", ) result := &omise.ChargeList{} er := client.Do(result, &operations.ListCharges{ operations.List{ Limit: 100, From: time.Now().Add(-1 * time.Hour), }, }) if err != nil { log.Fatalln(err) } log.Println(result) ``` -------------------------------- ### List Pending Disputes with C# Source: https://docs.omise.co/disputes-api Get a list of pending disputes using the Omise C# SDK. This example demonstrates fetching disputes with reverse chronological order. ```csharp var resource = Client.Disputes.PendingDisputes; var pendingDisputes = await resource.GetList(order: Ordering.ReverseChronological); Console.WriteLine($"pending disputes: {pendingDisputes.Total}"); ``` -------------------------------- ### Google Pay Tokenization Response Structure Source: https://docs.omise.co/googlepay This is an example of the JSON response received after successfully creating a Google Pay token. The 'id' attribute, starting with 'tokn', is the token identifier. ```json { "object": "token", "id": "tokn_test_5s7p3w9z0xhnily5g3j", "livemode": false, "location": "https://vault.omise.co/tokens/tokn_test_5s7p3w9z0xhnily5g3j", "used": false, "charge_status": "unknown", "card": { "object": "card", "id": "card_test_5s7p3w9ygewzs8yfliv", "livemode": false, "location": null, "deleted": false, "street1": null, "street2": null, "city": null, "state": null, "phone_number": null, "postal_code": null, "country": "us", "financing": "credit", "bank": "JPMORGAN CHASE BANK N.A.", "brand": "Visa", "fingerprint": "uHGUFYpH0GCcilfcEdJWQe/+j/FLNfXsZKeW5Xrydc4=", "first_digits": null, "last_digits": "1111", "name": "Google Pay", "expiration_month": 12, "expiration_year": 2027, "security_code_check": true, "tokenization_method": "googlepay", "created_at": "2022-06-21T02:32:10Z" }, "created_at": "2022-06-21T02:32:10Z" } ``` -------------------------------- ### Create and charge a new source Source: https://docs.omise.co/api/charges This example shows how to create a charge by specifying a new source type, such as Alipay. ```APIDOC ## POST /charges ### Description Creates a charge using a new source, like Alipay, and specifies a return URI. ### Method POST ### Endpoint https://api.omise.co/charges ### Parameters #### Request Body - **amount** (number) - Required - The amount to charge. - **currency** (string) - Required - The currency of the charge (e.g., THB). - **return_uri** (string) - Required - The URI to redirect the user to after the charge is completed. - **source[type]** (string) - Required - The type of the source (e.g., 'alipay'). ``` -------------------------------- ### Example Event Verification Workflow Source: https://docs.omise.co/api-webhooks?selected_country=singapore This workflow outlines the steps for verifying webhook event data using an independent GET request when signature verification is not feasible. It helps confirm the authenticity of received event data. ```text 1. Receive `charge.complete` webhook 2. Extract Charge ID from the webhook payload 3. Perform GET request to `/charges/{CHARGE_ID}` 4. Verify the charge status independently ``` -------------------------------- ### Destroy Customer using Go Source: https://docs.omise.co/customers-api This Go example shows how to initialize the Omise client and then use the client.Do method with DestroyCustomer operation to delete a customer. It includes error handling and logs the result. ```go client, _ := omise.NewClient( "pkey_test_no1t4tnemucod0e51mo", "skey_test_no1t4tnemucod0e51mo", ) result := &omise.Deletion{} err := client.Do(result, &operations.DestroyCustomer{ CustomerID: "cust_test_no1t4tnemucod0e51mo", }) if err != nil { log.Fatalln(err) } log.Println(result) ``` -------------------------------- ### Example Event Verification Workflow Source: https://docs.omise.co/api-webhooks This workflow outlines the steps for verifying webhook event authenticity when signature verification is not feasible. It involves retrieving event-specific data via a GET request to confirm the event's status. ```text 1. Receive `charge.complete` webhook 2. Extract Charge ID from the webhook payload 3. Perform GET request to `/charges/{CHARGE_ID}` 4. Verify the charge status independently ``` -------------------------------- ### Create and charge a new source Source: https://docs.omise.co/charges-api?selected_country=thailand This example demonstrates how to create a charge by specifying a new source type, such as Alipay. The return URI is also provided for redirecting the user after payment. ```APIDOC ## Create and charge a new source ### Description Creates a charge using a new payment source, such as Alipay. Requires a return URI for redirecting the user after the payment process. ### Method POST ### Endpoint https://api.omise.co/charges ### Parameters #### Request Body - **amount** (integer) - Required - The charge amount. - **currency** (string) - Required - The currency of the charge (e.g., "thb"). - **return_uri** (string) - Required - The URI to redirect the user to after payment completion. - **source[type]** (string) - Required - The type of the payment source (e.g., "alipay"). ### Request Example ```bash curl https://api.omise.co/charges \ -u $OMISE_SECRET_KEY: \ -d "amount=100000" \ -d "currency=thb" \ -d "return_uri=https://www.omise.co/example_return_uri" \ -d "source[type]=alipay" ``` ``` -------------------------------- ### Create Internet Banking Source with Android SDK Source: https://docs.omise.co/source-api This example demonstrates creating an internet banking source using the Omise Android SDK. It requires initializing the client with a public key and using the `Source.CreateSourceRequestBuilder`. ```kotlin private val client = Client("pkey_test_123") val request = Source.CreateSourceRequestBuilder(25000L, "thb", SourceType.InternetBanking.Bbl).build() client.send(request, object: RequestListener{ override fun onRequestSucceed(model: Source) { // you created a source } override fun onRequestFailed(throwable: Throwable) { // something bad happened } }) ``` -------------------------------- ### Get Exchange Rate for USD to THB Source: https://docs.omise.co/multi-currency This cURL command retrieves the current exchange rate between USD and your account's funding currency (THB in this example). This is useful for understanding potential fluctuations in funding amounts for multi-currency charges. ```curl curl https://api.omise.co/forex/usd \ -u $OMISE_SECRET_KEY: ``` -------------------------------- ### Create Charge with Go Source: https://docs.omise.co/api/charges This Go example shows how to create a charge using the Omise Go client. It includes error handling and logging for the charge creation process. ```go client, _ := omise.NewClient( "pkey_test_no1t4tnemucod0e51mo", "skey_test_no1t4tnemucod0e51mo", ) result := &omise.Charge{} err := client.Do(result, &operations.CreateCharge{ Amount: 204842, // THB 2,048.42 Currency: "thb", Card: "tokn_test_no1t4tnemucod0e51mo", }) if err != nil { log.Fatalln(err) } log.Println(result); ``` -------------------------------- ### Install Omise Magento Plugin Source: https://docs.omise.co/magento-plugin Use composer to install the omise-magento library. Run this command in your Magento installation directory. ```bash composer require omise/omise-magento ``` -------------------------------- ### Create an Installment Payment Charge using cURL Source: https://docs.omise.co/charges-api?selected_country=japan Use this cURL command to create an installment payment charge. Specify the installment term for the source. ```bash curl https://api.omise.co/charges \ -u $OMISE_SECRET_KEY: \ -d "description=Charge with source" \ -d "amount=500000" \ -d "currency=THB" \ -d "return_uri=https://www.omise.co/example_return_uri" \ -d "source[type]=installment_kbank" \ -d "source[installment_term]=4" ``` -------------------------------- ### Create Internet Banking Source with Node.js Source: https://docs.omise.co/source-api This Node.js example shows how to create an internet banking source using the Omise Node.js library. It requires initializing the library with a public key and calling the `sources.create` method. ```javascript '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); }); ``` -------------------------------- ### Create a charge and new customer Source: https://docs.omise.co/api/charges This example shows how to create a charge for a new customer by providing customer details directly in the charge creation request. ```APIDOC ## POST /charges ### Description Creates a charge for a new customer with card details provided. ### Method POST ### Endpoint https://api.omise.co/charges ### Parameters #### Request Body - **amount** (number) - Required - The amount to charge. - **currency** (string) - Required - The currency of the charge (e.g., THB). - **customer[card]** (string) - Required - The token of the card to be used for the charge. - **customer[metadata]** (string) - Optional - Metadata associated with the customer. - **customer[description]** (string) - Optional - Description of the purchase for the customer. - **customer[email]** (string) - Optional - Email address of the customer. ``` -------------------------------- ### Create Installment Payment Charge using cURL Source: https://docs.omise.co/api/charges Use this cURL command to create an installment payment charge. Specify the installment term for the source. ```curl curl https://api.omise.co/charges \ -u $OMISE_SECRET_KEY: \ -d "description=Charge with source" \ -d "amount=500000" \ -d "currency=THB" \ -d "return_uri=https://www.omise.co/example_return_uri" \ -d "source[type]=installment_kbank" \ -d "source[installment_term]=4" ``` -------------------------------- ### Create an Installment Payment charge Source: https://docs.omise.co/charges-api?selected_country=japan This section demonstrates how to create an Installment Payment charge using the Omise API. It specifies the payment type and installment term. ```APIDOC ## POST /charges ### Description Creates an Installment Payment charge. ### Method POST ### Endpoint https://api.omise.co/charges ### Parameters #### Request Body - **description** (string) - Optional - A description for the charge. - **amount** (integer) - Required - The charge amount. - **currency** (string) - Required - The charge currency (e.g., 'THB'). - **return_uri** (string) - Required - The URI to redirect to after payment. - **source[type]** (string) - Required - The payment source type, set to 'installment_kbank' for KBANK Installment. - **source[installment_term]** (integer) - Required - The number of installments. ### Request Example ```json { "description": "Charge with source", "amount": 500000, "currency": "THB", "return_uri": "https://www.omise.co/example_return_uri", "source": { "type": "installment_kbank", "installment_term": 4 } } ``` ### Response #### Success Response (200) - **id** (string) - The charge ID. - **status** (string) - The charge status. #### Response Example ```json { "id": "chrg_test_59wbyjrzf44d8nzcd6", "status": "pending" } ``` ``` -------------------------------- ### List Pagination Example Source: https://docs.omise.co/api-pagination?selected_country=singapore This example demonstrates how to use pagination parameters like 'from', 'to', 'offset', and 'limit' when fetching a list of customers' cards. The same principles apply to other list APIs. ```APIDOC ## GET /customers/{customer_id}/cards ### Description Retrieves a paginated list of cards associated with a specific customer. ### Method GET ### Endpoint /customers/{customer_id}/cards ### Parameters #### Query Parameters - **from** (datetime, iso8601) - Optional - The UTC date and time limiting the beginning of returned records. - **to** (datetime, iso8601) - Optional - The UTC date and time limiting the end of returned records. - **offset** (integer) - Optional - The offset of the first record returned. Skips a specified number of records from the beginning. - **limit** (integer) - Optional - The maximum amount of records to return. Maximum value is 100. - **order** (string) - Optional - The order of the list returned. Can be `chronological` or `reverse_chronological`. ### Request Example ``` curl https://api.omise.co/customers/cust_test_4xs68oo1vgalgffzsyw/cards \ -X GET \ -u skey_test_4xs68olyuul9lmmp375: \ -d "from=2014-10-20T00:00:00Z" \ -d "to=2014-10-25T00:00:00Z" \ -d "offset=1" \ -d "limit=5" ``` ### Response #### Success Response (200) - **object** (string) - The string `list`. - **from** (datetime, iso8601) - The UTC date and time limiting the beginning of returned records. - **to** (datetime, iso8601) - The UTC date and time limiting the end of returned records. - **offset** (integer) - The offset of the first record returned. - **limit** (integer) - The maximum amount of records returned. - **total** (integer) - Total amount of records between `from` and `to`. - **data** (array) - Array of returned objects (cards in this case). #### Response Example ```json { "object": "list", "from": "2014-10-20T00:00:00Z", "to": "2014-10-25T00:00:00Z", "offset": 1, "limit": 5, "total": 2, "data": [ { "object": "card", "id": "card_test_4xs68on6y9b4teqliza", "livemode": false, "location": "/customers/cust_test_4xs68oo1vgalgffzsyw/cards/card_4xs68on6y9b4teqliza", "country": "", "city": "Bangkok", "postal_code": "10310", "financing": "", "last_digits": 4242, "brand": "Visa", "expiration_month": 10, "expiration_year": 2018, "fingerprint": "uBNb5Z5J6firoMoDo80jEc1X/QucKQ4SCu80kP9U0gE=", "name": "Somchai Prasert", "created": "2014-10-20T04:47:15Z" } ] } ``` ``` -------------------------------- ### Create a charge and new customer Source: https://docs.omise.co/charges-api?selected_country=thailand This example demonstrates how to create a charge for a new customer using their card token. It also includes customer details like metadata, description, and email. ```APIDOC ## Create a charge and new customer ### Description Creates a charge for a new customer, associating a card token with the customer profile. Includes options for customer metadata, description, and email. ### Method POST ### Endpoint https://api.omise.co/charges ### Parameters #### Request Body - **amount** (integer) - Required - The charge amount. - **currency** (string) - Required - The currency of the charge (e.g., "thb"). - **customer[card]** (string) - Required - The token of the card to be used for the charge. - **customer[metadata]** (string) - Optional - Metadata associated with the customer. - **customer[description]** (string) - Optional - A description for the customer. - **customer[email]** (string) - Optional - The email address of the customer. ### Request Example ```bash curl https://api.omise.co/charges \ -u $OMISE_SECRET_KEY: \ -d "amount=100000" \ -d "currency=thb" \ -d "customer[card]=tokn_test_60kw4dxb9redghzf8zs" \ -d "customer[metadata]=ORDER-1234" \ -d "customer[description]=Details about the purchase" \ -d "customer[email]=email@example.com" ``` ``` -------------------------------- ### JSON Response Example Source: https://docs.omise.co/documents-api This is an example of a JSON response when retrieving document details. ```json { "object": "document", "livemode": false, "id": "docu_test_no1t4tnemucod0e51mo", "deleted": false, "filename": "this_is_fine.png", "location": "/disputes/dspt_test_no1t4tnemucod0e51mo/documents/docu_test_no1t4tnemucod0e51mo", "kind": "details_of_purchase", "download_uri": null, "created_at": "2019-12-31T12:59:59Z" } ``` -------------------------------- ### Card API Attributes and Example Source: https://docs.omise.co/cards-api This section outlines the attributes available for card objects and provides a JSON example of a card response. ```APIDOC ## Card API Retrieve, update, and delete credit card information for a given customer. New cards are created from tokens and can be added to new and existing customers. ### Attributes Name | Type | Description ---|---|--- object | string | The string `card`. id | string | The card identifier matching `/card(_test)?[0-9a-z]+/`. livemode | boolean | Whether this is a live (`true`) or test (`false`) card. location | string | API path to retrieve the current `card` object. bank | string | Card bank name. Note: derived from issuer identification number (IIN); may not be accurate. brand | string | Card brand (e.g. Visa, Mastercard). city | string | Billing address city. country | string | Billing address country as two-letter ISO 3166 code. Note: if not supplied at token creation, value derived from issuer identification number (IIN) so may not be accurate. created_at | string | UTC datetime of card creation in ISO 8601 format (`YYYY-MM-DDThh:mm:ssZ`). deleted | boolean | Whether card is deleted. expiration_month | integer | Card expiration month (`M` or `MM`). expiration_year | integer | Card expiration year (`YYYY`). financing | string | Type of credit card financing. Supported values are: * `Credit` * `Debit` * `Prepaid` * `Charge` * `Deferred Debit` * `Loan` * `Unknown` * `Empty field` **Note** : The value is derived from the issuer identification number (IIN) and may not be accurate. fingerprint | string | Unique card-based fingerprint. Allows detection of identical cards. first_digits | string | First six (6) digits of card number. Value will be present only for specific merchants based on additional security/business assessments. last_digits | string | Last four (4) digits of card number. name | string | Card owner name. phone_number | string | Phone number. postal_code | string | Card postal code. security_code_check | boolean | Whether card passed pre-authorization. A card may fail pre-authorization for several reasons including, but not limited to, having an invalid `security_code`. As of 1 April 2020, this attribute only returns `true` regardless of the actual pre-authorization result. state | string | Billing address state. street1 | string | Billing address street #1. street2 | string | Billing address street #2. tokenization_method | string | The method by which a card is tokenized. The possible values are: * `googlepay` (when tokenized by Google Pay * `null` (when tokenized by Omise). This is the default value. ### Example * #### JSON Response ```json { "object": "card", "id": "card_test_no1t4tnemucod0e51mo", "livemode": false, "location": "/customers/cust_test_no1t4tnemucod0e51mo/cards/card_test_no1t4tnemucod0e51mo", "deleted": false, "street1": "1448/4 Praditmanutham Road", "street2": null, "city": "Bangkok", "state": null, "phone_number": "0123456789", "postal_code": "10320", "country": "th", "financing": "credit", "bank": "Bank of the Unbanked", "brand": "Visa", "fingerprint": "XjOdjaoHRvUGRfmZacMPcJtm0U3SEIIfkA7534dQeVw=", "first_digits": null, "last_digits": "4242", "name": "Somchai Prasert", "expiration_month": 12, "expiration_year": 2024, "security_code_check": true, "tokenization_method": null, "created_at": "2019-12-31T12:59:59Z" } ``` ``` -------------------------------- ### Destroy Customer with Go Source: https://docs.omise.co/api/customers This Go example shows how to initialize the Omise client and use it to destroy a customer. It includes error handling for the API call. ```go client, _ := omise.NewClient( "pkey_test_no1t4tnemucod0e51mo", "skey_test_no1t4tnemucod0e51mo", ) result := &omise.Deletion{} err := client.Do(result, &operations.DestroyCustomer{ CustomerID: "cust_test_no1t4tnemucod0e51mo", }) if err != nil { log.Fatalln(err) } log.Println(result) ``` -------------------------------- ### Create a token Source: https://docs.omise.co/tokens-api This section provides examples of how to create a token using different client-side and server-side implementations. ```APIDOC ## Create a token ### Description This endpoint allows you to create a token representing sensitive card details, which can then be used for processing payments without directly handling the card information. ### Method POST ### Endpoint /tokens ### Parameters #### Request Body - **card** (object) - Required - An object containing card details. - **name** (string) - Required - The name of the cardholder. - **number** (string) - Required - The credit card number. - **expiration_month** (integer) - Required - The expiration month of the card (1-12). - **expiration_year** (integer) - Required - The expiration year of the card (e.g., 2022). - **security_code** (string) - Required - The CVV/CVC code. - **street1** (string) - Optional - The street address. - **city** (string) - Optional - The city. - **state** (string) - Optional - The state or province. - **postal_code** (string) - Optional - The postal code. - **country** (string) - Optional - The country code (e.g., US). ### Request Example ```json { "card": { "name": "Somchai Prasert", "number": "4242424242424242", "expiration_month": 10, "expiration_year": 2022, "city": "Bangkok", "postal_code": "10320", "security_code": "123" } } ``` ### Response #### Success Response (200) - **id** (string) - The unique identifier for the created token. - **object** (string) - The type of object, usually "token". - **livemode** (boolean) - Indicates if the token was created in live mode. - **created** (timestamp) - The timestamp when the token was created. - **used** (boolean) - Indicates if the token has been used. - **deleted** (boolean) - Indicates if the token has been deleted. - **card** (object) - An object containing details of the card associated with the token (excluding sensitive information). #### Response Example ```json { "id": "tokn_1234567890abcdef", "object": "token", "livemode": false, "created": "2023-10-27T10:00:00Z", "used": false, "deleted": false, "card": { "id": "card_1234567890abcdef", "object": "card", "livemode": false, "last_digits": "4242", "brand": "visa", "expiration_month": 10, "expiration_year": 2022, "name": "Somchai Prasert", "street1": null, "street2": null, "city": "Bangkok", "state": null, "postal_code": "10320", "country": "TH", "security_code_check": "pass", "deleted": false } } ``` ```