@@ -18,9 +18,19 @@ func CreateCustomerTest() (*conekta.Customer, error){
18
18
return c , err
19
19
}
20
20
21
+ func CreateDeclinedCustomerTest () (* conekta.Customer , error ){
22
+ cus := & conekta.CustomerParams {}
23
+ customerParams := cus .MockCustomerPaymentSource ()
24
+ customerParams .PaymentSources [0 ].TokenID = "tok_test_card_declined"
25
+ c , err := customer .Create (customerParams )
26
+ return c , err
27
+ }
28
+
21
29
func CreatePlanTest () (* conekta.Plan , error ) {
22
30
pl := & conekta.PlanParams {}
23
- p , err := plan .Create (pl .MockPlanCreate ())
31
+ pl .MockPlanCreate ()
32
+ pl .TrialPeriodDays = 0
33
+ p , err := plan .Create (pl )
24
34
return p , err
25
35
}
26
36
@@ -40,6 +50,23 @@ func TestCreate(t *testing.T){
40
50
assert .Nil (t , err )
41
51
}
42
52
53
+ func TestCreateProcessingError (t * testing.T ){
54
+ c , _ := CreateDeclinedCustomerTest ()
55
+ p , _ := CreatePlanTest ()
56
+
57
+ sp := & conekta.SubscriptionParams {
58
+ PlanID : p .ID ,
59
+ CardID : c .DefaultPaymentSourceID ,
60
+ }
61
+ sub , err := Create (c .ID , sp )
62
+
63
+ assert .Equal (t , sp .CardID , sub .CardID )
64
+ assert .Equal (t , sp .PlanID , sub .PlanID )
65
+ assert .Equal (t , "past_due" , sub .Status )
66
+
67
+ assert .Nil (t , err )
68
+ }
69
+
43
70
44
71
func TestCreateError (t * testing.T ) {
45
72
cus := & conekta.CustomerParams {}
@@ -64,6 +91,22 @@ func TestResume(t *testing.T) {
64
91
assert .Nil (t , err )
65
92
}
66
93
94
+ func TestResumeProcessingError (t * testing.T ) {
95
+ c , _ := CreateDeclinedCustomerTest ()
96
+ p , _ := CreatePlanTest ()
97
+
98
+ sp := & conekta.SubscriptionParams {
99
+ PlanID : p .ID ,
100
+ CardID : c .DefaultPaymentSourceID ,
101
+ }
102
+ sub , _ := Create (c .ID , sp )
103
+ Pause (sub .CustomerID )
104
+
105
+ pausedSub , err := Resume (sub .CustomerID )
106
+ assert .Nil (t , err )
107
+ assert .Equal (t , "past_due" , pausedSub .Status )
108
+ }
109
+
67
110
func TestPause (t * testing.T ) {
68
111
c , _ := CreateCustomerTest ()
69
112
p , _ := CreatePlanTest ()
@@ -90,4 +133,4 @@ func TestCancel(t *testing.T) {
90
133
91
134
_ , err := Cancel (sub .CustomerID )
92
135
assert .Nil (t , err )
93
- }
136
+ }
0 commit comments