randler / ipag-php
IPag PHP 库
2.2.1
2023-08-22 17:27 UTC
Requires
- php: >=5.6.0
- guzzlehttp/guzzle: ^6.4
Requires (Dev)
- phpunit/phpunit: ^8
- squizlabs/php_codesniffer: ^3.3
README
网关 IPag PHP
该库是为了方便与 IPag 支付网关进行通信而开发的。
简介
该 SDK 的目的是使支付方法调用更加灵活,以便所有人都能使用所有 API 版本的所有功能。
您可以通过访问此链接来查看 API 的官方文档。
目录
安装
使用以下命令安装库
composer require randler/ipag-php
请求令牌化
在本节中,将解释如何使用此库通过 IPag 进行卡请求。
卡令牌
<?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); ?>
交易请求
进行交易请求。
创建交易
$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());
交易详情
$appId = "***"; $appKey = "D5***DA"; $sandbox = true; $id = "020001409102281247420000012620420000000000"; $client = new Client($this->appId, $this->appKey, $this->sandbox); $detail = $client ->payment() ->details($id);
取消交易
$appId = "***"; $appKey = "D5***DA"; $sandbox = true; $id = "020001409102281247420000012620420000000000"; $client = new Client($this->appId, $this->appKey, $this->sandbox); $detail = $client ->payment() ->cancel($id);
抓取交易
$appId = "***"; $appKey = "D5***DA"; $sandbox = true; $id = "020001409102281247420000012620420000000000"; $client = new Client($this->appId, $this->appKey, $this->sandbox); $detail = $client ->payment() ->capture($id);
请求销售者
进行交易请求。
存储销售者
$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);
更新销售者
$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);
列出销售者
$appId = "***"; $appKey = "D5***DA"; $sandbox = true; $client = new Client($this->appId, $this->appKey, $this->sandbox); $seller = $client ->seller() ->list();
查询销售者
$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);