Google Wallet API and PHP, Handling Postbacks

北城余情 提交于 2019-12-08 12:12:44

问题


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:


  • 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.



来源:https://stackoverflow.com/questions/23980730/google-wallet-api-and-php-handling-postbacks

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!