Skip to content

Instantly share code, notes, and snippets.

@dbrent-amazon
Last active October 2, 2015 19:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dbrent-amazon/b9604ed8ccc2030d5385 to your computer and use it in GitHub Desktop.
Save dbrent-amazon/b9604ed8ccc2030d5385 to your computer and use it in GitHub Desktop.
InstantPaymentNotification (Flask)
from flask import request
@app.route('/ipn_handler', methods=['GET', 'POST'])
def ipn_handler():
from pay_with_amazon.ipn_handler import IpnHandler
response = IpnHandler(request.data, request.headers)
if response.authenticate():
return(response.to_json())
else:
return(response.error)
# example response
{
"OrderReferenceNotification": {
"OrderReference": {
"OrderTotal": {
"CurrencyCode": "USD",
"Amount": "0.0"
},
"CreationTimestamp": "2013-01-01T01:01:01.001Z",
"OrderReferenceStatus": {
"State": "Closed",
"ReasonCode": "AmazonClosed",
"LastUpdateTimestamp": "2013-01-01T01:01:01.001Z"
},
"SellerOrderAttributes": null,
"AmazonOrderReferenceId": "P01-0000000-0000000-000000",
"ExpirationTimestamp": "2013-01-01T01:01:01.001Z"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment