PHP code example of paggi / sdk56-ecommerce

1. Go to this page and download the library: Download paggi/sdk56-ecommerce library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

paggi / sdk56-ecommerce example snippets


use Paggi\SDK;
$envConfiguration = new \Paggi\SDK\EnvironmentConfiguration();
$target = new \Paggi\SDK\Card();
$envConfiguration->setEnv("Staging");
$envConfiguration->setToken(getenv("ENVTOKEN"));
$envConfiguration->setPartnerIdByToken(getenv("ENVTOKEN"));
$cardParams =
[
    "cvv" => "123",
    "year" => "2022",
    "number" => "4123200700046446",
    "month" => "09",
    "holder" => "BRUCE WAYNER",
    "document" => "16123541090"
];
$card = $target->create($cardParams);

$envConfiguration = new \Paggi\SDK\EnvironmentConfiguration();
$OrderCreator = new \Paggi\SDK\Order();
$envConfiguration->setEnv("Staging");
$envConfiguration->setToken(getenv("ENVTOKEN"));
$envConfiguration->setPartnerIdByToken(getenv("ENVTOKEN"));
$charge =
[
    "amount" => 5000,
    "installments" => 10,
    "card" =>
    [
        "number" => "5573710095684403",
        "cvc" => "123",
        "holder" => "BRUCE WAYNE",
        "year" => "2020",
        "month" => "04",
        "document" => "16123541090"
    ]
];
$orderParams=
[
    "external_identifier" => "ABC123",
    "ip" => "8.8.8.8",
    "charges" => [$charge],
    "customer" =>
    [
        "name" => "Bruce Wayne",
        "document" => "86219425006",
        "email" => "[email protected]"
    ]
];
$response = $OrderCreator->create($orderParams);

$envConfiguration = new \Paggi\SDK\EnvironmentConfiguration();
$bankFinder = new \Paggi\SDK\Bank();
$envConfiguration->setEnv("Staging");
$envConfiguration->setToken(getenv("ENVTOKEN"));
$envConfiguration->setPartnerIdByToken(getenv("ENVTOKEN"));
$banks = $bankFinder->find(["start"=>0, "count"=>20]);