Google Checkout API费用金额通知

时间:2012-09-01 13:32:11

标签: android-pay

我从收费金额通知中收到以下回复。 (在沙盒环境中)。我想要做的是在我确定付款被清除时向客户发送电子邮件提醒。现在我正在使用新订单通知,有时客户付款会失败,我想确保在我拿到钱时提供数字下载。

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

这是我的代码:

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);
            }            
        }
    }

1 个答案:

答案 0 :(得分:0)

<order-summary>元素仅包含在2.5 API version的通知中 Google Checkout HTML API Notification API州:

  

建立您的网络服务后,请登录您的Merchant Center   帐户,单击“设置”选项卡,然后单击“集成”   链接在页面左侧的菜单中。输入您的网址   API回调URL字段中的Web服务。 (您需要输入您的API   您的沙箱帐户和生产中的回调网址   帐户。)您还必须指明您希望收到的格式   通知和API版本。本文档包含   “通知为序列号”和API版本2.5。

enter image description here