gencomm/genpay-sdk-php
Composer 安装命令:
composer require gencomm/genpay-sdk-php
包简介
Cliente em PHP para integração server-side com APIs GenPay
README 文档
README
GenComm PHP SDK Client.
O jeito mais simples e rápido de integrar o GenPay a sua aplicação PHP
Instruções
Dependências
require
- PHP >= 5.6
require-dev
- phpunit/phpunit ~ 5.7.27
Instalação
Execute em seu shell:
composer require gencomm/gencomm-sdk-php
Configurando a autenticação
require 'vendor/autoload.php'; use GenComm\GenPay; use GenComm\Enum\Environment; $document = '77753821000123'; $apiKey = '546JK45NJ6K4N6456JKLN6464J5N'; $signature = '123IOU3OI2U1IIOU1OI3UIO23';
Implementando GenPay
$genPay = new GenPay($document, $apiKey, $signature, Environment::SANDBOX);
Implementando GenLog
$genLog = new GenLog($document, $apiKey, $signature, Environment::SANDBOX);
GenPay
Pedidos
Criando pedido no boleto
Neste exemplo será criado um pedido.
$order = $genPay ->order() ->setAmount(200.0) ->setCurrency("BRL") ->setFingerprint("fake-fingerprint") ->setWebhookUrl("http://intregation.test/sdk/") ->setReference("Pedido#01") ->setItemsAmount(200.0) ->setPayerIp("127.0.0.1") ->setTaxesAmount(0) ->setShippingAmount(0) ->setDiscountAmount(0) ->addItem( "Pedido#01", "NIKE TENIS", 1, 200.0, 200.0 ); $customer = $genPay ->customer() ->setName("Maria") ->setBirthDate("1985-04-16") ->setBusinessName("Maria") ->setDocument("12345678909") ->setEmail("teste@teste.com.br") ->setKind("personal") ->addAddress("shipping", "09840-500", "Rua Dos Morros", "1000", "ABC", "Maua", "SP", "Maria", "") ->addAddress("billing", "09840-500", "Rua Dos Morros", "1000", "ABC", "Maua", "SP", "Maria", "") ->addAPhones("55", "11", "999999998", "others", "shipping") ->addAPhones("55", "11", "999999998", "others", "billing"); $payment = $genPay ->asBillet() ->setAmount(200.0) ->setExpiresOn("3"); $response = $genPay->createOrder($order, $customer, $payment); print_r($response);
Criando pedido no cartão de crédito
Neste exemplo será criado um pedido.
$order = $genPay ->order() ->setAmount(200.0) ->setCurrency("BRL") ->setFingerprint("fake-fingerprint") ->setWebhookUrl("http://intregation.test/sdk/") ->setReference("Pedido#01") ->setItemsAmount(200.0) ->setPayerIp("127.0.0.1") ->setTaxesAmount(0) ->setShippingAmount(0) ->setDiscountAmount(0) ->addItem( "Pedido#01", "NIKE TENIS", 1, 200.0, 200.0 ); $customer = $genPay ->customer() ->setName("Maria") ->setBirthDate("1985-04-16") ->setBusinessName("Maria") ->setDocument("12345678909") ->setEmail("teste@teste.com.br") ->setKind("personal") ->addAddress("shipping", "09840-500", "Rua Dos Morros", "1000", "ABC", "Maua", "SP", "Maria", "") ->addAddress("billing", "09840-500", "Rua Dos Morros", "1000", "ABC", "Maua", "SP", "Maria", "") ->addAPhones("55", "11", "999999998", "others", "shipping") ->addAPhones("55", "11", "999999998", "others", "billing"); $payment = $genPay ->asCreditCard() ->setToken("fake-credit-card-token") ->setReference("Pedido#01") ->setInstallmentsQuantity(10) ->setHolderName("MARIA DA SILVA") ->setHolderDocument("12345678909") ->setCvv("123") ->setBrand("VISA") ->setAmount(200.0) ->setInstallmentInterest( 1, 0, 200, 200, 200 ); $response = $genPay->createOrder($order, $customer, $payment); print_r($response);
Cancelando um Pedido
Neste exemplo será cancelado um pedido.
$response = $genPay->cancel("fake-charge-uuid", Requester::MERCHANT, "Produto errado."); print_r($response);
Estorno Total de um Pedido
Neste exemplo será feito o estorno total de um pedido.
// Parametro Opcional $bankAccount = [ 'document' => '11111111111', 'bank_code' => '341', 'bank_agency' => '1234', 'bank_number' => '12345678-1', ]; $refund = $genPay->asRefund(); $refund->setReason("Comprou errado.") ->setRequester(Requester::MERCHANT) ->addPayment('fake-payment-id', 250, $bankAccount); $response = $genPay->refund($refund, "fake-charge-uuid"); print_r($response);
Estorno Parcial de um Pedido
Neste exemplo será feito o estorno parcial de um pedido.
// Parametro Opcional $bankAccount = [ 'document' => '11111111111', 'bank_code' => '341', 'bank_agency' => '1234', 'bank_number' => '12345678-1', ]; $refund = $genPay->asRefund(); $refund->setReason("Comprou errado.") ->setRequester(Requester::MERCHANT) ->addPayment('fake-payment-id', 50, $bankAccount); $response = $genPay->refundPartial($refund, "fake-charge-uuid"); print_r($response);
Consulta
Juros Comprador
$amount = 1000 $response = $genPay->checkout($amount); print_r($response);
Verificar Credenciais
$response = $genPay->authorizationValidate(); print_r($response);
GenLog
Consultar Endereço
$response = $genLog->autocomplete("01415001"); // Parametro Opcional - Autocomplete Online $response = $genLog->autocomplete("01415001", true); print_r($response);
Criar Cálculo
$code = "Product-Code"; $name = "TENIS NIKE"; $quantity = 1; $cost = 50; $width = 1; $weight = 1; $lenght = 1; $height = 1; $calculation = $genLog->calculation(); $calculation->setDestinationZipcode("05001100") ->calculation->setPostageServiceCodes(array()); ->calculation->addProducts( $code, $name, $quantity, $cost, $width, $weight, $lenght, $height ); $response = $genLog->createCalculation($calculation); print_r($response);
Criar Lote
$firstName = "Maria"; $lastName = "Da Silva"; $document = "12345678909"; $valueBaseICMS = 1.0; $valueICMS = 0.50; $valueBaseICMSST = 1.0; $valueICMSST = 1; $batch = $genLog->batch(); $batch->setCalculationCode("fake-calculation-code") ->setPostageServiceCode("fake-postage-service-code") ->setOrder("1666000041", "1666000041", 200.83) ->setCustomer($firstName, $lastName, $document) ->setInvoice( "series", "number", "key", "cfop", "2019-01-01", $valueBaseICMS, $valueICMS, $valueBaseICMSST, $valueICMSST ) ->setDeliveryAddress( $firstName, $lastName, "Av. Francisco Matarazzo", "1500", "Torre New York 6 Andar", "Água Branca", "São Paulo", "SP", "05001100", "maria@teste.com.br", "1144556677", "1155667788" ); $response = $genLog->generateBatch($batch); print_r($response);
Detalhes do Pedido
$response = $genLog->orderDetail("order-id"); print_r($response);
Suporte
Dúvidas ou deseja implementar o serviço GenComm acesse GenPay
gencomm/genpay-sdk-php 适用场景与选型建议
gencomm/genpay-sdk-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 14 次下载、GitHub Stars 达 2, 最近一次更新时间为 2019 年 11 月 06 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「checkout」 「libraries」 「marketplace」 「intermediary」 「gencomm」 「genpay」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 gencomm/genpay-sdk-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 gencomm/genpay-sdk-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 gencomm/genpay-sdk-php 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Custom libraries for CakePHP framework
O2System PSR it's build based on PHP Framework Interop Group (PHP-FIG) standards recommendations. This repository contains a collection of PHP interfaces based on the PSR-0 until the PSR-7.
Meta-package of Tatter modules for CodeIgniter 4
Automatically translate and review your content via Lokalise.
Adds a 'checkout' to a SilverStripe site which links to an Estimate and adds the ability to setup and pay
PHP Cache Handler Library
统计信息
- 总下载量: 14
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 2
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-11-06
