qoin

package module
v0.0.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 12, 2020 License: MIT Imports: 14 Imported by: 0

README

Qoin-Go

Installation

go get github.com/Qoin-Digital-Indonesia/qoin-go

Usage

Transaction Description Example
import "encoding/json"

type DescriptionDetail struct {
	Item   uint8
	Desc   string
	Amount float32
}

type Description struct {
	Objects []DescriptionDetail
}

var description Description
description.Objects = make([]DescriptionDetail, 0)
description.Objects = append(description.Objects, DescriptionDetail{1, "T-Shirt", 15000})
description.Objects = append(description.Objects, DescriptionDetail{2, "Admin", 5000})
description.Objects = append(description.Objects, DescriptionDetail{3, "Shipping", 1000})
descriptionJSON, err := json.Marshal(description.Objects)
1. BRI VA
a. Create Order
import "github.com/Qoin-Digital-Indonesia/qoin-go"

qoin.SetEnvironment("sandbox") // sandbox || production
qoin.SetPrivateKey(`<your private key>`) // must use back quote (`) symbol
qoin.SetSecretKey("<your secret key>")
response := qoin.BriVaCreateOrder(map[string]interface{}{
    "MerchantNumber":  "<your merchant code>",
    "ReferenceNumber": "<reference number>",
    "Amount":          21000,
    "Currency":        "IDR",
    "Description":     string(descriptionJSON),
    "UserName":        "Giovanni Reinard",
    "UserContact":     "628123456789;giovanni@qoin.id", // format: phone_number;email_address
    "RequestTime":     time.Now().Format("2006-01-02 15:04:05"),
})
b. Get Status
import "github.com/Qoin-Digital-Indonesia/qoin-go"

qoin.SetEnvironment("sandbox") // sandbox || production
qoin.SetPrivateKey(`<your private key>`) // must use back quote (`) symbol
qoin.SetSecretKey("<your secret key>")
response := qoin.BriVaGetStatus(map[string]string{
    "OrderNumber": "<order number>",
    "ReqTime":     time.Now().Format("2006-01-02 15:04:05"),
})
2. Credit Card
a. Create Order
import "github.com/Qoin-Digital-Indonesia/qoin-go"

qoin.SetEnvironment("sandbox") // sandbox || production
qoin.SetPrivateKey(`<your private key>`) // must use back quote (`) symbol
qoin.SetSecretKey("<your secret key>")
response := qoin.CreditCardCreateOrder(map[string]interface{}{
    "reference_no":   "<reference number>",
    "account_number": "4000000000000002",
    "exp_month":      "12",
    "exp_year":       "2020",
    "card_cvn":       "123",
    "amount":         25000,
    "request_time":   time.Now().Format("2006-01-02 15:04:05"),
    "merchant_code":  "<your merchant code>",
})
b. Charge
import "github.com/Qoin-Digital-Indonesia/qoin-go"

qoin.SetEnvironment("sandbox") // sandbox || production
qoin.SetPrivateKey(`<your private key>`) // must use back quote (`) symbol
response := qoin.CreditCardCharge(map[string]string{}{
    "order_no": "<order number>",
})
c. Get Status
import "github.com/Qoin-Digital-Indonesia/qoin-go"

qoin.SetEnvironment("sandbox") // sandbox || production
qoin.SetPrivateKey(`<your private key>`) // must use back quote (`) symbol
qoin.SetSecretKey("<your secret key>")
qoin.SetReferenceNumber("<reference number>")
response := qoin.CreditCardGetStatus(map[string]string{
    "MerchantCode":  "<your merchant code>",
    "OrderNo":       "<order number>",
    "ReqTime":       time.Now().Format("2006-01-02 15:04:05"),
})
3. OVO
a. Create Order
import "github.com/Qoin-Digital-Indonesia/qoin-go"

qoin.SetEnvironment("sandbox") // sandbox || production
qoin.SetPrivateKey(`<your private key>`) // must use back quote (`) symbol
qoin.SetSecretKey("<your secret key>")
response := qoin.OvoCreateOrder(map[string]interface{}{
    "Amount":         10,
    "Currency":       "IDR",
    "Description":    string(descriptionJSON),
    "ReqTime":        time.Now().Format("2006-01-02 15:04:05"),
    "MerchantCode":   "<your merchant code>",
    "ReferenceNo":    "<reference number>",
    "CustomerName":   "Giovanni Reinard",
    "CustomerPhone":  "08123456789",
    "CustomerEmail":  "giovanni@qoin.id",
    "WalletType":     "OVO",
})
b. Get Status
import "github.com/Qoin-Digital-Indonesia/qoin-go"

qoin.SetEnvironment("sandbox") // sandbox || production
qoin.SetPrivateKey(`<your private key>`) // must use back quote (`) symbol
qoin.SetSecretKey("<your secret key>")
response := qoin.OvoGetStatus(map[string]string{
    "RequestTime":  time.Now().Format("2006-01-02 15:04:05"),
    "MerchantCode": "<your merchant code>",
    "ReferenceNo":  "<reference number>",
})
4. LinkAja
a. Create Order
import "github.com/Qoin-Digital-Indonesia/qoin-go"

qoin.SetEnvironment("sandbox") // sandbox || production
qoin.SetPrivateKey(`<your private key>`) // must use back quote (`) symbol
qoin.SetSecretKey("<your secret key>")
response := qoin.LinkAjaCreateOrder(map[string]interface{}{
    "Amount":         10,
    "Currency":       "IDR",
    "Description":    string(descriptionJSON),
    "ReqTime":        time.Now().Format("2006-01-02 15:04:05"),
    "MerchantCode":   "<your merchant code>",
    "ReferenceNo":    "<reference number>",
    "CustomerName":   "Giovanni Reinard",
    "CustomerPhone":  "08123456789",
    "CustomerEmail":  "giovanni@qoin.id",
    "WalletType":     "LINKAJA",
})
b. Get Status
import "github.com/Qoin-Digital-Indonesia/qoin-go"

qoin.SetEnvironment("sandbox") // sandbox || production
qoin.SetPrivateKey(`<your private key>`) // must use back quote (`) symbol
qoin.SetSecretKey("<your secret key>")
response := qoin.LinkAjaGetStatus(map[string]string{
    "RequestTime":  time.Now().Format("2006-01-02 15:04:05"),
    "MerchantCode": "<your merchant code>",
    "ReferenceNo":  "<reference number>",
})

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BriVaCreateOrder added in v0.0.2

func BriVaCreateOrder(body map[string]interface{}) map[string]interface{}

BriVaCreateOrder returns the response from BRI VA Create Order API

func BriVaGetStatus added in v0.0.9

func BriVaGetStatus(body map[string]string) map[string]interface{}

BriVaGetStatus returns the response from BRI VA Get Status API

func CreditCardCharge added in v0.0.11

func CreditCardCharge(body map[string]string) map[string]interface{}

CreditCardCharge returns the response from Credit Card Charge API

func CreditCardCreateOrder added in v0.0.10

func CreditCardCreateOrder(body map[string]interface{}) map[string]interface{}

CreditCardCreateOrder returns the response from Credit Card Create Order API

func CreditCardGetStatus added in v0.0.10

func CreditCardGetStatus(body map[string]string) map[string]interface{}

CreditCardGetStatus returns the response from Credit Card Get Status API

func LinkAjaCreateOrder added in v0.0.11

func LinkAjaCreateOrder(body map[string]interface{}) map[string]interface{}

LinkAjaCreateOrder returns the response from LinkAja Create Order API

func LinkAjaGetStatus added in v0.0.11

func LinkAjaGetStatus(body map[string]string) map[string]interface{}

LinkAjaGetStatus returns the response from LinkAja Get Status API

func OvoCreateOrder added in v0.0.11

func OvoCreateOrder(body map[string]interface{}) map[string]interface{}

OvoCreateOrder returns the response from OVO Create Order API

func OvoGetStatus added in v0.0.11

func OvoGetStatus(body map[string]string) map[string]interface{}

OvoGetStatus returns the response from OVO Get Status API

func SetEnvironment added in v0.0.2

func SetEnvironment(environment string)

SetEnvironment set the API environment

func SetPrivateKey added in v0.0.3

func SetPrivateKey(privKey string)

SetPrivateKey set the private key for generate signature

func SetReferenceNumber added in v0.0.3

func SetReferenceNumber(refNumber string)

SetReferenceNumber set the reference number for generate signature

func SetSecretKey added in v0.0.3

func SetSecretKey(secKey string)

SetSecretKey set the secret key for generate signature

func SnapCreateOrder added in v0.0.11

func SnapCreateOrder(body map[string]interface{}) map[string]interface{}

SnapCreateOrder returns the response from Snap Create Order API

Types

type Signer added in v0.0.4

type Signer interface {
	Sign(data []byte) ([]byte, error)
}

Signer can create signatures that verify against a public key.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL