ipagdevs/ipag-sdk-php

v1.2.1 2024-04-10 20:23 UTC

This package is auto-updated.

Last update: 2024-11-08 20:47:52 UTC


README

A ferramenta certa para efetuar a sua integração de forma rápida e segura com os serviços iPag.

Observação

Este SDK, não necessariamente, reflete todos dos recursos e funcionalidades disponíveis na API do iPag. Veja a documentação completa da API em https://developers.ipag.com.br/.

Status

Minimum PHP Version Versão Build Status Code Intelligence Status Scrutinizer Code Quality Maintainability Test Coverage Licença Docs

Índice

Dependências

require

  • [PHP >= 7.4]
  • [guzzlehttp/guzzle]
  • [kubinyete/assertation]
  • [psr/log]
  • [symfony/polyfill-php81]
  • [symfony/polyfill-php80]

require-dev

  • [phpunit/phpunit]
  • [symfony/var-dumper]
  • [fakerphp/faker]

Instalação

Execute em seu shell:

composer require ipagdevs/ipag-sdk-php

IpagClient

Classe responsável pela integração com a API do iPag. Através dela você consegue acessar todos os endpoints disponíveis na API.

Para mais informações de como funciona a autenticação no Ipag, consulte: Autenticação Ipag

Autenticação

$ipagClient = new \Ipag\Sdk\Core\IpagClient(
    'apiID',
    'apiKey',
    IpagEnvironment::SANDBOX
);

Pagamento (Payment)

Exemplo de Pagamento via Cartão de Crédito (Simples): examples/payment/00-payment-create-card-simple.php

Exemplo de Pagamento via Cartão de Crédito (Completo): examples/payment/01-payment-create-card-complete.php

Exemplo de Pagamento via Cartão de Crédito para Clientes Estrangeiros (Simples): examples/payment/02-payment-create-card-foreign-customer.php

Exemplo de Pagamento via Cartão de Crédito para um Evento: examples/payment/03-payment-create-card-for-event.php

Exemplo de Pagamento via Boleto (Completo): examples/payment/04-payment-create-bankslip.php

Exemplo de Pagamento com Tokenização do Cartão de Crédito: examples/payment/05-payment-create-card-tokenization.php

Exemplo de Pagamento utilizando apenas o Token de Cartão: examples/payment/06-payment-create-card-token.php

Exemplo de Pagamento via Cartão de Crédito com Criação de Assinatura|Cobrança Recorrente: examples/payment/07-payment-create-subscription-recurring-billing-card.php

Exemplo de Pagamento via Cartão de Crédito com Split de Pagamento: examples/payment/08-payment-create-card-with-split.php

Exemplo de Pagamento via Pix (Completo): examples/payment/09-payment-create-pix.php

$paymentTransaction = new \Ipag\Sdk\Model\PaymentTransaction(
    [
        'amount' => 100,
        'callback_url' => 'https://ipag-sdk.requestcatcher.com/callback',
        'order_id' => '12345679',
        'payment' => [
            'type' => Ipag\Sdk\Core\Enums\PaymentTypes::CARD,
            'method' => Ipag\Sdk\Core\Enums\Cards::VISA,
            'installments' => 4,
            'card' => [
                'holder' => 'Bruce Wayne',
                'number' => '4111 1111 1111 1111',
                'expiry_month' => '01',
                'expiry_year' => '2025',
                'cvv' => '123'
            ]
        ],
        'customer' => [
            'name' => 'Bruce Wayne',
            'cpf_cnpj' => '490.558.550-30'
        ]
    ]
);

ou

$paymentTransaction = (new \Ipag\Sdk\Model\PaymentTransaction())
    ->setAmount(100)
    ->setOrderId('123456')
    ->setCallbackUrl('https://ipag-sdk.requestcatcher.com/callback')
    ->setAntifraud(
        (new \Ipag\Sdk\Model\PaymentAntifraud())
            ->setFingerprint('123')
            ->setProvider('anti')
    )
    ->setPayment(
        (new \Ipag\Sdk\Model\Payment())
            ->setType(Ipag\Sdk\Core\Enums\PaymentTypes::CARD)
            ->setMethod(Ipag\Sdk\Core\Enums\Cards::VISA)
            ->setCard(
                (new \Ipag\Sdk\Model\PaymentCard())
                    ->setHolder('Bruce Wayne')
                    ->setNumber('4111 1111 1111 1111')
                    ->setCvv('123')
            )
    )
    ->setCustomer(
        (new \Ipag\Sdk\Model\Customer())
            ->setName('Bruce Wayne')
            ->setCpfCnpj('490.558.550-30')
            ->setBillingAddress(
                (new \Ipag\Sdk\Model\Address())
                    ->setStreet('Avenida Principal')
            )
            ->setShippingAddress(
                (new \Ipag\Sdk\Model\Address())
                    ->setStreet('Avenida Principal')
            )
    )
    ->setProducts([
        (new \Ipag\Sdk\Model\Product())
            ->setName('Smart TV LG 55 4K UHD'),
    ])
    ->addProduct(
        (new \Ipag\Sdk\Model\Product())
            ->setName('LED Android TV 4K UHD LED')
    )
    ->setSubscription(
        (new \Ipag\Sdk\Model\PaymentSubscription())
            ->setFrequency(1)
            ->setTrial(
                (new \Ipag\Sdk\Model\Trial())
                    ->setAmount(100)
            )
    )
    ->setSplitRules([
        (new \Ipag\Sdk\Model\PaymentSplitRules())
            ->setSellerId('vendedor1@mail.me')
            ->setAmount(15),
    ])
    ->addSplitRules(
        (new \Ipag\Sdk\Model\PaymentSplitRules())
            ->setSellerId('vendedor2@mail.me')
            ->setPercentage(20.0)
    );

Criar Pagamento

$responsePayment = $ipagClient->payment()->create($paymentTransaction);

Consultar Pagamento

$responsePayment = $ipagClient->payment()->getById($transactionId);
$responsePayment = $ipagClient->payment()->getByUuid($transactionUuid);
$responsePayment = $ipagClient->payment()->getByUuid($transactionTid);
$responsePayment = $ipagClient->payment()->getByUuid($orderId);

Capturar Pagamento

$responsePayment = $ipagClient->payment()->captureById($transactionId, $amount);

ou

$responsePayment = $ipagClient->payment()->captureByUuid($transactionUuid, $amount);

ou

$responsePayment = $ipagClient->payment()->captureByUuid($transactionTid, $amount);

ou

$responsePayment = $ipagClient->payment()->captureByUuid($orderId, $amount);

Cancelar Pagamento

$responsePayment = $ipagClient->payment()->cancelById($transactionId, $amount);

ou

$responsePayment = $ipagClient->payment()->cancelByUuid($transactionUuid, $amount);

ou

$responsePayment = $ipagClient->payment()->cancelByUuid($transactionTid, $amount);

ou

$responsePayment = $ipagClient->payment()->cancelByUuid($orderId, $amount);

Todos os exemplos: examples/payment/

Cliente (Customer)

$customer = new \Ipag\Sdk\Model\Customer([
    'name' => 'Bruce Wayne',
    'email' => 'brucewayne@email.com',
    'cpf_cnpj' => '490.558.550-30',
    'phone' => '(22) 2222-33333',
    'business_name' => 'Wayne Enterprises',
    'birthdate' => '1987-02-19',
    'address' => [
        'street' => 'Avenida Principal',
        'number' => '12345',
        'district' => 'São Paulo',
        'city' => 'São Paulo',
        'state' => 'SP',
        'zipcode' => '01310-000'
    ]
]);

ou

$customer = new \Ipag\Sdk\Model\Customer()
    ->setName('Bruce Wayne')
    ->setEmail('brucewayne@email.com')
    ->setCpfCnpj('490.558.550-30')
    ->setPhone('(22) 2222-33333')
    ->setBusinessName('Wayne Enterprises')
    ->setAddress(
        new \Ipag\Sdk\Model\Address()
            ->setStreet('Avenida Paulista')
            ->setNumber('12345')
            ->setDistrict('São Paulo')
            ->setCity('São Paulo')
            ->setState('SP')
            ->setZipcode('01310-000')
);

Novo Cliente

$responseCustomer = $ipagClient->customer()->create($customer);

Alterar Cliente

$responseCustomer = $ipagClient->customer()->update($customer, $customerId);

Obter Cliente

$responseCustomer = $ipagClient->customer()->get($customerId);

Listar Clientes

$responseCustomer = $ipagClient->customer()->list([
    'name' => 'wayne'
]);

Deletar Cliente

$responseCustomer = $ipagClient->customer()->delete($customerId);

Todos os exemplos: examples/customer/

Plano de Assinatura (Subscription Plan)

$subscriptionPlan = new \Ipag\Sdk\Model\SubscriptionPlan([
    'name' => 'PLANO GOLD',
    'description' => 'Plano Gold com até 4 treinos por semana',
    'amount' => 100,
    'frequency' => Ipag\Sdk\Core\Enums\Interval::MONTHLY,
    'interval' => 1,
    'cycles' => 0,
    'best_day' => true,
    'pro_rated_charge' => true,
    'grace_period' => 0,
    'callback_url' => 'https://ipag-sdk.requestcatcher.com/callback',
    'installments' => 1,
    'trial' => [
        'amount' => 0,
        'cycles' => 0
    ]
]);

ou

$subscriptionPlan = new \Ipag\Sdk\Model\SubscriptionPlan()
    ->setName("PLANO GOLD")
    ->setDescription("Plano Gold com até 4 treinos por semana")
    ->setAmount(100)
    ->setFrequency(Ipag\Sdk\Core\Enums\Interval::MONTHLY)
    ->setInterval(1)
    ->setCycles(0)
    ->setBestDay(true)
    ->setProRatedCharge(true)
    ->setGracePeriod(0)
    ->setCallbackUrl("https://ipag-sdk.requestcatcher.com/callback")
    ->setInstallments(1)
    ->setTrial(
        new \Ipag\Sdk\Model\Trial()
            ->setAmount(0)
            ->setCycles(0)
);

Novo Plano de Assinatura

$responseSubscriptionPlan = $ipagClient->subscriptionPlan()->create($subscriptionPlan);

Alterar Plano de Assinatura

$responseSubscriptionPlan = $ipagClient->subscriptionPlan()->update($subscriptionPlan, $subscriptionPlanId);

Obter Plano de Assinatura

$responseSubscriptionPlan = $ipagClient->subscriptionPlan()->get($subscriptionPlanId);

Listar Planos de Assinatura

$responseSubscriptionPlan = $ipagClient->subscriptionPlan()->list([
    'name' => 'GOLD',
]);

Deletar Plano de Assinatura

$ipagClient->subscriptionPlan()->delete($subscriptionPlanId);

Todos os exemplos: examples/subscription_plan/

Assinatura (Subscription)

$subscription = new \Ipag\Sdk\Model\Subscription([
    'is_active' => true,
    'profile_id' => 'SUB_01',
    'plan_id' => 1,
    'customer_id' => 100001,
    'starting_date' => '2021-07-11',
    'closing_date' => '2021-08-11',
    'callback_url' => 'https://ipag-sdk.requestcatcher.com/callback',
    'creditcard_token' => '123'
]);

ou

$subscription = new \Ipag\Sdk\Model\Subscription()
    ->setIsActive(true)
    ->setProfileId('SUB_001')
    ->setPlanId(1)
    ->setCustomerId(100001)
    ->setStartingDate('2021-07-11')
    ->setClosingDate('2021-08-11')
    ->setCallbackUrl('https://ipag-sdk.requestcatcher.com/callback')
    ->setCreditcardToken('123');

Nova Assinatura

$responseSubscription = $ipagClient->subscription()->create($subscription);

Alterar Assinatura

$responseSubscription = $ipagClient->subscription()->update($subscription, $subscriptionId);

Obter Assinatura

$responseSubscription = $ipagClient->subscription()->get($subscriptionId);

Listar Assinaturas

$responseSubscription = $ipagClient->subscription()->list([
    'is_active' => true,
]);

Desvincular Token da Assinatura

$responseSubscription = $ipagClient->subscription()->unlinkToken($subscriptionId);

Quitar Parcela da Assinatura

$responseSubscription = $ipagClient->subscription()->payOffInstallment($subscriptionId, $invoiceNumber);

Agendar Parcelamento da Assinatura

$responseSubscription = $ipagClient->subscription()->scheduleInstallmentPayment($subscriptionId, $invoiceNumber);

Todos os exemplos: examples/subscription/

Transação (Transaction)

Obter Transação

$responseTransaction = $ipagClient->transaction()->get($transactionId);

Listar Transações

$responseTransaction = $ipagClient->transaction()->list([
    'order' => 'desc',
    'from_date' => '2023-08-29'
]);

Liberar Recebíveis da Transação

$responseTransaction = $client->transaction()->releaseReceivables($sellerId, $transactionId);

Todos os exemplos: examples/transaction/

Token (Card Token)

$token = new \Ipag\Sdk\Model\Token([
    'card' => [
        'holderName' => 'Bruce Wayne',
        'number' => '4111 1111 1111 1111',
        'expiryMonth' => '01',
        'expiryYear' => '2025',
        'cvv' => '123'
    ],
    'holder' => [
        'name' => 'Bruce Wayne',
        'cpfCnpj' => '490.558.550-30',
        'mobilePhone' => '(22) 2222-33333',
        'birthdate' => '1987-02-19',
        'address' => [
                'street' => 'Avenida Principal',
                'number' => '12345',
                'complement' => 'Sala 02',
                'district' => 'São Paulo',
                'city' => 'São Paulo',
                'state' => 'SP',
                'zipcode' => '01310-000'
            ]
    ]
]);

ou

$token = (new \Ipag\Sdk\Model\Token())
    ->setCard(
        (new \Ipag\Sdk\Model\Card())
            ->setHolderName('Bruce Wayne')
            ->setNumber('4111 1111 1111 1111')
            ->setExpiryMonth('01')
            ->setExpiryYear('2025')
            ->setCvv('123')
    )
    ->setHolder(
        (new \Ipag\Sdk\Model\Holder())
            ->setName('Bruce Wayne')
            ->setCpfCnpj('490.558.550-30')
            ->setMobilePhone('(22) 2222-33333')
            ->setBirthdate('1987-02-19')
            ->setAddress(
                new \Ipag\Sdk\Model\Address()
                    ->setStreet('Avenida Principal')
            )
    );

Novo Token

$responseToken = $ipagClient->token()->create($token);

Obter Token

$responseToken = $ipagClient->token()->get($tokenValue);

Todos os exemplos: examples/token/

Cobrança (Charge)

$charge = new \Ipag\Sdk\Model\Charge([
    'amount' => 100,
    'description' => 'Cobrança referente a negociação de débito pendente na Empresa X',
    'due_date' => '2020-10-30',
    'frequency' => 1,
    'interval' => Ipag\Sdk\Core\Enums\Interval::MONTH,
    'type' => 'charge',
    'last_charge_date' => '2020-10-30',
    'callback_url' => 'https://ipag-sdk.requestcatcher.com/callback',
    'auto_debit' => false,
    'installments' => 12,
    'is_active' => true,
    'products' => [1, 2, 3],
    'customer' => [
        'name' => 'Bruce Wayne',
    ],
    'checkout_settings' => [
        'max_installments' => 12,
    ]
]);

ou

$charge = (new \Ipag\Sdk\Model\Charge())
    ->setAmount(100)
    ->setDescription('Cobrança referente a negociação de débito pendente na Empresa X')
    ->setDueDate('2020-10-30')
    ->setFrequency(1)
    ->setInterval(Ipag\Sdk\Core\Enums\Interval::MONTH)
    ->setType('charge')
    ->setLastChargeDate('2020-10-30')
    ->setCallbackUrl('https://ipag-sdk.requestcatcher.com/callback')
    ->setAutoDebit(false)
    ->setInstallments(12)
    ->setIsActive(true)
    ->setProducts([1, 2, 3])
    ->setCustomer(
        (new \Ipag\Sdk\Model\Customer())
            ->setName('Bruce Wayne')
    )
    ->setCheckoutSettings(
        (new \Ipag\Sdk\Model\CheckoutSettings())
            ->setMaxInstallments(12)
    );

Nova Cobrança

$responseCharge = $ipagClient->charge()->create($charge);

Alterar Cobrança

$responseCharge = $ipagClient->charge()->update($charge, $chargeId);

Obter Cobrança

$responseCharge = $ipagClient->charge()->get($chargeId);

Listar Cobranças

$responseCharge = $ipagClient->charge()->list([
    'is_active' => false,
]);

Todos os exemplos: examples/charge/

Estabelecimento (Establishment)

$establishment = new \Ipag\Sdk\Model\Establishment([
    'name' => 'Bruce Wayne',
    'email' => 'brucewayne@email.com',
    'login' => 'wayne1',
    'password' => 'bat123',
    'document' => '490.558.550-30',
    'phone' => '(22) 2222-33333',
    'address' =>
        [
            'street' => 'Avenida Principal',
        ],
    'owner' => [
        'name' => 'Bruce Wayne',
    ],
    'bank' => [
        'code' => '999'
    ]
]);

ou

$establishment = (new \Ipag\Sdk\Model\Establishment())
    ->setName('Bruce Wayne')
    ->setEmail('brucewayne@email.com')
    ->setLogin('wayne1')
    ->setPassword('bat123')
    ->setPhone('(22) 2222-33333')
    ->setDocument('490.558.550-30')
    ->setAddress(new \Ipag\Sdk\Model\Address())
    ->setOwner(new \Ipag\Sdk\Model\Owner())
    ->setBank(new \Ipag\Sdk\Model\Bank());

Novo Estabelecimento

$responseEstablishment = $ipagClient->establishment()->create($establishment);

Alterar Estabelecimento

$responseEstablishment = $ipagClient->establishment()->update($establishment, $establishmentTid);

Obter Estabelecimento

$responseEstablishment = $ipagClient->establishment()->get($establishmentTid);

Listar Estabelecimentos

$responseEstablishment = $ipagClient->establishment()->list();

Transações (Transactions)

Listar todas Transações dos Estabelecimentos

$responseTransactions = $ipagClient->establishment()->transaction()->list();

Listar Transações dos Estabelecimentos

$responseTransactions = $ipagClient->establishment()->transaction()->listByEstablishment($establishmentTid);

Obter Transação de um Estabelecimento

$responseTransactions = $ipagClient->establishment()->transaction()->getByEstablishment($establishmentTid, $transactionTid);

Métodos de Pagamento (Payment Methods)

$paymentMethod = new \Ipag\Sdk\Model\PaymentMethod([
    'acquirer' => 'stone',
    'priority' => 100,
    'environment' => 'test',
    'capture' => true,
    'retry' => true,
    'credentials' =>
        (
            (new Ipag\Sdk\Support\Credentials\PaymentMethods\StoneCredentials())
                ->setStoneCode('xxxxx')
                ->setStoneSak('xxxxxx')
        )->jsonSerialize(),
]);

Configurar Métodos de Pagamento

$responseConfig = $ipagClient
    ->establishment()
    ->paymentMethods()
    ->config($paymentMethod, $establishmentTid);

Antifraudes (Antifraud)

$antifraud = new \Ipag\Sdk\Model\Antifraud(
    [
        'provider' => (
            new Ipag\Sdk\Support\Provider\Antifraudes\RedShieldProvider([
                'token' => 'xxxxxxxx',
                'entityId' => 'xxxxxxxx',
                'channelId' => 'xxxxxxxx',
                'serviceId' => 'xxxxxxxx'
            ])
        )->jsonSerialize(),
        'settings' => [
            'enable' => true,
            'environment' => 'test',
            'consult_mode' => 'auto',
            'capture_on_approval' => false,
            'cancel_on_refused' => true,
            'review_score_threshold' => 0.8
        ]
    ]
);

Configurar Antifraudes

$responseConfig = $ipagClient
    ->establishment()
    ->antifraud()
    ->config($antifraud, $establishmentTid);

Todos os exemplos: examples/establishment/

Regra de Split (Split Rules)

$splitRules = new \Ipag\Sdk\Model\SplitRules([
    'receiver_id' => '1000000',
    'percentage' => 10.00
]);

ou

$splitRules = (new \Ipag\Sdk\Model\SplitRules())
    ->setReceiverId('1000000')
    ->setPercentage(10);

Nova Regra de Split

$responseSplitRules = $ipagClient->splitRules()->create($splitRules, $transactionId);

Obter Regra de Split

$responseSplitRules = $ipagClient->splitRules()->get($splitRuleId, $transactionId);

Listar Regras de Split

$responseSplitRules = $ipagClient->splitRules()->list($transactionId);

Deletar Regra de Split

$responseSplitRules = $ipagClient->splitRules()->delete($splitRuleId, $transactionId);

Todos os exemplos: examples/split_rules/

Vendedor (Seller)

$seller = new \Ipag\Sdk\Model\Seller([
    'login' => 'jimgordon',
    'password' => 'jim123',
    'name' => 'Jim Gordon',
    'cpf_cnpj' => '168.853.290-02',
    'email' => 'jimgordon@email.com',
    'phone' => '(11) 3333-44444',
    'description' => '',
    'address' => [
        'street' => 'Avenida Principal',
        'number' => '12345',
        'district' => 'São Paulo',
        'city' => 'São Paulo',
        'state' => 'SP',
        'zipcode' => '01310-000'
    ],
    'owner' => [
        'name' => 'Bruce Wayne',
        'email' => 'brucewayne@email.com',
        'cpf' => '490.558.550-30',
        'phone' => '(22) 2222-33333',
        'birthdate' => '1987-02-19',
    ],
    'bank' => [
        'code' => '999',
        'agency' => '1234',
        'account' => '54321',
        'type' => 'checkings',
        'external_id' => '1',
    ]
]);

ou

$seller = (new \Ipag\Sdk\Model\Seller())
    ->setLogin('jimgordon')
    ->setPassword('jim123')
    ->setName('Jim Gordon')
    ->setCpfCnpj('168.853.290-02')
    ->setEmail('jimgordon@email.com')
    ->setPhone('(11) 3333-44444')
    ->setDescription('')
    ->setAddress(
        (new \Ipag\Sdk\Model\Address())
            ->setStreet('Avenida Principal')
    )
    ->setOwner(
        (new \Ipag\Sdk\Model\Owner())
            ->setName('Bruce Wayne')
    )
    ->setBank(
        (new \Ipag\Sdk\Model\Bank())
            ->setCode('999')
    );

Novo Vendedor

$responseSeller = $ipagClient->seller()->create($seller);

Alterar Vendedor

$responseSeller = $ipagClient->seller()->update($seller, $sellerId);

Obter Vendedor

$responseSeller = $ipagClient->seller()->get($sellerId);

Listar Vendedores

$responseSellers = $ipagClient->seller()->list();

Todos os exemplos: examples/seller/

Transferência (Transfer)

Listar Transferências

$responseTransfers = $ipagClient->transfer()->list();

Obter Transferência

$responseTransfers = $ipagClient->transfer()->get($transferId);

Transferência dos Vendedores (Sellers Transfers)

Listar Transferências dos Vendedores

$responseTransfers = $ipagClient->transfer()->seller()->list();

Obter Transferência de Vendedor

$responseTransfers = $ipagClient->transfer()->seller()->get($transferId);

Lançamentos Futuros (Future Transfers)

Listar Lançamentos Futuros

$responseTransfers = $ipagClient->transfer()->future()->list();

Listar Lançamentos Futuros de Vendedor (Por Id)

$responseTransfers = $ipagClient->transfer()->future()->listBySellerId($sellerId);

Listar Lançamentos Futuros de Vendedor (Por CPF/CNPJ)

$responseTransfers = $ipagClient->transfer()->future()->listBySellerCpfCnpj($sellerCpf);

Todos os exemplos: examples/transfer/

Link de Pagamento (Payment Links)

$paymentLink = new \Ipag\Sdk\Model\PaymentLink([
    'externalCode' => '131',
    'amount' => 0,
    'description' => 'LINK DE PAGAMENTO SUPER BACANA',
    'expireAt' => '2020-12-30 23:00:00',
    'buttons' => [
        'enable' => false,
    ],
    'checkout_settings' => [
        'max_installments' => 12,
    ],
]);

ou

$paymentLink = (new \Ipag\Sdk\Model\PaymentLink())
    ->setExternalCode('131')
    ->setAmount(0)
    ->setDescription('LINK DE PAGAMENTO SUPER BACANA')
    ->setExpireAt('2020-12-30 23:00:00')
    ->setButtons(
        (new \Ipag\Sdk\Model\Buttons())
            ->setEnable(false)
    )
    ->setCheckoutSettings(
        (new \Ipag\Sdk\Model\CheckoutSettings())
            ->setMaxInstallments(12)
    );

Novo Link de Pagamento

$responsePaymentLink = $ipagClient->paymentLinks()->create($paymentLink);

Obter Link de Pagamento (Por Id)

$responsePaymentLink = $ipagClient->paymentLinks()->getById($paymentLinkId);

Obter Link de Pagamento (Por External Code)

$responsePaymentLink = $ipagClient->paymentLinks()->getByExternalCode($externalCode);

Todos os exemplos: examples/payment_links/

Webhook

$webhook = new \Ipag\Sdk\Model\Webhook([
    'http_method' => 'POST',
    'url' => 'https://ipag-sdk.requestcatcher.com/webhook',
    'description' => 'Webhook para receber notificações de atualização das transações',
    'actions' => [
        \Ipag\Sdk\Core\Enums\Webhooks::PAYMENT_LINK_PAYMENT_SUCCEEDED,
        \Ipag\Sdk\Core\Enums\Webhooks::PAYMENT_LINK_PAYMENT_FAILED,
    ]
]);

ou

$webhook = (new \Ipag\Sdk\Model\Webhook())
    ->setHttpMethod('POST')
    ->setUrl('https://ipag-sdk.requestcatcher.com/webhook')
    ->setDescription('Webhook para receber notificações de atualização das transações')
    ->setActions([
        \Ipag\Sdk\Core\Enums\Webhooks::PAYMENT_LINK_PAYMENT_SUCCEEDED,
        \Ipag\Sdk\Core\Enums\Webhooks::PAYMENT_LINK_PAYMENT_FAILED,
    ]);

Novo Webhook

$responseWebhook = $ipagClient->webhook()->create($webhook);

Obter Webhook

$responseWebhook = $ipagClient->webhook()->get($webhookId);

Listar Webhooks

$responseWebhook = $ipagClient->webhook()->list();

Deletar Webhook

$ok = $ipagClient->webhook()->delete($webhookId);

Todos os exemplos: examples/webhook/

Checkout

$checkout = new \Ipag\Sdk\Model\Checkout([
    'customer' => [
        'name' => 'Bruce Wayne',
        'tax_receipt' => '490.558.550-30',
        'email' => 'brucewayne@email.com',
        'phone' => '(22) 2222-33333',
        'birthdate' => '1987-02-19',
        'address' => [
            'street' => 'Avenida Principal',
            'number' => '12345',
            'district' => 'São Paulo',
            'city' => 'São Paulo',
            'state' => 'SP',
            'zipcode' => '01310-000'
        ]
    ],
    'installment_setting' => [
        'max_installments' => 12,
        'min_installment_value' => 5,
        'interest' => 0,
        'interest_free_installments' => 12
    ],
    'order' => [
        'order_id' => '100001',
        'amount' => '15.00',
        'return_url' => 'https://ipag-sdk.requestcatcher.com/callback',
        'return_type' => 'json'
    ],
    'products' => [
        [
            'name' => 'Smart TV LG 55 4K UHD',
            'unit_price' => 5000,
            'quantity' => 1,
            'sku' => 'LG123',
            'description' => 'Experiência cristalina em 4K.'
        ],
        [
            'name' => 'LED Android TV 4K UHD LED',
            'unit_price' => 5000,
            'quantity' => 1,
            'sku' => 'SAM123',
            'description' => 'Android TV de 126 cm (50).'
        ],
    ],
    'split_rules' => [
        [
            'receiver' => 'qwertyuiopasdfghjklzxcvbnm123456',
            'percentage' => '50',
            'charge_processing_fee' => true,
        ],
        [
            'receiver' => '654321mnbvcxzlkjhgfdsapoiuytrewq',
            'percentage' => '20'
        ]
    ],
    'sellerId' => '100014',
    'expires_in' => 60,
]);

ou

$checkout = (new \Ipag\Sdk\Model\Checkout())
    ->setCustomer(
        (new \Ipag\Sdk\Model\Customer())
            ->setName('Bruce Wayne')
    )
    ->setInstallmentSetting(
        (new \Ipag\Sdk\Model\InstallmentSetting())
            ->setMaxInstallments(12)
    )
    ->setOrder(
        (new \Ipag\Sdk\Model\Order())
            ->setOrderId('1000001')
    )
    ->addProduct(
        (new \Ipag\Sdk\Model\Product())
            ->setName('Smart TV LG 55 4K UHD')
    )
    ->addProduct(
        (new \Ipag\Sdk\Model\Product())
            ->setName('Smart TV 50" UHD 4K')
    )
    ->addSplitRule(
        (new \Ipag\Sdk\Model\SplitRules())
            ->setReceiverId('1000000')
    )
    ->addSplitRule(
        (new \Ipag\Sdk\Model\SplitRules())
            ->setReceiverId('1000001')
    )
    ->setSellerId('100014')
    ->setExpiresIn(60);

Novo Checkout

$responseCheckout = $ipagClient->checkout()->create($checkout);

Todos os exemplos: examples/checkout/

Voucher

$voucher = new \Ipag\Sdk\Model\Voucher([
    'order' => [
        'order_id' => '100015',
        'amount' => 100,
        'created_at' => '2020-08-04 21:45:10',
        'callback_url' => 'https://ipag-sdk.requestcatcher.com/callback'
    ],
    'seller' => [
        'cpf_cnpj' => '168.853.290-02',
    ],
    'customer' => [
        'name' => 'Jim Gordon',
        'cpf_cnpj' => '168.853.290-02',
        'email' => 'jimgordon@email.com',
        'phone' => '(11) 3333-44444',
        'birthdate' => '1990-10-10',
        'address' => [
            'street' => 'Avenida Principal',
            'number' => '12345',
            'district' => 'São Paulo',
            'city' => 'São Paulo',
            'state' => 'SP',
            'zipcode' => '01310-000'
        ]
    ]
]);

ou

$voucher = (new \Ipag\Sdk\Model\Voucher())
    ->setOrder(
        (new \Ipag\Sdk\Model\Order())
            ->setOrderId(
                '1000001'
            )
    )
    ->setSeller(
        (new \Ipag\Sdk\Model\Seller())
            ->setCpfCnpj(
                '168.853.290-02'
            )
    )
    ->setCustomer(
        (new \Ipag\Sdk\Model\Customer())
            ->setName(
                'Jim Gordon'
            )
            ->setAddress(
                (new \Ipag\Sdk\Model\Address())
                    ->setStreet('Avenida Principal')
            )
    );

Novo Voucher

$responseVoucher = $ipagClient->voucher()->create($voucher);

Todos os exemplos: examples/voucher/

Helpers

Credenciais dos Provedores de Antifraudes

Clear Sale

$clearSaleCredentials = (new \Ipag\Sdk\Support\Credentials\Antifraudes\ClearSaleCredentials())
    ->setName('XXXXX')
    ->setPassword('XXXXXXXX');

Konduto

$kondutoCredentials = (new \Ipag\Sdk\Support\Credentials\Antifraudes\KondutoCredentials())
    ->setApiKey('XXXXX')
    ->setPublicKey('XXXXXXXX');

Red Shield

$redShieldCredentials = (new \Ipag\Sdk\Support\Credentials\Antifraudes\RedShieldCredentials())
    ->setToken('XXXXX')
    ->setEntityId('XXX')
    ->setChannelId('XXXXX')
    ->setServiceId('XX');

Credenciais dos Provedores de Meios de Pagamentos

Adiq

$adiqCredentials = (new \Ipag\Sdk\Support\Credentials\PaymentMethods\AdiqCredentials())
    ->setClientId('XXXXX')
    ->setClientSecret('XXXXXXXX');

Bin

$binCredentials = (new \Ipag\Sdk\Support\Credentials\PaymentMethods\BinCredentials())
    ->setStoreIdSubscription('XXXXX')
    ->setStoreId('XXXXXXXX');

Cielo

$cieloCredentials = (new \Ipag\Sdk\Support\Credentials\PaymentMethods\CieloCredentials())
    ->setMerchantId('XXXXX')
    ->setMerchantKey('XXXXXXXX');

Getnet

$getnetCredentials = (new \Ipag\Sdk\Support\Credentials\PaymentMethods\GetnetCredentials())
    ->setEstablishmentNumber('XXX')
    ->setKey('XXXXXXXX')
    ->setUser('XXX')
    ->setPassword('XXXXX');

Global Payments

$globalPaymentsCredentials = (new \Ipag\Sdk\Support\Credentials\PaymentMethods\GlobalPaymentsCredentials())
    ->setTerminal('XXXXX')
    ->setMerchantId('XXX')
    ->setMerchantKey('XXXXXXXX');

Rede

$redeCredentials = (new \Ipag\Sdk\Support\Credentials\PaymentMethods\RedeCredentials())
    ->setEredeKey('XXXXXXXX')
    ->setPv('XXXXX');

Sipag

$sipagCredentials = (new \Ipag\Sdk\Support\Credentials\PaymentMethods\SipagCredentials())
    ->setStoreIdSubscription('XXXXXXXX')
    ->setStoreId('XXXXX');

Stone

$stoneCredentials = (new \Ipag\Sdk\Support\Credentials\PaymentMethods\StoneCredentials())
    ->setStoneCode('XXXXX')
    ->setStoneSak('XXXXXXXX');

Zoop

$zoopCredentials = (new \Ipag\Sdk\Support\Credentials\PaymentMethods\ZoopCredentials())
    ->setMarketplaceId('XXX')
    ->setPublishableKey('XXXXXXXX')
    ->setSellerId('XXXXX');

Testes

É necessário a instalação do PHPUnit para a realização dos testes.

Licença

The MIT License

Documentação

Documentação Oficial

Dúvidas & Sugestões

Em caso de dúvida ou sugestão para o SDK abra uma nova Issue.