randler / ipag-php
IPag PHP Library
Installs: 947
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
Type:lib
Requires
- php: >=5.6.0
- guzzlehttp/guzzle: ^6.4
Requires (Dev)
- phpunit/phpunit: ^8
- squizlabs/php_codesniffer: ^3.3
README
Gateway IPag PHP
Biblioteca desenvolvida para facilitar a comunicação com o gateway de pagamento IPag.
Introdução
Essa SDK foi construída com o intuito de tornar flexível as chamadas dos metodos de pagamento, de forma que todos possam utilizar todas as features, de todas as versões de API.
Você pode acessar a documentação oficial da API acessando esse link.
Índice
Instalação
Instale a biblioteca utilizando o comando
composer require randler/ipag-php
Requisição de Tokenização
Nesta seção será explicado como realizar requisições para cartão pelo IPag com essa biblioteca.
Token de Cartão
<?php $appId = "***"; $appKey = "D5***DA"; $sandbox = true; $client = new Client($appId, $appKey, $sandbox); $cardInfo = new CustomerCard(); $cardInfo->setCardholderName("JOSE SILVA") ->setCardNumber("4111111111111111") ->setExpirationMonth("01") ->setExpirationYear("2029") ->setCvv("123") ->setCpfCnpj("80630047014") ->setMobilePhone("11999999999") ->setBirthdate("1989-03-28") ->setStreet("Rua dos Bobos") ->setNumber("0") ->setDistrict("Centro") ->setZipcode("12345678") ->setCity("São Paulo") ->setState("SP"); $data_card = $cardInfo->getCardData(); //fwrite(STDERR, print_r($data_card)); $response = $client->card()->create($data_card); ?>
Requisição de transação
Para fazer a requisição de transação.
Criar Transação
$appId = "***"; $appKey = "D5***DA"; $sandbox = true; $client = new Client($this->appId, $this->appKey, $this->sandbox); $payment = new PaymentData(); $payment->setAmount(10.35) ->setType("card") // card, boleto, pix ->setInstallments(1) ->setCapture(true) ->setCard_token("aea788f4-34cd-4f3d-8003-9c361fc4da99") ->setName("JOSE SILVA") ->setCpf_cnpj("80630047014"); $payment = $client ->payment() ->create($payment->getPaymentCardTokenData());
Detalhe de uma transação
$appId = "***"; $appKey = "D5***DA"; $sandbox = true; $id = "020001409102281247420000012620420000000000"; $client = new Client($this->appId, $this->appKey, $this->sandbox); $detail = $client ->payment() ->details($id);
Cancelar uma transação
$appId = "***"; $appKey = "D5***DA"; $sandbox = true; $id = "020001409102281247420000012620420000000000"; $client = new Client($this->appId, $this->appKey, $this->sandbox); $detail = $client ->payment() ->cancel($id);
Capturar uma transação
$appId = "***"; $appKey = "D5***DA"; $sandbox = true; $id = "020001409102281247420000012620420000000000"; $client = new Client($this->appId, $this->appKey, $this->sandbox); $detail = $client ->payment() ->capture($id);
Requisição de Seller
Para fazer a requisição de transação.
Store Seller
$appId = "***"; $appKey = "D5***DA"; $sandbox = true; $client = new Client($this->appId, $this->appKey, $this->sandbox); $address = new Address(); $address->setStreet('Rua') ->setNumber('1A') ->setDistrict('Bairro') ->setComplement('Apto') ->setCity('Belo Horizonte') ->setState('BH') ->setZipcode('30190-050'); $owner = new Owner(); $owner->setName('João') ->setEmail('Joao@mail.com') ->setPhone('(77) 98845-5689') ->setCPF('012.345.678-90') ->setBirthdate('01/01/2001'); $bank = new Bank(); $bank->setCode('290') ->setAgency('0001') ->setAccount('100500') ->setType('checkings') ->setExternalId('joao@mail.com'); $address = $address->getAddressData(); $owner = $owner->getOwnerData(); $bank = $bank->getBankData(); $dataSeller = new SellerData(); $dataSeller->setLogin('username') ->setPassword('senha') ->setName('joao') ->setCpfCnpj('012.345.678-90') ->setEmail('joao@mail.com') ->setPhone('(77) 98845-5689') ->setDescription("description seller") ->addAddress($address) ->addOwner($owner) ->addBank($bank); $dataSeller = $dataSeller->getSellersStoreData(); $seller = $client ->seller() ->create($dataSeller);
Update Seller
$appId = "***"; $appKey = "D5***DA"; $sandbox = true; $client = new Client($this->appId, $this->appKey, $this->sandbox); $address = new Address(); $address->setStreet('Rua') ->setNumber('1A') ->setDistrict('Bairro') ->setComplement('Apto') ->setCity('Belo Horizonte') ->setState('BH') ->setZipcode('30190-050'); $owner = new Owner(); $owner->setName('João') ->setEmail('Joao@mail.com') ->setPhone('(77) 98845-5689') ->setCPF('012.345.678-90') ->setBirthdate('01/01/2001'); $bank = new Bank(); $bank->setCode('290') ->setAgency('0001') ->setAccount('100500') ->setType('checkings') ->setExternalId('joao@mail.com'); $address = $address->getAddressData(); $owner = $owner->getOwnerData(); $bank = $bank->getBankData(); $dataSeller = new SellerData(); $dataSeller->setId('123456789') ->setLogin('username') ->setPassword('senha') ->setName('joao') ->setCpfCnpj('012.345.678-90') ->setEmail('joao@mail.com') ->setPhone('(77) 98845-5689') ->setDescription("description seller") ->addAddress($address) ->addOwner($owner) ->addBank($bank); $dataSeller = $dataSeller->getSellersUpdateData(); $seller = $client ->seller() ->update($dataSeller);
List Sellers
$appId = "***"; $appKey = "D5***DA"; $sandbox = true; $client = new Client($this->appId, $this->appKey, $this->sandbox); $seller = $client ->seller() ->list();
Query Sellers
$appId = "***"; $appKey = "D5***DA"; $sandbox = true; $client = new Client($this->appId, $this->appKey, $this->sandbox); $payload = array( 'id' => '123456789' 'cpf_cnpj' => '23589642596' 'email' => 'joao@mail.com' ); $seller = $client ->seller() ->query($payload);