Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/297.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
谷歌签出php回调解释_Php_Google Checkout - Fatal编程技术网

谷歌签出php回调解释

谷歌签出php回调解释,php,google-checkout,Php,Google Checkout,大家好,我不知道我这样做是否正确,但我不明白谷歌结账是如何工作的。 我有php代码,可以将XML发送到google checkout。我在checkout过程中看到的一切都正常 $_currency = $params['currency']; $base_domain = 'https://' . (($params['mode'] == 'transaction') ? 'checkout.google.com' : 'sandbox.google.com/c

大家好,我不知道我这样做是否正确,但我不明白谷歌结账是如何工作的。 我有php代码,可以将XML发送到google checkout。我在checkout过程中看到的一切都正常

$_currency    = $params['currency'];
            $base_domain  = 'https://' . (($params['mode'] == 'transaction') ? 'checkout.google.com' : 'sandbox.google.com/checkout');
            $base_url     = $base_domain . '/cws/v2/Merchant/' . $params['merchantId'] . '/checkout';

            // Form XML array with cart items
            $_items = '';

            $google_products = $this->CI->go_cart->contents();

            foreach ($google_products as $k => $v) {
                $item_options = '';

                if (isset($v['options'])) {
                    foreach ($v['options'] as $name => $value) {
                        if (is_array($value)) {
                            foreach ($value as $item) {
                                $item_options .= $item;
                            }
                        } else {
                            $item_options .= $value;
                        }
                    }
                }


                $_items .= '<item>' . '<merchant-item-id>' . $v['id'] . '</merchant-item-id>' . '<item-name>' . strip_tags($v['name']) . ' ' . $item_options . '</item-name>' . '<item-description>' . substr(strip_tags($item_options), 0, 299) . '</item-description>' . "<unit-price currency='" . $_currency . "'>" . $v['price'] . '</unit-price>' . '<quantity>' . $v['quantity'] . '</quantity>' . '</item>';
            }

$xml_cart = "<?xml version='1.0' encoding='UTF-8'?>
    <checkout-shopping-cart xmlns='http://checkout.google.com/schema/2'>
      <shopping-cart>
        <merchant-private-data>
            <additional_data>
                <session_id>" . base64_encode($customer['bill_address']["email"] . date('h:i:s')) . "</session_id>
                <currency_code>" . $_currency . "</currency_code>
                <payment_id>" . base64_encode($customer['bill_address']["email"] . date('h:i:s')) . "</payment_id>
                " . $private_ship_data . "
            </additional_data>
        </merchant-private-data>
        <items>" . $_items . "</items>
      </shopping-cart>
      <checkout-flow-support>
        <merchant-checkout-flow-support>
          <platform-id>971865505315434</platform-id>
          <request-buyer-phone-number>true</request-buyer-phone-number>
          <edit-cart-url>" . $edit_cart_url . "</edit-cart-url>
          <merchant-calculations>
            <merchant-calculations-url>" . $calculation_url . "</merchant-calculations-url>
          </merchant-calculations>
          <continue-shopping-url>" . $return_url . "</continue-shopping-url>
          " . $shippings . $taxes . "
        </merchant-checkout-flow-support>
      </checkout-flow-support>
    </checkout-shopping-cart>";

            $signature     = $this->fn_calc_hmac_sha1($xml_cart, $params['merchantKey']);
            $b64_cart      = base64_encode($xml_cart);
            $b64_signature = base64_encode($signature);


            echo '<form method="post" action="' . $base_url . '" name="BB_BuyButtonForm">
        <input type="hidden" name="cart" value="' . $b64_cart . '" />
        <input type="hidden" name="signature" value="' . $b64_signature . '" />
        <input alt="" src="' . $base_domain . '/buttons/checkout.gif?merchant_id=' . $params['merchantId'] . '&amp;w=160&amp;h=43&amp;style=' . 'white' . '&amp;variant=text&amp;loc=en_US" type="image"/>
        </form>';

            exit;
        }
$\u currency=$params['currency'];
$base_domain='https://'。($params['mode']=='transaction')?'checkout.google.com':'sandbox.google.com/checkout');
$base\u url=$base\u domain'/cws/v2/Merchant/”$参数['merchantId']。'/结帐';
//使用购物车项目形成XML数组
$\项目='';
$google_products=$this->CI->go_cart->contents();
foreach($k=>v的谷歌产品){
$item_options='';
如果(isset($v['options'])){
foreach($v['options']作为$name=>$value){
if(是_数组($value)){
foreach(价值为$item){
$item_选项=$item;
}
}否则{
$item_options.=$value;
}
}
}
$项目。=''.$v['id'.'.''.'.$v['name'].'.'.$item选项。'.''.'.''.$substr(条状标签('item选项)$0299.'.'.$v['price'.''.$v['QUOTE'.'.';
}
$xml_cart=”
" . base64_编码($customer['bill_address'][“email”].date('h:i:s'))。"
" . $_货币。"
" . base64_编码($customer['bill_address'][“email”].date('h:i:s'))。"
" . $私人船舶数据。"
" . $_项目。"
971865505315434
真的
" . $编辑购物车网址。"
" . $计算url。"
" . $返回url。"
" . $船运$税。"
";
$signature=$this->fn_calc_hmac_sha1($xml_cart,$params['merchantKey']);
$b64_cart=base64_编码($xml_cart);
$b64_签名=base64_编码($signature);
回声'
';
出口
}
在我点击提交付款后,我会被重定向到一个页面,页面上有成功消息和一个返回我网站的链接。 我想知道如何检查付款是否成功。 还有一个回调,我不知道该怎么做。 请帮助我更好地理解


我已经附上了下面的代码。

免责声明:我不是PHP开发人员

  • 上面的代码称为
    第1部分。签出API
    。它介绍了如何将数据/购物车发送到谷歌进行结帐

  • 第二部分。订单处理
    介绍如何从谷歌
    获取数据(进入您的系统)。提供了一个教程。这里提供了一个
    回调API URL
    ,用于侦听(等待)来自Google的HTTP帖子并继续处理数据


谷歌将发送通知。如何设置和配置通知,您可以在此处找到: