croatiangrn/pikpay-php

PikPay的支付处理库

1.3.0 2018-06-25 09:25 UTC

This package is not auto-updated.

Last update: 2024-09-29 05:48:27 UTC


README

SensioLabsInsight

Latest Stable Version Minimum PHP Version Build Status StyleCI

安装

通过Composer

$ composer require selimsalihovic/pikpay-php

用法

使用此包之前,请从您的PikPay账户获取凭据。您需要您的真实性令牌(API_KEY)和密钥(SECRET_KEY)。在发出任何请求之前,必须构建一个Gateway实例。

$gateway = new Gateway(getenv('ENDPOINT'), getenv('API_KEY'), getenv('SECRET_KEY'));

输入数据

对于每个请求,需要一个数据数组。请参阅PikPay文档,了解哪些请求需要包含哪些值。注意:您不需要包含'digest'参数,因为它在每个请求中根据数据数组为您计算。

以下是一个有效数据数组的示例。

$data = [
    'amount'          => 5500,
    'expiration-date' => 1707,
    'cvv'             => 286,
    'pan'             => 5464000000000008,
    'ip'              => '128.93.108.112',
    'order-info'      => 'Test Order',
    'ch-address'      => '1419 Westwood Blvd',
    'ch-city'         => 'Los Angeles',
    'ch-country'      => 'USA',
    'ch-email'        => 'john.doe@gmail.com',
    'ch-full-name'    => 'John Doe',
    'ch-phone'        => '636-48018',
    'ch-zip'          => '90024',
    'currency'        => 'USD', //EUR, BAM, HRK
    'order-number'    => 'order-d234djflq0wz',
    'language'        => 'en',
];

发送授权请求

$response = $gateway->authorize($data);
if ($response->isSuccessfull()) {
    //handle success case
} else {
    //display error
}

发送捕获请求

捕获请求仅针对先前已授权的交易发送。

$gateway->authorize($data);
$response = $gateway->capture($data);

发送购买请求

购买请求执行两项操作。

$response = $gateway->purchase($data);

发送退款请求

$response = $gateway->refund($data);

发送作废请求

$response = $gateway->void($data);

测试

要运行测试,请确保已安装composer.json中的所有开发依赖项。

$ cd pikpay-php && cp example.phpunit.xml.dist phpunit.xml.dist
$ nano phpunit.xml.dist #update your credentials and save them
$ vendor/bin/phpunit