guimap/gprcielo

此包的最新版本(0.9.4)没有可用的许可证信息。

Cielo WebService 1.5 集成

0.9.4 2016-09-19 18:31 UTC

This package is not auto-updated.

Last update: 2024-09-14 19:20:12 UTC


README

GPRZF2 是一个 zend 2 模块,用于与 cielo 网关集成

创建 CIELOAPI 对象

创建 cieloService 实例的简短代码

//Defining estabelecimento credentials
$estabelecimento = new \GPRCielo\Entity\Estabelecimento();
$estabelecimento->setEstabelecimento('1006993069')
      ->setKey('25fbb99741c739dd84d7b06ec78c9bac718838630f30b112d033ce2e621b34f3');

//Create a portador object
$validadeCartao = new \DateTime('2018-05-01');
$portador = new \GPRCielo\Entity\Portador();
$portador->setCodigoSeguranca('123')
        ->setNome('GPR Test')
        ->setNumeroCartao('4012001037141112')
        ->setIndicador(\GPRCielo\Entity\Helpers\Indicador::INFORMADO)
        ->setValidadeCartao($validadeCartao)
        ->setNomeImpresso('GPR Cielo');

//Creating a Pedido (Order) 
$pedido = new \GPRCielo\Entity\Pedido();
$pedido->setDescricao('Only demo Test')
    ->setIdPedido(uniqid('test'))
    ->setDate(new \DateTime('now'))
    ->setValor(1.00);


//Set a FormaPagamento 
$forma = new \GPRCielo\Entity\FormaPagamento();
$forma->setBandeira(\GPRCielo\Entity\Helpers\Bandeira::VISA)
    ->setParcelas(2)
    ->setProduto(\GPRCielo\Entity\Helpers\Produto::PARCELADO);

//We need define a address, even if this address is empty
$endereco = new \GPRCielo\Entity\Endereco($portador);

/*Then we create the cieloAPI object
 *here we're using the development URL, 
 *but we can use the Production URL using the \GPRCielo\Entity\Helpers\URLCielo::PRODUCTION
 */  
$cieloAPI = new \GPRCielo\Services\CieloAPI(
    $estabelecimento,
    $portador,
    $pedido,
    $forma,
    $endereco,
    \GPRCielo\Entity\Helpers\URLCielo::DEVELOPMENT
);

交易

```
$result = $cieloAPI->transacao();
```

为了生成卡片的 token,在第一个参数中传递 true

$result = $cieloAPI->transacao(true)

为了生成卡片的 token 并收取这笔交易

$result = $cieloAPI->transacao(true,true);

此方法返回一个包含 TID、PAN、交易状态和 token(如果请求)的数组

查询

$cieloAPI->consulta($tid);

收费

为了收费,需要将一个 GRPCielo\Entity\Pedido 对象传递给 cobrar 方法,可以收取交易的全部或部分金额

$cieloAPI->cobrar($pedido,'10069930690007E69B6A');

取消

为了取消,需要将一个 GRPCielo\Entity\Pedido 对象传递给 cancelar 方法,可以取消交易的部分金额。

$cieloAPI->cancelar('10069930690007E6937A',$pedido)