PHP code example of yurunsoft / pay-sdk
1. Go to this page and download the library: Download yurunsoft/pay-sdk library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once ('vendor/autoload.php' );
yurunsoft / pay-sdk example snippets
$pay = new \Yurun\PaySDK\Alipay\SDK($params);
$request = new \Yurun\PaySDK\Alipay\Params\Pay\Request;
$request->notify_url = '' ;
$request->return_url = '' ;
$request->businessParams->seller_id = $GLOBALS['PAY_CONFIG' ]['appid' ];
$request->businessParams->out_trade_no = 'test' . mt_rand(10000000 ,99999999 );
$request->businessParams->total_fee = 0.01 ;
$request->businessParams->subject = '测试商品' ;
$pay->prepareExecute($request, $url);
var_dump($url);
$pay = new \Yurun\PaySDK\AlipayApp\SDK($params);
$request = new \Yurun\PaySDK\AlipayApp\Wap\Params\Pay\Request;
$request->notify_url = '' ;
$request->return_url = '' ;
$request->businessParams->out_trade_no = 'test' . mt_rand(10000000 ,99999999 );
$request->businessParams->total_amount = 0.01 ;
$request->businessParams->subject = '小米手机9黑色陶瓷尊享版' ;
$pay->prepareExecute($request, $url);
var_dump($url);
$pay = new \Yurun\PaySDK\Weixin\SDK($params);
$request = new \Yurun\PaySDK\Weixin\H5\Params\Pay\Request;
$request->body = 'test' ;
$request->out_trade_no = 'test' . mt_rand(10000000 ,99999999 );
$request->total_fee = 1 ;
$request->spbill_create_ip = '127.0.0.1' ;
$request->notify_url = '' ;
$result = $pay->execute($request);
if ($pay->checkResult())
{
header('Location: ' . $result['mweb_url' ]);
}
else
{
var_dump($pay->getErrorCode() . ':' . $pay->getError());
}
exit ;
public function test ()
{
$payNotify = new class extends \Yurun \PaySDK \Weixin \Notify \Pay
{
protected function __exec ()
{
}
};
$context = RequestContext::getContext();
$payNotify->swooleRequest = $context['request' ];
$payNotify->swooleResponse = $context['response' ];
$sdk->notify($payNotify);
return $payNotify->swooleResponse;
}
$payNotify = new class extends \Yurun \PaySDK \Weixin \Notify \Pay
{
protected function __exec ()
{
}
};
$payNotify->swooleRequest = $request;
$payNotify->swooleResponse = $response;
$sdk->notify($payNotify);
$payNotify = new class extends \Yurun \PaySDK \Weixin \Notify \Pay
{
protected function __exec ()
{
}
};
$payNotify->swooleRequest = $request;
$payNotify->swooleResponse = $response;
$sdk->notify($payNotify);
return $payNotify->swooleResponse;