本文整理汇总了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>';
}