gianninasd/pplib

PHP支付集成库

v1.0.2 2021-11-11 17:11 UTC

This package is auto-updated.

Last update: 2024-09-11 23:03:37 UTC


README

Latest Stable Version Latest Unstable Version Total Downloads

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 );

参考