Skip to content
This repository has been archived by the owner on Jun 29, 2020. It is now read-only.

Galaco/komoju-go

Repository files navigation

GoDoc Go report card GolangCI Build Status codecov CircleCI

komoju-go

Unoffical Golang wrapper for Komoju api. Based on documentation available here: https://docs.komoju.com/en/getting_started/overview/#products

A work-in-progress written mostly for fun. Any bugs found please feel free to open an issue and/or raise a PR.

Usage

Hosted Page

package main

import (
	komoju "github.com/galaco/komoju-go"
)

func main() {
	locale := "en"
	merchantUuid := "degica-mart"
	paymentMethod := komoju.PaymentMethodCreditCard
	baseUri := komoju.HostedPageBaseURI(locale, merchantUuid, paymentMethod)
	
	// your secret key
	secretKey := []byte("ABCD1234567890")
	config := komoju.HostedPageConfig{
    	Transaction: komoju.HostedPageTransaction{
    		Amount: 130,
    		Currency: "JPY",
    		Customer: komoju.HostedPageCustomer{
    			GivenName: "John",
    			FamilyName: "Smith",
    			GivenNameKana: "John",
    			FamilyNameKana: "Smith",
    			Email: "",
    			Phone: "",
    		},
    		ExternalOrderNumber: "M8x6U6Z5HEeXv3",
    		ReturnUrl: "http://example.com/?sucess=true",
    		CancelUrl: "http://example.com/?cancel=true",
    		Tax: 0,
    	},
        Timestamp: 1561022519,
    }
	
	paymentUri,_ := komoju.HostedPageURI(secretKey, baseUri, &config)
	// Now redirect to paymentUri
}

API

package main

import (
	komoju "github.com/galaco/komoju-go"
	"log"
)	
func main() {
    // ... make a request to the komoju API
    // expect a standard response.Body as io.ReadCloser

    payload := komoju.ApiResponseEvents{}
    // remember to handle error
    _ := komoju.ParseApiResponse(response.Body, &payload)
    
    // Do whatever with response
    log.Println(payload.Data[0].Resource)
}

About

Golang wrapper for Komoju payments api

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages