-
Notifications
You must be signed in to change notification settings - Fork 5
/
create-checkout-page.py
executable file
·33 lines (25 loc) · 1.08 KB
/
create-checkout-page.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
#!/usr/bin/env python3
from utilities import make_request
import json
import argparse
parser = argparse.ArgumentParser(description="Create Checkout Page")
parser.add_argument("filename", help="the json file that contains the body; see https://docs.rapyd.net/build-with-rapyd/reference/checkout-page#create-checkout-page")
parser.add_argument("env", help="the rapyd environment")
parser.add_argument("-a", "--all", help="outputs all rapyd's api response", action="store_true")
args = parser.parse_args()
confirm = input("Do you want to create a checkout page? (y/n): ")
if confirm.lower() != 'y':
print("Checkout page not created")
exit(0)
f = open(f'{args.filename}', 'r')
path = f'/v1/checkout'
payment = json.load(f)
response = make_request(env=args.env, method='post', path=path, body=payment)
if args.all:
print(json.dumps(response, indent=4))
else:
s = f"token: {response['data']['id']}\n" \
f"amount: {response['data']['amount']}\n" \
f"currency: {response['data']['currency']}\n" \
f"redirect_url: {response['data']['redirect_url']}"
print(s)