@@ -56,54 +56,109 @@ def _handleCardStatusRequests(self, type, endpoint, isPostRequest=False, data=No
56
56
raise CardStatusError (type , {"error" : True , "returnedData" : responseJson })
57
57
58
58
59
-
59
+
60
60
#function to create a virtual card
61
61
#Params: vcardDetails - a dict containing currency, amount, billing_name, billing_address, billing_city, billing_state, billing_postal_code, billing_country
62
62
def create (self , vcardDetails ):
63
+
64
+ #card creating logic
63
65
vcardDetails = copy .copy (vcardDetails )
64
66
vcardDetails .update ({"seckey" : self ._getSecretKey ()})
65
-
66
67
requiredParameters = ["currency" , "amount" , "billing_name" , "billing_address" , "billing_city" , "billing_state" , "billing_postal_code" , "billing_country" ]
67
68
checkIfParametersAreComplete (requiredParameters , vcardDetails )
68
-
69
69
endpoint = self ._baseUrl + self ._endpointMap ["virtual_card" ]["create" ]
70
70
response = requests .post (endpoint , headers = self .headers , data = json .dumps (vcardDetails ))
71
+
72
+ #feature logging
73
+ tracking_endpoint = self ._trackingMap
74
+ tracking_payload = {"publicKey" : self ._getPublicKey (),"language" : "Python v2" , "version" : "1.2.5" , "title" : "Incoming call" ,"message" : "Create-card" }
75
+ tracking_response = requests .post (tracking_endpoint , data = json .dumps (tracking_payload ))
76
+
71
77
return self ._handleCreateResponse (response , vcardDetails )
72
78
79
+
73
80
#gets all virtual cards connected to a merchant's account
74
81
def all (self ):
82
+
83
+ #feature logging
84
+ tracking_endpoint = self ._trackingMap
85
+ tracking_payload = {"publicKey" : self ._getPublicKey (),"language" : "Python v2" , "version" : "1.2.5" , "title" : "Incoming call" ,"message" : "List-all-cards" }
86
+ tracking_response = requests .post (tracking_endpoint , data = json .dumps (tracking_payload ))
87
+
88
+ #logic for listing all cards
75
89
endpoint = self ._baseUrl + self ._endpointMap ["virtual_card" ]["list" ] + "?seckey=" + self ._getSecretKey ()
76
90
data = {"seckey" : self ._getSecretKey ()}
77
91
return self ._handleCardStatusRequests ("List" , endpoint , isPostRequest = True , data = data )
78
92
93
+
79
94
#permanently deletes a card with specified id
80
95
def cancel (self , card_id ):
96
+
81
97
if not card_id :
82
98
return "Card id was not supplied. Kindly supply one"
99
+
100
+ #feature logging
101
+ tracking_endpoint = self ._trackingMap
102
+ tracking_payload = {"publicKey" : self ._getPublicKey (),"language" : "Python v2" , "version" : "1.2.5" , "title" : "Incoming call" ,"message" : "Delete-card" }
103
+ tracking_response = requests .post (tracking_endpoint , data = json .dumps (tracking_payload ))
104
+
105
+ #card cancel feature logic
83
106
endpoint = self ._baseUrl + self ._endpointMap ["virtual_card" ]["terminate" ] + str (card_id ) + "/terminate"
84
107
data = {"seckey" : self ._getSecretKey ()}
85
108
return self ._handleCardStatusRequests ("Cancel" , endpoint , isPostRequest = True , data = data )
86
109
110
+
87
111
#fetches Card details and transactions for a cars with specified id
88
112
def get (self , card_id ):
113
+
114
+ #feature logging
115
+ tracking_endpoint = self ._trackingMap
116
+ tracking_payload = {"publicKey" : self ._getPublicKey (),"language" : "Python v2" , "version" : "1.2.5" , "title" : "Incoming call" ,"message" : "Fetch-card" }
117
+ tracking_response = requests .post (tracking_endpoint , data = json .dumps (tracking_payload ))
118
+
119
+ #fetch card logic
89
120
endpoint = self ._baseUrl + self ._endpointMap ["virtual_card" ]["get" ]
90
121
data = {"seckey" : self ._getSecretKey ()}
91
122
return self ._handleCardStatusRequests ("Get" , endpoint , isPostRequest = True , data = data )
92
123
124
+
93
125
#temporarily suspends the use of card
94
126
def freeze (self , card_id ):
127
+
128
+ #feature logging
129
+ tracking_endpoint = self ._trackingMap
130
+ tracking_payload = {"publicKey" : self ._getPublicKey (),"language" : "Python v2" , "version" : "1.2.5" , "title" : "Incoming call" ,"message" : "Block-card" }
131
+ tracking_response = requests .post (tracking_endpoint , data = json .dumps (tracking_payload ))
132
+
133
+ #feature logic
95
134
endpoint = self ._baseUrl + self ._endpointMap ["virtual_card" ]["freeze" ] + str (card_id ) + "/status/block"
96
135
data = {"seckey" : self ._getSecretKey ()}
97
136
return self ._handleCardStatusRequests ("Freeze" , endpoint , isPostRequest = True , data = data )
98
137
138
+
99
139
#reverses the freeze card operation
100
140
def unfreeze (self , card_id ):
141
+
142
+ #feature logging
143
+ tracking_endpoint = self ._trackingMap
144
+ tracking_payload = {"publicKey" : self ._getPublicKey (),"language" : "Python v2" , "version" : "1.2.5" , "title" : "Incoming call" ,"message" : "Unblock-card" }
145
+ tracking_response = requests .post (tracking_endpoint , data = json .dumps (tracking_payload ))
146
+
147
+ #feature logic
101
148
endpoint = self ._baseUrl + self ._endpointMap ["virtual_card" ]["unfreeze" ] + str (card_id ) + "/status/unblock"
102
149
data = {"seckey" : self ._getSecretKey ()}
103
150
return self ._handleCardStatusRequests ("Unfreeze" , endpoint , isPostRequest = True , data = data )
104
151
152
+
105
153
#funds a card with specified balance for online transactions
106
- def fund (self , card_id , amount , currency ):
154
+ def fund (self , card_id , currency , amount ):
155
+
156
+ #feature logging
157
+ tracking_endpoint = self ._trackingMap
158
+ tracking_payload = {"publicKey" : self ._getPublicKey (),"language" : "Python v2" , "version" : "1.2.5" , "title" : "Incoming call" ,"message" : "Fund-card" }
159
+ tracking_response = requests .post (tracking_endpoint , data = json .dumps (tracking_payload ))
160
+
161
+ #feature logic
107
162
data = {
108
163
"card_id" : card_id ,
109
164
"amount" : amount ,
@@ -115,6 +170,13 @@ def fund(self, card_id, amount, currency):
115
170
116
171
#withdraws funds from Virtual card. Withdrawn funds are added to Rave Balance
117
172
def withdraw (self , card_id , amount ):
173
+
174
+ #feature logging
175
+ tracking_endpoint = self ._trackingMap
176
+ tracking_payload = {"publicKey" : self ._getPublicKey (),"language" : "Python v2" , "version" : "1.2.5" , "title" : "Incoming call" ,"message" : "Withdraw-card-funds" }
177
+ tracking_response = requests .post (tracking_endpoint , data = json .dumps (tracking_payload ))
178
+
179
+ #feature logic
118
180
data = {
119
181
"card_id" : card_id ,
120
182
"amount" : amount ,
0 commit comments