ikechukwuokalia/paylot-php

[由 @dozieogbo 定制的 paylot/paylot-php 版本] Paylot API 的 PHP 封装

v1.0.2 2020-11-08 12:46 UTC

This package is auto-updated.

Last update: 2024-09-08 21:08:05 UTC


README

PHP API 封装 Paylot

Paylot

要求

  • Guzzle 6.3.0 或更高版本(除非使用 Guzzle)
  • PHP 5.4.0 或更高版本
  • OpenSSL v1.0.1 或更高版本

安装

通过 Composer

    $ composer require paylot/paylot-php

通过下载

发布页面 下载一个版本。解压后

    require 'path/to/src/autoload.php';

使用方法

要使用,请遵循以下步骤。

0. 前提条件

请确认您的服务器可以与 Paylot 服务器建立 TLSv1.2 连接。大多数最新的软件都具备此功能。如果您遇到任何 SSL 错误,请联系您的服务提供商以获得指导。不要禁用 SSL 证书验证!

0b. 密钥

请确保您手头有 Paylot 的密钥。您可以从您的业务资料中获取。

1. 验证交易

交易成功后,请在给予价值之前验证交易。

    $reference = isset($_GET['reference']) ? $_GET['reference'] : '';
    if(!$reference){
      die('No reference supplied');
    }

    // initiate the Library's Paystack Object
    $paylot = new Paylot\Paylot(SECRET_KEY);
    try
    {
      // verify using the library
      $tranx = $paylot->transaction->verify($reference);
    } catch(\Paylot\Exceptions\ApiResponseException $e){
      print_r($e->getResponseObject());
      die($e->getMessage());
    }

    if ($tranx->sent) {
      // Payment has been made. You can give value
    }
    
    if ($tranx->confirmed) {
      // Payment has been confirmed on blockchain. 
      // If you don't give value here, I don't know what you are waiting for.
    }