-
Notifications
You must be signed in to change notification settings - Fork 155
Legacy WAP Gateway
Loki Else edited this page Jun 21, 2017
·
5 revisions
/**
* @var LegacyWapGateway $gateway
*/
$gateway = Omnipay::create('Alipay_LegacyWap');
$gateway->setPartner('the_partner_id');
$gateway->setKey('the_md5_sign_key');
$gateway->setSellerId( $this->partner);
$gateway->setPrivateKey('the_rsa_sign_key');
$gateway->setAlipayPublicKey('the_alipay_public_key');
$gateway->setReturnUrl('https://www.example.com/return');
$gateway->setNotifyUrl('https://www.example.com/notify');
$request = $gateway->purchase([
'out_trade_no' => date('YmdHis').mt_rand(1000,9999),
'subject' => 'test',
'total_fee' => '0.01',
'app_pay' => 'Y',
]);
/**
* @var LegacyWapPurchaseResponse $response
*/
$response = $request->send();
$redirectUrl = $response->getRedirectUrl();
//or
$response->redirect();
$request = $gateway->completePurchase();
$request->setParams(array_merge($_POST, $_GET)); //Don't use $_REQUEST for may contain $_COOKIE
/**
* @var AopTradeAppPayResponse $response
*/
$response = $request->send();
try {
$response = $request->send();
if($response->isPaid()){
/**
* Payment is successful
*/
die('success'); //The notify response should be 'success' only
}else{
/**
* Payment is not successful
*/
die('fail'); //The notify response
}
} catch (Exception $e) {
/**
* Payment is not successful
*/
die('fail'); //The notify response
}