CI codecov GitHub Go Report Card

Go Veritrans4G

Overview

  • Account and card management (Add/Update/Delete/Restore/Get)
  • Payment with the MDK token
  • Payment with the registered account

Getting Started

MDK Token Payment

  1. Initialize the MDK service

cardService := NewMDKService(MDKConfig{
  APIURL:   "MDK_API_URL",
  APIToken: "MDK_API_TOKEN",
})
  1. Get MDK token from the card information

cardToken, err := cardService.GetCardToken(&ClientCardInfo{
  CardNumber:   "4111111111111111",
  CardExpire:   "12/25",
  SecurityCode: "123",
})
  1. Initialize the payment service

config := ConnectionConfig{
  MerchantCCID:     "MERCHANT_CCID",
  MerchantPassword: "MERCHANT_PASSWORD",
  PaymentAPIURL:    "PAYMENT_API_URL",
  TxnVersion:       "TXN_VERSION",
  DummyRequest:     "DUMMY_REQUEST",
}
paymentService, _ = NewPaymentService(config)
  1. Pay with the MDK token

authorizeParam := Params{
  OrderID:     "MDK Order ID",
  Amount:      "Amount",
  JPO:         "10",
  WithCapture: "true",
  PayNowIDParam: &PayNowIDParam{
    Token: "MDK TOKEN"
  },
}
paymentService.Authorize(&authorizeParam, PaymentServiceType(PayCard))

Account Management

  1. Initialize the account service

accountService = NewAccountService(ConnectionConfig{
  MerchantCCID:    "MERCHANT_CCID",
  MerchantPassword:"MERCHANT_PASSWORD",
  AccountAPIURL:   "ACCOUNT_API_URL",
  TxnVersion:      "TXN_VERSION",
  DummyRequest:    "DUMMY_REQUEST",
})
accountService.CreateAccount(accountParam)
  1. Create a veritrans account

accountParam := &AccountParam{
  AccountID: "Your Account ID",
}
accountService.CreateAccount(accontParam)
  1. Add a credit card

accountParam.CardParam = &CardParam{
  CardNumber:  "Your Card Number",
  CardExpire:  "12/25",
  DefaultCard: "1",
}
accountService.CreateCard(accountParam)
  1. Pay with the registered account

authorizeParam := Params{
  OrderID:     "Account Order ID",
  Amount:      payAmount,
  JPO:         "10",
  WithCapture: "false",
  PayNowIDParam: &PayNowIDParam{
    AccountParam: &AccountParam{
      AccountID: "Your Account ID",
    },
  },
}
paymentService.Authorize(&authorizeParam, PaymentServiceType(PayCard))

Test

Create .env file and define the required variables

MDK_API_TOKEN=xxxxxxxx-xxxx-xxxx-xxxxxxxxxx
MDK_API_URL=https://api.veritrans.co.jp/4gtoken
MERCHANT_CCID=A100000000000001069713cc
MERCHANT_PASSWORD=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
DUMMY_REQUEST=0
TXN_VERSION=2.0.0
ACCOUNT_API_URL=https://api.veritrans.co.jp:443/paynowid/v1
PAYMENT_API_URL=https://api.veritrans.co.jp:443/paynow/v2
SEARCH_API_URL=https://api.veritrans.co.jp:443/paynow-search/v2

Run the test using the following command

$ go test -v

GitHub

View Github