iopay-payments / sdk-php
用于将IoPay Api与PHP系统集成的软件
v2.0.0
2023-03-27 20:18 UTC
Requires
- php: >=5.6.0
This package is auto-updated.
Last update: 2024-09-27 23:23:52 UTC
README
💡 要求
PHP 5.6或更高版本
💻 通过Composer安装
- 如果您尚未安装,请下载 Composer
- 在您的项目中下载IOPAY SDK:
composer require "iopay-payments/sdk-php"
💻 手动安装
- 下载最新版本的SDK包 下载
- 将包内容提取到您的项目中(lib或vendor文件夹,具体取决于您的框架)
完成,您的SDK已成功安装并准备好使用!
环境配置
访问配置文件: src/Environment.php
- 配置环境(为了测试,我们建议使用我们的sandbox环境)
/** * true para sandbox * false para production */ const IS_SANDBOX = true;
- 根据您的卖家账户配置凭证
/** * Credenciais da conta do seller * https://minhaconta.iopay.com.br */ const IOPAY_EMAIL = "integracao@iopay.com.br"; 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;
完成,您的SDK已安装!
🌟 使用示例
所有测试和示例都编写在 examples
tokenization
require_once __DIR__ . '/../../vendor/autoload.php'; // Autoload files using Composer autoload 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"); }
使用PIX进行的交易
require_once __DIR__ . '/../../vendor/autoload.php'; // Autoload files using Composer autoload 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);
📚 文档
🏻 许可证
MIT license. Copyright (c) 2022 - IOPAY
https://apache.ac.cn/licenses/LICENSE-2.0