san tan ami c/php-picpay-sdk

v1 2019-04-04 05:39 UTC

This package is auto-updated.

Last update: 2024-09-16 08:57:28 UTC


README

Screenshot

Latest Version on Packagist Software License PHP Version Coverage Status Build Status Total Downloads

PHP应用程序与PicPay API集成的SDK。这是一个非官方的开源项目。

要求

  • PHP 5.5及以后版本
  • 已安装Composer
  • PicPay Token电子商务

结构

docs/
src/
example/
lib/
tests/

安装与使用

Composer

通过composer安装绑定

$ composer require santanamic/php-picpay-sdk

测试

运行单元测试

composer test

入门

以下示例展示了如何获取支付URL。请按照安装过程进行,然后运行以下命令

<?php
require_once(__DIR__ . '/vendor/autoload.php');

// Configure API key authorization: E-commerce Token
$config = PicPay\Configuration::getDefaultConfiguration()->setApiKey('x-picpay-token', 'YOUR_API_KEY');

$apiInstance = new PicPay\SDK\RequisioDePagamentoApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
	new GuzzleHttp\Client([
		'verify'  => false,
		'headers' => [
			'Content-Type'    => 'text/html; charset=UTF-8',
			'Cache-Control'   => 'no-cache',
			'Accept-Encoding' => 'none'
		]
	]),
    $config
);

//Pass the parameters and make the magic happen. 
//Law the official documentation to know more details about the parameters 
$body = new \PicPay\modelPackage\PaymentRequest([
	'reference_id' => '123456',
	'callback_url' => 'https://example.com/',
	  'return_url' => 'https://example.com/return',
	       'value' => '230.22',
	       'buyer' => [
				'firstName' => 'João',
				'lastName'  => 'Da Silva',
				'document' => '123.456.789-10',
				'email' => 'teste@picpay.com',
				'phone' => '+55 27 12345-6789'
			]
]);

try {
    $result = $apiInstance->postPayments($body);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling RequisioDePagamentoApi->postPayments: ', $e->getMessage(), PHP_EOL;
}
?>

API端点文档

所有URI都是相对于https://appws.picpay.com/ecommerce/public/

官方文档

如何获取PicPay Token

与作者联系

许可证和关于项目