-
Notifications
You must be signed in to change notification settings - Fork 76
/
run_all.py
50 lines (42 loc) · 1.69 KB
/
run_all.py
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
from capture_order import CaptureOrder
from create_order import CreateOrder
from sample.refund_order import RefundOrder
response = CreateOrder().create_order()
order_id = ''
print 'Creating Order...'
if response.status_code == 201:
order_id = response.result.id
for link in response.result.links:
print('\t{} link: {}\tCall Type: {}'.format(str(link.rel).capitalize(), link.href, link.method))
print 'Created Successfully\n'
print 'Copy approve link and paste it in browser. Login with buyer account and follow the instructions.\nOnce approved hit enter...'
else:
print 'Link is unreachable'
exit(1)
raw_input()
print 'Capturing Order...'
capture_id =""
response = CaptureOrder().capture_order(order_id)
if response.status_code == 201:
print 'Captured Successfully\n'
print 'Status Code: ', response.status_code
print 'Status: ', response.result.status
print 'Order ID: ', response.result.id
print 'Capture Ids: '
for purchase_unit in response.result.purchase_units:
for capture in purchase_unit.payments.captures:
print '\t', capture.id
capture_id =capture.id
print 'Links: '
for link in response.result.links:
print('\t{}: {}\tCall Type: {}'.format(link.rel, link.href, link.method))
print 'Refunding Order...'
response = RefundOrder().refund_order(capture_id)
if response.status_code == 201:
print 'Refunded Successfully\n'
print 'Status Code: ', response.status_code
print 'Status: ', response.result.status
print 'Refund ID: ', response.result.id
print 'Links: '
for link in response.result.links:
print('\t{}: {}\tCall Type: {}'.format(link.rel, link.href, link.method))