Skip to content
Browse files

Send users a system message when they buy gold with google wallet.

  • Loading branch information...
1 parent a769dd6 commit 7398916b886a5284c2511e696c4cbe74ba3addd3 @bsimpson63 bsimpson63 committed Feb 26, 2013
Showing with 19 additions and 7 deletions.
  1. +19 −7 r2/r2/controllers/ipn.py
View
26 r2/r2/controllers/ipn.py
@@ -376,6 +376,13 @@ def POST_gcheckout(self, full_sn):
# get the financial details
auth = trans.find("authorization-amount-notification")
+ custom = None
+ cart = trans.find("shopping-cart")
+ if cart:
+ private_item_data = cart.find("merchant-private-item-data")
+ if private_item_data:
+ custom = str(private_item_data.contents[0])
+
if not auth:
# see if the payment was declinded
status = trans.findAll('financial-order-state')
@@ -390,17 +397,22 @@ def POST_gcheckout(self, full_sn):
g.log.error(("google transaction status: " +
"'%s', status: %s")
% (short_sn, [x.contents[0] for x in status]))
+ if custom:
+ payment_blob = validate_blob(custom)
+ buyer = payment_blob['buyer']
+ subject = _('gold order')
+ msg = _('your order has been received and gold will'
+ ' be delivered shortly. please bear with us'
+ ' as google wallet payments can take up to an'
+ ' hour to complete')
+ try:
+ send_system_message(buyer, subject, msg)
+ except MessageError:
+ g.log.error('gcheckout send_system_message failed')
elif auth.find("financial-order-state"
).contents[0] == "CHARGEABLE":
email = str(auth.find("email").contents[0])
payer_id = str(auth.find('buyer-id').contents[0])
- # get the "secret"
- custom = None
- cart = trans.find("shopping-cart")
- if cart:
- for item in cart.findAll("merchant-private-item-data"):
- custom = str(item.contents[0])
- break
if custom:
days = None
try:

0 comments on commit 7398916

Please sign in to comment.
Something went wrong with that request. Please try again.