定义常量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接口的地址设置为: