0

I'm trying to handle postbacks with Google Wallet but I'm unsure as to the best way to detect the type of postback.

For example, how would I differentiate a Subscription Cancellation vs a Subscription Sale vs a One Time Purchase?

I've read the Documentation: https://developers.google.com/wallet/digital/docs/postback

It's a little unclear as to the best method, as you only provide a single postback URL for everything.

if($decoded_jwt->typ === "google/payments/inapp/subscription/v1/canceled") {
   //Logic to handle cancel
}

Would this work in production? What would I use if it weren't a cancellation?

Thanks for any input!

1 Answer 1

1
  • A single purchase typ : google/payments/inapp/item/v1/postback/buy
  • A subscription purchase typ : google/payments/inapp/subscription/v1/postback/buy
  • A subscription cancellation typ: google/payments/inapp/subscription/v1/canceled

I'm going through some of my old notes, and remember that the docs for subscription postback seem to have an error - which is probably why you asked :)

I ran into exceptions back then and after debugging, the typ for the subscription postback is actually what I have above (re: the docs show the postback typ for single item).

Hth....


Update

When the cancellation postback is sent, do I get the sellerdata in the JWT?

Nope. You'll see a sample cancellation postback JWT in the docs

How would I know which account to deactivate in the event of a cancellation? Or should I store the orderID?

You will get the original orderId in the cancellation postback. So yes, you'll need to store it.

6
  • Thanks! I couldn't find this anywhere. The docs don't seem complete when it come to this. At least not for PHP.
    – Guy
    Commented Jun 2, 2014 at 4:04
  • How would I tell if the payment went through on a subscription then? Would I use the same postback URL?
    – Guy
    Commented Jun 2, 2014 at 4:37
  • @Guy Well, you only get 1 postback url in your account so yes, it's the same url for all. You'd need to parse the typ in the postback to "know" what it is (and handle appropriately)...you can also go deeper if you need to and check for the existence (or non-existence) of fields (e.g. a subscription postback will have recurrence, single item will not)
    – EdSF
    Commented Jun 2, 2014 at 5:19
  • A postback call would be made on payment then?
    – Guy
    Commented Jun 2, 2014 at 6:57
  • @Guy Yup - if Google successfully charges, otherwise, no (payment) postback. Cancellation postback is when a user cancels a subscription or if Google can't charge a subscription payment for some reason (e.g. before subscription ends, card fails). Hth....
    – EdSF
    Commented Jun 2, 2014 at 7:05

Not the answer you're looking for? Browse other questions tagged or ask your own question.