Skip to content

santanamic/php-picpay-sdk

Repository files navigation

PHP PicPay SDK

Screenshot

Latest Version on Packagist Software License PHP Version Coverage Status Build Status Total Downloads

SDK for integration of PHP applications with the PicPay API. This is an unofficial open source project.

Requirements

  • PHP 5.5 and later
  • Composer installed
  • PicPay Token E-commerce

Structure

docs/
src/
example/
lib/
tests/

Installation & Usage

Composer

To install the bindings via composer:

$ composer require santanamic/php-picpay-sdk

Tests

To run the unit tests:

composer test

Getting Started

This example shows how to get payment URLs. Please follow the installation procedure and then run the following:

<?php
require_once(__DIR__ . '/vendor/autoload.php');

// Configure API key authorization: E-commerce Token
$config = PicPay\Configuration::getDefaultConfiguration()->setApiKey('x-picpay-token', 'YOUR_API_KEY');

$apiInstance = new PicPay\SDK\RequisioDePagamentoApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
	new GuzzleHttp\Client([
		'verify'  => false,
		'headers' => [
			'Content-Type'    => 'text/html; charset=UTF-8',
			'Cache-Control'   => 'no-cache',
			'Accept-Encoding' => 'none'
		]
	]),
    $config
);

//Pass the parameters and make the magic happen. 
//Law the official documentation to know more details about the parameters 
$body = new \PicPay\modelPackage\PaymentRequest([
	'reference_id' => '123456',
	'callback_url' => 'https://example.com/',
	  'return_url' => 'https://example.com/return',
	       'value' => '230.22',
	       'buyer' => [
				'firstName' => 'João',
				'lastName'  => 'Da Silva',
				'document' => '123.456.789-10',
				'email' => 'teste@picpay.com',
				'phone' => '+55 27 12345-6789'
			]
]);

try {
    $result = $apiInstance->postPayments($body);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling RequisioDePagamentoApi->postPayments: ', $e->getMessage(), PHP_EOL;
}
?>

Documentation for API Endpoints

All URIs are relative to https://appws.picpay.com/ecommerce/public/

Class Method HTTP request Description
CancelamentoApi postCancellations POST /payments/{referenceId}/cancellations Cancel Request
RequisioDePagamentoApi postPayments POST /payments Payment Request
StatusApi getStatus GET /payments/{referenceId}/status Status Request

Documentation Official

How to get a PicPay Token

Talk to the author

License and About Project

About

PHP SDK for integration with the PicPay Payment API

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages