Skip to content

Commit

Permalink
Release 2.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiano-mallmann authored Jun 13, 2024
2 parents 3e75e53 + 9dff92d commit 7566480
Show file tree
Hide file tree
Showing 42 changed files with 2,063 additions and 31 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
/vendor/
/tests/report
/tests/mock/db_test.sqlite
composer.lock
.phpunit.result.cache
coverage
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "pagarme/ecommerce-module-core",
"description": "Core component for Pagar.me e-commerce platform modules.",
"license": "MIT",
"version": "2.4.1",
"version": "2.5.0",
"authors": [
{
"name":"Open Source Team"
Expand All @@ -12,7 +12,7 @@
"require": {
"php": ">=7.1",
"monolog/monolog": "<3",
"pagarme/pagarmecoreapi": "v5.6.4",
"pagarme/pagarmecoreapi": "v5.6.5",
"ext-json": "*"
},
"require-dev": {
Expand Down
2 changes: 1 addition & 1 deletion src/Kernel/Aggregates/Charge.php
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ public function updateTransaction(Transaction $updatedTransaction, $overwriteId
/**
* @return array
*/
public function getAcquirerTidCapturedAndAutorize()
public function getAcquirerTidCapturedAndAuthorize()
{
$transactions = $this->getTransactions();

Expand Down
33 changes: 33 additions & 0 deletions src/Kernel/Aggregates/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Pagarme\Core\Kernel\ValueObjects\Configuration\RecurrenceConfig;
use Pagarme\Core\Kernel\ValueObjects\Configuration\VoucherConfig;
use Pagarme\Core\Kernel\ValueObjects\Configuration\DebitConfig;
use Pagarme\Core\Kernel\ValueObjects\Configuration\GooglePayConfig;
use Pagarme\Core\Kernel\ValueObjects\Key\AbstractSecretKey;
use Pagarme\Core\Kernel\ValueObjects\Key\AbstractPublicKey;
use Pagarme\Core\Kernel\ValueObjects\Key\TestPublicKey;
Expand Down Expand Up @@ -42,6 +43,7 @@ final class Configuration extends AbstractEntity
* @var bool
*/
private $creditCardEnabled;
private $googlepayEnabled;
/**
*
* @var bool
Expand Down Expand Up @@ -158,6 +160,7 @@ final class Configuration extends AbstractEntity

/** @var DebitConfig */
private $debitConfig;
private $googlePayConfig;

/**
* @var PixConfig
Expand Down Expand Up @@ -222,6 +225,18 @@ public function getDebitConfig()
return $this->debitConfig;
}

public function getGooglePayConfig()
{
return $this->googlePayConfig;
}

/**
* @param GooglePayConfig $googlePayConfig
*/
public function setGooglePayConfig(GooglePayConfig $googlePayConfig)
{
$this->googlePayConfig = $googlePayConfig;
}
/**
* @param DebitConfig $debitConfig
*/
Expand Down Expand Up @@ -421,6 +436,19 @@ public function setCreditCardEnabled($creditCardEnabled)
return $this;
}

/**
*
* @param bool $googlepayEnabled
* @return Configuration
*/
public function setGooglePayEnabled($googlepayEnabled)
{
$this->googlepayEnabled = filter_var(
$googlepayEnabled,
FILTER_VALIDATE_BOOLEAN
);
return $this;
}
/**
* @param $sendMailEnable
* @return $this
Expand Down Expand Up @@ -492,6 +520,10 @@ protected function isCreditCardEnabled()
{
return $this->creditCardEnabled;
}
protected function isGooglePayEnabled()
{
return $this->googlepayEnabled;
}

/**
* @return bool
Expand Down Expand Up @@ -845,6 +877,7 @@ public function jsonSerialize()
"voucherConfig" => $this->getVoucherConfig(),
"debitConfig" => $this->getDebitConfig(),
"pixConfig" => $this->getPixConfig(),
"googlePayConfig" => $this->getGooglePayConfig(),
"marketplaceConfig" => $this->getMarketplaceConfig()
];
}
Expand Down
8 changes: 7 additions & 1 deletion src/Kernel/Aggregates/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,18 @@ public function applyOrderStatusFromCharges()
}

if (
in_array(ChargeStatus::failed()->getStatus(), $listChargeStatus) &&
in_array(ChargeStatus::canceled()->getStatus(), $listChargeStatus)
) {
$this->setStatus(OrderStatus::canceled());
}

if (
in_array(ChargeStatus::failed()->getStatus(), $listChargeStatus)
)
{
$this->setStatus(OrderStatus::failed());
}

if (
$chargesStatusEquals &&
!$this->getCharges()[0]->getStatus()->equals(ChargeStatus::underpaid())
Expand Down
6 changes: 6 additions & 0 deletions src/Kernel/Factories/ConfigurationFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Pagarme\Core\Kernel\Factories\Configurations\DebitConfigFactory;
use Pagarme\Core\Kernel\Factories\Configurations\MarketplaceConfigFactory;
use Pagarme\Core\Kernel\Factories\Configurations\PixConfigFactory;
use Pagarme\Core\Kernel\Factories\Configurations\GooglePayConfigFactory;
use Pagarme\Core\Kernel\Factories\Configurations\RecurrenceConfigFactory;
use Pagarme\Core\Kernel\Factories\Configurations\VoucherConfigFactory;
use Pagarme\Core\Kernel\Interfaces\FactoryInterface;
Expand Down Expand Up @@ -231,6 +232,11 @@ public function createFromJsonData($json)
(new PixConfigFactory())->createFromDbData($data->pixConfig)
);
}
if (!empty($data->googlePayConfig)) {
$config->setGooglePayConfig(
(new GooglePayConfigFactory())->createFromDbData($data->googlePayConfig)
);
}

if (!empty($data->allowNoAddress)) {
$config->setAllowNoAddress($data->allowNoAddress);
Expand Down
35 changes: 35 additions & 0 deletions src/Kernel/Factories/Configurations/GooglePayConfigFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

namespace Pagarme\Core\Kernel\Factories\Configurations;

use Pagarme\Core\Kernel\Interfaces\FactoryCreateFromDbDataInterface;
use Pagarme\Core\Kernel\ValueObjects\Configuration\GooglePayConfig;

class GooglePayConfigFactory implements FactoryCreateFromDbDataInterface
{
/**
* @param object $data
* @return GooglePayConfig
*/
public function createFromDbData($data)
{
$googlePayConfig = new GooglePayConfig();

if (isset($data->enabled)) {
$googlePayConfig->setEnabled((bool) $data->enabled);
}

if (!empty($data->title)) {
$googlePayConfig->setTitle($data->title);
}

if (!empty($data->merchantId)) {
$googlePayConfig->setMerchantId($data->merchantId);
}
if (!empty($data->merchantName)) {
$googlePayConfig->setMerchantName($data->merchantName);
}

return $googlePayConfig;
}
}
5 changes: 3 additions & 2 deletions src/Kernel/Services/LogService.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,10 @@ class LogService
*/
public function __construct(
$channelName,
$addHost = false
$addHost = false,
$stackTraceDepth = 2
) {
$this->stackTraceDepth = 2;
$this->stackTraceDepth = $stackTraceDepth;
$this->channelName = $channelName;
$this->path = AbstractModuleCoreSetup::getLogPath();
if (is_array($this->path)) {
Expand Down
92 changes: 92 additions & 0 deletions src/Kernel/ValueObjects/Configuration/GooglePayConfig.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<?php

namespace Pagarme\Core\Kernel\ValueObjects\Configuration;

use Pagarme\Core\Kernel\Abstractions\AbstractValueObject;

class GooglePayConfig extends AbstractValueObject
{
private $enabled;
private $title;
private $merchantId;
private $merchantName;

/**
* @param bool $enabled
* @return GooglePayConfig
*/
public function setEnabled($enabled)
{
$this->enabled = $enabled;
return $this;
}

/**
* @param string $title
* @return GooglePayConfig
*/
public function setTitle($title)
{
$this->title = $title;
return $this;
}

/**
* @param string $merchantId
* @return GooglePayConfig
*/
public function setMerchantId($merchantId)
{
$this->merchantId = $merchantId;
return $this;
}

/**
* @param string $merchantId
* @return GooglePayConfig
*/
public function setMerchantName($merchantName)
{
$this->merchantName = $merchantName;
return $this;
}

protected function isEqual($object)
{
return $this->enabled === $this->isEnabled()
&& $this->title === $this->getTitle()
&& $this->merchantName === $this->getMerchantName()
&& $this->merchantId === $this->getMerchantId();
}

public function isEnabled()
{
return $this->enabled;
}

public function getTitle()
{
return $this->title;
}

public function getMerchantName()
{
return $this->merchantName;
}

public function getMerchantId()
{
return $this->merchantId;
}

#[\ReturnTypeWillChange]
public function jsonSerialize()
{
return [
"enabled" => $this->isEnabled(),
"title" => $this->getTitle(),
"merchantId" => $this->getMerchantId(),
"merchantName" => $this->getMerchantName(),
];
}
}
5 changes: 5 additions & 0 deletions src/Kernel/ValueObjects/PaymentMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ final class PaymentMethod extends AbstractValueObject
const DEBIT_CARD = 'debit_card';
const VOUCHER = 'voucher';
const PIX = 'pix';
const GOOGLEPAY = 'googlepay';

/**
* @var string
Expand Down Expand Up @@ -51,6 +52,10 @@ static public function pix()
{
return new self(self::PIX);
}
static public function googlepay()
{
return new self(self::GOOGLEPAY);
}

/**
*
Expand Down
5 changes: 5 additions & 0 deletions src/Kernel/ValueObjects/TransactionType.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ final class TransactionType extends AbstractValueObject
const VOUCHER = "voucher";
const DEBIT_CARD = "debit_card";
const PIX = 'pix';
const GOOGLEPAY = 'googlepay';
/**
*
* @var string
Expand Down Expand Up @@ -51,6 +52,10 @@ public static function pix()
{
return new self(self::PIX);
}
public static function googlepay()
{
return new self(self::GOOGLEPAY);
}

/**
*
Expand Down
44 changes: 44 additions & 0 deletions src/Marketplace/Aggregates/Recipient.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ class Recipient extends AbstractEntity implements RecipientInterface
/** @var int */
private $transferDay = 0;
/** @var string */
private $status = '';
/** @var string */
private $createdAt;
/** @var string */
private $updatedAt;
Expand Down Expand Up @@ -477,6 +479,48 @@ public function setTransferDay($transferDay)
return $this;
}

/**
* @return string
*/
public function getStatus()
{
return $this->status;
}

/**
* @param string $status
* @return Recipient
*/
public function setStatus($status, $kycStatus = '')
{
$recipientStatus = static::parseStatus($status, $kycStatus);
$this->status = $recipientStatus;
return $this;
}

public static function parseStatus($status, $kycStatus)
{
if ($status === 'registration') {
if ($kycStatus === 'pending') {
return static::REGISTERED;
}

if ($kycStatus === 'denied') {
return static::DISAPPROVED;
}
}

if ($status === 'affiliation' && $kycStatus === 'pending') {
return static::WAITING_FOR_ANALYSIS;
}

if ($kycStatus === 'partially_denied') {
return static::VALIDATION_REQUESTED;
}

return $status;
}

/**
* @return string
*/
Expand Down
Loading

0 comments on commit 7566480

Please sign in to comment.