developercielo/webservice-1.5-php
Composer 安装命令:
composer require developercielo/webservice-1.5-php
包简介
SDK PHP para integração com webservice 1.5 da Cielo
README 文档
README
Integração em PHP com o Webservice Cielo 1.5
Dependências
- PHP >= 5.4
- libxml
Instalação
Se já possui um arquivo composer.json, basta adicionar a seguinte dependência ao seu projeto:
"require": { "developercielo/webservice-1.5-php":"dev-master" }
Com a dependência adicionada ao composer.json, basta executar:
composer install
Alternativamente, você pode executar diretamente em seu terminal:
composer require "developercielo/webservice-1.5-php:dev-master"
EXEMPLO DE TRANSAÇÃO
<?php require 'vendor/autoload.php'; use Cielo\Cielo; use Cielo\CieloException; use Cielo\Transaction; use Cielo\Holder; use Cielo\PaymentMethod; $mid = '12345678'; //seu merchant id $key = 'xxxx'; //sua chave $cielo = new Cielo($mid, $key, Cielo::TEST); $holder = $cielo->holder('4551870000000183', 2018, 5, Holder::CVV_INFORMED, 123); $order = $cielo->order('178148599', 1000); $paymentMethod = $cielo->paymentMethod(PaymentMethod::VISA, PaymentMethod::CREDITO_A_VISTA); $transaction = $cielo->transaction($holder, $order, $paymentMethod, 'http://localhost/cielo.php', Transaction::AUTHORIZE_WITHOUT_AUTHENTICATION, true); try { $transaction = $cielo->transactionRequest($transaction); if ($transaction->getAuthorization()->getLR() == 0) printf("Transação autorizada com sucesso. TID=%s\n", $transaction->getTid()); } catch (CieloException $e) { printf("Opz[%d]: %s\n", $e->getCode(), $e->getMessage()); }
EXEMPLO DE CONSULTA
<?php require 'vendor/autoload.php'; use Cielo\Cielo; use src\Cielo\CieloException; use src\Cielo\Consultation; $mid = '12345678'; //seu merchant id $key = 'xxxx'; //sua chave $cielo = new Cielo($mid, $key, Cielo::TEST); $consultation = $cielo->consultation('10069930693EF9D81001'); //tid da transação try { $consultationResponse = $cielo->consultationRequest($consultation); if (is_object($consultationResponse)){ printf("TID=%s\n", $consultationResponse->getTid()); printf("STATUS=%s\n", $consultationResponse->getStatus()); printf("PAN=%s\n", $consultationResponse->getPan()); printf("AUTORIZATION CODE=%s\n", $consultationResponse->getAuthorization()->getCode()); printf("AUTORIZATION MESSAGE=%s\n", $consultationResponse->getAuthorization()->getMessage()); printf("AUTORIZATION DATE=%s\n", $consultationResponse ->getAuthorization()->getDateTime()); } } catch (CieloException $e) { printf("Opz[%d]: %s\n", $e->getCode(), $e->getMessage()); }
EXEMPLO DE CAPTURA TOTAL DA TRANSAÇÃO
<?php require 'vendor/autoload.php'; use Cielo\Cielo; use src\Cielo\CieloException; use src\Cielo\Capture; $mid = '12345678'; //seu merchant id $key = 'xxxx'; //sua chave $cielo = new Cielo($mid, $key, Cielo::TEST); $capture = $cielo->Capture('10069930693EF9D81001'); //tid da transação try { $captureResponse = $cielo->captureRequest($capture); if (is_object($captureResponse)){ printf("TID=%s\n", $captureResponse->getTid()); printf("STATUS=%s\n", $captureResponse->getStatus()); printf("PAN=%s\n", $captureResponse->getPan()); printf("STATUS CODE=%s\n", $captureResponse->getCaptureInformation()->getCode()); printf("CAPTURE MESSAGE=%s\n", $captureResponse->getCaptureInformation()->getMessage()); printf("CAPTURE DATE=%s\n", $captureResponse ->getCaptureInformation()->getDateTime()); printf("CAPTURED VALUE=%s\n", $captureResponse ->getCaptureInformation()->getValue()); } } catch (CieloException $e) { printf("Opz[%d]: %s\n", $e->getCode(), $e->getMessage()); }
EXEMPLO DE CANCELAMENTO DA CAPTURA
<?php require 'vendor/autoload.php'; use Cielo\Cielo; use src\Cielo\CieloException; use src\Cielo\Cancellation; $mid = '12345678'; //seu merchant id $key = 'xxxx'; //sua chave $cielo = new Cielo($mid, $key, Cielo::TEST); $cancellation = $cielo->Cancellation('10069930693EF9D81001'); //tid da transação try { $cancellationResponse = $cielo->cancellationRequest($cancellation); if (is_object($cancellationResponse)){ printf("TID=%s\n", $cancellationResponse->getTid()); printf("STATUS=%s\n", $cancellationResponse->getStatus()); printf("PAN=%s\n", $cancellationResponse->getPan()); printf("STATUS CODE=%s\n", $cancellationResponse->getCancellationInformation()->getCode()); printf("CACELLATION MESSAGE=%s\n", $cancellationResponse->getCancellationInformation()->getMessage()); printf("CACELLATION DATE=%s\n", $cancellationResponse ->getCancellationInformation()->getDateTime()); printf("CACELLATION VALUE=%s\n", $cancellationResponse->getCancellationInformation()->getValue()); } } catch (CieloException $e) { printf("Opz[%d]: %s\n", $e->getCode(), $e->getMessage()); }
developercielo/webservice-1.5-php 适用场景与选型建议
developercielo/webservice-1.5-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 30.36k 次下载、GitHub Stars 达 58, 最近一次更新时间为 2015 年 07 月 29 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 developercielo/webservice-1.5-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 developercielo/webservice-1.5-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 30.36k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 58
- 点击次数: 7
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-07-29