Skip to content

Commit

Permalink
New Feature - Adicionar Configuração de Status para Pagamento Confirmado
Browse files Browse the repository at this point in the history
  • Loading branch information
Warley Elias committed Sep 9, 2024
1 parent 1bb9c4d commit 6ca5ae8
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 8 deletions.
16 changes: 12 additions & 4 deletions Helper/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ class Config extends AbstractHelper

public const PAYMENT_STATUS = 'payment/pagaleve/order_status';
public const PAYMENT_STATUS_NEW = 'payment/pagaleve/order_status_new';
public const PAYMENT_STATUS_PROCESSING = 'payment/pagaleve/order_status_processing';
public const PAYMENT_CONFIRMED_STATUS = 'payment/pagaleve/payment_confirmed_status';

public const UPFRONT_PAYMENT_STATUS = 'payment/pagaleve_upfront/order_status';
public const UPFRONT_PAYMENT_STATUS_NEW = 'payment/pagaleve_upfront/order_status_new';
public const UPFRONT_PAYMENT_STATUS_PROCESSING = 'payment/pagaleve_upfront/order_status_processing';
public const UPFRONT_PAYMENT_CONFIRMED_STATUS = 'payment/pagaleve_upfront/payment_confirmed_status';

/**
* @return bool
Expand Down Expand Up @@ -136,9 +136,17 @@ public function getPaymentStatusNew()
/**
* @return mixed
*/
public function getPaymentStatusProcessing()
public function getPaymentConfirmedStatus()
{
return $this->getStoreConfig(self::PAYMENT_STATUS_PROCESSING) ?? Order::STATE_PROCESSING;
return $this->getStoreConfig(self::PAYMENT_CONFIRMED_STATUS) ?? Order::STATE_PROCESSING;
}

/**
* @return mixed
*/
public function getUpfrontPaymentConfirmedStatus()
{
return $this->getStoreConfig(self::UPFRONT_PAYMENT_CONFIRMED_STATUS) ?? Order::STATE_PROCESSING;
}

/**
Expand Down
9 changes: 8 additions & 1 deletion Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
use Pagaleve\Payment\Model\Pagaleve;
use Pagaleve\Payment\Logger\Logger;
use Magento\Framework\Module\ModuleListInterface;
use Pagaleve\Payment\Model\PagaleveUpFront;

class Data extends AbstractHelper
{
Expand Down Expand Up @@ -199,8 +200,14 @@ public function createInvoice($order, $checkoutData)
$transactionSave->save();
$this->invoiceSender->send($invoice);

$orderStatus = $this->helperConfig->getPaymentConfirmedStatus();
//if payment method code is upfront
if ($order->getPayment()->getMethod() == PagaleveUpFront::PAYMENT_METHOD_PAGALEVE_CODE) {
$orderStatus = $this->helperConfig->getUpfrontPaymentConfirmedStatus();
}

$orderState = Order::STATE_PROCESSING;
$order->setState($orderState)->setStatus($orderState);
$order->setState($orderState)->setStatus($orderStatus);
$order->addStatusHistoryComment(
__('Notified customer about invoice creation #%1.', $invoice->getId())
)->setIsCustomerNotified(true);
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "2",
"homepage": "https://github.com/pagaleve/pagaleve-magento2-extension",
"type": "magento2-module",
"version": "1.4.1",
"version": "1.4.2",
"minimum-stability": "dev",
"license": [
"OSL-3.0",
Expand Down
10 changes: 10 additions & 0 deletions etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@
<source_model>Magento\Sales\Model\Config\Source\Order\Status\NewStatus</source_model>
<config_path>payment/pagaleve/order_status</config_path>
</field>
<field id="payment_confirmed_status" type="select" sortOrder="50" showInWebsite="1" showInStore="1" showInDefault="1" translate="label">
<label>Payment Confirmed Status</label>
<source_model>Magento\Sales\Model\Config\Source\Order\Status\Processing</source_model>
<config_path>payment/pagaleve/payment_confirmed_status</config_path>
</field>
<field id="retry_deadline" type="text" sortOrder="60" showInWebsite="1" showInStore="1" showInDefault="1" translate="label">
<label>Retry deadline</label>
<config_path>payment/pagaleve/retry_deadline</config_path>
Expand Down Expand Up @@ -190,6 +195,11 @@
<source_model>Magento\Sales\Model\Config\Source\Order\Status\NewStatus</source_model>
<config_path>payment/pagaleve_upfront/order_status</config_path>
</field>
<field id="payment_confirmed_status" type="select" sortOrder="50" showInWebsite="1" showInStore="1" showInDefault="1" translate="label">
<label>Payment Confirmed Status</label>
<source_model>Magento\Sales\Model\Config\Source\Order\Status\Processing</source_model>
<config_path>payment/pagaleve_upfront/payment_confirmed_status</config_path>
</field>
<field id="retry_deadline" type="text" sortOrder="60" showInWebsite="1" showInStore="1" showInDefault="1" translate="label">
<label>Retry deadline</label>
<config_path>payment/pagaleve_upfront/retry_deadline</config_path>
Expand Down
4 changes: 2 additions & 2 deletions etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<sandbox_mode>1</sandbox_mode>
<payment_action>authorize</payment_action>
<order_status_new>pending</order_status_new>
<order_status_processing>processing</order_status_processing>
<payment_confirmed_status>processing</payment_confirmed_status>
<token_url>https://api.pagaleve.com.br/v1/authentication</token_url>
<token_url_sandbox>https://sandbox-api.pagaleve.io/v1/authentication</token_url_sandbox>
<checkout_url>https://api.pagaleve.com.br/v1/checkouts</checkout_url>
Expand All @@ -52,7 +52,7 @@
<retry_deadline>2</retry_deadline>
<payment_action>authorize</payment_action>
<order_status_new>pending</order_status_new>
<order_status_processing>processing</order_status_processing>
<payment_confirmed_status>processing</payment_confirmed_status>
<sort_order>2</sort_order>
</pagaleve_upfront>
</payment>
Expand Down

0 comments on commit 6ca5ae8

Please sign in to comment.