本文整理匯總了PHP中AlipaySubmit::buildRequestPara方法的典型用法代碼示例。如果您正苦於以下問題:PHP AlipaySubmit::buildRequestPara方法的具體用法?PHP AlipaySubmit::buildRequestPara怎麽用?PHP AlipaySubmit::buildRequestPara使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類AlipaySubmit
的用法示例。
在下文中一共展示了AlipaySubmit::buildRequestPara方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: index
//.........這裏部分代碼省略.........
*/
// 計算提交地址
$seller_email = $this->config->get('alipay_dual_seller_email');
// 商家郵箱
$security_code = $this->config->get('alipay_dual_security_code');
//安全檢驗碼
$partner = $this->config->get('alipay_dual_partner');
//合作夥伴ID
$currency_code = $this->config->get('alipay_dual_currency_code');
//人民幣代號(CNY)
$item_name = $this->config->get('config_store');
$first_name = $order_info['payment_firstname'];
$last_name = $order_info['payment_lastname'];
$total = $order_info['total'];
if ($currency_code == '') {
$currency_code = 'CNY';
}
$currency_value = $this->currency->getValue($currency_code);
$amount = $total * $currency_value;
$amount = number_format($amount, 2, '.', '');
$_input_charset = "utf-8";
//字符編碼格式 目前支持 GBK 或 utf-8
$sign_type = "MD5";
//加密方式 係統默認(不要修改)
$transport = "http";
//訪問模式,你可以根據自己的服務器是否支持ssl訪問而選擇http以及https訪問模式(係統默認,不要修改)
$notify_url = HTTP_SERVER . 'catalog/controller/payment/alipay_dual_notify_url.php';
$return_url = HTTPS_SERVER . 'index.php?route=checkout/success';
$show_url = "";
//你網站商品的展示地址
$out_trade_no = $order_id;
$subject = $this->config->get('config_name') . ' - #' . $order_id;
$body = $subject;
//商品描述,必填
$total_fee = $amount;
//↓↓↓↓↓↓↓↓↓↓請在這裏配置您的基本信息↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
//合作身份者id,以2088開頭的16位純數字
$aliapy_config['partner'] = trim($partner);
//安全檢驗碼,以數字和字母組成的32位字符
$aliapy_config['key'] = trim($security_code);
//簽約支付寶賬號或賣家支付寶帳戶
$aliapy_config['seller_email'] = trim($seller_email);
//頁麵跳轉同步通知頁麵路徑,要用 http://格式的完整路徑,不允許加?id=123這類自定義參數
//return_url的域名不能寫成http://localhost/trade_create_by_buyer_php_utf8/return_url.php ,否則會導致return_url執行無效
$aliapy_config['return_url'] = $return_url;
//'http://127.0.0.1/trade_create_by_buyer_php_utf8/return_url.php';
//服務器異步通知頁麵路徑,要用 http://格式的完整路徑,不允許加?id=123這類自定義參數
$aliapy_config['notify_url'] = $notify_url;
//'http://www.xxx.com/trade_create_by_buyer_php_utf8/notify_url.php';
//↑↑↑↑↑↑↑↑↑↑請在這裏配置您的基本信息↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
//簽名方式 不需修改
$aliapy_config['sign_type'] = 'MD5';
//字符編碼格式 目前支持 gbk 或 utf-8
$aliapy_config['input_charset'] = 'utf-8';
//訪問模式,根據自己的服務器是否支持ssl訪問,若支持請選擇https;若不支持請選擇http
$aliapy_config['transport'] = 'http';
$logistics_fee = "0.00";
//物流費用,即運費。
$logistics_type = "EXPRESS";
//物流類型,三個值可選:EXPRESS(快遞)、POST(平郵)、EMS(EMS)
$logistics_payment = "SELLER_PAY";
//物流支付方式,兩個值可選:SELLER_PAY(賣家承擔運費)、BUYER_PAY(買家承擔運費)
$quantity = "1";
//商品數量,建議默認為1,不改變值,把一次交易看成是一次下訂單而非購買一件商品。
//選填參數//
//買家收貨信息(推薦作為必填)
//該功能作用在於買家已經在商戶網站的下單流程中填過一次收貨信息,而不需要買家在支付寶的付款流程中再次填寫收貨信息。
//若要使用該功能,請至少保證receive_name、receive_address有值
//收貨信息格式請嚴格按照姓名、地址、郵編、電話、手機的格式填寫
$receive_name = "收貨人姓名";
//收貨人姓名,如:張三
$receive_address = "收貨人地址";
//收貨人地址,如:XX省XXX市XXX區XXX路XXX小區XXX棟XXX單元XXX號
$receive_zip = "123456";
//收貨人郵編,如:123456
$receive_phone = "0571-81234567";
//收貨人電話號碼,如:0571-81234567
$receive_mobile = "13312341234";
//收貨人手機號碼,如:13312341234
//構造要請求的參數數組,無需改動
$parameter = array("service" => "trade_create_by_buyer", "payment_type" => "1", "partner" => trim($partner), "_input_charset" => trim($_input_charset), "seller_email" => trim($seller_email), "return_url" => trim($return_url), "notify_url" => trim($notify_url), "out_trade_no" => $out_trade_no, "subject" => $subject, "body" => $body, "price" => $total_fee, "quantity" => $quantity, "logistics_fee" => $logistics_fee, "logistics_type" => $logistics_type, "logistics_payment" => $logistics_payment, "receive_name" => $receive_name, "receive_address" => $receive_address, "receive_zip" => $receive_zip, "receive_phone" => $receive_phone, "receive_mobile" => $receive_mobile, "show_url" => $show_url);
$alipayService = new AlipayDualService($aliapy_config);
$html_text = $alipayService->trade_create_by_buyer($parameter);
//生成表單提交HTML文本信息
$alipaySubmit = new AlipaySubmit();
//待請求參數數組
$para = $alipaySubmit->buildRequestPara($parameter, $aliapy_config);
$action = "";
$this->data['action'] = $action;
$this->data['para'] = $para;
$this->data['input_charset'] = $aliapy_config['input_charset'];
$this->data['html_text'] = $html_text;
$this->id = 'payment';
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/payment/alipay_dual.tpl')) {
$this->template = $this->config->get('config_template') . '/template/payment/alipay_dual.tpl';
} else {
$this->template = 'default/template/payment/alipay_dual.tpl';
}
$this->render();
}
示例2: AlipaySubmit
/**
* Generate the alipay button link (POST method)
*
* @access public
* @param mixed $order_id
* @return string
*/
function generate_alipay_form($order_id)
{
$order = new WC_Order($order_id);
require_once "lib/alipay_submit.class.php";
$alipay_args = $this->get_alipay_args($order);
$alipay_config = $this->get_alipay_config();
$alipaySubmit = new AlipaySubmit($alipay_config);
$alipay_adr = $alipaySubmit->alipay_gateway_new;
$para = $alipaySubmit->buildRequestPara($alipay_args, $alipay_config);
$alipay_args_array = array();
foreach ($para as $key => $value) {
$alipay_args_array[] = '<input type="hidden" name="' . esc_attr($key) . '" value="' . esc_attr($value) . '" />';
}
wc_enqueue_js('
$.blockUI({
message: "' . esc_js(__('Thank you for your order. We are now redirecting you to Alipay to make payment.', 'alipay')) . '",
baseZ: 99999,
overlayCSS:
{
background: "#fff",
opacity: 0.6
},
css: {
padding: "20px",
zindex: "9999999",
textAlign: "center",
color: "#555",
border: "3px solid #aaa",
backgroundColor:"#fff",
cursor: "wait",
lineHeight: "24px",
}
});
jQuery("#submit_alipay_payment_form").click();
');
return '<form id="alipaysubmit" name="alipaysubmit" action="' . $alipay_adr . '_input_charset=' . trim(strtolower($alipay_config['input_charset'])) . '" method="post" target="_top">' . implode('', $alipay_args_array) . '
<!-- Button Fallback -->
<div class="payment_buttons">
<input type="submit" class="button-alt" id="submit_alipay_payment_form" value="' . __('Pay via Alipay', 'alipay') . '" /> <a class="button cancel" href="' . esc_url($order->get_cancel_order_url()) . '">' . __('Cancel order & restore cart', 'alipay') . '</a>
</div>
<script type="text/javascript">
jQuery(".payment_buttons").hide();
</script>
</form>';
}