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-04-04 22:03:24 UTC


README

PHP version Download stats Latest release CI status

Welcome to the OpenPix PHP SDK! This SDK provides convenient access to the OpenPix REST API, allowing you to easily integrate payment services into your PHP applications.

usage example screenshot

Documentation

See SDK documentation and Rest API documentation.

Installation

Install the SDK with the necessary dependencies using Composer:

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

Basic usage

Here is the basic usage of the SDK. See SDK documentation for more details.

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";

Contributing

If you have suggestions for how OpenPix PHP SDK could be improved, or want to report a bug, open an issue! We'd love all and any contributions.

For more, check out the Contributing Guide.

License

OpenPix PHP SDK is distributed under the terms of the MIT license.