phonepe / php-merchant-client

此包的最新版本(1.0)没有可用的许可信息。

PhonePe 商户客户端 Php

1.0 2016-11-22 08:39 UTC

This package is not auto-updated.

Last update: 2024-09-28 20:20:04 UTC


README

这是一个商户集成用的 Php 客户端。使用此客户端需要至少 PHP 5.3。有关所有 API 的参考,请访问

http://developer.phonepe.com.

命名空间

  • 客户端在 PhonePe 命名空间下
  • 请求和响应对象定义在 PhonePe\Models 命名空间下的模型中

安装

  • 如果你的项目使用 composer,请在你的 composer.json 文件中添加以下行
    {
        "require": {
            "phonepe/php-merchant-client": "1.*"
        }
    }
  • 现在,运行 "composer update"。你将在 vendors 文件夹中找到 php-merchant-client 文件夹。

请注意,你将需要要求 vendor/autoloader.php 以自动加载所有必需的类。

使用方法

使用 PhonePe 命名空间来访问客户端,并通过 PhonePeClient 类的对象调用所需 API 的函数。

例如

    use PhonePe\PhonePeClientImpl;
    use PhonePe\Models\RegularCreditRequest;
    
    require('vendor/autoload.php')      // For autoloading all the required classes
    
    $phonePeClientObject = new PhonePeClientImpl();
    $regularCreditRequestObject = new RegularCreditRequest();
    
    // 
    // Build the regularCreditRequestObject here
    // 
    
    $response = $phonePeClientObject->$regularCredit($regularCreditRequestObject)
    
    echo $response->redirectUrl;    // To get the location to redirect to.

该函数将始终返回对应返回类型的对象。

校验和生成器使用方法

  • PhonePe\Utils 命名空间下
  • 调用带有所有必需变量和盐索引数组的 checkSumGenerate 函数
  • 查看以下示例
    use PhonePe\Utils\ChecksumGenerator
    
    require('vendor/autoload.php')
    
    $args = array($merchantId, $transactionId, $amount, $saltKey, $saltIndex);
    $result = ChecksumGenerator::checkSumGenerate($args);