php购物网站支付paypal使用方法

https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_html_Appx_websitestandard_htmlvariables

定义常量paypalurl

const PAYPAL_URL = 'https://www.sandbox.paypal.com/';

将要传送的数据记录为一个数组

$paypalData = array(
                   'add'                => 1,
                    'cmd'               => '_ext-enter',
                    'redirect_cmd'    => '_xclick',
                    'business'            => $paypalAccount, --------liangliangfeng211@gmail.com这个是收款人的paypal账号
                    'item_name'       => '51customimprint shopping cart',
                    'item_number'   => $order->id,
                    'first_name'        => $address->first_name,
                    'last_name'         => $address->last_name,
                    'address1'           => $address->address1,
                    'city'                     => $address->city,
                    'state'                  => $address->state_or_province,
                    'zip'                      => $address->zip_code,
                    'amount'            => $order->subtotal,
                    'shipping'          => $order->shipping_fee,
                    'no_note'            => 1,
                    'currency_code'    => 'USD',
                    'lc'                      => 'US'
                );

将这个数组转化为一个url地址

$paypalArguments = array();
                foreach($paypalData as $k => $v){
                    array_push($paypalArguments, $k . '=' . urlencode($v));
                }
                $paypalUrl = self::PAYPAL_URL . '?' . implode('&', $paypalArguments);
                $this->_redirect($paypalUrl);

接下来,我们测试的时候,应该将Paypal接口的地址设置为:

https://www.sandbox.paypal.com/cgi-bin/webscr

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/d86f7d5738b5e5528130aebc2cdfd318.html