gianninasd / pplib
PHP支付集成库
v1.0.2
2021-11-11 17:11 UTC
Requires
- php: >=7.3.0
Requires (Dev)
- codeception/codeception: ^4.1
- codeception/module-asserts: ^1.0.0
- codeception/module-phpbrowser: ^1.0.0
This package is auto-updated.
Last update: 2024-09-11 23:03:37 UTC
README
PPLib
PHP支付集成库
先决条件
- 安装Composer
- 安装PHP 7.x
入门
- 从github克隆仓库到本地机器
- 安装所有依赖项,运行
composer install
,将生成一个vendor文件夹
自动化测试
- 在
tests/unit/_bootstrap.php
文件中更新全局变量的值 - 要执行单元测试,从控制台运行:
vendor/bin/codecept.bat run unit
使用方法
以下是使用各种类准备、发送和处理支付的一些示例代码。
// will be your own class representing the full billing data $member = new class { ... public $firstName = "John"; public $lastName = "Doe"; ... }; $parser = new PaysafeParser(); // create the JSON body first $obj = $parser->parseRequest( $uuid, $token, $member, $amt ); $body = json_encode($obj, JSON_NUMERIC_CHECK); $req = new PaymentRequest(); $req->id = "rick@sdf3.com"; $req->uuid = uniqid("", true); $req->body = $body; // Send the request to the remote third party service provider $ps = new PaysafePaymentService( "https://somedomain.com/somepath", "some authentication token" ); $resp = $ps->process( $req ); // Process the response $jsonResponse = $parser->parseResponse( $resp ); echo( $jsonResponse );
参考
- https://getcomposer.org/
- https://packagist.org.cn/
- https://poser.pugx.org/
- http://www.darwinbiler.com/creating-composer-package-library/
- https://blog.jgrossi.com/2013/creating-your-first-composer-packagist-package/
- https://www.w3resource.com/php/composer/create-publish-and-use-your-first-composer-package.php - 描述如何提交到Packagist
- https://mdn.org.cn/en-US/docs/Web/HTTP/Status