6
6
from mangopaysdk .types .payinpaymentdetailscard import PayInPaymentDetailsCard
7
7
from mangopaysdk .types .payinexecutiondetailsweb import PayInExecutionDetailsWeb
8
8
from mangopaysdk .types .payinpaymentdetailsbankwire import PayInPaymentDetailsBankWire
9
+ from mangopaysdk .types .payinpaymentdetailspreauthorized import PayInPaymentDetailsPreAuthorized
10
+ from mangopaysdk .types .money import Money
9
11
10
12
11
13
class Test_PayIns (TestBase ):
12
14
"Tests methods for pay-ins"
13
15
14
16
def test_PayIns_Create_CardWeb (self ):
15
17
payIn = self .getJohnsPayInCardWeb ()
16
- self .assertTrue (int (payIn .Id ) > 0 )
18
+ self .assertTrue (len (payIn .Id ) > 0 )
17
19
self .assertEqual (payIn .PaymentType , PayInPaymentType .CARD )
18
20
self .assertIsInstance (payIn .PaymentDetails , PayInPaymentDetailsCard )
19
21
self .assertEqual (payIn .ExecutionType , ExecutionType .WEB )
@@ -40,7 +42,7 @@ def test_PayIns_Create_CardDirect(self):
40
42
payIn = self .getJohnsPayInCardDirect ()
41
43
wallet = self .sdk .wallets .Get (johnWallet .Id )
42
44
user = self .getJohn ()
43
- self .assertTrue (int (payIn .Id ) > 0 )
45
+ self .assertTrue (len (payIn .Id ) > 0 )
44
46
self .assertEqual (wallet .Id , payIn .CreditedWalletId )
45
47
self .assertEqual (PayInPaymentType .CARD , payIn .PaymentType )
46
48
self .assertIsInstance (payIn .PaymentDetails , PayInPaymentDetailsCard )
@@ -71,16 +73,53 @@ def test_PayIns_CreateRefund_CardDirect(self):
71
73
payIn = self .getJohnsPayInCardDirect (wallet )
72
74
walletAfterPayIn = self .sdk .wallets .Get (wallet .Id )
73
75
self .assertEqual (walletAfterPayIn .Balance .Amount , payIn .DebitedFunds .Amount )
74
- self .assertTrue (int (payIn .Id ) > 0 )
76
+ self .assertTrue (len (payIn .Id ) > 0 )
75
77
76
78
refund = self .getJohnsRefundForPayIn (payIn )
77
79
walletAfterRefund = self .sdk .wallets .Get (wallet .Id )
78
- self .assertTrue (int (refund .Id ) > 0 )
80
+ self .assertTrue (len (refund .Id ) > 0 )
79
81
self .assertTrue (refund .DebitedFunds .Amount , payIn .DebitedFunds .Amount )
80
82
self .assertEqual (walletAfterRefund .Balance .Amount , walletAfterPayIn .Balance .Amount - payIn .DebitedFunds .Amount )
81
83
self .assertEqual (TransactionType .PAYOUT , refund .Type )
82
84
self .assertEqual (TransactionNature .REFUND , refund .Nature )
83
85
86
+ def test_PayIns_PreAuthorizedDirect (self ):
87
+ cardPreAuthorization = self .getJohnsCardPreAuthorization ()
88
+ wallet = self .getJohnsWalletWithMoney ()
89
+ user = self .getJohn ()
90
+ # create pay-in PRE-AUTHORIZED DIRECT
91
+ payIn = PayIn ()
92
+ payIn .CreditedWalletId = wallet .Id
93
+ payIn .AuthorId = user .Id
94
+ payIn .DebitedFunds = Money ()
95
+ payIn .DebitedFunds .Amount = 1000
96
+ payIn .DebitedFunds .Currency = 'EUR'
97
+ payIn .Fees = Money ()
98
+ payIn .Fees .Amount = 0
99
+ payIn .Fees .Currency = 'EUR'
100
+ # payment type as CARD
101
+ payIn .PaymentDetails = PayInPaymentDetailsPreAuthorized ()
102
+ payIn .PaymentDetails .PreauthorizationId = cardPreAuthorization .Id
103
+ # execution type as DIRECT
104
+ payIn .ExecutionDetails = PayInExecutionDetailsDirect ()
105
+ payIn .ExecutionDetails .SecureModeReturnURL = 'http://test.com'
106
+
107
+ createPayIn = self .sdk .payIns .Create (payIn )
108
+
109
+ self .assertTrue (len (createPayIn .Id ) > 0 )
110
+ self .assertEqual (wallet .Id , createPayIn .CreditedWalletId )
111
+ self .assertEqual ('PREAUTHORIZED' , createPayIn .PaymentType )
112
+ self .assertIsInstance (createPayIn .PaymentDetails , PayInPaymentDetailsPreAuthorized )
113
+ self .assertEqual ('DIRECT' , createPayIn .ExecutionType )
114
+ self .assertIsInstance (createPayIn .ExecutionDetails , PayInExecutionDetailsDirect )
115
+ self .assertIsInstance (createPayIn .DebitedFunds , Money )
116
+ self .assertIsInstance (createPayIn .CreditedFunds , Money )
117
+ self .assertIsInstance (createPayIn .Fees , Money )
118
+ self .assertEqual (user .Id , createPayIn .AuthorId )
119
+ self .assertEqual ('SUCCEEDED' , createPayIn .Status )
120
+ self .assertEqual ('PAYIN' , createPayIn .Type )
121
+
122
+
84
123
def test_PayIns_Create_BankWireDirect (self ):
85
124
payIn = self .getJohnsPayInBankWireDirect ()
86
125
self .assertTrue (len (payIn .Id ) > 0 )
@@ -101,7 +140,7 @@ def test_PayIns_Create_BankWireDirect(self):
101
140
def test_PayIns_Get_BankWireDirect (self ):
102
141
payIn = self .getJohnsPayInBankWireDirect ()
103
142
getPayIn = self .sdk .payIns .Get (payIn .Id )
104
- self .assertTrue (int (payIn .Id ) > 0 )
143
+ self .assertTrue (len (payIn .Id ) > 0 )
105
144
self .assertEqual (payIn .PaymentType , PayInPaymentType .BANK_WIRE )
106
145
self .assertIsInstance (payIn .PaymentDetails , PayInPaymentDetailsBankWire )
107
146
self .assertEqual (payIn .ExecutionType , ExecutionType .DIRECT )
0 commit comments