PHP code example of randler / ipag-php

1. Go to this page and download the library: Download randler/ipag-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

randler / ipag-php example snippets



  $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('[email protected]')
      ->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('[email protected]');

  $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('[email protected]')
      ->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('[email protected]')
      ->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('[email protected]');

  $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('[email protected]')
      ->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' => '[email protected]'
  );
  $seller = $client
    ->seller()
    ->query($payload);