-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstallment_test.go
85 lines (78 loc) · 2.72 KB
/
installment_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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package asaas
import (
"context"
"testing"
"time"
)
func TestInstallmentUpdateSplitsById(t *testing.T) {
initBankSlipCharge(true)
accessToken := getEnvValue(EnvAccessToken)
installmentId := getEnvValue(EnvChargeInstallmentId)
walletIdSecondary := getEnvValue(EnvWalletIdSecondary)
ctx, cancel := context.WithTimeout(context.TODO(), 40*time.Second)
defer cancel()
nInstallment := NewInstallment(EnvSandbox, accessToken)
resp, err := nInstallment.UpdateSplitsById(ctx, installmentId, UpdateSplitsRequest{
Splits: []SplitRequest{
{
WalletId: walletIdSecondary,
FixedValue: 0,
PercentualValue: 50,
TotalFixedValue: 0,
},
},
})
assertResponseSuccess(t, resp, err)
}
func TestInstallmentDeleteById(t *testing.T) {
initBankSlipCharge(true)
accessToken := getEnvValue(EnvAccessToken)
installmentId := getEnvValue(EnvChargeInstallmentId)
ctx, cancel := context.WithTimeout(context.TODO(), 40*time.Second)
defer cancel()
nInstallment := NewInstallment(EnvSandbox, accessToken)
resp, err := nInstallment.DeleteById(ctx, installmentId)
assertResponseSuccess(t, resp, err)
}
func TestInstallmentRefundById(t *testing.T) {
initCreditCardCharge(true, false)
accessToken := getEnvValue(EnvAccessToken)
installmentId := getEnvValue(EnvChargeInstallmentId)
ctx, cancel := context.WithTimeout(context.TODO(), 40*time.Second)
defer cancel()
nInstallment := NewInstallment(EnvSandbox, accessToken)
resp, err := nInstallment.RefundById(ctx, installmentId)
assertResponseSuccess(t, resp, err)
}
func TestInstallmentGetById(t *testing.T) {
initBankSlipCharge(true)
accessToken := getEnvValue(EnvAccessToken)
installmentId := getEnvValue(EnvChargeInstallmentId)
ctx, cancel := context.WithTimeout(context.TODO(), 40*time.Second)
defer cancel()
nInstallment := NewInstallment(EnvSandbox, accessToken)
resp, err := nInstallment.GetById(ctx, installmentId)
assertResponseSuccess(t, resp, err)
}
func TestInstallmentGetPaymentBookById(t *testing.T) {
initBankSlipCharge(true)
accessToken := getEnvValue(EnvAccessToken)
installmentId := getEnvValue(EnvChargeInstallmentId)
ctx, cancel := context.WithTimeout(context.TODO(), 40*time.Second)
defer cancel()
nInstallment := NewInstallment(EnvSandbox, accessToken)
resp, err := nInstallment.GetPaymentBookById(ctx, installmentId, InstallmentPaymentBookRequest{
Sort: "",
Order: "",
})
assertResponseFailure(resp, err)
}
func TestInstallmentGetAll(t *testing.T) {
initBankSlipCharge(true)
accessToken := getEnvValue(EnvAccessToken)
ctx, cancel := context.WithTimeout(context.TODO(), 40*time.Second)
defer cancel()
nInstallment := NewInstallment(EnvSandbox, accessToken)
resp, err := nInstallment.GetAll(ctx, PageableDefaultRequest{})
assertResponseSuccess(t, resp, err)
}