Skip to content

Commit

Permalink
feat(payment): introduce new type of receive for proof of the payment…
Browse files Browse the repository at this point in the history
… via WhatsApp

Introduce a new feature to facilitate proof of payment submission by customers. This enhancement adds a new type of receive for proof of the payment. Now, customers can conveniently submit proof of payment by sending it through WhatsApp to the store.
  • Loading branch information
GabrielFNLima committed Nov 13, 2023
1 parent dd34aa4 commit 5b8eb80
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 8 deletions.
12 changes: 11 additions & 1 deletion Block/Info/PixQrCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,18 @@ public function getPayloadPix()
return $info['payload_pix'] ?? '';
}

public function getTypeOfProofPayment()
{
return $this->helper->getStoreConfigValue('payment/gfnl_pixqrcode/type_proof_payment');
}

public function getEmailForConfirmation()
{
return $this->helper->getStoreConfigValue('payment/gfnl_pixqrcode/send_proof_payment');
return $this->helper->getStoreConfigValue('payment/gfnl_pixqrcode/send_proof_payment_to_email');
}

public function getWhastappNumber()
{
return $this->helper->getStoreConfigValue('payment/gfnl_pixqrcode/send_proof_payment_to_whatsapp_number');
}
}
15 changes: 13 additions & 2 deletions Block/Success.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,18 @@ public function getOrder()
return $this->orderModel->loadByIncrementId($orderId);
}

public function getEmailForConfirmation(){
return $this->helper->getStoreConfigValue('payment/gfnl_pixqrcode/send_proof_payment');
public function getTypeOfProofPayment()
{
return $this->helper->getStoreConfigValue('payment/gfnl_pixqrcode/type_proof_payment');
}

public function getEmailForConfirmation()
{
return $this->helper->getStoreConfigValue('payment/gfnl_pixqrcode/send_proof_payment_to_email');
}

public function getWhastappNumber()
{
return $this->helper->getStoreConfigValue('payment/gfnl_pixqrcode/send_proof_payment_to_whatsapp_number');
}
}
22 changes: 22 additions & 0 deletions Model/Adminhtml/System/Config/Source/TypeProofPayment.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace GFNL\PixQrCode\Model\Adminhtml\System\Config\Source;

use Magento\Framework\Option\ArrayInterface;

class TypeProofPayment implements ArrayInterface
{

/**
* @inheritDoc
*/
public function toOptionArray()
{
$options = [
"by_whatsapp" => "By Whatsapp",
"by_email" => "By E-mail"
];

return $options;
}
}
28 changes: 25 additions & 3 deletions etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,35 @@
<label>Comment</label>
<comment>Comment that will appear at checkout for the customer.</comment>
</field>
<field id="send_proof_payment" translate="label comment" type="text" sortOrder="4" showInDefault="1"
<field id="type_proof_payment" translate="label" type="select" sortOrder="4" showInDefault="1"
showInWebsite="1" showInStore="1">
<label>Select Type of receive for proof of the payment</label>
<source_model>GFNL\PixQrCode\Model\Adminhtml\System\Config\Source\TypeProofPayment</source_model>
<validate>validate-select</validate>
</field>
<field id="send_proof_payment_to_email" translate="label comment" type="text" sortOrder="5"
showInDefault="1"
showInWebsite="1"
showInStore="1">
<label>Email to send the proof of payment</label>
<label>E-mail</label>
<validate>required-entry validate-email</validate>
<depends>
<field id="active">1</field>
<field id="type_proof_payment">by_email</field>
</depends>
</field>
<field id="send_proof_payment_to_whatsapp_number" translate="label comment" type="text" sortOrder="5"
showInDefault="1"
showInWebsite="1"
showInStore="1">
<label>WhatsApp Number</label>
<comment>
<![CDATA[
exemplo: 5561912345678<br>55: código do país.<br>61: código do território ou estado.<br>912345678: número do telefone celular.
]]>
</comment>
<validate>required-entry</validate>
<depends>
<field id="type_proof_payment">by_whatsapp</field>
</depends>
</field>
<field id="pix_key" translate="label comment" type="text" sortOrder="5" showInDefault="1"
Expand Down
2 changes: 2 additions & 0 deletions i18n/pt_BR.csv
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@
"Merchant Name","Nome do titular da chave pix"
"Merchant City","Cidade do titular da chave pix"
"An error occurred in your payment, Please contact the store.","Ocorreu um erro no seu pagamento. Por favor, entre em contato com a loja."
"Select Type of receive for proof of the payment","Selecione o tipo de recebimento para comprovação do pagamento"
"Whatsapp Number","Número do WhastsApp
11 changes: 10 additions & 1 deletion view/frontend/templates/checkout/success.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,16 @@ $payloadPix = $paymentInfo['payload_pix'] ?? '';
<div class="separate-bar"></div>
<div class="instruction">
<span><?= __('Instruções após pagamento') ?></span>
<p><?= __("Após efetuar o pagamento, por favor, nos envie o comprovante para o e-mail: <a href='mailto:%1&subject=Comporvante de pagamento para o pedido: #%2'>%1</a> junto com seu número de pedido: #%2", $block->getEmailForConfirmation(), $order->getIncrementId()) ?></p>
<?php if ($block->getTypeOfProofPayment() === 'by_email'): ?>
<p>
<?= __("Após efetuar o pagamento, por favor, nos envie o comprovante para o e-mail: <a href='mailto:%1&subject=Comporvante de pagamento para o pedido: #%2'>%1</a> junto com seu número de pedido: #%2", $block->getEmailForConfirmation(), $order->getIncrementId()) ?>
</p>
<?php endif; ?>
<?php if ($block->getTypeOfProofPayment() === 'by_whatsapp'): ?>
<p>
<?= __("Após efetuar o pagamento, por favor, nos envie o comprovante pelo número de WhatsApp <a href='https://api.whatsapp.com/send?phone=%1&text=Segue o comprovante para o pedido: %2' target='_blank'>%1</a>.", $block->getWhastappNumber(), $order->getIncrementId()) ?>
</p>
<?php endif; ?>
</div>
</div>

Expand Down
11 changes: 10 additions & 1 deletion view/frontend/templates/info/pixqrcode.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,16 @@ $paymentTitle = $block->getMethod()->getConfigData('title', $block->getOrder()->
</div>
<div class="instruction">
<span><?= __("Instruções após pagamento") ?></span>
<p><?= __("Após efetuar o pagamento, por favor, nos envie o comprovante para o e-mail: <a href='mailto:%1&subject=Comporvante de pagamento para o pedido: #%2'>%1</a> junto com seu número de pedido: #%2", $block->getEmailForConfirmation(), $order->getIncrementId()) ?></p>
<?php if ($block->getTypeOfProofPayment() === 'by_email'): ?>
<p>
<?= __("Após efetuar o pagamento, por favor, nos envie o comprovante para o e-mail: <a href='mailto:%1&subject=Comporvante de pagamento para o pedido: #%2'>%1</a> junto com seu número de pedido: #%2", $block->getEmailForConfirmation(), $order->getIncrementId()) ?>
</p>
<?php endif; ?>
<?php if ($block->getTypeOfProofPayment() === 'by_whatsapp'): ?>
<p>
<?= __("Após efetuar o pagamento, por favor, nos envie o comprovante pelo número de WhatsApp <a href='https://api.whatsapp.com/send?phone=%1&text=Segue o comprovante para o pedido: %2' target='_blank'>%1</a>.", $block->getWhastappNumber(), $order->getIncrementId()) ?>
</p>
<?php endif; ?>
</div>
</div>
<?php endif; ?>
Expand Down

0 comments on commit 5b8eb80

Please sign in to comment.