使用Google电子钱包的示例文件会出错

时间:2014-02-25 21:25:58

标签: php android-pay

我已在我的测试网站https://code.google.com/p/iap-php/上实施了http://whatisthesite.com处的示例代码。正如您可能会看到单击“购买”按钮后出现模糊的错误消息:

There is an error in the setup for your purchase. Please contact the merchant with this error message: Expected 3 components in jwt: $jwtToken

控制台提供:

Uncaught SecurityError: Failed to read the 'contentDocument' property from 'HTMLIFrameElement': Blocked a frame with origin "http://whatisthesite.com" from accessing a frame with origin "https://sandbox.google.com".  The frame requesting access has a protocol of "http", the frame being accessed has a protocol of "https". Protocols must match.
 markdown-here.js:33
findFocusedElem markdown-here.js:33
intervalCheck

演示站点http://iap-php.appspot.com/不是https:代码中也没有定义协议的地方。任何建议都将不胜感激,谢谢!

更新:

它与示例使用“Here Doc”语法在JS函数中使用内联PHP变量有关。更改了这种语法:

echo <<< INDEX <button id='runDemoButton' value='buy' class='buy-button' onclick='DemoButton("$jwtToken");'><b>Purchase</b></button> INDEX;

到此:

<button id='runDemoButton' value='buy' class='buy-button' onclick='DemoButton("<?php echo $jwtToken;?>");'><b>Purchase</b></button>

但现在却出现了更加模糊的错误。

1 个答案:

答案 0 :(得分:0)

“购买设置中存在错误”等对话框错误会将相应的错误代码返回给客户端失败处理程序:

https://developers.google.com/wallet/digital/docs/jsreference#failurehandler

在您的情况下,错误代码是MERCHANT_ERROR,表示格式错误的JWT。这可能是由于使用不正确的卖方密钥或秘密来签署JWT。