Giter VIP home page Giter VIP logo

go-be2bill's Introduction

Be2bill Merchant API

Build Status GoDoc Coverage Go Report Card

This is a Go language library for the Be2bill merchant API that supports the Form and DirectLink client APIs.

This library closely adheres to the official Merchant API guidelines.

Installation

Installing go-be2bill may be done via the usual go get procedure:

$ go get github.com/noirotm/go-be2bill

Documentation

See https://godoc.org/github.com/noirotm/go-be2bill

Examples of use

In all cases, you need to import the go-be2bill package:

import "github.com/noirotm/go-be2bill"

Form Client

Every initial transaction is made using a secure form. The Form Client API exposes methods that return the HTML code for payment or authorization buttons.

The first step is to build a client for the given environment, using your credentials:

client := be2bill.BuildSandboxFormClient("test", "password")

To build a payment form button, call:

button := client.BuildPaymentFormButton(
	be2bill.SingleAmount(15235),   // amount in cents
	"order_1412327697",            // order ID
	"[email protected]", // user ID
	"Fashion jacket",              // order description
	be2bill.Options{
		be2bill.HTMLOptionSubmit: be2bill.Options{
			"value": "Pay with be2bill",
			"class": "flatButton",
		},
		be2bill.HTMLOptionForm: be2bill.Options{"id": "myform"},
	},                             // HTML options for the form
	be2bill.Options{
		be2bill.ParamClientEmail: "[email protected]",
		be2bill.Param3DSecure:    "yes",
	},                             // additional platform options
)

Authorization form buttons are created similarily, except that the method to call is BuildAuthorizationFormButton that takes the same parameters. An authorization must be captured using the Capture method of the Direct Link Client API.

Direct Link Client

All operations that do not require interactive data input from the client can be made using HTTP POST calls to the be2bill servers. The Direct Link Client API is an abstraction layer for these calls.

Just like the Form Client API, the first step is to build a client for the given environment, using your credentials:

client := be2bill.BuildSandboxDirectLinkClient("test", "password")

Then, for example to capture a previously authorized transaction, call:

result, err := client.Capture(
	"A151621",
	"order_1423675675",
	"capture_transaction_A151621",
	be2bill.Options{},
)

Testing

The library comes with a complete test suite which can be run using the following command:

$ go test -v

Please note that there are a few sandbox tests that depend on having a be2bill test account configured, and are skipped by default.

The environment variables BE2BILL_IDENTIFIER and BE2BILL_PASSWORD need to be present and correctly configured with a test account in order to run the sandbox tests.

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.