PHP Postback URL

680 views
Skip to first unread message

Smart

unread,
Feb 14, 2012, 9:50:04 AM2/14/12
to In-App Payments
should my postback php file look like this?

this is to buy a pizza for $0.50

my concern is that this seems to only cater for one item I also would
like to sell hotdogs for $0.20


<?php
$payload = array(
"iss" => $sellerIdentifier,
"aud" => "Google",
"typ" => "google/payments/inapp/item/v1",
"exp" => time() + 3600,
"iat" => time(),
"request" => array (
"name" => "pizza1",
"description" => "yum yum"
"price" => "0.50",
"currencyCode" => "USD",
"sellerData" => "",
)
);
$pizzaToken = JWT::encode($payload, $sellerSecret);
?>

Mihai Ionescu

unread,
Feb 14, 2012, 7:18:20 PM2/14/12
to in-app-...@googlegroups.com
Hi,

Please keep in mind that the In-App Payments API is only for digital goods.
If you sell virtual hotdogs and pizza inside a game you are fine :-)
You can bundle as many virtual items as you want in one JWT. 

Thanks,
Mihai

Peng Ying

unread,
Feb 14, 2012, 7:37:26 PM2/14/12
to in-app-...@googlegroups.com
Also as an FYI with the JWT PHP library:

In JWT.php change 
$json = json_encode($input);
to
$json = json_encode($input, JSON_UNESCAPED_SLASHES);

otherwise you get some \/ s
--
Developer Programs Engineer
Google Commerce

Google+

Smart

unread,
Feb 15, 2012, 5:09:52 AM2/15/12
to In-App Payments
I think you miss understand me... I need people to choose between more
than one item, not to buy multiple items in the same transaction.

In any case; the docs do not say how to do this!

Smart

unread,
Feb 15, 2012, 5:37:55 AM2/15/12
to In-App Payments
postback.php
require_once 'JWT.php';

JWT.php
$json = json_encode($input, JSON_UNESCAPED_SLASHES);

Uh oh. There was a problem.
We couldn't complete your purchase because of a technical issue.
Details of the problem below:
Unfortunately, we could not confirm your purchase with the merchant's
server. Your order has been canceled. Please contact the merchant if
this problem continues.



On Feb 15, 12:37 am, Peng Ying <py...@google.com> wrote:
> Also as an FYI with the JWT PHP library:
>
> In JWT.php change
> $json = json_encode($input);
> to
> $json = json_encode($input, *JSON_UNESCAPED_SLASHES*);
>
> otherwise you get some \/ s
>
>
>
>
>
>
>
>
>
> On Tue, Feb 14, 2012 at 4:18 PM, Mihai Ionescu <mi...@google.com> wrote:
> > Hi,
>
> > Please keep in mind that the In-App Payments API is only for digital goods.
> > If you sell virtual hotdogs and pizza inside a game you are fine :-)
> > You can bundle as many virtual items as you want in one JWT.
>
> > Thanks,
> > Mihai
>
> Google+ <http://goo.gl/28b8c>

Peng Ying

unread,
Feb 15, 2012, 4:17:07 PM2/15/12
to in-app-...@googlegroups.com
Something else is probably wrong.  Try decoding your jwt with atob in a chrome developer tools.

Smart

unread,
Feb 15, 2012, 6:02:11 PM2/15/12
to In-App Payments
I used your tool to create the jwt:

In-App Payments demo
https://checkout.google.com/customer/gadget/inapp/demo.html?hl=en_US

what the hell is atob?
> Google+ <http://goo.gl/28b8c>

Peng Ying

unread,
Feb 15, 2012, 7:12:46 PM2/15/12
to in-app-...@googlegroups.com
You're probably purchasing from yourself then, create a separate buyer account

Follow the dev guide instead of copying and pasting for instructions on defining dynamic items

Atob is a tool for base64 encoding/decoding:

Smart

unread,
Feb 15, 2012, 10:02:28 PM2/15/12
to In-App Payments
I'm not buying from myself, I have a separate account. you should know
that google wallet stops you from completing the transaction when
attempting to buy from yourself.

I have 'only' studied this page:
https://developers.google.com/in-app-payments/docs/tutorial#2

I will try atob now that I know where/what it is. thanks


On Feb 16, 12:12 am, Peng Ying <py...@google.com> wrote:
> You're probably purchasing from yourself then, create a separate buyer
> account
>
> Follow the dev guide instead of copying and pasting for instructions on
> defining dynamic itemshttps://developers.google.com/in-app-payments/docs/tutorial#2
> Google+ <http://goo.gl/28b8c>

Smart

unread,
Feb 15, 2012, 10:33:41 PM2/15/12
to In-App Payments
window.atob: produces [Object Object]


I tried encoding my jwt using window.btoa like this:

google.load('payments','1.0',{'packages':['production_config']});
function purchase(){
var encodedData = window.btoa({"iss":"02------
secret------94","aud":"Google","typ":"google/payments/inapp/item/
v1","iat":1329362137,"exp":1329448537,"request":
{"currencyCode":"USD","price":"0.01","name":"penny","sellerData":"","description":"none"}});
goog.payments.inapp.buy({
    jwt: encodedData,
    success: function() { window.alert('success')},
    failure: function() { window.alert('failure')}
  })
}

and I get this wallet error:

Uh oh. There was a problem.
We couldn't start your purchase because of a technical issue.
Details of the problem below:
Looks like there is an error in the setup for your purchase. Please
contact the merchant with this error message: Expected 3 components in
jwt: W29iamVjdCBPYmplY3Rd



!?

Thanks


On Feb 16, 12:12 am, Peng Ying <py...@google.com> wrote:
> You're probably purchasing from yourself then, create a separate buyer
> account
>
> Follow the dev guide instead of copying and pasting for instructions on
> defining dynamic itemshttps://developers.google.com/in-app-payments/docs/tutorial#2
> Google+ <http://goo.gl/28b8c>
Reply all
Reply to author
Forward
0 new messages