-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
73 lines (60 loc) · 2.02 KB
/
test.py
File metadata and controls
73 lines (60 loc) · 2.02 KB
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
import logging
import merchantwarrior as mw
from pprint import pprint
# logging.basicConfig()
# logging.getLogger().setLevel(logging.DEBUG)
# requests_log = logging.getLogger("requests.packages.urllib3")
# requests_log.setLevel(logging.DEBUG)
# requests_log.propagate = True
credentials = mw.ApiCredentials(
merchant_uuid='57314b72e0624',
api_key='yxh5l1if',
api_pass_phrase='ejzzrepf',
)
api = mw.Api(
credentials=credentials
)
customer = mw.Customer()
customer.name = 'Samir patel'
customer.country = 'au'
customer.state = 'QLD'
customer.city = 'Brisbane'
customer.address = '123 Fake St'
customer.postcode = '4000'
customer.phone = '07 3123 4567'
customer.email = 'john@smith.com'
customer.ip = '127.0.0.1'
transaction = mw.Transaction(
amount='10.00',
currency='aud',
product='Test Product'
)
card = mw.PaymentCard(
number='5123456789012346',
name='Samir Patel Card Name',
expiry='0517'
)
auth_transaction = mw.Transaction(
amount='6.66',
currency='aud',
product='Test Product 420'
)
print "Attempting to process a transaction\n"
response = api.process_card(transaction, customer, card)
if response.success:
print "\nSuccessfully processed transaction"
print "Response code: " + response.response_code
print "Response message: " + response.response_message
print "Transaction Id: " + str(response.transaction_id)
print "\nAttempting to query card"
query_response = api.query_card(transaction)
print "\nSuccessfully queried card"
print "Response code: " + query_response.response_code
print "Response message: " + str(query_response.response_message)
print "\nAttempting to refund the same transaction by transactionId"
refund_response = api.refund_card(transaction, transaction.amount)
print "Successfully refunded transactionId: " + transaction.id
print "Response code: " + response.response_code
print "Response message: " + str(refund_response.response_message)
else:
print "\nAn error occurred while trying to process your transaction"