Skip to content

Instantly share code, notes, and snippets.

@michaelbrewer
Last active April 12, 2021 07:50
Show Gist options
  • Save michaelbrewer/18e17fc5a73a7fba05099acd6b8523d5 to your computer and use it in GitHub Desktop.
Save michaelbrewer/18e17fc5a73a7fba05099acd6b8523d5 to your computer and use it in GitHub Desktop.
00 - Basic Payment Lambda
import json
import time
def create_payment(payment):
order_key = payment["order_key"]
print(f"Order key:", order_key)
# Simulate failure
if "FAILURE" in order_key:
raise RuntimeError("Failed to make payment")
# Simulate a slow transaction
time.sleep(2)
return {"order_id": "1111111", "status": "SUCCESS"}
def lambda_handler(event, context):
print("event", event)
payment = create_payment(json.loads(event["body"]))
return {
"statusCode": 200,
"headers": {"Content-Type": "application/json"},
"body": json.dumps(payment),
}
@michaelbrewer
Copy link
Author

A example of a "bare" lambda.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment