Skip to content

woovibr/php-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

37dc08e · Nov 19, 2024
Jan 4, 2024
Nov 19, 2024
Nov 19, 2024
Jun 3, 2023
Jun 23, 2023
Jul 30, 2023
Jan 4, 2024
Jul 8, 2023
Jul 8, 2023
Jul 8, 2023
Oct 25, 2023
Jan 4, 2024
Jun 21, 2023
Jun 3, 2023
Jul 30, 2023

Repository files navigation

OpenPix PHP SDK

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" => "[email protected]",
    "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.