PHP code example of misterioso013 / picpay-php

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

    

misterioso013 / picpay-php example snippets




isterioso013\Payments\PicPay; 
$picpay = New PicPay(x_picpay_token, x_seller_token);



isterioso013\Payments\PicPay; 
$picpay = New PicPay(x_picpay_token, x_seller_token);

$data = array(
  "referenceId" => 100000000,
  "callbackUrl" => "http://www.sualoja.com.br/callback",
  "returnUrl" => "http://www.sualoja.com.br/cliente/pedido/102030",
  "value" => 0.50,
  "expiresAt" => "2022-05-01T16:00:00-03:00",
  "channel" => "my-channel",
  "purchaseMode" => "in-store",
  "buyer" =>  [
    "firstName"=> "João",
    "lastName"=> "Da Silva",
    "document"=> "123.456.789-10",
    "email"=> "[email protected]",
    "phone" => "+55 27 12345-6789"
  ]);

  print_r($picpay->Payments($data));

$request = $picpay->Status($referenceId);
print_r($request);


stdClass Object
(
    [referenceId] => 960361262
    [status] => paid
    [createdAt] => 2021-09-09T07:29:37.000000Z
    [updatedAt] => 2021-09-09T09:00:17.000000Z
    [value] => 0.5
    [authorizationId] => 0000b800cf788600237f30f3
)


# o authorizationId só é obrigatório para pedidos que já foram pagos
$request = $picpay->Cancellations($referenceId, $authorizationId);
print_r($request);


stdClass Object
(
    [referenceId] => 960361262
    [cancellationId] => 0000b800cf788600237f30f3
)


composer 

$data = array(
  "referenceId" => "",
  "callbackUrl" => "",
  "returnUrl" => "",
  "value" => "",
  "expiresAt" => "",
  "channel" => "my-channel",
  "purchaseMode" => "in-store",
  "buyer" =>  [
    "firstName"=> "",
    "lastName"=> "",
    "document"=> "",
    "email"=> "",
    "phone" => ""
  ]);
$payment = $picpay->Payments($data);

  if(isset($payment->error)) {

    if(isset($payment->error->errors)){
      
      foreach($payment->error->errors as $error) {

        $message = $error->message;
        $field = $error->field;
  
        echo "Atenção! {$message} | Campo: {$field} <br>";
      }
    }
  }