Postback url call not happening.

546 views
Skip to first unread message

darian311

unread,
May 6, 2012, 11:29:41 PM5/6/12
to in-app-...@googlegroups.com
Trying Google Inapp payments integration with a php/CodeIgniter 2.1.0 based web app. 

I tried setting my postback url and waiting for Google to call it after successfully completing purchase.  No luck so far. 
The javascript successhandler executes fine on the same transaction. 
App url:
Postback url:

No Error messages.  No log entries from my getcash function/callback url. 

Any thoughts? 

darian311

unread,
May 6, 2012, 11:47:04 PM5/6/12
to in-app-...@googlegroups.com
If it helps here is the full function that doesnt produce any log messages or anything when relying on the google postback url. 
[code]
public function getcash(){
$this->load->helper('JWT');
log_message("debug","getcash called: ". $_POST['action']);
$jwt = JWT::decode($_POST['action'], SELLER_SECRET, true);
//log_message("debug", "Payload: ". var_dump($jwt));
$fb_id = $jwt->request->sellerData;
$inc = $jwt->request->price;
$qry = $this->db->get_where('villagegame', array("fb_id" => $fb_id), 1);
$user = $qry->row_array();
$newcash = $user['cash'] + $inc;
$data = array("cash" => $newcash);
$orderid = 0;
if(isset($jwt->response->orderid)){
$orderid = $jwt->response->orderid;
}else{
$orderid = -1;
}
$this->db->where("fb_id", $fb_id);
$this->db->update("villagegame", $data );
//$params['orderid'] = $orderid;
//$this->load->view('buyresponse', $params);
$this->output->set_header("HTTP/1.0 200 OK");
$this->output->set_output($orderid);
}
[/code]

Mihai Ionescu

unread,
May 7, 2012, 6:11:06 PM5/7/12
to in-app-...@googlegroups.com
Hi,
One thing to check is that your postback url is not behind a login wall. Also re-directs can sometimes cause problems (the callback will timeout and fail). Thanks,
Mihai

darian311

unread,
May 7, 2012, 7:29:01 PM5/7/12
to in-app-...@googlegroups.com
Hi Mihai, thanks for following up. I double checked that it wasn't blocked by a login.  How can I debug a redirect if that's the case?

Mihai Ionescu

unread,
May 7, 2012, 9:37:38 PM5/7/12
to in-app-...@googlegroups.com
Hi,

You mention below that the client-side success handler was called, which means the order completed successfully (successful orders will be showing up in the Merchant Center and you should have also received a purchase confirmation email.). Was a postback url specified at that time or added afterwards? 

Thanks,
Mihai

darian311

unread,
May 8, 2012, 11:49:33 PM5/8/12
to in-app-...@googlegroups.com
I went to the merchant center which I haven't used before. Not seeing any obvious entries after signing up. i'm guessing since my server didn't return 200 OK it didn't got through.  Would it show a  failed transaction in merchant center? 

Also if the postback hit my server what should it look like in my access log?
Notes: I'm using dreamhost webhosting, CodeIgniter 2.1 for my framework. Facebook sdk for my login.  They have php 5.2  installed. 

darian311

unread,
May 9, 2012, 12:23:36 AM5/9/12
to in-app-...@googlegroups.com
Also I just went through my access log and confirmed there's no hit coming from google's postback url except for my manual calls. What's the next step for troubleshooting?

darian311

unread,
May 9, 2012, 1:09:11 AM5/9/12
to in-app-...@googlegroups.com
Ok troubleshooted a few more steps: 
 1. My postback url was blanked out somehow so reset it. 
 2. I'm now getting hits from google that look like
74.125.64.94 - - [08/May/2012:21:53:27 -0700] "POST /CodeIgniter/index.php/villagesocial/getcash HTTP/1.1" 200 829 "-" "Google-In-App-Payments; (+http://www.google.com/payments)" 
 But getting a new failure message right from the website.  Is there somewhere I can get a more detailed error message from google? 

Thanks!

On Sunday, May 6, 2012 8:29:41 PM UTC-7, darian311 wrote:
Screen Shot 2012-05-08 at 9.53.39 PM.png

darian311

unread,
May 9, 2012, 3:03:47 AM5/9/12
to in-app-...@googlegroups.com
Ok so got everything working I think.  Some notes for other people going through this:
  1. you have to have http: or https: as part of your postback url.  Error message wont say this. It says "No host in url." which wasn't true. Oops. 
  2. The vars inside the decoded jwt are case sensitive. so in PHP it breaks if you reference $jwt->response->orderid. Remember $jwt->response->orderId
  3. Also in php the jwt's going to be stdClass type not an array so you can't reference like $jwt['response']['orderId']. 
  4. The entry in your access log will look like: 74.125.64.94 - - [08/May/2012:21:53:27 -0700] "POST /CodeIgniter/index.php/villagesocial/getcash HTTP/1.1" 200 829 "-" "Google-In-App-Payments; 
  5. CodeIgniter 2.1.0 doesn't allow query strings by default so you have to enable that in the respective config.php if you want to test calls with manual GET querystring param call of your postback url.
  6. CodeIgniter has a set_header and set_output function so there's no need to create a view for that postback. Just end the processing with
  1. $this->output->set_header("HTTP/1.0 200 OK");
  2. $this->output->set_output($orderid);
    Cheers,
    Darian
     

    Mihai Ionescu

    unread,
    May 9, 2012, 12:02:54 PM5/9/12
    to in-app-...@googlegroups.com
    Hi Darian,

    Great to hear you got In-App Payments working! 
    Thanks for sharing your findings with the developer community.
    I assume you also figured out how to manage the orders in the Merchant Center.

    Thanks,
    Mihai

    Shrek

    unread,
    May 10, 2012, 4:15:19 PM5/10/12
    to in-app-...@googlegroups.com
    Hi Mihai

    for some reason i'm unable to get In-App Payments to callback my Postback URL.
    I'm using app-engine. No login required url. URL looks like this: http://app-id.appspot.com/payment/gateway
    I'm able to hit the above url via browser and appengine logs is showing all the debug message that i've implemented in servlet.
    however when click the buy button, Google server is never calling back my Postback.

    in the In-App Payments merchant center: i see my orders in "cancelled" status with following details
    "Google cancelled this order. Reason: Other (describe below).

    Any help

    Mihai Ionescu

    unread,
    May 10, 2012, 4:33:22 PM5/10/12
    to in-app-...@googlegroups.com
    I get a 404 when trying to access http://app-id.appspot.com/payment/gateway (or app-id.appspot.com).

    The fact that the order shows up in the Merchant Center means you're halfway there :-)
    The order is cancelled automatically if your server does not reply to the postback within 10 seconds.

    Thanks,
    Mihai

    Shrek

    unread,
    May 10, 2012, 7:14:38 PM5/10/12
    to in-app-...@googlegroups.com
    Mihai (Google) worked directly with me to debug this issue.  In the end.. I had to create a brand new buyer account (gmail+wallet account) and then everything worked without any changes in my code or settings.

    Although this is not a solution, I'm posting it here in the hope that it might unblock someone like me.
    Always use fake credit card numbers in sandbox (listed here https://developers.google.com/in-app-payments/docs/testing ). They work.

    After my end-to-end testing I found these short falls that prevents me to use this service.
    1. In notification emails from wallet to buyers we show Order Id (something like  07743248137569471886.C.1146276497159633 ). Whereas in Merchant center OrderNumber is shown (somthing like 442682939023030084). Order Id and Order Number co-relation cannot be found anywhere.. Pick one number and show it everywhere consistently, including in the Postback URL response. Sorry I cannot use this service until this issue is fixed. Without "A" order number I will not be able to track my orders.
    2. Why is there no email notification to the seller? Seller would also like to be notified when a transaction occurs. Have I missed any preference setting in the merchant center?
    3. Is there some kind of caching between Google Wallet and Sandbox? It has been an hour since I removed few credit cards in Google Wallet, but they are still showing up in Sandbox  In-App popup. I hope this will not occur in production.
    4. In-App popup just shows top 4 credit cards from my Google wallet setup. I really really wanted to use 5th and 6th credit cards. I hope my real customers don't run into this problem.
    5. Lastly, why didnt my original buyer account work? It is a genuine gmail account with the same fake (VISA). what if some of my customers are not able to use the service, and some are. It will be a very confusing situation. It should either work for everyone or not work for anyone - is less confusing situation. ;)
    Thank you Google for a good product. Please fix these few minor issues.
    Thank you Mihai for your wonderful email support.

    Peng Ying

    unread,
    May 11, 2012, 1:03:37 PM5/11/12
    to in-app-...@googlegroups.com
    Inline

    On Thu, May 10, 2012 at 4:14 PM, Shrek <srikanth...@gmail.com> wrote:
    Mihai (Google) worked directly with me to debug this issue.  In the end.. I had to create a brand new buyer account (gmail+wallet account) and then everything worked without any changes in my code or settings.

    Although this is not a solution, I'm posting it here in the hope that it might unblock someone like me.
    Always use fake credit card numbers in sandbox (listed here https://developers.google.com/in-app-payments/docs/testing ). They work.

    After my end-to-end testing I found these short falls that prevents me to use this service.
    1. In notification emails from wallet to buyers we show Order Id (something like  07743248137569471886.C.1146276497159633 ). Whereas in Merchant center OrderNumber is shown (somthing like 442682939023030084). Order Id and Order Number co-relation cannot be found anywhere.. Pick one number and show it everywhere consistently, including in the Postback URL response. Sorry I cannot use this service until this issue is fixed. Without "A" order number I will not be able to track my orders.
    Working on being fixed.  Why not use the Order Id found within the postback JWT? 
    1. Why is there no email notification to the seller? Seller would also like to be notified when a transaction occurs. Have I missed any preference setting in the merchant center?
    Better if you have a large number of orders.  We prefer to not be spammy.  But email notifications could be an opt in feature we add later on. 
    1. Is there some kind of caching between Google Wallet and Sandbox? It has been an hour since I removed few credit cards in Google Wallet, but they are still showing up in Sandbox  In-App popup. I hope this will not occur in production.
    Nope, are you sure you're removing the sandbox credit cards?  The production + sandbox are completely separate environments
    1. In-App popup just shows top 4 credit cards from my Google wallet setup. I really really wanted to use 5th and 6th credit cards. I hope my real customers don't run into this problem.
    Same as the last one 
    1. Lastly, why didnt my original buyer account work? It is a genuine gmail account with the same fake (VISA). what if some of my customers are not able to use the service, and some are. It will be a very confusing situation. It should either work for everyone or not work for anyone - is less confusing situation. ;)
    Were you trying to purchase from yourself?



    --
    Developer Programs Engineer
    Google Commerce

    Google+

    Srikanth Pagadala

    unread,
    May 11, 2012, 2:25:44 PM5/11/12
    to in-app-...@googlegroups.com
    Peng (Google)

    thanks for your response. 

    1. Yes, let us use OrderId consistently everywhere. I don't have any preference between OrderId and OrderNumber. Thank you for the fix in advance.
    2. I understand that google wants to avoid spammy emails. But believe me this feature will go a long way with lot of non-technical users.(doctors, businessmen etc). It is already hard for me to convince them to relinquish $$$ aspects from their pre-historic processes and hand it over to Google @ 5% fee. One way to win over such customers is to constantly assure them that they still in full control. I think email to seller as an opt-in feature will serve that purpose well. After few years, when they start trusting Google more, they will automatically opt-out. So please do consider this fix as well. You may say, why don't I send out an email from my application in my Postback routine. Well the answer is, getting an email from Google Wallet carries more credibility. I hope i have made my case sufficiently.
    3. Is there a Sandbox Google Wallet too? I thought there is only one Google wallet (production), that I use as a Buyer. I went through your documentation again and again and didn't find any mention of Sandbox-Google-Wallet. I just have one Google Wallet Account (production), which shows up in the sandbox In-App popup. What have I missed here? 
    4. Same as the last one. I'd like to find out if there is a Sandbox-Google-Wallet, where I can setup more than 4 credit cards and observe that In-App popup will allow me to choose the 10th credit card.
    5. No. I've a separate Buyer's Google-Wallet-Account & Seller's Google-Wallet-Account. Now that you have mentioned Sandbox-Google-Wallet, I'm guess that this is somehow related to confusion between Sandbox and Production environment.

    Thank you

    shrek
    Reply all
    Reply to author
    Forward
    0 new messages