descubraomundo / omnipay-pagarme
Pagarme支付处理库的驱动程序
v3.1
2019-09-03 21:04 UTC
Requires
- omnipay/common: ^3.0
Requires (Dev)
- omnipay/tests: ~3.0
- phpro/grumphp: ^0.14
- squizlabs/php_codesniffer: ^3
README
Pagar.Me网关为Omnipay PHP支付处理库
Omnipay 是一个不依赖于框架的多网关支付处理库,适用于PHP 5.3+。此包实现了Omnipay对Pagar.Me的支持。
安装
通过Composer
$ composer require descubraomundo/omnipay-pagarme
基本用法
本包提供以下网关
有关通用用法说明,请参阅主Omnipay 存储库。
使用信用卡示例
// Create a gateway for the Pagarme Gateway // (routes to GatewayFactory::create) $gateway = Omnipay::create('Pagarme'); // Initialise the gateway $gateway->initialize(array( 'apiKey' => 'MyApiKey', )); // Create a credit card object // This card can be used for testing. $card = new CreditCard(array( 'firstName' => 'Example', 'lastName' => 'Customer', //'name' => 'Example Customer', 'birthday' => '1988-02-28', 'gender' => 'M', 'number' => '4242424242424242', 'expiryMonth' => '01', 'expiryYear' => '2020', 'cvv' => '123', 'email' => 'customer@example.com', 'address1' => 'Street name, Street number, Complementary', 'address2' => 'Neighborhood', 'postcode' => '05443100', 'phone' => '19 3242 8855', 'holder_document_number' => '246.375.149-23', // CPF or CNPJ )); // Do an authorize transaction on the gateway $transaction = $gateway->authorize(array( 'amount' => '10.00', 'soft_descriptor' => 'test', // 13 characters allowed 'payment_method' => 'credit_card', 'installments' => 5, 'postback_url' => 'http://application.com/api/', 'card' => $card, // 'card_hash' => 'card_k5sT...', // 'card_id' => 254786, 'metadata' => array( 'product_id' => 'ID1111', 'invoice_id' => 'IV2222', ), )); $response = $transaction->send(); if ($response->isSuccessful()) { echo "Authorize transaction was successful!\n"; $sale_id = $response->getTransactionReference(); $customer_id = $response->getCustomerReference(); $card_id = $response->getCardReference(); echo "Transaction reference = " . $sale_id . "\n"; }
使用Boleto示例
// Create a gateway for the Pagarme Gateway // (routes to GatewayFactory::create) // Create array with customer data $customer = array( 'firstName' => 'Example', 'lastName' => 'Customer', //'name' => 'Example Customer', 'email' => 'customer@example.com', 'address1' => 'Street name, Street number, Complementary', 'address2' => 'Neighborhood', 'postcode' => '05443100', 'phone' => '19 3242 8855', 'holder_document_number => '246.375.149-23', // CPF or CNPJ )); // Do an authorize transaction on the gateway $transaction = $gateway->authorize(array( 'amount' => '10.00', 'soft_descriptor' => 'test', 'payment_method' => 'boleto', 'postback_url' => 'http://application.com/api/', 'customer' => $customer, 'metadata' => array( 'product_id' => 'ID1111', 'invoice_id' => 'IV2222', ), )); $response = $transaction->send(); if ($response->isSuccessful()) { echo "Authorize Boleto transaction was successful!\n"; $sale_id = $response->getTransactionReference(); $boleto = $response->getBoleto(); echo "Boleto Url = " . $boleto['boleto_url']; echo "Boleto Barcode = " . $boleto['boleto_barcode']; echo "Boleto Expiration Date = " . $boleto['boleto_expiration_date']; echo "Transaction reference = " . $sale_id . "\n"; }
文档
阅读完整的类文档这里
测试模式
Pagar.Me账户具有测试模式的API密钥以及实时模式的API密钥。使用测试模式凭据创建的数据永远不会触达信用卡网络,也不会花费任何人的钱。
与某些网关不同,没有测试模式端点和实时模式端点之分,Pagar.Me API端点对测试和实时都是相同的。
支持
如果您在使用Omnipay时遇到一般性问题,我们建议您在 Stack Overflow 上发布。请务必添加 omnipay标签,以便更容易找到。
如果您想了解发布公告、讨论项目想法或提出更详细的问题,还可以订阅邮件列表。
如果您认为您已发现一个错误,请使用GitHub问题跟踪器报告,或者更好的是,分支库并提交一个拉取请求。
变更日志
有关最近更改的更多信息,请参阅CHANGELOG。
许可证
MIT许可证(MIT)。有关更多信息,请参阅许可证文件。