Go NextPay API Wrapper
go get github.com/haashemi/go-nextpay
package main
import (
...
"github.com/haashemi/go-nextpay"
)
func main() {
nx := nextpay.New("My-NextPay-APIKey")
...
}
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())
// 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)
// 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)