本文整理匯總了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);
}