1. Go to this page and download the library: Download iopay-payments/sdk-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/ */
iopay-payments / sdk-php example snippets
/**
* true para sandbox
* false para production
*/
const IS_SANDBOX = true;
/**
* Credenciais da conta do seller
* https://minhaconta.iopay.com.br
*/
const IOPAY_EMAIL = "[email protected]";
const IOPAY_SECRET = "bdSt_xTiKcbMj2348EiDBuGjKdn5hKqv+GmqRNFTwK39HFKf=Ecf-";
const IOPAY_SELLER_ID = "076b53180-6e5d9-47a1-rb1c4-973747fbb6de0";
/*
* Habilitar ou desabilitar o sistema de logger/debug
*/
const LOGGER = true;
use IoPay\Authentication\Auth;
$logger = new IoPay\Logger\Log();
$auth = new Auth();
$token = $auth->token();
if (!$token) {
$logger->log("Não foi possivel gerar o token");
} else {
$logger->log("Token {$token} gerado com sucesso");
}
use IoPay\Environment;
use IoPay\Logger\Log;
use IoPay\Source\Payment;
use IoPay\Transaction\Transaction;
$customerId = "30cdb54284424e10b9beae475c8c9879";
$transaction = new Transaction();
$transaction->setCustomerId($customerId);
$transaction->setAmount("4509");
$transaction->setCurrency(Payment::CURRENCY);
$transaction->setDescription("Venda na loja ABC");
$transaction->setStatementDescriptor("Pedido 12345");
$transaction->setIoSellerId(Environment::IOPAY_SELLER_ID);
$transaction->setPaymentType(Payment::TYPE_PIX);
$transaction->setReferenceId("123456");
/* Testando a saída do array para a transaction */
$logger = new Log();
$logger->log($transaction->getData());
/* Criando a transação e conectando */
$response = $transaction->createTransactionPix();
$logger->log("---- Transação com Pix ----");
$logger->log($response);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.