aboutsummaryrefslogtreecommitdiff
path: root/rtol_inquiry.go
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2022-11-04 13:49:28 +0700
committerShulhan <ms@kilabit.info>2022-11-04 19:01:07 +0700
commit0eef440900eda71b3a257707e49e0ad53be5353f (patch)
tree7682364bc2f6ac826afd27fe71980ede98160b73 /rtol_inquiry.go
parent1846d3fc5d6a364986c073afccc66936ab3e469d (diff)
downloadduitku-0eef440900eda71b3a257707e49e0ad53be5353f.tar.xz
all: implement API for online transfer inquiry
The RtolInquiry method get the information of the name of the account owner of the transfer destination. After getting this information, customers can determine whether the purpose of such a transfer is in accordance with the intended or not. If appropriate, the customer can proceed to the transfer process. Ref: https://docs.duitku.com/disbursement/en/#transfer-online
Diffstat (limited to 'rtol_inquiry.go')
-rw-r--r--rtol_inquiry.go46
1 files changed, 46 insertions, 0 deletions
diff --git a/rtol_inquiry.go b/rtol_inquiry.go
new file mode 100644
index 0000000..33ab55d
--- /dev/null
+++ b/rtol_inquiry.go
@@ -0,0 +1,46 @@
+package duitku
+
+import (
+ "crypto/sha256"
+ "encoding/hex"
+ "fmt"
+)
+
+// RtolInquiry contains request to initiate transfer from merchant to
+// customer's bank account using [Online Transfer].
+//
+// The signature formula is SHA256(email + timestamp + bankCode +
+// bankAccount + amountTransfer + purpose + apiKey).
+//
+// [Online Transfer]: https://docs.duitku.com/disbursement/en/#online-transfer-inquiry-request
+type RtolInquiry struct {
+ // Destination Bank Code.
+ BankCode string `json:"bankCode"`
+
+ // Destination account number.
+ BankAccount string `json:"bankAccount"`
+
+ // Description of transfer purpose.
+ Purpose string `json:"purpose"`
+
+ // Customer name provided by merchant.
+ SenderName string `json:"senderName"`
+
+ request
+
+ // Customer ID provided by merchant.
+ SenderID int64 `json:"senderID"`
+
+ // Disbursement transfer amount.
+ Amount int64 `json:"amountTransfer"`
+}
+
+func (inq *RtolInquiry) sign(apiKey string) {
+ var (
+ plain = fmt.Sprintf(`%s%d%s%s%d%s%s`, inq.Email,
+ inq.Timestamp, inq.BankCode, inq.BankAccount,
+ inq.Amount, inq.Purpose, apiKey)
+ plainHash [sha256.Size]byte = sha256.Sum256([]byte(plain))
+ )
+ inq.Signature = hex.EncodeToString(plainHash[:])
+}