PHP code example of snowrunescape / picpay-php-sdk

1. Go to this page and download the library: Download snowrunescape/picpay-php-sdk 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/ */

    

snowrunescape / picpay-php-sdk example snippets


$picpay = new \PicPay\PicPay("x-picpay-token", "x-seller-token");

$preference = $picpay->create_preference([
    "referenceId" => "PICPAY00001REFERENCE",
    "callbackUrl" => "https://example.com/api/notification",
    "returnUrl" => "https://example.com/order/success",
    "items" => [
        [
            "id" => 1,
            "quantity" => 1
        ]
    ],
    "value" => 30.00,
    "expiresAt" => (new \DateTime("+1 hour"))->format("Y-m-d\TH:i:s.000-04:00"),
    "buyer" => [
        "firstName" => "Bruno",
        "lastName" => "Caitano",
        "document" => "123.456.789-10",
        "email" => "[email protected]",
        "phone" => "+55 11 9 9999-9999"
    ]
]);

$url = $preference["response"]["paymentUrl"];

$picpay = new \PicPay\PicPay("x-picpay-token", "x-seller-token");

$data = json_decode(file_get_contents("php://input"), true);

$payment = $picpay->get_preference($data["referenceId"]);

composer