From 4f601a6ef7969a5824992d370e772fa3faa2718e Mon Sep 17 00:00:00 2001 From: Lucas Rosa Date: Fri, 31 Oct 2025 15:55:24 -0300 Subject: [PATCH 1/3] feat: adiciona params faltantes no PaymentTrnsaction --- .gitignore | 1 + examples/checkout/00-create-checkout.php | 6 +- examples/customer/00-customer-create.php | 3 +- examples/customer/01-customer-update.php | 3 +- .../payment/00-payment-create-card-simple.php | 10 ++-- .../01-payment-create-card-complete.php | 11 ++-- ...2-payment-create-card-foreign-customer.php | 10 ++-- .../03-payment-create-card-for-event.php | 10 ++-- .../payment/04-payment-create-bankslip.php | 10 ++-- .../05-payment-create-card-tokenization.php | 10 ++-- .../payment/06-payment-create-card-token.php | 10 ++-- ...te-subscription-recurring-billing-card.php | 10 ++-- .../08-payment-create-card-with-split.php | 10 ++-- examples/payment/09-payment-create-pix.php | 10 ++-- .../split_rules/00-split-rules-create.php | 4 +- src/Model/Address.php | 29 ++++++++++ src/Model/Customer.php | 42 +++++++++++--- src/Model/Payment.php | 32 +++++++++-- src/Model/PaymentTransaction.php | 56 +++++++++++++++++-- src/Model/SplitRules.php | 54 ++++++++++++------ tests/Model/AddressTest.php | 39 +++++++++++-- tests/Model/CheckoutTest.php | 22 ++++---- tests/Model/CustomerTest.php | 12 +++- tests/Model/PaymentTest.php | 11 +++- tests/Model/PaymentTransactionTest.php | 20 ++++++- tests/Model/SplitRulesTest.php | 54 ++++++++---------- 26 files changed, 355 insertions(+), 134 deletions(-) diff --git a/.gitignore b/.gitignore index 5af0663..8ca8cbd 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ composer.phar .devcontainer .vscode Dockerfile +*docker* annotations.md .phpunit.cache clover.xml \ No newline at end of file diff --git a/examples/checkout/00-create-checkout.php b/examples/checkout/00-create-checkout.php index 7177a4b..e3ce582 100644 --- a/examples/checkout/00-create-checkout.php +++ b/examples/checkout/00-create-checkout.php @@ -49,12 +49,12 @@ ], 'split_rules' => [ [ - 'receiver' => 'vendedor1@email.com', + 'seller_id' => '1000000', 'percentage' => '50', 'charge_processing_fee' => true, ], [ - 'receiver' => 'vendedor2@email.com', + 'seller_id' => '1000001', 'percentage' => '20' ] ], @@ -86,4 +86,4 @@ var_dump($error); echo "" . PHP_EOL; -} \ No newline at end of file +} diff --git a/examples/customer/00-customer-create.php b/examples/customer/00-customer-create.php index 0e82aa5..4475ee7 100644 --- a/examples/customer/00-customer-create.php +++ b/examples/customer/00-customer-create.php @@ -6,6 +6,7 @@ 'name' => 'Bruce Wayne', 'email' => 'brucewayne@email.com', 'cpf_cnpj' => '490.558.550-30', + 'tax_id' => '49055855030', 'phone' => '(22) 2222-33333', 'business_name' => 'Wayne Enterprises', 'birthdate' => '1987-02-19', @@ -43,4 +44,4 @@ var_dump($error); echo "" . PHP_EOL; -} \ No newline at end of file +} diff --git a/examples/customer/01-customer-update.php b/examples/customer/01-customer-update.php index 15f9e98..5e2fb29 100644 --- a/examples/customer/01-customer-update.php +++ b/examples/customer/01-customer-update.php @@ -6,6 +6,7 @@ 'name' => 'Arthur Morgan', 'email' => 'arthurmorgan@email.com', 'cpf_cnpj' => '212.348.796-11', + 'tax_id' => '49055855030', 'phone' => '(11) 2222-3333', 'business_name' => 'Arthur Morgan Ltda.', 'birthdate' => '1987-11-21', @@ -46,4 +47,4 @@ var_dump($error); echo "" . PHP_EOL; -} \ No newline at end of file +} diff --git a/examples/payment/00-payment-create-card-simple.php b/examples/payment/00-payment-create-card-simple.php index 8b5c839..64f8578 100644 --- a/examples/payment/00-payment-create-card-simple.php +++ b/examples/payment/00-payment-create-card-simple.php @@ -6,7 +6,9 @@ [ 'amount' => 100, 'callback_url' => 'https://ipag-sdk.requestcatcher.com/callback', + 'redirect_url' => 'https://ipag-sdk.requestcatcher.com/redirect', 'order_id' => '12345679', + 'merchant_id' => '12345678', 'payment' => [ 'type' => Ipag\Sdk\Core\Enums\PaymentTypes::CARD, 'method' => Ipag\Sdk\Core\Enums\Cards::VISA, @@ -42,7 +44,7 @@ // Faça algo aqui... break; default: - // Faça algo aqui... + // Faça algo aqui... } // Verifica o status retornado do gateway de pagamento @@ -51,7 +53,7 @@ // Faça algo aqui... break; default: - // Faça algo aqui... + // Faça algo aqui... } // Verifica o status retornado da Adquirente de pagamento @@ -60,7 +62,7 @@ // Faça algo aqui... break; default: - // Faça algo aqui... + // Faça algo aqui... } echo "Status do Pagamento retornado: {$statusPayment}" . PHP_EOL; @@ -86,4 +88,4 @@ var_dump($error); echo "" . PHP_EOL; -} \ No newline at end of file +} diff --git a/examples/payment/01-payment-create-card-complete.php b/examples/payment/01-payment-create-card-complete.php index 1337397..cf44c78 100644 --- a/examples/payment/01-payment-create-card-complete.php +++ b/examples/payment/01-payment-create-card-complete.php @@ -6,6 +6,8 @@ [ 'amount' => 10000, 'callback_url' => 'https://ipag-sdk.requestcatcher.com/callback', + 'redirect_url' => 'https://ipag-sdk.requestcatcher.com/redirect', + 'merchant_id' => '12345678', 'payment' => [ 'type' => Ipag\Sdk\Core\Enums\PaymentTypes::CARD, 'method' => Ipag\Sdk\Core\Enums\Cards::VISA, @@ -13,6 +15,7 @@ 'capture' => false, 'softdescriptor' => 'BRUCE ENTER', 'fraud_analysis' => true, + 'recurring' => true, 'card' => [ 'holder' => 'Bruce Wayne', 'number' => '4111 1111 1111 1111', @@ -74,7 +77,7 @@ // Faça algo aqui... break; default: - // Faça algo aqui... + // Faça algo aqui... } // Verifica o status retornado do gateway de pagamento @@ -83,7 +86,7 @@ // Faça algo aqui... break; default: - // Faça algo aqui... + // Faça algo aqui... } // Verifica o status retornado da Adquirente de pagamento @@ -92,7 +95,7 @@ // Faça algo aqui... break; default: - // Faça algo aqui... + // Faça algo aqui... } echo "Status do Pagamento retornado: {$statusPayment}" . PHP_EOL; @@ -118,4 +121,4 @@ var_dump($error); echo "" . PHP_EOL; -} \ No newline at end of file +} diff --git a/examples/payment/02-payment-create-card-foreign-customer.php b/examples/payment/02-payment-create-card-foreign-customer.php index b976c4a..42b4bc8 100644 --- a/examples/payment/02-payment-create-card-foreign-customer.php +++ b/examples/payment/02-payment-create-card-foreign-customer.php @@ -6,6 +6,8 @@ [ 'amount' => 100, 'callback_url' => 'https://ipag-sdk.requestcatcher.com/callback', + 'redirect_url' => 'https://ipag-sdk.requestcatcher.com/redirect', + 'merchant_id' => '12345678', 'order_id' => '1234567', 'payment' => [ 'type' => Ipag\Sdk\Core\Enums\PaymentTypes::CARD, @@ -41,7 +43,7 @@ // Faça algo aqui... break; default: - // Faça algo aqui... + // Faça algo aqui... } // Verifica o status retornado do gateway de pagamento @@ -50,7 +52,7 @@ // Faça algo aqui... break; default: - // Faça algo aqui... + // Faça algo aqui... } // Verifica o status retornado da Adquirente de pagamento @@ -59,7 +61,7 @@ // Faça algo aqui... break; default: - // Faça algo aqui... + // Faça algo aqui... } echo "Status do Pagamento retornado: {$statusPayment}" . PHP_EOL; @@ -85,4 +87,4 @@ var_dump($error); echo "" . PHP_EOL; -} \ No newline at end of file +} diff --git a/examples/payment/03-payment-create-card-for-event.php b/examples/payment/03-payment-create-card-for-event.php index fd6cad0..b23afb4 100644 --- a/examples/payment/03-payment-create-card-for-event.php +++ b/examples/payment/03-payment-create-card-for-event.php @@ -6,6 +6,8 @@ [ 'amount' => 100, 'callback_url' => 'https://ipag-sdk.requestcatcher.com/callback', + 'redirect_url' => 'https://ipag-sdk.requestcatcher.com/redirect', + 'merchant_id' => '12345678', 'order_id' => '123456789', 'payment' => [ 'type' => Ipag\Sdk\Core\Enums\PaymentTypes::CARD, @@ -79,7 +81,7 @@ // Faça algo aqui... break; default: - // Faça algo aqui... + // Faça algo aqui... } // Verifica o status retornado do gateway de pagamento @@ -88,7 +90,7 @@ // Faça algo aqui... break; default: - // Faça algo aqui... + // Faça algo aqui... } // Verifica o status retornado da Adquirente de pagamento @@ -97,7 +99,7 @@ // Faça algo aqui... break; default: - // Faça algo aqui... + // Faça algo aqui... } echo "Status do Pagamento retornado: {$statusPayment}" . PHP_EOL; @@ -123,4 +125,4 @@ var_dump($error); echo "" . PHP_EOL; -} \ No newline at end of file +} diff --git a/examples/payment/04-payment-create-bankslip.php b/examples/payment/04-payment-create-bankslip.php index 609e70e..111e106 100644 --- a/examples/payment/04-payment-create-bankslip.php +++ b/examples/payment/04-payment-create-bankslip.php @@ -6,6 +6,8 @@ [ "amount" => 7000, "callback_url" => "https://ipag-sdk.requestcatcher.com/callback", + 'redirect_url' => 'https://ipag-sdk.requestcatcher.com/redirect', + 'merchant_id' => '12345678', "payment" => [ "type" => Ipag\Sdk\Core\Enums\PaymentTypes::BOLETO, "method" => Ipag\Sdk\Core\Enums\BankSlips::SIMULADO, @@ -79,7 +81,7 @@ // Faça algo aqui... break; default: - // Faça algo aqui... + // Faça algo aqui... } // Verifica o status retornado do gateway de pagamento @@ -88,7 +90,7 @@ // Faça algo aqui... break; default: - // Faça algo aqui... + // Faça algo aqui... } // Verifica o status retornado da Adquirente de pagamento @@ -97,7 +99,7 @@ // Faça algo aqui... break; default: - // Faça algo aqui... + // Faça algo aqui... } echo "Status do Pagamento retornado: {$statusPayment}" . PHP_EOL; @@ -124,4 +126,4 @@ var_dump($error); echo "" . PHP_EOL; -} \ No newline at end of file +} diff --git a/examples/payment/05-payment-create-card-tokenization.php b/examples/payment/05-payment-create-card-tokenization.php index d8a6081..e8a21ea 100644 --- a/examples/payment/05-payment-create-card-tokenization.php +++ b/examples/payment/05-payment-create-card-tokenization.php @@ -6,6 +6,8 @@ [ 'amount' => 100, 'callback_url' => 'https://ipag-sdk.requestcatcher.com/callback', + 'redirect_url' => 'https://ipag-sdk.requestcatcher.com/redirect', + 'merchant_id' => '12345678', 'payment' => [ 'type' => Ipag\Sdk\Core\Enums\PaymentTypes::CARD, 'method' => Ipag\Sdk\Core\Enums\Cards::VISA, @@ -43,7 +45,7 @@ // Faça algo aqui... break; default: - // Faça algo aqui... + // Faça algo aqui... } // Verifica o status retornado do gateway de pagamento @@ -52,7 +54,7 @@ // Faça algo aqui... break; default: - // Faça algo aqui... + // Faça algo aqui... } // Verifica o status retornado da Adquirente de pagamento @@ -61,7 +63,7 @@ // Faça algo aqui... break; default: - // Faça algo aqui... + // Faça algo aqui... } echo "Status do Pagamento retornado: {$statusPayment}" . PHP_EOL; @@ -88,4 +90,4 @@ var_dump($error); echo "" . PHP_EOL; -} \ No newline at end of file +} diff --git a/examples/payment/06-payment-create-card-token.php b/examples/payment/06-payment-create-card-token.php index 206a1f4..55030b6 100644 --- a/examples/payment/06-payment-create-card-token.php +++ b/examples/payment/06-payment-create-card-token.php @@ -6,6 +6,8 @@ [ 'amount' => 100, 'callback_url' => 'https://ipag-sdk.requestcatcher.com/callback', + 'redirect_url' => 'https://ipag-sdk.requestcatcher.com/redirect', + 'merchant_id' => '12345678', 'payment' => [ 'type' => Ipag\Sdk\Core\Enums\PaymentTypes::CARD, 'installments' => 2, @@ -36,7 +38,7 @@ // Faça algo aqui... break; default: - // Faça algo aqui... + // Faça algo aqui... } // Verifica o status retornado do gateway de pagamento @@ -45,7 +47,7 @@ // Faça algo aqui... break; default: - // Faça algo aqui... + // Faça algo aqui... } // Verifica o status retornado da Adquirente de pagamento @@ -54,7 +56,7 @@ // Faça algo aqui... break; default: - // Faça algo aqui... + // Faça algo aqui... } echo "Status do Pagamento retornado: {$statusPayment}" . PHP_EOL; @@ -80,4 +82,4 @@ var_dump($error); echo "" . PHP_EOL; -} \ No newline at end of file +} diff --git a/examples/payment/07-payment-create-subscription-recurring-billing-card.php b/examples/payment/07-payment-create-subscription-recurring-billing-card.php index a172c80..c07035a 100644 --- a/examples/payment/07-payment-create-subscription-recurring-billing-card.php +++ b/examples/payment/07-payment-create-subscription-recurring-billing-card.php @@ -6,6 +6,8 @@ [ 'amount' => 100, 'callback_url' => 'https://ipag-sdk.requestcatcher.com/callback', + 'redirect_url' => 'https://ipag-sdk.requestcatcher.com/redirect', + 'merchant_id' => '12345678', 'payment' => [ 'type' => Ipag\Sdk\Core\Enums\PaymentTypes::CARD, 'method' => Ipag\Sdk\Core\Enums\Cards::VISA, @@ -63,7 +65,7 @@ // Faça algo aqui... break; default: - // Faça algo aqui... + // Faça algo aqui... } // Verifica o status retornado do gateway de pagamento @@ -72,7 +74,7 @@ // Faça algo aqui... break; default: - // Faça algo aqui... + // Faça algo aqui... } // Verifica o status retornado da Adquirente de pagamento @@ -81,7 +83,7 @@ // Faça algo aqui... break; default: - // Faça algo aqui... + // Faça algo aqui... } echo "Status do Pagamento retornado: {$statusPayment}" . PHP_EOL; @@ -109,4 +111,4 @@ var_dump($error); echo "" . PHP_EOL; -} \ No newline at end of file +} diff --git a/examples/payment/08-payment-create-card-with-split.php b/examples/payment/08-payment-create-card-with-split.php index f34a4f4..c7617e7 100644 --- a/examples/payment/08-payment-create-card-with-split.php +++ b/examples/payment/08-payment-create-card-with-split.php @@ -6,6 +6,8 @@ [ 'amount' => 100, 'callback_url' => 'https://ipag-sdk.requestcatcher.com/callback', + 'redirect_url' => 'https://ipag-sdk.requestcatcher.com/redirect', + 'merchant_id' => '12345678', 'payment' => [ 'type' => Ipag\Sdk\Core\Enums\PaymentTypes::CARD, 'method' => Ipag\Sdk\Core\Enums\Cards::VISA, @@ -69,7 +71,7 @@ // Faça algo aqui... break; default: - // Faça algo aqui... + // Faça algo aqui... } // Verifica o status retornado do gateway de pagamento @@ -78,7 +80,7 @@ // Faça algo aqui... break; default: - // Faça algo aqui... + // Faça algo aqui... } // Verifica o status retornado da Adquirente de pagamento @@ -87,7 +89,7 @@ // Faça algo aqui... break; default: - // Faça algo aqui... + // Faça algo aqui... } echo "Status do Pagamento retornado: {$statusPayment}" . PHP_EOL; @@ -113,4 +115,4 @@ var_dump($error); echo "" . PHP_EOL; -} \ No newline at end of file +} diff --git a/examples/payment/09-payment-create-pix.php b/examples/payment/09-payment-create-pix.php index 90fca28..caba56a 100644 --- a/examples/payment/09-payment-create-pix.php +++ b/examples/payment/09-payment-create-pix.php @@ -6,6 +6,8 @@ [ 'amount' => 100, 'callback_url' => 'https://ipag-sdk.requestcatcher.com/callback', + 'redirect_url' => 'https://ipag-sdk.requestcatcher.com/redirect', + 'merchant_id' => '12345678', 'order_id' => '1234567', 'payment' => [ 'type' => Ipag\Sdk\Core\Enums\PaymentTypes::PIX, @@ -74,7 +76,7 @@ // Faça algo aqui... break; default: - // Faça algo aqui... + // Faça algo aqui... } // Verifica o status retornado do gateway de pagamento @@ -83,7 +85,7 @@ // Faça algo aqui... break; default: - // Faça algo aqui... + // Faça algo aqui... } // Verifica o status retornado da Adquirente de pagamento @@ -92,7 +94,7 @@ // Faça algo aqui... break; default: - // Faça algo aqui... + // Faça algo aqui... } echo "Status do Pagamento retornado: {$statusPayment}" . PHP_EOL; @@ -119,4 +121,4 @@ var_dump($error); echo "" . PHP_EOL; -} \ No newline at end of file +} diff --git a/examples/split_rules/00-split-rules-create.php b/examples/split_rules/00-split-rules-create.php index 030d9a7..9a41fe3 100644 --- a/examples/split_rules/00-split-rules-create.php +++ b/examples/split_rules/00-split-rules-create.php @@ -3,7 +3,7 @@ require_once __DIR__ . '/..' . '/config.php'; $splitRules = new \Ipag\Sdk\Model\SplitRules([ - "receiver_id" => "100024", + "seller_id" => "100024", "percentage" => 10.00 ]); @@ -33,4 +33,4 @@ var_dump($error); echo "" . PHP_EOL; -} \ No newline at end of file +} diff --git a/src/Model/Address.php b/src/Model/Address.php index 2ba20da..85c2c94 100644 --- a/src/Model/Address.php +++ b/src/Model/Address.php @@ -25,6 +25,7 @@ final class Address extends Model * + [`'city'`] string (opcional). * + [`'state'`] string (opcional). * + [`'zipcode'`] string (opcional). + * + [`'country'`] string (opcional). */ public function __construct(?array $data = []) { @@ -40,6 +41,7 @@ protected function schema(SchemaBuilder $schema): Schema $schema->string('city')->nullable(); $schema->string('state')->nullable(); $schema->string('zipcode')->nullable(); + $schema->string('country')->nullable(); return $schema->build(); } @@ -234,4 +236,31 @@ public function setZipcode(?string $zipcode): self $this->set('zipcode', $zipcode); return $this; } + + public function country(): Mutator + { + return new Mutator(null, fn ($value, $ctx) => is_null($value) ? null : (strlen($value) !== 2 ? $ctx->raise('inválido') : strval($value))); + } + + /** + * Retorna o valor da propriedade country. + * + * @return string|null + */ + public function getCountry(): ?string + { + return $this->get('country'); + } + + /** + * Seta o valor da propriedade country. + * + * @param string|null $country + * @return self + */ + public function setCountry(?string $country): self + { + $this->set('country', $country); + return $this; + } } diff --git a/src/Model/Customer.php b/src/Model/Customer.php index 6b6cf09..77cb42f 100644 --- a/src/Model/Customer.php +++ b/src/Model/Customer.php @@ -2,10 +2,10 @@ namespace Ipag\Sdk\Model; -use Ipag\Sdk\Model\Schema\Mutator; use Ipag\Sdk\Model\Schema\Schema; -use Ipag\Sdk\Model\Schema\SchemaBuilder; use Kubinyete\Assertation\Assert; +use Ipag\Sdk\Model\Schema\Mutator; +use Ipag\Sdk\Model\Schema\SchemaBuilder; /** * Customer Class @@ -24,6 +24,7 @@ final class Customer extends Model * + [`'is_active'`] bool (opcional). * + [`'email'`] string (opcional). * + [`'phone'`] string (opcional). + * + [`'tax_id'`] string (opcional). * + [`'cpf_cnpj'`] string (opcional). * + [`'business_name'`] string (opcional). * + [`'birthdate'`] string (opcional) {`Formato: Y-m-d`}. @@ -67,6 +68,7 @@ protected function schema(SchemaBuilder $schema): Schema $schema->bool('is_active')->nullable(); $schema->string('email')->nullable(); $schema->string('phone')->nullable(); + $schema->string('tax_id')->nullable(); $schema->string('cpf_cnpj')->nullable(); $schema->string('tax_receipt')->nullable(); $schema->string('business_name')->nullable(); @@ -127,7 +129,7 @@ public function setUuid(?string $uuid): self protected function name(): Mutator { - return new Mutator(null, fn($value) => strval($value)); + return new Mutator(null, fn ($value) => strval($value)); } /** @@ -154,7 +156,7 @@ public function setName(?string $name = null): self protected function is_active(): Mutator { - return new Mutator(null, fn($value) => (bool) $value); + return new Mutator(null, fn ($value) => (bool) $value); ; } @@ -184,7 +186,7 @@ protected function email(): Mutator { return new Mutator( null, - fn($value, $ctx) => + fn ($value, $ctx) => is_null($value) ? $value : Assert::value($value)->email()->get() ?? $ctx->raise('inválido') @@ -217,7 +219,7 @@ protected function phone(): Mutator { return new Mutator( null, - fn($value, $ctx) => + fn ($value, $ctx) => is_null($value) ? $value : Assert::value($value)->asDigits()->lbetween(10, 11)->get() ?? $ctx->raise('inválido') @@ -250,7 +252,7 @@ protected function cpf_cnpj(): Mutator { return new Mutator( null, - fn($value, $ctx) => + fn ($value, $ctx) => is_null($value) ? $value : Assert::value($value)->asCpf(false)->or()->asCnpj(false)->get() ?? $ctx->raise('inválido') @@ -261,7 +263,7 @@ protected function tax_receipt(): Mutator { return new Mutator( null, - fn($value, $ctx) => + fn ($value, $ctx) => is_null($value) ? $value : Assert::value($value)->asCpf(false)->or()->asCnpj(false)->get() ?? $ctx->raise('inválido') @@ -290,6 +292,28 @@ public function setTaxReceipt(?string $taxReceipt = null): self return $this; } + /** + * Retorna o valor da propriedade tax_id. + * + * @return string|null + */ + public function getTaxId(): ?string + { + return $this->get('tax_id'); + } + + /** + * Seta o valor da propriedade tax_id. + * + * @param string|null $taxId + * @return self + */ + public function setTaxId(?string $taxId = null): self + { + $this->set('tax_id', $taxId); + return $this; + } + /** * Retorna o valor da propriedade cpf_cnpj. * @@ -463,4 +487,4 @@ public function setShippingAddress(?Address $address = null): self return $this; } -} \ No newline at end of file +} diff --git a/src/Model/Payment.php b/src/Model/Payment.php index a08a16e..f8465a1 100644 --- a/src/Model/Payment.php +++ b/src/Model/Payment.php @@ -2,10 +2,10 @@ namespace Ipag\Sdk\Model; -use Ipag\Sdk\Model\Schema\Mutator; use Ipag\Sdk\Model\Schema\Schema; -use Ipag\Sdk\Model\Schema\SchemaBuilder; use Kubinyete\Assertation\Assert; +use Ipag\Sdk\Model\Schema\Mutator; +use Ipag\Sdk\Model\Schema\SchemaBuilder; /** * Payment Class @@ -26,6 +26,7 @@ final class Payment extends Model * + [`'fraud_analysis'`] bool. * + [`'softdescriptor'`] string. * + [`'pix_expires_in'`] int. + * + [`'recurring'`] bool. * * + [`'card'`] array (opcional) dos dados do Payment Card. * +   [`'holder'`] string. @@ -54,6 +55,7 @@ public function schema(SchemaBuilder $schema): Schema $schema->bool('fraud_analysis')->nullable(); $schema->string('softdescriptor')->nullable(); $schema->int('pix_expires_in')->nullable(); + $schema->bool('recurring')->nullable(); $schema->has('card', PaymentCard::class)->nullable(); $schema->has('boleto', Boleto::class)->nullable(); @@ -65,7 +67,7 @@ protected function installments(): Mutator { return new Mutator( null, - fn($value, $ctx) => + fn ($value, $ctx) => is_null($value) ? $value : ( Assert::value(intval($value))->gt(0)->get() @@ -228,6 +230,28 @@ public function setPixExpiresIn(?int $pixExpiresIn = null): self return $this; } + /** + * Retorna o valor da propriedade `recurring`. + * + * @return bool|null + */ + public function getRecurring(): ?bool + { + return $this->get('recurring'); + } + + /** + * Seta o valor da propriedade `recurring`. + * + * @param bool|null $recurring + * @return self + */ + public function setRecurring(?bool $recurring = null): self + { + $this->set('recurring', $recurring); + return $this; + } + /** * Retorna o objeto `Card` vinculado ao `Payment`. * @@ -272,4 +296,4 @@ public function setBoleto(?Boleto $boleto = null): self return $this; } -} \ No newline at end of file +} diff --git a/src/Model/PaymentTransaction.php b/src/Model/PaymentTransaction.php index f3843c0..680b608 100644 --- a/src/Model/PaymentTransaction.php +++ b/src/Model/PaymentTransaction.php @@ -2,10 +2,10 @@ namespace Ipag\Sdk\Model; -use Ipag\Sdk\Model\Schema\Mutator; use Ipag\Sdk\Model\Schema\Schema; -use Ipag\Sdk\Model\Schema\SchemaBuilder; use Kubinyete\Assertation\Assert; +use Ipag\Sdk\Model\Schema\Mutator; +use Ipag\Sdk\Model\Schema\SchemaBuilder; /** * PaymentTransaction Class @@ -21,7 +21,9 @@ final class PaymentTransaction extends Model * * + [`'amount'`] float. * + [`'order_id'`] string. + * + [`'merchant_id'`] string. * + [`'callback_url'`] string. + * + [`'redirect_url'`] string. * * + [`'antifraud'`] array (opcional) dos dados do Antifraud. * +   [`'fingerprint'`] string. @@ -113,7 +115,9 @@ public function schema(SchemaBuilder $schema): Schema { $schema->float('amount')->nullable(); $schema->string('order_id')->nullable(); + $schema->string('merchant_id')->nullable(); $schema->string('callback_url')->nullable(); + $schema->string('redirect_url')->nullable(); $schema->has('antifraud', PaymentAntifraud::class)->nullable(); $schema->has('payment', Payment::class)->nullable(); @@ -130,7 +134,7 @@ protected function amount(): Mutator { return new Mutator( null, - fn($value, $ctx) => + fn ($value, $ctx) => is_null($value) ? $value : ( Assert::value(floatval($value))->gte(0)->get() @@ -183,6 +187,28 @@ public function setOrderId(?string $orderId = null): self return $this; } + /** + * Retorna o valor da propriedade `merchant_id`. + * + * @return string|null + */ + public function getMerchantId(): ?string + { + return $this->get('merchant_id'); + } + + /** + * Seta o valor da propriedade `merchant_id`. + * + * @param string|null $merchantId + * @return self + */ + public function setMerchantId(?string $merchantId = null): self + { + $this->set('merchant_id', $merchantId); + return $this; + } + /** * Retorna o valor da propriedade `callback_url`. * @@ -205,6 +231,28 @@ public function setCallbackUrl(?string $callbackUrl = null): self return $this; } + /** + * Retorna o valor da propriedade `redirect_url`. + * + * @return string|null + */ + public function getRedirectUrl(): ?string + { + return $this->get('redirect_url'); + } + + /** + * Seta o valor da propriedade `redirect_url`. + * + * @param string|null $redirectUrl + * @return self + */ + public function setRedirectUrl(?string $redirectUrl = null): self + { + $this->set('redirect_url', $redirectUrl); + return $this; + } + /** * Retorna o valor da propriedade `PaymentAntifraud`. * @@ -397,4 +445,4 @@ public function setEvent(?Event $event = null): self return $this; } -} \ No newline at end of file +} diff --git a/src/Model/SplitRules.php b/src/Model/SplitRules.php index 6f5c8ae..b9c34d1 100644 --- a/src/Model/SplitRules.php +++ b/src/Model/SplitRules.php @@ -2,10 +2,10 @@ namespace Ipag\Sdk\Model; -use Ipag\Sdk\Model\Schema\Mutator; use Ipag\Sdk\Model\Schema\Schema; -use Ipag\Sdk\Model\Schema\SchemaBuilder; use Kubinyete\Assertation\Assert; +use Ipag\Sdk\Model\Schema\Mutator; +use Ipag\Sdk\Model\Schema\SchemaBuilder; /** * SplitRules Class @@ -18,10 +18,11 @@ class SplitRules extends Model * @param array $data * array de dados do Split Rules. * - * + [`'receiver_id'`] string. + * + [`'seller_id'`] string. * + [`'amount'`] float. * + [`'percentage'`] float. * + [`'charge_processing_fee'`] bool. + * + [`'hold_receivables'`] bool. */ public function __construct(?array $data = []) { @@ -30,11 +31,11 @@ public function __construct(?array $data = []) protected function schema(SchemaBuilder $schema): Schema { - $schema->string('receiver_id')->nullable(); - $schema->string('receiver')->nullable(); + $schema->string('seller_id')->nullable(); $schema->float('amount')->nullable(); $schema->float('percentage')->nullable(); $schema->bool('charge_processing_fee')->nullable(); + $schema->bool('hold_receivables')->nullable(); return $schema->build(); } @@ -43,7 +44,7 @@ protected function amount(): Mutator { return new Mutator( null, - fn($value, $ctx) => + fn ($value, $ctx) => is_null($value) ? $value : ( Assert::value(floatval($value))->gte(0)->get() @@ -56,7 +57,7 @@ protected function percentage(): Mutator { return new Mutator( null, - fn($value, $ctx) => + fn ($value, $ctx) => is_null($value) ? $value : ( Assert::value(floatval($value))->gte(0)->get() @@ -66,25 +67,24 @@ protected function percentage(): Mutator } /** - * Retorna o valor da propriedade receiver_id. + * Retorna o valor da propriedade seller_id. * * @return string|null */ - public function getReceiverId(): ?string + public function getSellerId(): ?string { - return $this->get('receiver_id'); + return $this->get('seller_id'); } /** - * Seta o valor da propriedade receiver_id. + * Seta o valor da propriedade seller_id. * - * @param string|null $receiverId + * @param string|null $sellerId * @return self */ - public function setReceiverId(?string $receiverId = null): self + public function setSellerId(?string $sellerId = null): self { - $this->set('receiver_id', $receiverId); - $this->set('receiver', $receiverId); + $this->set('seller_id', $sellerId); return $this; } @@ -155,4 +155,26 @@ public function setChargeProcessingFee(?bool $chargeProcessingFee = null): self return $this; } -} \ No newline at end of file + /** + * Retorna o valor da propriedade hold_receivables. + * + * @return boolean|null + */ + public function getHoldReceivables(): ?bool + { + return $this->get('hold_receivables'); + } + + /** + * Seta o valor da propriedade hold_receivables. + * + * @param boolean|null $holdReceivables + * @return self + */ + public function setHoldReceivables(?bool $holdReceivables = null): self + { + $this->set('hold_receivables', $holdReceivables); + return $this; + } + +} diff --git a/tests/Model/AddressTest.php b/tests/Model/AddressTest.php index c050de1..7ae42d3 100644 --- a/tests/Model/AddressTest.php +++ b/tests/Model/AddressTest.php @@ -3,7 +3,6 @@ namespace Ipag\Sdk\Tests\Model; use PHPUnit\Framework\TestCase; -use Ipag\Sdk\Model\Schema\Exception\MutatorAttributeException; class AddressTest extends TestCase { @@ -16,7 +15,8 @@ public function testShouldCreateAddressObjectWithConstructorSuccessfully() 'city' => 'São Luís', 'complement' => 'Sala 001', 'state' => 'MA', - 'zipcode' => '65076-020' + 'zipcode' => '65076-020', + 'country' => 'BR' ]); $this->assertEquals($address->getComplement(), 'Sala 001'); @@ -26,6 +26,7 @@ public function testShouldCreateAddressObjectWithConstructorSuccessfully() $this->assertEquals($address->getCity(), 'São Luís'); $this->assertEquals($address->getState(), 'MA'); $this->assertEquals($address->getZipcode(), '65076020'); + $this->assertEquals($address->getCountry(), 'BR'); } public function testShouldCreateAddressObjectAndSetTheValuesSuccessfully() @@ -37,7 +38,8 @@ public function testShouldCreateAddressObjectAndSetTheValuesSuccessfully() ->setComplement('Sala 001') ->setCity('São Luís') ->setState('MA') - ->setZipcode('65076020'); + ->setZipcode('65076020') + ->setCountry('BR'); $this->assertEquals($address->getComplement(), 'Sala 001'); $this->assertEquals($address->getStreet(), 'Rua Agenor Vieira'); @@ -46,6 +48,7 @@ public function testShouldCreateAddressObjectAndSetTheValuesSuccessfully() $this->assertEquals($address->getCity(), 'São Luís'); $this->assertEquals($address->getState(), 'MA'); $this->assertEquals($address->getZipcode(), '65076020'); + $this->assertEquals($address->getCountry(), 'BR'); } public function testShouldCreateEmptyAddressObjectSuccessfully() @@ -59,6 +62,8 @@ public function testShouldCreateEmptyAddressObjectSuccessfully() $this->assertEmpty($address->getCity()); $this->assertEmpty($address->getState()); $this->assertEmpty($address->getZipcode()); + $this->assertEmpty($address->getComplement()); + $this->assertEmpty($address->getCountry()); } public function testCreateAndSetEmptyPropertiesAddressObjectSuccessfully() @@ -70,7 +75,8 @@ public function testCreateAndSetEmptyPropertiesAddressObjectSuccessfully() 'city' => 'São Luís', 'complement' => 'Sala 001', 'state' => 'MA', - 'zipcode' => '65076-020' + 'zipcode' => '65076-020', + 'country' => 'BR' ]); $address @@ -80,7 +86,8 @@ public function testCreateAndSetEmptyPropertiesAddressObjectSuccessfully() ->setCity(null) ->setState(null) ->setZipcode(null) - ->setComplement(null); + ->setComplement(null) + ->setCountry(null); $this->assertEmpty($address->getComplement()); $this->assertEmpty($address->getStreet()); @@ -99,4 +106,26 @@ public function testShouldAcceptAddressNumberPropertyWithLetters() $this->assertEquals('BR 163', $address->getNumber()); } + + public function testShouldValidateCountryCodeLength() + { + $address = new \Ipag\Sdk\Model\Address(); + + // Valid 2-character country code + $address->setCountry('BR'); + $this->assertEquals('BR', $address->getCountry()); + + // Invalid country code (more than 2 characters) should raise exception + $this->expectException(\Ipag\Sdk\Model\Schema\Exception\MutatorAttributeException::class); + $address->setCountry('BRAZIL'); + } + + public function testShouldValidateCountryCodeLengthOneCharacter() + { + $address = new \Ipag\Sdk\Model\Address(); + + // Invalid country code (1 character) should raise exception + $this->expectException(\Ipag\Sdk\Model\Schema\Exception\MutatorAttributeException::class); + $address->setCountry('B'); + } } diff --git a/tests/Model/CheckoutTest.php b/tests/Model/CheckoutTest.php index a9e253c..7e9f6b3 100644 --- a/tests/Model/CheckoutTest.php +++ b/tests/Model/CheckoutTest.php @@ -28,10 +28,10 @@ public function testShouldCreateCheckoutObjectWithConstructorSuccessfully() ], 'split_rules' => [ [ - "receiver_id" => "1000000", + "seller_id" => "1000000", ], [ - "receiver_id" => "1000001", + "seller_id" => "1000001", ], ], 'seller_id' => '100014', @@ -60,8 +60,8 @@ public function testShouldCreateCheckoutObjectWithConstructorSuccessfully() $this->assertInstanceOf(\Ipag\Sdk\Model\SplitRules::class, $checkout->getSplitRules()[0]); $this->assertInstanceOf(\Ipag\Sdk\Model\SplitRules::class, $checkout->getSplitRules()[1]); - $this->assertEquals('1000000', $checkout->getSplitRules()[0]->getReceiverId()); - $this->assertEquals('1000001', $checkout->getSplitRules()[1]->getReceiverId()); + $this->assertEquals('1000000', $checkout->getSplitRules()[0]->getSellerId()); + $this->assertEquals('1000001', $checkout->getSplitRules()[1]->getSellerId()); $this->assertEquals('100014', $checkout->getSellerId()); $this->assertEquals(60, $checkout->getExpiresIn()); @@ -93,11 +93,11 @@ public function testShouldCreateCheckoutObjectAndSetTheValuesSuccessfully() ) ->addSplitRule( (new \Ipag\Sdk\Model\SplitRules()) - ->setReceiverId('1000000') + ->setSellerId('1000000') ) ->addSplitRule( (new \Ipag\Sdk\Model\SplitRules()) - ->setReceiverId('1000001') + ->setSellerId('1000001') ) ->setSellerId('100014') ->setExpiresIn(60); @@ -124,8 +124,8 @@ public function testShouldCreateCheckoutObjectAndSetTheValuesSuccessfully() $this->assertInstanceOf(\Ipag\Sdk\Model\SplitRules::class, $checkout->getSplitRules()[0]); $this->assertInstanceOf(\Ipag\Sdk\Model\SplitRules::class, $checkout->getSplitRules()[1]); - $this->assertEquals('1000000', $checkout->getSplitRules()[0]->getReceiverId()); - $this->assertEquals('1000001', $checkout->getSplitRules()[1]->getReceiverId()); + $this->assertEquals('1000000', $checkout->getSplitRules()[0]->getSellerId()); + $this->assertEquals('1000001', $checkout->getSplitRules()[1]->getSellerId()); $this->assertEquals('100014', $checkout->getSellerId()); $this->assertEquals(60, $checkout->getExpiresIn()); @@ -171,10 +171,10 @@ public function testCreateAndSetEmptyPropertiesCheckoutObjectSuccessfully() ], 'split_rules' => [ [ - "receiver_id" => "1000000", + "seller_id" => "1000000", ], [ - "receiver_id" => "1000001", + "seller_id" => "1000001", ], ], 'seller_id' => '100014', @@ -203,4 +203,4 @@ public function testCreateAndSetEmptyPropertiesCheckoutObjectSuccessfully() } -} \ No newline at end of file +} diff --git a/tests/Model/CustomerTest.php b/tests/Model/CustomerTest.php index 0c53ab1..35176d9 100644 --- a/tests/Model/CustomerTest.php +++ b/tests/Model/CustomerTest.php @@ -2,8 +2,8 @@ namespace Ipag\Sdk\Tests\Model; -use Ipag\Sdk\Model\Schema\Exception\MutatorAttributeException; use PHPUnit\Framework\TestCase; +use Ipag\Sdk\Model\Schema\Exception\MutatorAttributeException; class CustomerTest extends TestCase { @@ -13,6 +13,7 @@ public function testShouldCreateCustomerObjectWithConstructorSuccessfully() 'id' => '123', 'uuid' => 'abc123', 'tax_receipt' => '074.598.263-83', + 'tax_id' => '123456789', 'birthdate' => '1980-01-01', 'ip' => '10.0.0.1', 'name' => 'Lívia Julia Eduarda Barros', @@ -39,6 +40,7 @@ public function testShouldCreateCustomerObjectWithConstructorSuccessfully() $this->assertEquals($customer->getId(), '123'); $this->assertEquals($customer->getUuid(), 'abc123'); $this->assertEquals($customer->getTaxReceipt(), '07459826383'); + $this->assertEquals($customer->getTaxId(), '123456789'); $this->assertEquals($customer->getBirthdate(), '1980-01-01'); $this->assertEquals($customer->getIp(), '10.0.0.1'); @@ -66,6 +68,7 @@ public function testShouldCreateCustomerObjectAndSetTheValuesSuccessfully() ->setId('123') ->setUuid('abc123') ->setTaxReceipt('074.598.263-83') + ->setTaxId('123456789') ->setBirthdate('1980-01-01') ->setIp('10.0.0.1') ->setName('Lívia Julia Eduarda Barros') @@ -81,6 +84,7 @@ public function testShouldCreateCustomerObjectAndSetTheValuesSuccessfully() $this->assertEquals($customer->getId(), '123'); $this->assertEquals($customer->getUuid(), 'abc123'); $this->assertEquals($customer->getTaxReceipt(), '07459826383'); + $this->assertEquals($customer->getTaxId(), '123456789'); $this->assertEquals($customer->getBirthdate(), '1980-01-01'); $this->assertEquals($customer->getIp(), '10.0.0.1'); @@ -104,6 +108,7 @@ public function testShouldCreateEmptyCustomerObjectSuccessfully() $this->assertEmpty($customer->getId()); $this->assertEmpty($customer->getUuid()); $this->assertEmpty($customer->getTaxReceipt()); + $this->assertEmpty($customer->getTaxId()); $this->assertEmpty($customer->getBirthdate()); $this->assertEmpty($customer->getIp()); @@ -125,6 +130,7 @@ public function testCreateAndSetEmptyPropertiesCustomerObjectSuccessfully() 'id' => '123', 'uuid' => 'abc123', 'tax_receipt' => '074.598.263-83', + 'tax_id' => '123456789', 'birthdate' => '1980-01-01', 'ip' => '10.0.0.1', 'name' => 'Lívia Julia Eduarda Barros', @@ -151,6 +157,7 @@ public function testCreateAndSetEmptyPropertiesCustomerObjectSuccessfully() ->setId(null) ->setUuid(null) ->setTaxReceipt(null) + ->setTaxId(null) ->setBirthdate(null) ->setIp(null) ->setName(null) @@ -166,6 +173,7 @@ public function testCreateAndSetEmptyPropertiesCustomerObjectSuccessfully() $this->assertEmpty($customer->getId()); $this->assertEmpty($customer->getUuid()); $this->assertEmpty($customer->getTaxReceipt()); + $this->assertEmpty($customer->getTaxId()); $this->assertEmpty($customer->getBirthdate()); $this->assertEmpty($customer->getIp()); @@ -227,4 +235,4 @@ public function testShouldThrowAValidationExceptionOnTheCustomerBirthdatePropert } -} \ No newline at end of file +} diff --git a/tests/Model/PaymentTest.php b/tests/Model/PaymentTest.php index 78e2ba2..5162899 100644 --- a/tests/Model/PaymentTest.php +++ b/tests/Model/PaymentTest.php @@ -16,6 +16,7 @@ public function testShouldCreatePaymentObjectWithConstructorSuccessfully() 'fraud_analysis' => true, 'softdescriptor' => 'Maria José', 'pix_expires_in' => 1000, + 'recurring' => true, 'card' => [ 'holder' => 'Maria José', 'number' => '123456789', @@ -46,6 +47,7 @@ public function testShouldCreatePaymentObjectWithConstructorSuccessfully() $this->assertEquals(true, $payment->getFraudAnalysis()); $this->assertEquals('Maria José', $payment->getSoftDescriptor()); $this->assertEquals(1000, $payment->getPixExpiresIn()); + $this->assertEquals(true, $payment->getRecurring()); $this->assertInstanceOf(\Ipag\Sdk\Model\PaymentCard::class, $payment->getCard()); @@ -79,6 +81,7 @@ public function testShouldCreatePaymentObjectAndSetTheValuesSuccessfully() ->setFraudAnalysis(true) ->setSoftDescriptor('Maria José') ->setPixExpiresIn(1000) + ->setRecurring(true) ->setCard( (new \Ipag\Sdk\Model\PaymentCard()) ->setHolder('Maria José') @@ -101,7 +104,6 @@ public function testShouldCreatePaymentObjectAndSetTheValuesSuccessfully() 'instruction' => 'lálálá' ], ] - ) ); @@ -112,6 +114,7 @@ public function testShouldCreatePaymentObjectAndSetTheValuesSuccessfully() $this->assertEquals(true, $payment->getFraudAnalysis()); $this->assertEquals('Maria José', $payment->getSoftDescriptor()); $this->assertEquals(1000, $payment->getPixExpiresIn()); + $this->assertEquals(true, $payment->getRecurring()); $this->assertInstanceOf(\Ipag\Sdk\Model\PaymentCard::class, $payment->getCard()); @@ -146,6 +149,7 @@ public function testShouldCreateEmptyPaymentObjectSuccessfully() $this->assertEmpty($payment->getFraudAnalysis()); $this->assertEmpty($payment->getSoftDescriptor()); $this->assertEmpty($payment->getPixExpiresIn()); + $this->assertEmpty($payment->getRecurring()); $this->assertEmpty($payment->getCard()); $this->assertEmpty($payment->getBoleto()); @@ -162,6 +166,7 @@ public function testCreateAndSetEmptyPropertiesPaymentObjectSuccessfully() 'fraud_analysis' => true, 'softdescriptor' => 'Maria José', 'pix_expires_in' => 1000, + 'recurring' => true, 'card' => [ 'holder' => 'Maria José', 'number' => '123456789', @@ -193,6 +198,7 @@ public function testCreateAndSetEmptyPropertiesPaymentObjectSuccessfully() ->setFraudAnalysis(null) ->setSoftDescriptor(null) ->setPixExpiresIn(null) + ->setRecurring(null) ->setCard(null) ->setBoleto(null); @@ -203,10 +209,11 @@ public function testCreateAndSetEmptyPropertiesPaymentObjectSuccessfully() $this->assertEmpty($payment->getFraudAnalysis()); $this->assertEmpty($payment->getSoftDescriptor()); $this->assertEmpty($payment->getPixExpiresIn()); + $this->assertEmpty($payment->getRecurring()); $this->assertEmpty($payment->getCard()); $this->assertEmpty($payment->getBoleto()); } -} \ No newline at end of file +} diff --git a/tests/Model/PaymentTransactionTest.php b/tests/Model/PaymentTransactionTest.php index 14ef922..23ec421 100644 --- a/tests/Model/PaymentTransactionTest.php +++ b/tests/Model/PaymentTransactionTest.php @@ -2,8 +2,8 @@ namespace Ipag\Sdk\Tests\Model; -use Ipag\Sdk\Model\Schema\Exception\MutatorAttributeException; use PHPUnit\Framework\TestCase; +use Ipag\Sdk\Model\Schema\Exception\MutatorAttributeException; class PaymentTransactionTest extends TestCase { @@ -12,7 +12,9 @@ public function testShouldCreatePaymentTransactionObjectWithConstructorSuccessfu $paymentTransaction = new \Ipag\Sdk\Model\PaymentTransaction([ 'amount' => 100.0, 'order_id' => '123456', + 'merchant_id' => 'MERCHANT123', 'callback_url' => 'https://ipag-sdk.requestcatcher.com/callback', + 'redirect_url' => 'https://ipag-sdk.requestcatcher.com/redirect', 'antifraud' => [ 'fingerprint' => '123', 'provider' => 'test', @@ -87,7 +89,9 @@ public function testShouldCreatePaymentTransactionObjectWithConstructorSuccessfu $this->assertEquals(100.0, $paymentTransaction->getAmount()); $this->assertEquals('123456', $paymentTransaction->getOrderId()); + $this->assertEquals('MERCHANT123', $paymentTransaction->getMerchantId()); $this->assertEquals('https://ipag-sdk.requestcatcher.com/callback', $paymentTransaction->getCallbackUrl()); + $this->assertEquals('https://ipag-sdk.requestcatcher.com/redirect', $paymentTransaction->getRedirectUrl()); $this->assertEquals('123', $paymentTransaction->getAntifraud()->getFingerprint()); $this->assertEquals('test', $paymentTransaction->getAntifraud()->getProvider()); @@ -154,7 +158,9 @@ public function testShouldCreatePaymentTransactionObjectAndSetTheValuesSuccessfu $paymentTransaction = (new \Ipag\Sdk\Model\PaymentTransaction()) ->setAmount(100.0) ->setOrderId('123456') + ->setMerchantId('MERCHANT123') ->setCallbackUrl('https://ipag-sdk.requestcatcher.com/callback') + ->setRedirectUrl('https://ipag-sdk.requestcatcher.com/redirect') ->setAntifraud( (new \Ipag\Sdk\Model\PaymentAntifraud()) ->setFingerprint('123') @@ -237,7 +243,9 @@ public function testShouldCreatePaymentTransactionObjectAndSetTheValuesSuccessfu $this->assertEquals(100.0, $paymentTransaction->getAmount()); $this->assertEquals('123456', $paymentTransaction->getOrderId()); + $this->assertEquals('MERCHANT123', $paymentTransaction->getMerchantId()); $this->assertEquals('https://ipag-sdk.requestcatcher.com/callback', $paymentTransaction->getCallbackUrl()); + $this->assertEquals('https://ipag-sdk.requestcatcher.com/redirect', $paymentTransaction->getRedirectUrl()); $this->assertEquals('123', $paymentTransaction->getAntifraud()->getFingerprint()); $this->assertEquals('test', $paymentTransaction->getAntifraud()->getProvider()); @@ -305,7 +313,9 @@ public function testShouldCreateEmptyPaymentTransactionObjectSuccessfully() $this->assertEmpty($paymentTransaction->getAmount()); $this->assertEmpty($paymentTransaction->getOrderId()); + $this->assertEmpty($paymentTransaction->getMerchantId()); $this->assertEmpty($paymentTransaction->getCallbackUrl()); + $this->assertEmpty($paymentTransaction->getRedirectUrl()); $this->assertEmpty($paymentTransaction->getAntifraud()); $this->assertEmpty($paymentTransaction->getPayment()); $this->assertEmpty($paymentTransaction->getCustomer()); @@ -321,7 +331,9 @@ public function testCreateAndSetEmptyPropertiesPaymentTransactionObjectSuccessfu $paymentTransaction = new \Ipag\Sdk\Model\PaymentTransaction([ 'amount' => 100.0, 'order_id' => '123456', + 'merchant_id' => 'MERCHANT123', 'callback_url' => 'https://ipag-sdk.requestcatcher.com/callback', + 'redirect_url' => 'https://ipag-sdk.requestcatcher.com/redirect', 'antifraud' => [ 'fingerprint' => '123', 'provider' => 'test', @@ -397,7 +409,9 @@ public function testCreateAndSetEmptyPropertiesPaymentTransactionObjectSuccessfu $paymentTransaction ->setAmount(null) ->setOrderId(null) + ->setMerchantId(null) ->setCallbackUrl(null) + ->setRedirectUrl(null) ->setAntifraud(null) ->setPayment(null) ->setCustomer(null) @@ -408,7 +422,9 @@ public function testCreateAndSetEmptyPropertiesPaymentTransactionObjectSuccessfu $this->assertEmpty($paymentTransaction->getAmount()); $this->assertEmpty($paymentTransaction->getOrderId()); + $this->assertEmpty($paymentTransaction->getMerchantId()); $this->assertEmpty($paymentTransaction->getCallbackUrl()); + $this->assertEmpty($paymentTransaction->getRedirectUrl()); $this->assertEmpty($paymentTransaction->getAntifraud()); $this->assertEmpty($paymentTransaction->getPayment()); $this->assertEmpty($paymentTransaction->getCustomer()); @@ -437,4 +453,4 @@ public function testShouldThrowAValidationExceptionOnThePaymentTransactionAmount $paymentTransaction->setAmount(-1); } -} \ No newline at end of file +} diff --git a/tests/Model/SplitRulesTest.php b/tests/Model/SplitRulesTest.php index f4f2a1e..88a3b02 100644 --- a/tests/Model/SplitRulesTest.php +++ b/tests/Model/SplitRulesTest.php @@ -2,39 +2,43 @@ namespace Ipag\Sdk\Tests\Model; -use Ipag\Sdk\Model\Schema\Exception\MutatorAttributeException; use PHPUnit\Framework\TestCase; +use Ipag\Sdk\Model\Schema\Exception\MutatorAttributeException; class SplitRulesTest extends TestCase { public function testShouldCreateSplitRulesObjectWithConstructorSuccessfully() { $splitRules = new \Ipag\Sdk\Model\SplitRules([ - "receiver_id" => "1000000", + "seller_id" => "1000000", "percentage" => 10.00, "amount" => 9.99, - "charge_processing_fee" => false + "charge_processing_fee" => false, + "hold_receivables" => true ]); - $this->assertEquals("1000000", $splitRules->getReceiverId()); + $this->assertEquals("1000000", $splitRules->getSellerId()); $this->assertEquals(10.00, $splitRules->getPercentage()); $this->assertEquals(9.99, $splitRules->getAmount()); $this->assertEquals(false, $splitRules->getChargeProcessingFee()); + $this->assertEquals(true, $splitRules->getHoldReceivables()); } public function testShouldCreateSplitRulesObjectAndSetTheValuesSuccessfully() { $splitRules = (new \Ipag\Sdk\Model\SplitRules()) - ->setReceiverId("1000000") + ->setSellerId("1000000") ->setPercentage(10.00) ->setAmount(9.99) - ->setChargeProcessingFee(false); + ->setChargeProcessingFee(false) + ->setHoldReceivables(true); - $this->assertEquals("1000000", $splitRules->getReceiverId()); + $this->assertEquals("1000000", $splitRules->getSellerId()); $this->assertEquals(10.00, $splitRules->getPercentage()); $this->assertEquals(9.99, $splitRules->getAmount()); $this->assertEquals(false, $splitRules->getChargeProcessingFee()); + $this->assertEquals(true, $splitRules->getHoldReceivables()); } @@ -42,44 +46,39 @@ public function testShouldCreateEmptySplitRulesObjectSuccessfully() { $splitRules = new \Ipag\Sdk\Model\SplitRules(); - $this->assertEmpty($splitRules->getReceiverId()); + $this->assertEmpty($splitRules->getSellerId()); $this->assertEmpty($splitRules->getPercentage()); $this->assertEmpty($splitRules->getAmount()); $this->assertEmpty($splitRules->getChargeProcessingFee()); + $this->assertEmpty($splitRules->getHoldReceivables()); } public function testCreateAndSetEmptyPropertiesSplitRulesObjectSuccessfully() { $splitRules = new \Ipag\Sdk\Model\SplitRules([ - "receiver_id" => "1000000", + "seller_id" => "1000000", "percentage" => 10.00, "amount" => 9.99, - "charge_processing_fee" => false + "charge_processing_fee" => false, + "hold_receivables" => true ]); $splitRules - ->setReceiverId(null) + ->setSellerId(null) ->setPercentage(null) ->setAmount(null) - ->setChargeProcessingFee(null); + ->setChargeProcessingFee(null) + ->setHoldReceivables(null); - $this->assertEmpty($splitRules->getReceiverId()); + $this->assertEmpty($splitRules->getSellerId()); $this->assertEmpty($splitRules->getPercentage()); $this->assertEmpty($splitRules->getAmount()); $this->assertEmpty($splitRules->getChargeProcessingFee()); + $this->assertEmpty($splitRules->getHoldReceivables()); } - public function testShouldThrowATypeExceptionOnTheSplitRulesAmountProperty() - { - $splitRules = new \Ipag\Sdk\Model\SplitRules(); - - $this->expectException(\TypeError::class); - - $splitRules->setAmount('a'); - } - public function testShouldThrowAValidationExceptionOnTheSplitRulesAmountProperty() { $splitRules = new \Ipag\Sdk\Model\SplitRules(); @@ -89,15 +88,6 @@ public function testShouldThrowAValidationExceptionOnTheSplitRulesAmountProperty $splitRules->setAmount(-1); } - public function testShouldThrowATypeExceptionOnTheSplitRulesPercentageProperty() - { - $splitRules = new \Ipag\Sdk\Model\SplitRules(); - - $this->expectException(\TypeError::class); - - $splitRules->setPercentage('a'); - } - public function testShouldThrowAValidationExceptionOnTheSplitRulesPercentageProperty() { $splitRules = new \Ipag\Sdk\Model\SplitRules(); @@ -107,4 +97,4 @@ public function testShouldThrowAValidationExceptionOnTheSplitRulesPercentageProp $splitRules->setPercentage(-1); } -} \ No newline at end of file +} From 585e4d84f6dc3676899808d2d217da48e7fcfb8c Mon Sep 17 00:00:00 2001 From: Lucas Rosa Date: Fri, 31 Oct 2025 16:22:57 -0300 Subject: [PATCH 2/3] =?UTF-8?q?fix:=20melhoria=20e=20corre=C3=A7=C3=B5es?= =?UTF-8?q?=20ci-tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci-tests.yml | 71 ++++++++++++++++++++++++++++++---- 1 file changed, 64 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci-tests.yml b/.github/workflows/ci-tests.yml index 0f911dc..f9749bc 100644 --- a/.github/workflows/ci-tests.yml +++ b/.github/workflows/ci-tests.yml @@ -9,18 +9,19 @@ on: permissions: contents: read +env: + # pin a Code Climate test-reporter release to avoid "latest" redirects returning HTML + CC_TEST_REPORTER_VERSION: v0.11.1 + jobs: phpunit: - runs-on: ubuntu-latest - env: CC_TEST_REPORTER_ID: ${{ secrets.CODE_CLIMATE_ID }} steps: - uses: actions/checkout@v3 - - uses: actions/checkout@master - name: Setup PHP uses: shivammathur/setup-php@v2 @@ -31,13 +32,69 @@ jobs: - name: Install Composer Dependencies run: composer install --no-progress --prefer-dist --optimize-autoloader - - name: Code Climate Setup + - name: Download Code Climate test-reporter run: | - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter && chmod +x ./cc-test-reporter - ./cc-test-reporter before-build + set -euo pipefail + echo "Downloading test-reporter from CodeClimate v${CC_TEST_REPORTER_VERSION}" + curl -fsSL "https://github.com/codeclimate/test-reporter/releases/download/${CC_TEST_REPORTER_VERSION}/artifacts.tar.gz" -o artifacts.tar.gz || { echo "curl failed"; exit 1; } + # Extract the linux-amd64 binary from the artifacts + tar -xf artifacts.tar.gz ./artifacts/bin/test-reporter-${CC_TEST_REPORTER_VERSION#v}-linux-amd64 + mv ./artifacts/bin/test-reporter-${CC_TEST_REPORTER_VERSION#v}-linux-amd64 ./cc-test-reporter + chmod +x ./cc-test-reporter + rm -rf artifacts.tar.gz artifacts/ + # Verify the binary works + ./cc-test-reporter --version + + - name: Check CodeClimate Configuration + run: | + if [ -z "${{ env.CC_TEST_REPORTER_ID }}" ]; then + echo "WARNING: CC_TEST_REPORTER_ID is not set. CodeClimate reporting will be skipped." + else + echo "CodeClimate Reporter ID is configured (length: ${#CC_TEST_REPORTER_ID})" + fi + + - name: Code Climate before-build + if: env.CC_TEST_REPORTER_ID != '' + run: | + echo "Initializing CodeClimate test reporter..." + ./cc-test-reporter before-build || { + echo "CodeClimate before-build failed, but continuing..." + exit 0 + } + - name: Run Tests run: | php vendor/bin/phpunit --color --testdox --coverage-clover clover.xml tests + echo "TEST_EXIT_CODE=$?" >> $GITHUB_ENV + + - name: Verify coverage file + run: | + if [ -f clover.xml ]; then + echo "Coverage file generated successfully" + ls -la clover.xml + head -5 clover.xml + else + echo "Coverage file not found!" + exit 1 + fi + - name: Send Report + if: env.CC_TEST_REPORTER_ID != '' run: | - ./cc-test-reporter after-build -t clover --exit-code $? + if [ -f clover.xml ]; then + echo "Sending coverage report to CodeClimate..." + echo "File size: $(wc -l < clover.xml) lines" + echo "Exit code: $TEST_EXIT_CODE" + + # Enable debug mode to see what's happening + ./cc-test-reporter after-build -d -t clover --exit-code $TEST_EXIT_CODE || { + echo "CodeClimate upload failed. This might be due to:" + echo "1. Invalid CC_TEST_REPORTER_ID" + echo "2. Network issues" + echo "3. CodeClimate API problems" + echo "Continuing without failing the build..." + exit 0 + } + else + echo "No coverage file found, skipping CodeClimate report" + fi From 781906770e33e501ca07d416756e8aab3443e157 Mon Sep 17 00:00:00 2001 From: Lucas Rosa Date: Fri, 31 Oct 2025 16:53:08 -0300 Subject: [PATCH 3/3] fix: corrige namespaces incorretos de alguns tests --- tests/Examples/ModelTest.php | 7 ++++--- .../Credentials/Antifraudes/ClearSaleCredentialsTest.php | 4 ++-- .../Credentials/Antifraudes/KondutoCredentialsTest.php | 4 ++-- .../Credentials/Antifraudes/RedShieldCredentialsTest.php | 4 ++-- .../Credentials/PaymentMethods/AdiqCredentialsTest.php | 4 ++-- .../Credentials/PaymentMethods/BinCredentialsTest.php | 4 ++-- .../Credentials/PaymentMethods/CieloCredentialsTest.php | 4 ++-- .../Credentials/PaymentMethods/GetnetCredentialsTest.php | 4 ++-- .../PaymentMethods/GlobalPaymentsCredentialsTest.php | 4 ++-- .../Credentials/PaymentMethods/RedeCredentialsTest.php | 4 ++-- .../Credentials/PaymentMethods/SipagCredentialsTest.php | 4 ++-- .../Credentials/PaymentMethods/StoneCredentialsTest.php | 4 ++-- .../Credentials/PaymentMethods/ZoopCredentialsTest.php | 4 ++-- .../Support/Provider/Antifraudes/ClearSaleProviderTest.php | 4 ++-- tests/Support/Provider/Antifraudes/KondutoProviderTest.php | 4 ++-- .../Support/Provider/Antifraudes/RedShieldProviderTest.php | 4 ++-- 16 files changed, 34 insertions(+), 33 deletions(-) diff --git a/tests/Examples/ModelTest.php b/tests/Examples/ModelTest.php index e19b3ce..e604b0b 100644 --- a/tests/Examples/ModelTest.php +++ b/tests/Examples/ModelTest.php @@ -1,12 +1,13 @@ $x > 0 ? $x : $ctx->raise('Um ID nao pode ser menor ou igual a zero') + fn ($x, $ctx) => $x > 0 ? $x : $ctx->raise('Um ID nao pode ser menor ou igual a zero') ); } @@ -63,4 +64,4 @@ public function testCanParseModel() $this->assertIsArray($model->jsonSerialize()); } -} \ No newline at end of file +} diff --git a/tests/Support/Credentials/Antifraudes/ClearSaleCredentialsTest.php b/tests/Support/Credentials/Antifraudes/ClearSaleCredentialsTest.php index af55ec1..4c89259 100644 --- a/tests/Support/Credentials/Antifraudes/ClearSaleCredentialsTest.php +++ b/tests/Support/Credentials/Antifraudes/ClearSaleCredentialsTest.php @@ -1,6 +1,6 @@ assertEmpty($clearSaleCredentials->getPassword()); } -} \ No newline at end of file +} diff --git a/tests/Support/Credentials/Antifraudes/KondutoCredentialsTest.php b/tests/Support/Credentials/Antifraudes/KondutoCredentialsTest.php index ab716ff..1b5917b 100644 --- a/tests/Support/Credentials/Antifraudes/KondutoCredentialsTest.php +++ b/tests/Support/Credentials/Antifraudes/KondutoCredentialsTest.php @@ -1,6 +1,6 @@ assertEmpty($kondutoCredentials->getPublicKey()); } -} \ No newline at end of file +} diff --git a/tests/Support/Credentials/Antifraudes/RedShieldCredentialsTest.php b/tests/Support/Credentials/Antifraudes/RedShieldCredentialsTest.php index 8290d16..6c71d6e 100644 --- a/tests/Support/Credentials/Antifraudes/RedShieldCredentialsTest.php +++ b/tests/Support/Credentials/Antifraudes/RedShieldCredentialsTest.php @@ -1,6 +1,6 @@ assertEmpty($redShieldCredentials->getServiceId()); } -} \ No newline at end of file +} diff --git a/tests/Support/Credentials/PaymentMethods/AdiqCredentialsTest.php b/tests/Support/Credentials/PaymentMethods/AdiqCredentialsTest.php index 898faaa..96acc19 100644 --- a/tests/Support/Credentials/PaymentMethods/AdiqCredentialsTest.php +++ b/tests/Support/Credentials/PaymentMethods/AdiqCredentialsTest.php @@ -1,6 +1,6 @@ assertEmpty($adiqCredentials->getClientSecret()); } -} \ No newline at end of file +} diff --git a/tests/Support/Credentials/PaymentMethods/BinCredentialsTest.php b/tests/Support/Credentials/PaymentMethods/BinCredentialsTest.php index fe1465c..4854a10 100644 --- a/tests/Support/Credentials/PaymentMethods/BinCredentialsTest.php +++ b/tests/Support/Credentials/PaymentMethods/BinCredentialsTest.php @@ -1,6 +1,6 @@ assertEmpty($binCredentials->getStoreId()); } -} \ No newline at end of file +} diff --git a/tests/Support/Credentials/PaymentMethods/CieloCredentialsTest.php b/tests/Support/Credentials/PaymentMethods/CieloCredentialsTest.php index 43baed1..ae979cc 100644 --- a/tests/Support/Credentials/PaymentMethods/CieloCredentialsTest.php +++ b/tests/Support/Credentials/PaymentMethods/CieloCredentialsTest.php @@ -1,6 +1,6 @@ assertEmpty($cieloCredentials->getMerchantKey()); } -} \ No newline at end of file +} diff --git a/tests/Support/Credentials/PaymentMethods/GetnetCredentialsTest.php b/tests/Support/Credentials/PaymentMethods/GetnetCredentialsTest.php index 21e599f..49034d5 100644 --- a/tests/Support/Credentials/PaymentMethods/GetnetCredentialsTest.php +++ b/tests/Support/Credentials/PaymentMethods/GetnetCredentialsTest.php @@ -1,6 +1,6 @@ assertEmpty($getnetCredentials->getPassword()); } -} \ No newline at end of file +} diff --git a/tests/Support/Credentials/PaymentMethods/GlobalPaymentsCredentialsTest.php b/tests/Support/Credentials/PaymentMethods/GlobalPaymentsCredentialsTest.php index 4bde9d8..546bb20 100644 --- a/tests/Support/Credentials/PaymentMethods/GlobalPaymentsCredentialsTest.php +++ b/tests/Support/Credentials/PaymentMethods/GlobalPaymentsCredentialsTest.php @@ -1,6 +1,6 @@ assertEmpty($globalPaymentsCredentials->getMerchantKey()); } -} \ No newline at end of file +} diff --git a/tests/Support/Credentials/PaymentMethods/RedeCredentialsTest.php b/tests/Support/Credentials/PaymentMethods/RedeCredentialsTest.php index 4d3f142..7c9102f 100644 --- a/tests/Support/Credentials/PaymentMethods/RedeCredentialsTest.php +++ b/tests/Support/Credentials/PaymentMethods/RedeCredentialsTest.php @@ -1,6 +1,6 @@ assertEmpty($redeCredentials->getPv()); } -} \ No newline at end of file +} diff --git a/tests/Support/Credentials/PaymentMethods/SipagCredentialsTest.php b/tests/Support/Credentials/PaymentMethods/SipagCredentialsTest.php index 0529322..06031dd 100644 --- a/tests/Support/Credentials/PaymentMethods/SipagCredentialsTest.php +++ b/tests/Support/Credentials/PaymentMethods/SipagCredentialsTest.php @@ -1,6 +1,6 @@ assertEmpty($sipagCredentials->getStoreId()); } -} \ No newline at end of file +} diff --git a/tests/Support/Credentials/PaymentMethods/StoneCredentialsTest.php b/tests/Support/Credentials/PaymentMethods/StoneCredentialsTest.php index 860749d..43db662 100644 --- a/tests/Support/Credentials/PaymentMethods/StoneCredentialsTest.php +++ b/tests/Support/Credentials/PaymentMethods/StoneCredentialsTest.php @@ -1,6 +1,6 @@ assertEmpty($stoneCredentials->getStoneSak()); } -} \ No newline at end of file +} diff --git a/tests/Support/Credentials/PaymentMethods/ZoopCredentialsTest.php b/tests/Support/Credentials/PaymentMethods/ZoopCredentialsTest.php index 653e992..b9621b4 100644 --- a/tests/Support/Credentials/PaymentMethods/ZoopCredentialsTest.php +++ b/tests/Support/Credentials/PaymentMethods/ZoopCredentialsTest.php @@ -1,6 +1,6 @@ assertEmpty($zoopCredentials->getSellerId()); } -} \ No newline at end of file +} diff --git a/tests/Support/Provider/Antifraudes/ClearSaleProviderTest.php b/tests/Support/Provider/Antifraudes/ClearSaleProviderTest.php index 2b8a69d..392272d 100644 --- a/tests/Support/Provider/Antifraudes/ClearSaleProviderTest.php +++ b/tests/Support/Provider/Antifraudes/ClearSaleProviderTest.php @@ -1,6 +1,6 @@ assertEmpty($clearSaleProvider->getCredentials()); } -} \ No newline at end of file +} diff --git a/tests/Support/Provider/Antifraudes/KondutoProviderTest.php b/tests/Support/Provider/Antifraudes/KondutoProviderTest.php index 9ec11bc..70f61be 100644 --- a/tests/Support/Provider/Antifraudes/KondutoProviderTest.php +++ b/tests/Support/Provider/Antifraudes/KondutoProviderTest.php @@ -1,6 +1,6 @@ assertEmpty($kondutoProvider->getCredentials()); } -} \ No newline at end of file +} diff --git a/tests/Support/Provider/Antifraudes/RedShieldProviderTest.php b/tests/Support/Provider/Antifraudes/RedShieldProviderTest.php index 02d4bce..e3ffac3 100644 --- a/tests/Support/Provider/Antifraudes/RedShieldProviderTest.php +++ b/tests/Support/Provider/Antifraudes/RedShieldProviderTest.php @@ -1,6 +1,6 @@ assertEmpty($redShieldProvider->getCredentials()); } -} \ No newline at end of file +}