本文整理汇总了PHP中AlipaySubmit::buildRequestUrl方法的典型用法代码示例。如果您正苦于以下问题:PHP AlipaySubmit::buildRequestUrl方法的具体用法?PHP AlipaySubmit::buildRequestUrl怎么用?PHP AlipaySubmit::buildRequestUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AlipaySubmit
的用法示例。
在下文中一共展示了AlipaySubmit::buildRequestUrl方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getRequestUrl
public function getRequestUrl($orderId, $returnUrl, $notifyUrl)
{
// 参数验证
$validator = new Validator(array('orderId' => $orderId, 'returnUrl' => $returnUrl, 'notifyUrl' => $notifyUrl));
$orderId = $validator->required()->digits()->min(1)->validate('orderId');
$returnUrl = $validator->required()->validate('returnUrl');
$notifyUrl = $validator->required()->validate('notifyUrl');
$this->validate($validator);
//设置订单 ID
$this->orderId = $orderId;
// 取得订单
$orderBasicService = new OrderBasicService();
$orderInfo = $orderBasicService->loadOrderInfoById($orderId);
if (empty($orderInfo) || $orderInfo->isEmpty()) {
throw new \InvalidArgumentException('invalid order_id [' . $orderId . ']');
}
$desc = $orderInfo['order_id'] . '|' . Money::toSmartyDisplay($orderInfo['order_amount']) . '|' . $orderInfo['system_id'];
//构造要请求的参数数组,无需改动
$parameter = array("service" => "create_direct_pay_by_user", "partner" => $this->partnerId, "payment_type" => 1, "notify_url" => $notifyUrl, "return_url" => $returnUrl, "seller_email" => $this->account, "out_trade_no" => $orderInfo['order_sn'] . '_' . $orderInfo['order_id'], "subject" => $desc, "total_fee" => Money::toDisplay($orderInfo['order_amount'], 2), "body" => $desc, "show_url" => '', "anti_phishing_key" => '', "exter_invoke_ip" => '', "_input_charset" => 'utf-8');
//建立请求
$alipaySubmit = new AlipaySubmit($this->alipayConfig);
return $alipaySubmit->buildRequestUrl($parameter);
}