forked from veritrans/go-midtrans
-
Notifications
You must be signed in to change notification settings - Fork 0
/
request_test.go
43 lines (34 loc) · 1.27 KB
/
request_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package midtrans_test
import (
"encoding/json"
"testing"
"github.com/cheekybits/is"
midtrans "github.com/veritrans/go-midtrans"
)
func TestCustomerFieldOmmittable(t *testing.T) {
is := is.New(t)
req := midtrans.ChargeReq{
PaymentType: midtrans.SourceCreditCard,
}
reqJSON, _ := json.Marshal(req)
is.Equal(string(reqJSON), `{"payment_type":"credit_card","transaction_details":{"order_id":"","gross_amount":0}}`)
req.CustField1 = "f1"
req.CustField2 = "f2"
req.CustField3 = "f3"
reqJSON, _ = json.Marshal(req)
is.Equal(string(reqJSON), `{"payment_type":"credit_card","transaction_details":{"order_id":"","gross_amount":0},"custom_field1":"f1","custom_field2":"f2","custom_field3":"f3"}`)
}
func TestBankTransferMandiriBill(t *testing.T) {
is := is.New(t)
req := midtrans.ChargeReq{
PaymentType: midtrans.SourceBankTransfer,
BankTransfer: &midtrans.BankTransferDetail{
MandiriBillBankTransferDetail: &midtrans.MandiriBillBankTransferDetail{
BillInfo1: "Silahkan transfer",
BillInfo2: "Untuk pembelian pulsa",
},
},
}
reqJSON, _ := json.Marshal(req)
is.Equal(string(reqJSON), `{"payment_type":"bank_transfer","transaction_details":{"order_id":"","gross_amount":0},"bank_transfer":{"bill_info1":"Silahkan transfer","bill_info2":"Untuk pembelian pulsa"}}`)
}