Skip to content

Latest commit

 

History

History
75 lines (50 loc) · 2.57 KB

README.md

File metadata and controls

75 lines (50 loc) · 2.57 KB

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.