Omise Go Library
Go Makefile
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
internal
omise
operations
testdata
.travis.yml
LICENSE
Makefile
README.md
account.go
balance.go
bank_account.go
base.go
card.go
charge.go
charge_status.go
client.go
client_test.go
customer.go
dispute.go
dispute_status.go
document.go
error.go
event.go
gen_list.go
gen_search.go
gen_string.go
json_test.go
link.go
list.go
offsite_types.go
omise.go
omise_test.go
ordering.go
recipient.go
recipient_type.go
refund.go
search_result.go
search_scope.go
source_of_funds.go
token.go
transaction.go
transaction_type.go
transfer.go
transport.go
webhook.go

README.md

OMISE-GO

GoDoc Build Status Gitter

Omise is a payment service provider currently operating in Thailand. Omise provides a set of clean APIs that helps merchants of any size accept credit cards online.

This library offers GO integration to the Omise API.

Install with:

go get github.com/omise/omise-go

COMPLIANCE WARNING

Card data should never transit through your server. This library provides means to create tokens on the server side but should only be used for testing or only if you currently have a valid PCI-DSS Attestation of Compliance (AoC) delivered by a certified QSA Auditor.

Instead we recommend that you follow our guide on how to safely collect credit information.

USAGE

See godoc.org in tandem with the Omise API Documentation for usage instruction.

Example:

package main

import (
    "log"

    "github.com/omise/omise-go"
    "github.com/omise/omise-go/operations"
)

const (
    // Read these from environment variables or configuration files!
    OmisePublicKey = "pkey_test_521w1g1t7w4x4rd22z0"
    OmiseSecretKey = "skey_test_521w1g1t6yh7sx4pu8n"
)

func main() {
    client, e := omise.NewClient(OmisePublicKey, OmiseSecretKey)
    if e != nil {
        log.Fatal(e)
    }

    // Creates a token from a test card.
    token, createToken := &omise.Token{}, &operations.CreateToken{
        Name:            "OMISE-GO Test Card",
        Number:          "4242424242424242",
        ExpirationMonth: 12,
        ExpirationYear:  2018,
    }
    if e := client.Do(token, createToken); e != nil {
        log.Fatal(e)
    }

    // Creates a charge from the token
    charge, createCharge := &omise.Charge{}, &operations.CreateCharge{
        Amount:   100000, // ฿ 1,000.00
        Currency: "thb",
        Card:     token.ID,
    }
    if e := client.Do(charge, createCharge); e != nil {
        log.Fatal(e)
    }

    log.Printf("charge: %s  amount: %s %d\n", charge.ID, charge.Currency, charge.Amount)
}

API VERSION

You can choose which API version to use with Omise. Each new API version has new features and might not be compatible with previous versions. You can change the default version by visiting your Omise Dashboard.

The version configured here will have higher priority than the version set in your Omise account. This is useful if you have multiple environments with different API versions for testing. (e.g. Development on the latest version but production is on an older version).

client.APIVersion = "2015-11-06"

It is highly recommended to set this version to the current version you're using. You can learn more about this feature in our versioning guide.

LICENSE

See LICENSE file.