首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Google Checkout API费用-金额-通知

Google Checkout API费用-金额-通知
EN

Stack Overflow用户
提问于 2012-09-01 21:32:11
回答 1查看 361关注 0票数 1

我从一个费用-金额-通知中得到以下响应。(在沙箱环境中)。我要做的是,当我确定付款已结清时,向客户发送一封电子邮件警报。现在我正在使用新订单通知,有时客户付款会失败,我想确保当我拿到钱时,我正在交付数字下载。

代码语言:javascript
复制
array (
  'charge-amount-notification' => 
  array (
    'xmlns' => 'http://checkout.google.com/schema/2',
    'serial-number' => '962015304346298-00013-2',
    'timestamp' => 
    array (
      'VALUE' => '2012-09-01T13:25:18.732Z',
    ),
    'latest-charge-amount' => 
    array (
      'currency' => 'USD',
      'VALUE' => '99.0',
    ),
    'total-charge-amount' => 
    array (
      'currency' => 'USD',
      'VALUE' => '99.0',
    ),
    'google-order-number' => 
    array (
      'VALUE' => '962015304346298',
    ),
  ),

)

我期望的是一个订单摘要关键字,其中包含文档中所述的客户信息。

https://developers.google.com/checkout/developer/Google_Checkout_XML_API_Notification_API#charge_amount_notification

下面是我的代码:

代码语言:javascript
复制
if (isset($_POST['serial-number']))
    {
        require_once('lib/google_checkout/googleresponse.php');
        require_once('lib/google_checkout/googlerequest.php');
        require_once('lib/google_checkout/googlenotificationhistory.php');      
        $response = new GoogleResponse(GOOGLE_MERCHANT_ID, GOOGLE_MERCHANT_KEY);
        $google_notification_history = new GoogleNotificationHistoryRequest(GOOGLE_MERCHANT_ID, GOOGLE_MERCHANT_KEY, GOOGLE_SANDBOX ? 'sandbox' : 'production');
        $raw_xml_array = $google_notification_history->SendNotificationHistoryRequest($_POST['serial-number']);
        $raw_xml = $raw_xml_array[1];
        $response->SendAck($_POST['serial-number'], false);
        list($root, $order_data) = $response->GetParsedXML($raw_xml);

        if (isset($order_data['charge-amount-notification']))
        {
            $data = array();
            file_put_contents("google.txt", var_export($order_data, true));
            $data['name'] = $order_data['charge-amount-notification']['order-summary']['buyer-billing-address']['contact-name']['VALUE'];
            $data['email'] = $order_data['charge-amount-notification']['order-summary']['buyer-billing-address']['email']['VALUE'];
            $data['txn_id'] = $order_data['charge-amount-notification']['google-order-number']['VALUE'];
            $data['payment_status'] = 'Completed';
            $res = save_payment($data);
            if ($res) {
                $data = payment_details(array('txn_id' => $data['txn_id']));
                mail_notification($data);
            }            
        }
    }
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-09-08 22:32:01

<order-summary>元素仅随2.5 API version一起包含在通知中。

Google Checkout HTML API Notification API声明:

建立web服务后,登录到您的商务中心帐户,单击设置选项卡,然后单击页面左侧菜单中的集成链接。在API回调URL字段中输入web服务的URL。(您的沙盒账号和生产账号都需要填写API回调URL。)您还必须指明您希望接收通知的格式和API版本。本文档介绍了序列号通知和API 2.5版本。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12228186

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档