Git Product home page Git Product logo

omise-go's Introduction

Omise Go Library

GoDoc omise-go v1

Opn Payments helps merchants of any size accept payments online. This library offers Go integration to the Opn Payments API.

Install with:

go get github.com/omise/omise-go

Security Warning

Please do NOT use Omise Go library versions less than 1.0.5, as they are outdated and have security vulnerabilities.

Compliance warning

Card data should never transit through your server. This library provides the 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.

Compatibility

Version v1.2.0 and higher of this package is designed to work with Go version 1.16 or higher. It is not compatible with Go versions 1.15 and lower.

If you are using an older version of Go, please consider upgrading to a compatible version to use this library effectively.

Usage

For usage instructions, see godoc.org in tandem with the Opn Payments API Documentation.

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_no1t4tnemucod0e51mo"
	OmiseSecretKey = "skey_test_no1t4tnemucod0e51mo"
)

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

  /** Retrieve a token from a request
   * A token should be created from a client side by using our client-side libraries
   * https://docs.opn.ooo/libraries#client-side-libraries
   * More information:
   * - https://docs.opn.ooo/collecting-card-information
   * - https://docs.opn.ooo/security-best-practices
   **/
	token := "tokn_test_no1t4tnemucod0e51mo"

	// Creates a charge from the token
	charge, createCharge := &omise.Charge{}, &operations.CreateCharge{
		Amount:   100000, // ฿ 1,000.00
		Currency: "thb",
		Card:     token,
	}
	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 the API version to use with Opn Payments. Each new API version has new features that might be incompatible with previous versions. You can change the default version by visiting your Opn Payments Dashboard.

The version configured here will have higher priority than the version set in your Opn Payments 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 that you are using. You can learn more about this feature in our versioning guide.

Enable debug mode

You can monitor the response code and body from each API call by utilizing the library's debug mode, which you can turn on or off. To activate this feature, invoke SetDebug() immediately after initializing your client.

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

// Enabling debug mode to monitor response from API call
client.SetDebug(true)

License

See LICENSE file.

omise-go's People

Contributors

aashishgurung avatar ajzkk avatar anasnaouchi avatar chakrit avatar danfowler avatar dvrkps avatar fred avatar hpariwat avatar iporsut avatar kanokorn avatar keeratita avatar kongz avatar kyokomi avatar mazon avatar muthuswamyopn avatar new4762 avatar nuxzero avatar rezigned avatar rossigee avatar wingyplus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

omise-go's Issues

How can I get PayNow QR code through create a charge

hello,
I checked the API docs, the download image is contained in the source struct.
But in the omise-go source struct, there is no image structure.
If I want to get the QR code for the PayNow method, what should I do?

OMISE-GO or Omise GO

It seems that Omise has another subsidiary called "Omise GO". Now there are 2 Omise Goes, one for SDK, another one for business. Any plan to rename either this or that?

Omise client has `debug` field, but there is no method to enable it

Expected behavior

client.SetDebugMode(true)

so we can see request log

Actual behavior

there is no method available to enable it.

Steps to reproduce the issue

client , err := omise.NewClient(key, secret)

Logs

No response

Screenshots

No response

Name and version information

V1.41.

Contributing

Hi, is there a plan to have more documentation on how to begin contributing? Noticed there isn't a "getting started" page in terms of reading code or list of issues etc. Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.