open-pix/php-sdk

PHP OpenPix/Woovi SDK

v1.1.3 2024-01-04 21:28 UTC

This package is auto-updated.

Last update: 2024-09-04 22:54:02 UTC


README

PHP version Download stats Latest release CI status

欢迎使用 OpenPix PHP SDK!此 SDK 提供了对 OpenPix REST API 的便捷访问,让您轻松将支付服务集成到您的 PHP 应用程序中。

usage example screenshot

文档

请参阅SDK 文档REST API 文档

安装

使用 Composer 安装 SDK 及其必要依赖项

$ composer require open-pix/php-sdk guzzlehttp/guzzle guzzlehttp/psr7

基本用法

以下是 SDK 的基本用法。有关更多详细信息,请参阅SDK 文档

use OpenPix\PhpSdk\Client;

// Load autoload of Composer.
require_once __DIR__ . "/vendor/autoload.php";

$client = Client::create("YOUR_APP_ID");

// Create a customer.
$customer = [
    "name" => "Dan PHP-SDK",
    "taxID" => "00000000000", // CPF
    "email" => "email0@example.com",
    "phone" => "5511999999999",
    "correlationID" => "test-php-sdk-customer-" . mt_rand(1, 10000),
];

$client->customers()->create($customer);

// Create a charge using above customer.
$charge = [
    // Charge value.
    "value" => 1000, // (R$ 10,00)

    // Your correlation ID to keep track of this charge.
    "correlationID" => "test-php-sdk-charge-" . mt_rand(1, 10000),

    // Charge customer.
    "customer" => $customer,
];

$result = $client->charges()->create($charge);

// Get the generated dynamic BR code to be rendered as a QR Code.
echo $result["brCode"] . "\n";

贡献

如果您对如何改进 OpenPix PHP SDK 有建议,或想要报告一个错误,请创建一个问题!我们欢迎所有形式的贡献。

更多信息,请查看贡献指南

许可

OpenPix PHP SDK 在 MIT 许可证的条款下分发。