-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathspec.py
More file actions
48 lines (39 loc) · 1.78 KB
/
spec.py
File metadata and controls
48 lines (39 loc) · 1.78 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
import processout
from processout.errors.notfounderror import NotFoundError
from processout.gatewayrequest import GatewayRequest
def main():
client = processout.ProcessOut("test-proj_gAO1Uu0ysZJvDuUpOGPkUBeE3pGalk3x",
"key_sandbox_mah31RDFqcDxmaS7MvhDbJfDJvjtsFTB")
# Create and fetch an invoice
invoice = client.new_invoice({
"name": "Test invoice",
"amount": "9.99",
"currency": "USD"
}).create()
assert invoice.id != "", "The invoice ID should not be empty"
fetched = client.new_invoice().find(invoice.id)
assert fetched.id != "", "The fetched invoice ID should not be empty"
assert invoice.id == fetched.id, "The invoices ID should be equal"
# Capture an invoice
gr = GatewayRequest("gway_conf_44ae90db0a62f819a404ef6a8ff994ca", "POST", "https://processout.com?token=test-valid", {
"Content-Type": "application/json"
}, "")
transaction = invoice.capture(gr.to_string())
assert transaction.status == "completed", "The transaction status was not completed"
# Expand the gateway configuration used on the transaction
transaction = transaction.find(transaction.id, {
"expand": ["gateway_configuration"]
})
assert transaction.gateway_configuration.id != "", "The transaction gateway configuration ID is empty"
# Fetch the customers
client.new_customer().all()
# Expand a customers' project and fetch gateways
customer = client.new_customer().create({"expand": ["project"]})
assert customer.project != None, "The customer project should be expanded"
# Check error code
try:
pass
except NotFoundError as err:
assert err.code == "resource.customer.not-found", "The error code was invalid"
if __name__ == "__main__":
main()