Skip to content
This repository has been archived by the owner on Mar 19, 2024. It is now read-only.

haashemi/go-nextpay

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go NextPay API Wrapper

Go Report Card Go Reference

Installation

go get github.com/haashemi/go-nextpay

Usage

0- First step

package main

import (
 ...
	"github.com/haashemi/go-nextpay"
)

func main() {
	nx := nextpay.New("My-NextPay-APIKey")
 ...
}

1- Create Token

token, err := nx.CreateToken("MYORDER999", MyCallbackUri, 20000, nil)
// Handle err...
fmt.Println(token.PaymentURL())

////////
// OR //
////////

token, err := nx.CreateToken("MYORDER999", MyCallbackUri, 200_000, &nextpay.CreateTokenOptions{
	Currency:      nextpay.CurrencyIRR,
	CustomerPhone: "09123456789",
	AutoVerify:    true,
	PayerName:     "علی هاشمی",
	CustomFields: &nextpay.Map{
		"Product": "MyProduct",
		"UserID":  "23908758",
	},
	...
})
// Handle err...
fmt.Println(token.PaymentURL())

2- Verify

// TransactionID => token.TransactionID from step one
// 20_000 => IRT amount from step one

vr, err := nx.Verify(TransactionID, 20_000)
// Handle err...
fmt.Println(vr)

2.1- Refund

// TransactionID => token.TransactionID from step one
// 20_000 => IRT amount from step one

rf, err := nx.Refund(token.TransactionID, 20_000)
// Handle err...
fmt.Println(rf)