Skip to content

Commit

Permalink
Merge pull request #385 from abyssparanoia/feature/impl-remittance-re…
Browse files Browse the repository at this point in the history
…gistration-deposit

Feature/impl remittance registration deposit
  • Loading branch information
abyssparanoia authored Jun 7, 2024
2 parents c93ae35 + 001c81e commit 627503b
Show file tree
Hide file tree
Showing 22 changed files with 283 additions and 63 deletions.
6 changes: 2 additions & 4 deletions payment/bank_account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ func TestEntryBancAccount(t *testing.T) {
}
defer func() { http.DefaultTransport.(*http.Transport).Proxy = defaultProxy }()

cli, _ := NewClient("siteID", "sitePass", "shopID", "shopPass", false)
cli.APIHost = apiHostTest
cli := newTestClient()
req := &EntryBankAccountRequest{
MemberID: "memberID",
MemberName: "member name",
Expand Down Expand Up @@ -79,8 +78,7 @@ func TestGetResultEntryBankAccount(t *testing.T) {
}
defer func() { http.DefaultTransport.(*http.Transport).Proxy = defaultProxy }()

cli, _ := NewClient("siteID", "sitePass", "shopID", "shopPass", false)
cli.APIHost = apiHostTest
cli := newTestClient()
req := &GetResultEntryBankAccountRequest{
TranID: "tranID",
}
Expand Down
6 changes: 2 additions & 4 deletions payment/bank_transfer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ func TestEntryGANBTran(t *testing.T) {
}
defer func() { http.DefaultTransport.(*http.Transport).Proxy = defaultProxy }()

cli, _ := NewClient("siteID", "sitePass", "shopID", "shopPass", false)
cli.APIHost = apiHostTest
cli := newTestClient()
req := &EntryTranGANBRequest{
OrderID: "orderID",
Amount: 4214144,
Expand Down Expand Up @@ -59,8 +58,7 @@ func TestExecGANBTran(t *testing.T) {
}
defer func() { http.DefaultTransport.(*http.Transport).Proxy = defaultProxy }()

cli, _ := NewClient("siteID", "sitePass", "shopID", "shopPass", false)
cli.APIHost = apiHostTest
cli := newTestClient()
req := &ExecTranGANBRequest{
AccessID: "accessID",
AccessPass: "accessPass",
Expand Down
20 changes: 19 additions & 1 deletion payment/client.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package payment

import (
"crypto/tls"
"fmt"
"io"
"net"
"net/http"
"net/url"
"strings"
Expand Down Expand Up @@ -39,7 +41,23 @@ func NewClient(

return &Client{
HTTPClient: &http.Client{
Timeout: time.Second * 30,
Timeout: 5 * time.Second, // limitation of the request time
Transport: &http.Transport{
DialContext: (&net.Dialer{
Timeout: time.Second, // limitation of the dial time
}).DialContext,
TLSClientConfig: &tls.Config{
MinVersion: tls.VersionTLS12,
// #nosec G402
CipherSuites: []uint16{tls.TLS_RSA_WITH_AES_128_GCM_SHA256},
},
TLSHandshakeTimeout: 10 * time.Second, // limitation of the TLS handshake time
ResponseHeaderTimeout: 10 * time.Second, // limitation of the response header time
IdleConnTimeout: 10 * time.Second, // limitation of the idle connection time
MaxIdleConns: 100, // limitation of the max idle connections
MaxConnsPerHost: 100, // limitation of the max connections per host
MaxIdleConnsPerHost: 100, // limitation of the max idle connections per host
},
},
SiteID: siteID,
SitePass: sitePass,
Expand Down
9 changes: 3 additions & 6 deletions payment/convenience_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ func TestClient_ConvenienceStoreEntryTran(t *testing.T) {
}
defer func() { http.DefaultTransport.(*http.Transport).Proxy = defaultProxy }()

cli, _ := NewClient("siteID", "sitePass", "shopID", "shopPass", false)
cli.APIHost = apiHostTest
cli := newTestClient()
req := &ConvenienceStoreEntryTranRequest{
OrderID: "orderID",
Amount: 4214144,
Expand Down Expand Up @@ -58,8 +57,7 @@ func TestClient_ConvenienceStoreExecTran(t *testing.T) {
}
defer func() { http.DefaultTransport.(*http.Transport).Proxy = defaultProxy }()

cli, _ := NewClient("siteID", "sitePass", "shopID", "shopPass", false)
cli.APIHost = apiHostTest
cli := newTestClient()

req := &ConvenienceStoreExecTranRequest{
AccessID: "accessID",
Expand Down Expand Up @@ -92,8 +90,7 @@ func TestClient_ConvenienceStoreCancel(t *testing.T) {
}
defer func() { http.DefaultTransport.(*http.Transport).Proxy = defaultProxy }()

cli, _ := NewClient("siteID", "sitePass", "shopID", "shopPass", false)
cli.APIHost = apiHostTest
cli := newTestClient()
req := &ConvenienceStoreCancelRequest{
AccessID: "accessID",
AccessPass: "accessPass",
Expand Down
12 changes: 4 additions & 8 deletions payment/credit_card_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ func TestSaveCard(t *testing.T) {
}
defer func() { http.DefaultTransport.(*http.Transport).Proxy = defaultProxy }()

cli, _ := NewClient("siteID", "sitePass", "shopID", "shopPass", false)
cli.APIHost = apiHostTest
cli := newTestClient()
req := &SaveCardRequest{
MemberID: "memberID",
SeqMode: "1",
Expand Down Expand Up @@ -61,8 +60,7 @@ func TestTradedCard(t *testing.T) {
}
defer func() { http.DefaultTransport.(*http.Transport).Proxy = defaultProxy }()

cli, _ := NewClient("siteID", "sitePass", "shopID", "shopPass", false)
cli.APIHost = apiHostTest
cli := newTestClient()
req := &TradedCardRequest{
OrderID: "orderID",
MemberID: "memberID",
Expand Down Expand Up @@ -90,8 +88,7 @@ func TestDeleteCard(t *testing.T) {
}
defer func() { http.DefaultTransport.(*http.Transport).Proxy = defaultProxy }()

cli, _ := NewClient("siteID", "sitePass", "shopID", "shopPass", false)
cli.APIHost = apiHostTest
cli := newTestClient()
req := &DeleteCardRequest{
MemberID: "memberID",
CardSeq: "0001",
Expand Down Expand Up @@ -128,8 +125,7 @@ func TestSearchCard(t *testing.T) {
}
defer func() { http.DefaultTransport.(*http.Transport).Proxy = defaultProxy }()

cli, _ := NewClient("siteID", "sitePass", "shopID", "shopPass", false)
cli.APIHost = apiHostTest
cli := newTestClient()
req := &SearchCardRequest{
MemberID: "memberID",
}
Expand Down
12 changes: 4 additions & 8 deletions payment/member_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ func TestSaveMember(t *testing.T) {
}
defer func() { http.DefaultTransport.(*http.Transport).Proxy = defaultProxy }()

cli, _ := NewClient("siteID", "sitePass", "shopID", "shopPass", false)
cli.APIHost = apiHostTest
cli := newTestClient()
req := &SaveMemberRequest{
MemberID: "memberID",
MemberName: "memberName",
Expand Down Expand Up @@ -58,8 +57,7 @@ func TestUpdateMember(t *testing.T) {
}
defer func() { http.DefaultTransport.(*http.Transport).Proxy = defaultProxy }()

cli, _ := NewClient("siteID", "sitePass", "shopID", "shopPass", false)
cli.APIHost = apiHostTest
cli := newTestClient()
req := &UpdateMemberRequest{
MemberID: "memberID",
MemberName: "memberName",
Expand Down Expand Up @@ -87,8 +85,7 @@ func TestDeleteMember(t *testing.T) {
}
defer func() { http.DefaultTransport.(*http.Transport).Proxy = defaultProxy }()

cli, _ := NewClient("siteID", "sitePass", "shopID", "shopPass", false)
cli.APIHost = apiHostTest
cli := newTestClient()
req := &DeleteMemberRequest{
MemberID: "memberID",
}
Expand Down Expand Up @@ -117,8 +114,7 @@ func TestSearchMember(t *testing.T) {
}
defer func() { http.DefaultTransport.(*http.Transport).Proxy = defaultProxy }()

cli, _ := NewClient("siteID", "sitePass", "shopID", "shopPass", false)
cli.APIHost = apiHostTest
cli := newTestClient()
req := &SearchMemberRequest{
MemberID: "memberID",
}
Expand Down
3 changes: 1 addition & 2 deletions payment/multi_payment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ func TestSearchTradeMulti(t *testing.T) {
}
defer func() { http.DefaultTransport.(*http.Transport).Proxy = defaultProxy }()

cli, _ := NewClient("siteID", "sitePass", "shopID", "shopPass", false)
cli.APIHost = apiHostTest
cli := newTestClient()
req := &SearchTradeMultiRequest{
OrderID: "orderID",
PayType: PayEasyPayType,
Expand Down
6 changes: 2 additions & 4 deletions payment/payeasy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ func TestPayEasyEntryTran(t *testing.T) {
}
defer func() { http.DefaultTransport.(*http.Transport).Proxy = defaultProxy }()

cli, _ := NewClient("siteID", "sitePass", "shopID", "shopPass", false)
cli.APIHost = apiHostTest
cli := newTestClient()
req := &PayEasyEntryTranRequest{
OrderID: "orderID",
Amount: 4214144,
Expand Down Expand Up @@ -59,8 +58,7 @@ func TestPayEasyExecTran(t *testing.T) {
}
defer func() { http.DefaultTransport.(*http.Transport).Proxy = defaultProxy }()

cli, _ := NewClient("siteID", "sitePass", "shopID", "shopPass", false)
cli.APIHost = apiHostTest
cli := newTestClient()

req := &PayEasyExecTranRequest{
AccessID: "accessID",
Expand Down
12 changes: 4 additions & 8 deletions payment/paypay_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ func TestPayPayEntryTran(t *testing.T) {
}
defer func() { http.DefaultTransport.(*http.Transport).Proxy = defaultProxy }()

cli, _ := NewClient("siteID", "sitePass", "shopID", "shopPass", false)
cli.APIHost = apiHostTest
cli := newTestClient()
req := &PayPayEntryTranRequest{
OrderID: "orderID",
Amount: 4214144,
Expand Down Expand Up @@ -60,8 +59,7 @@ func TestPayPayExecTran(t *testing.T) {
}
defer func() { http.DefaultTransport.(*http.Transport).Proxy = defaultProxy }()

cli, _ := NewClient("siteID", "sitePass", "shopID", "shopPass", false)
cli.APIHost = apiHostTest
cli := newTestClient()

req := &PayPayExecTranRequest{
AccessID: "accessID",
Expand Down Expand Up @@ -91,8 +89,7 @@ func TestPayPaySales(t *testing.T) {
}
defer func() { http.DefaultTransport.(*http.Transport).Proxy = defaultProxy }()

cli, _ := NewClient("siteID", "sitePass", "shopID", "shopPass", false)
cli.APIHost = apiHostTest
cli := newTestClient()

req := &PayPaySalesRequest{
AccessID: "accessID",
Expand Down Expand Up @@ -122,8 +119,7 @@ func TestPayPayCancelReturn(t *testing.T) {
}
defer func() { http.DefaultTransport.(*http.Transport).Proxy = defaultProxy }()

cli, _ := NewClient("siteID", "sitePass", "shopID", "shopPass", false)
cli.APIHost = apiHostTest
cli := newTestClient()

req := &PayPayCancelReturnRequest{
AccessID: "accessID",
Expand Down
9 changes: 3 additions & 6 deletions payment/postpay_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ func TestPostpayEntryTran(t *testing.T) {
}
defer func() { http.DefaultTransport.(*http.Transport).Proxy = defaultProxy }()

cli, _ := NewClient("siteID", "sitePass", "shopID", "shopPass", false)
cli.APIHost = apiHostTest
cli := newTestClient()
req := &PostpayEntryTranRequest{
OrderID: "orderID",
Amount: 4214144,
Expand Down Expand Up @@ -60,8 +59,7 @@ func TestPostpayExecTran(t *testing.T) {
}
defer func() { http.DefaultTransport.(*http.Transport).Proxy = defaultProxy }()

cli, _ := NewClient("siteID", "sitePass", "shopID", "shopPass", false)
cli.APIHost = apiHostTest
cli := newTestClient()
req := &PostpayExecTranRequest{
AccessID: "accessID",
AccessPass: "accessPass",
Expand Down Expand Up @@ -104,8 +102,7 @@ func TestPostpayShippedTran(t *testing.T) {
}
defer func() { http.DefaultTransport.(*http.Transport).Proxy = defaultProxy }()

cli, _ := NewClient("siteID", "sitePass", "shopID", "shopPass", false)
cli.APIHost = apiHostTest
cli := newTestClient()
req := &PostpayShippedTranRequest{
AccessID: "accessID",
AccessPass: "accessPass",
Expand Down
10 changes: 10 additions & 0 deletions payment/test_util.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package payment

import "net/http"

func newTestClient() *Client {
cli, _ := NewClient("siteID", "sitePass", "shopID", "shopPass", false)
cli.APIHost = apiHostTest
cli.SetHTTPClient(http.DefaultClient)
return cli
}
15 changes: 5 additions & 10 deletions payment/tran_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ func TestEntryTran(t *testing.T) {
}
defer func() { http.DefaultTransport.(*http.Transport).Proxy = defaultProxy }()

cli, _ := NewClient("siteID", "sitePass", "shopID", "shopPass", false)
cli.APIHost = apiHostTest
cli := newTestClient()
req := &EntryTranRequest{
OrderID: "orderID",
JobCD: JobCDAuth,
Expand Down Expand Up @@ -63,8 +62,7 @@ func TestExecTran(t *testing.T) {
}
defer func() { http.DefaultTransport.(*http.Transport).Proxy = defaultProxy }()

cli, _ := NewClient("siteID", "sitePass", "shopID", "shopPass", false)
cli.APIHost = apiHostTest
cli := newTestClient()
req := &ExecTranRequest{
AccessID: "accessID",
AccessPass: "accessPass",
Expand Down Expand Up @@ -97,8 +95,7 @@ func TestExecTranWithToken(t *testing.T) {
}
defer func() { http.DefaultTransport.(*http.Transport).Proxy = defaultProxy }()

cli, _ := NewClient("siteID", "sitePass", "shopID", "shopPass", false)
cli.APIHost = apiHostTest
cli := newTestClient()
req := &ExecTranRequestWithToken{
AccessID: "accessID",
AccessPass: "accessPass",
Expand Down Expand Up @@ -130,8 +127,7 @@ func TestAlterTran(t *testing.T) {
}
defer func() { http.DefaultTransport.(*http.Transport).Proxy = defaultProxy }()

cli, _ := NewClient("siteID", "sitePass", "shopID", "shopPass", false)
cli.APIHost = apiHostTest
cli := newTestClient()
req := &AlterTranRequest{
AccessID: "accessID",
AccessPass: "accessPass",
Expand Down Expand Up @@ -162,8 +158,7 @@ func TestChangeAlterTran(t *testing.T) {
}
defer func() { http.DefaultTransport.(*http.Transport).Proxy = defaultProxy }()

cli, _ := NewClient("siteID", "sitePass", "shopID", "shopPass", false)
cli.APIHost = apiHostTest
cli := newTestClient()
req := &ChangeTranRequest{
AccessID: "accessID",
AccessPass: "accessPass",
Expand Down
2 changes: 1 addition & 1 deletion remittance/account_registration.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

type AccountRegistrationRequest struct {
Method BankAccountRegistrationMethod `json:"Method" validate:"required"`
BankID string `json:"Bank_ID" validate:"required"`
BankID string `json:"Bank_ID" validate:"required,max=60"`
BankCode string `json:"Bank_Code,omitempty"`
BranchCode string `json:"Branch_Code,omitempty"`
AccountType string `json:"Account_Type,omitempty"` // 1 - Normal, 2 - Current, 4 - Savings
Expand Down
1 change: 1 addition & 0 deletions remittance/account_registration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func TestAccountRegistration(t *testing.T) {

cli, _ := NewClient("shopID", "shopPass", false)
cli.APIHost = apiHostTest
cli.SetHTTPClient(http.DefaultClient)
req := &AccountRegistrationRequest{
Method: BankAccountRegistrationMethodRegister,
BankID: "bankID",
Expand Down
Loading

0 comments on commit 627503b

Please sign in to comment.