forked from rajarampadmanathan/Checkout-Python-SDK-1
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherror_sample.py
More file actions
57 lines (50 loc) · 1.7 KB
/
error_sample.py
File metadata and controls
57 lines (50 loc) · 1.7 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
from sample import PayPalClient
import json
from paypalcheckoutsdk.orders import OrdersCreateRequest
from paypalhttp.http_error import HttpError
class CreateError(PayPalClient):
def create_error_1(self):
"""
Body has no required parameters (intent, purchase_units)
"""
body = {}
request = OrdersCreateRequest()
request.request_body(body)
print "Request Body:", body, "\n"
print "Response:"
try:
response = self.client.execute(request)
except HttpError as h:
print "Status Code:", h.status_code
print self.pretty_print(h.message)
def create_error_2(self):
"""
Body has invalid parameter value for intent
"""
body = \
{
"intent": "INVALID",
"purchase_units": [
{
"amount":
{
"currency_code": "USD",
"value": "100.00"
}
}
]
}
request = OrdersCreateRequest()
request.request_body(body)
print "Request Body:\n", json.dumps(body, indent=4), "\n"
print "Response:"
response = ""
try:
response = self.client.execute(request)
except HttpError as h:
print "Status Code: ", h.status_code
print self.pretty_print(h.message)
print "Calling create_error_1 (Body has no required parameters (intent, purchase_units))"
CreateError().create_error_1()
print "\nExecuting create_error_2 (Body has invalid parameter value for intent)"
CreateError().create_error_2()