PaySDK is a PHP integrated payment SDK that integrates the payment interfaces of Alipay and WeChat Pay and the operations of other related interfaces.
No framework dependencies, supports all frameworks, and supports Swoole coroutine environment.
We have complete online technical documentation: http://doc.yurunsoft.com/PaySDK
API documentation: https://apidoc.gitee.com/yurunsoft/PaySDK
This project has entered the maintenance stage and will not support the WeChat V3 interface. I am too lazy to follow them. If you need it, please look elsewhere!
The author himself does not provide any technical support. If necessary, you can join the group discussion: 17916227. It is not certain whether anyone will reply.
Everyone will definitely connect to various payment platforms during development. I personally have limited energy. You are welcome to submit a PR on Github and work together to improve PaySDK so that it can support more payment platforms and be more stable, reliable and easy to use.
Instant payment - computer website payment (old)
Instant payment - mobile website payment (old)
Pay in person
Mobile website payment
Computer website payment
APP payment server
Mini program payment
Single transfer to Alipay account
Overseas payment (computer website, mobile website, APP, scan code)
Customs declaration
Other auxiliary transaction interfaces (refunds, inquiries, etc.)
Pay by card
Official account payment
Scan code to pay
APP payment
H5 payment
Mini program payment
Business payments to change
Business payments to bank cards
Overseas payment (swipe card, official account, scan code, APP)
Customs declaration
Other auxiliary transaction interfaces (refunds, inquiries, etc.)
Add configuration to your composer.json:
PHP >= 5.5
{"require": {"yurunsoft/pay-sdk": "~3.0"} }
PHP >= 5.4
{"require": {"yurunsoft/pay-sdk": "~2.0"} }
Version 3.x supports PHP >= 5.5 and is under continuous iterative maintenance.
Version 2.x supports PHP >= 5.4, supports long-term BUG maintenance, ensures stability and availability, and stops functional updates.
Then execute the composer update
command.
// SDK instantiation, pass in the public configuration $pay = new YurunPaySDKAlipaySDK($params); // Payment interface $request = new YurunPaySDKAlipayParamsPayRequest; $request->notify_url = ''; // Notification address after payment (as payment success callback , this is reliable) $request->return_url = ''; // Jump to the return address after payment $request->businessParams->seller_id = $GLOBALS['PAY_CONFIG']['appid']; // Seller's Alipay user number $request->businessParams->out_trade_no = 'test' . mt_rand(10000000 ,99999999); // Merchant order number $request->businessParams->total_fee = 0.01; // Price $request->businessParams->subject = 'Test product'; // Product title // Jump to payment page // $pay->redirectExecute( $request);//Get the jump url$pay->prepareExecute($request, $url);var_dump($url);
// SDK instantiation, pass in the public configuration $pay = new YurunPaySDKAlipayAppSDK($params); // Payment interface $request = new YurunPaySDKAlipayAppWapParamsPayRequest; $request->notify_url = ''; // Notification address after payment (as payment success callback , this is reliable) $request->return_url = ''; // Jump to the return address after payment $request->businessParams->out_trade_no = 'test' . mt_rand(10000000,99999999); // Merchant order number $request->businessParams->total_amount = 0.01; // Price $request->businessParams ->subject = 'Xiaomi Mobile 9 Black Ceramic Exclusive Edition'; // product title // Jump to the payment page // $pay->redirectExecute($request); // Get the jump url $pay->prepareExecute($request, $url);var_dump($url);
// SDK instantiation, pass in the public configuration $pay = new YurunPaySDKWeixinSDK($params); // Payment interface $request = new YurunPaySDKWeixinH5ParamsPayRequest; $request->body = 'test'; // Product description $request->out_trade_no = 'test' .mt_rand(10000000,99999999); // Order number $request->total_fee = 1; // Total order amount, unit: cents $request->spbill_create_ip = '127.0.0.1'; // Client ip $request->notify_url = ''; // Asynchronous notification Address // Call interface $result = $pay->execute($request);if($pay->checkResult()) {// Jump to the payment interface header('Location: ' . $result['mweb_url']); }else{var_dump($pay->getErrorCode() . ':' . $pay->getError()); }exit;
In payment and refund asynchronous notifications, Swoole
's Request
and Response
objects need to be assigned, or objects that comply with the PSR-7 standard can be used.
The Request
and Response
objects of mainstream frameworks generally follow the PSR-7 standard and can be used directly.
imi is a high-performance coroutine application development framework based on PHP Swoole. It supports the development of HttpApi, WebSocket, TCP, and UDP services.
With the support of Swoole, compared with php-fpm's request response capability, I/O-intensive scene processing capabilities have been substantially improved.
The imi framework has rich functional components and can be widely used in the Internet, mobile communications, enterprise software, cloud computing, online games, Internet of Things (IOT), Internet of Vehicles, smart homes and other fields. It can greatly improve the efficiency of enterprise IT R&D teams and focus more on developing innovative products.
https://www.imiphp.com/
/** * This is an action method in the controller * @Action */public function test() {$payNotify = new class extends YurunPaySDKWeixinNotifyPay {/** * Subsequent execution operations * @return void */protected function __exec() { } };$context = RequestContext::getContext();//The following two lines are critical $payNotify->swooleRequest = $context['request'];$payNotify->swooleResponse = $context['response'];$sdk- >notify($payNotify);// This sentence must be filled in return $payNotify->swooleResponse; }
$payNotify = new class extends YurunPaySDKWeixinNotifyPay {/** * Subsequent execution operations * @return void */protected function __exec() { } }; // The following two lines are critical, $request, $response are obtained from request // Or check how to obtain them from the framework you are using $payNotify->swooleRequest = $request;$payNotify->swooleResponse = $response;$ sdk->notify($payNotify);
$payNotify = new class extends YurunPaySDKWeixinNotifyPay {/** * Subsequent execution operations * @return void */protected function __exec() { } }; // Currently, mainstream Swoole basically supports PSR-7 standard objects // so it can be passed in directly. Please refer to the documentation of the corresponding framework for how to obtain it. $payNotify->swooleRequest = $request; $payNotify->swooleResponse = $response; $sdk->notify($payNotify);//After the processing is completed, $response needs to be returned from the controller or assigned to the context// The operations of different frameworks are different. Please refer to the documentation of the corresponding framework. return $payNotify->swooleResponse;
Service content:
Low-cost account opening (only legal merchants)
Troubleshooting and consultation
Pay on behalf of others
Other cooperation
If necessary, add QQ: 369124067
WeChat: wx_zhangrunyu
(indicate the purpose of your visit)
Open source does not seek profit, it is all about your heart. Life is not easy, so just go with the flow...