【问题标题】:Google Checkout API charge-amount-notificationGoogle Checkout API 收费金额通知
【发布时间】:2012-08-27 00:42:36
【问题描述】:

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

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

【问题讨论】:

    标签: android-pay


    【解决方案1】:

    <order-summary> 元素仅与2.5 API version 一起包含在通知中。
    Google Checkout HTML API Notification API 声明:

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

    【讨论】:

    • 好像2.5需要java,是这样吗?
    • 当我可以保证收到钱时,我应该使用什么通知?
    • 我也应该打开通知过滤吗?
    • @Chris 为我迟到的回复道歉,但昨天,在发布我的答案后,我关闭了我的电脑并离开了,所以我现在才阅读你的 cmets。第一个问题的答案是否定的:2.5 API 不需要 Java。仅当不想接收所有类型的通知时才应打开通知过滤。由于您对新订单通知感兴趣,因此您也可以根据需要打开通知过滤。我不明白您收到钱时要使用的通知类型的问题。你能解释清楚吗?
    • 我遇到了一个问题,我会收到新订单通知,然后付款失败。我已经向他们发送了下载数字产品的链接。在我确定他们已被收费之前,我想做的不是向他们发送或通过电子邮件发送 URL。
    猜你喜欢
    • 2015-07-23
    • 2018-12-08
    • 1970-01-01
    • 2016-04-29
    • 1970-01-01
    • 2015-06-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多