diff options
| author | Shulhan <ms@kilabit.info> | 2023-01-31 21:24:45 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2023-02-01 11:02:09 +0700 |
| commit | b4b6699c27b04893c73c50553070682799220080 (patch) | |
| tree | 2579635e56702449a6427ac0a8586524e2adf3b6 /payment_method.go | |
| parent | d8b4bd20f3755a1f323c3a563167f240cdb11e23 (diff) | |
| download | duitku-b4b6699c27b04893c73c50553070682799220080.tar.xz | |
all: split the merchant into DefaultMerchant and PaymentMerchant
The PaymentMerchant will be used if the payment method during inquiry
exist as the key in it; otherwise it will use DefaultMerchant
Diffstat (limited to 'payment_method.go')
| -rw-r--r-- | payment_method.go | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/payment_method.go b/payment_method.go index b5e95fa..9dffcda 100644 --- a/payment_method.go +++ b/payment_method.go @@ -45,19 +45,21 @@ func (req *PaymentMethod) SetDateTime(t time.Time) { // Signature. func (req *PaymentMethod) Sign(opts ClientOptions) { var ( + merchant = opts.DefaultMerchant + plain string hash [sha256.Size]byte ) if len(req.MerchantCode) == 0 { - req.MerchantCode = opts.MerchantCode + req.MerchantCode = merchant.Code } if len(req.DateTime) == 0 { req.SetDateTime(time.Now()) } - plain = fmt.Sprintf(`%s%d%s%s`, req.MerchantCode, req.Amount, req.DateTime, opts.MerchantApiKey) + plain = fmt.Sprintf(`%s%d%s%s`, req.MerchantCode, req.Amount, req.DateTime, merchant.ApiKey) hash = sha256.Sum256([]byte(plain)) req.Signature = hex.EncodeToString(hash[:]) |
