-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adiciona método de pagamento Bolepix (#170)
* feat: creating PIX gateway class * feat: processando pagamentos com o método de pagamento PIX * feat: adicionando script para copiar código pix * fix: add cursor pointer no botão de copiar pix code * feat: criando renovação de cobrança PIX * fix: passando variavel order_id para a página de assinatura para poder ser possível utilizar o botão de gerar novo Qr code * feat: invertendo verificação na visualização de Qr Code para restringir a opção de renovação somente para pagamentos recorrentes * feat: melhorando compatibilidade com HPOS * fix: codeclimate issues * fix: codeclimate issues * fix: codeclimate issues * fix: codeclimate issues * fix: codeclimate issues * fix: codeclimate issues * fix: codeclimate issues * fix: codeclimate issues * fix: codeclimate issues * fix: codeclimate issues * fix: codeclimate issues * fix: codeclimate issues * fix: codeclimate issues * fix: codeclimate issues * fix: codeclimate issues * fix: codeclimate issues * fix: codeclimate issues * fix: codeclimate issues * fix: codeclimate issues * fix: codeclimate issues * fix: codeclimate issues * fix: codeclimate issues * fix: codeclimate issues * fix: codeclimate issues * fix: codeclimate issues * fix: codeclimate issues * fix: codeclimate issues * fix: codeclimate issues * fix: codeclimate issues * fix: codeclimate issues * fix: codeclimate issues * fix: codeclimate issues * fix: codeclimate issues * fix: codeclimate issues * fix: codeclimate issues * fix: codeclimate issues * fix: codeclimate issues * fix: codeclimate issues * fix: codeclimate issues * fix: codeclimate issues * fix: codeclimate issues * fix: codeclimate issues * fix: codeclimate issues * fix: codeclimate issues * fix: codeclimate issues * fix: codeclimate issues * fix: codeclimate issues * fix: codeclimate issues * fix: codeclimate issues * fix: trocando texto do método de pagamento pix * fix: verificação de tipo de transação para webhook * fix: removendo propriedade de pattern * fix: codeclimate issues * docs: update documentation files * feat: iniciando a criação do novo método de pagamento Bolepix * feat: adicionando suporte para bolepix no processo de pagamento * feat: criando visualização na thankyou page e processando pagamento * fix: codeclimate issues * fix: codeclimate issues * fix: codeclimate issues * fix: codeclimate issues * run ci * run ci * fix: codeclimate issues * fix: complexidade da função payment_method_code * fix: complexidade da função create_bill_meta_for_order * fix: adicionando timezone para verificação de vencimento do QRcode * fix: Line exceeds 120 characters; contains 146 characters * docs: atualiza número de versão do plugin * fix: corrigindo palavra expiration no template de visualização de PIX * fix: corrigindo textos nas classes de PIX e Bolepix * fix: corrigindo identação no arquivo VindiWooCommerce.php * fix: bug ao salvar produtos do tipo assinatura * fix: Line indented incorrectly; expected at least 12 spaces, found 10 * docs: update readme.txt * fix: atualiza identação do arquivo VindiWooCommerce.php
- Loading branch information
Showing
14 changed files
with
292 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
<?php | ||
|
||
namespace VindiPaymentGateways; | ||
|
||
/** | ||
* Vindi Payment Bolepix Gateway class. | ||
* | ||
* Extended by individual payment gateways to handle payments. | ||
* | ||
* @class VindiBolepixGateway | ||
* @extends VindiPaymentGateway | ||
*/ | ||
class VindiBolepixGateway extends VindiPaymentGateway | ||
{ | ||
/** | ||
* @var VindiSettings | ||
*/ | ||
public $vindiSettings; | ||
|
||
/** | ||
* @var VindiControllers | ||
*/ | ||
public $controllers; | ||
|
||
/** | ||
* Constructor for the gateway. | ||
*/ | ||
public function __construct(VindiSettings $vindiSettings, VindiControllers $controllers) | ||
{ | ||
$this->id = 'vindi-bolepix'; | ||
$this->icon = apply_filters('vindi_woocommerce_bolepix_icon', ''); | ||
$this->method_title = __('Vindi - Bolepix', VINDI); | ||
$this->method_description = __('Aceitar pagamentos via Bolepix utilizando a Vindi.', VINDI); | ||
$this->has_fields = true; | ||
$this->supports = array( | ||
'subscriptions', | ||
'products', | ||
'subscription_cancellation', | ||
'subscription_reactivation', | ||
'subscription_suspension', | ||
'subscription_amount_changes', | ||
'subscription_payment_method_change', | ||
'subscription_payment_method_change_customer', | ||
'subscription_payment_method_change_admin', | ||
'subscription_date_changes', | ||
'multiple_subscriptions', | ||
'pre-orders' | ||
); | ||
$this->init_form_fields(); | ||
$this->init_settings(); | ||
add_action('woocommerce_view_order', array(&$this, 'show_bolepix_download'), -10, 1); | ||
add_action('woocommerce_thankyou_' . $this->id, array(&$this, 'thank_you_page')); | ||
parent::__construct($vindiSettings, $controllers); | ||
} | ||
|
||
/** | ||
* Should return payment type for payment processing. | ||
* @return string | ||
*/ | ||
public function type() | ||
{ | ||
return 'bolepix'; | ||
} | ||
|
||
public function init_form_fields() | ||
{ | ||
|
||
$this->form_fields = array( | ||
'enabled' => array( | ||
'title' => __('Habilitar/Desabilitar', VINDI), | ||
'label' => __('Habilitar pagamento por Bolepix com Vindi', VINDI), | ||
'type' => 'checkbox', | ||
'default' => 'no', | ||
), | ||
'title' => array( | ||
'title' => __('Título', VINDI), | ||
'type' => 'text', | ||
'description' => __('Título que o cliente verá durante o processo de pagamento.', VINDI), | ||
'default' => __('Bolepix', VINDI), | ||
) | ||
); | ||
} | ||
|
||
# Essa função é responsável por verificar a compra que está sendo feita | ||
# No caso de uma assinatura única, o $order[0] não existirá e retornará ela mesmo | ||
# Issue: https://github.com/vindi/vindi-woocommerce/issues/75 | ||
public function bolepix_quantity_to_render($order) | ||
{ | ||
if (!isset($order[0])) { | ||
return $order; | ||
} | ||
|
||
return $order[0]; | ||
} | ||
|
||
public function payment_fields() | ||
{ | ||
$user_country = $this->get_country_code(); | ||
|
||
if (empty($user_country)) { | ||
_e('Selecione o País para visualizar as formas de pagamento.', VINDI); | ||
return; | ||
} | ||
|
||
$is_single_order = $this->is_single_order(); | ||
$is_trial = $this->vindi_settings->get_is_active_sandbox(); | ||
if ($is_trial) { | ||
$is_trial = $this->routes->isMerchantStatusTrialOrSandbox(); | ||
} | ||
|
||
$this->vindi_settings->get_template('bolepix-checkout.html.php', compact('is_trial', 'is_single_order')); | ||
} | ||
|
||
public function thank_you_page($order_id) | ||
{ | ||
$order = wc_get_order($order_id); | ||
$vindi_order = []; | ||
$order_to_iterate = 0; | ||
|
||
if ($order->get_payment_method() == 'vindi-bolepix') { | ||
$vindi_order = $order->get_meta('vindi_order', true); | ||
$order_to_iterate = $this->bolepix_quantity_to_render($vindi_order); | ||
$this->vindi_settings->get_template( | ||
'bolepix-download.html.php', | ||
compact('vindi_order', 'order_to_iterate', 'order_id') | ||
); | ||
} | ||
} | ||
|
||
public function show_bolepix_download($order_id) | ||
{ | ||
$order = wc_get_order($order_id); | ||
$vindi_order = []; | ||
$order_to_iterate = 0; | ||
|
||
if ($order->get_payment_method() == 'vindi-bolepix') { | ||
$vindi_order = $order->get_meta('vindi_order', true); | ||
$order_to_iterate = $this->bolepix_quantity_to_render($vindi_order); | ||
if (!$order->is_paid() && !$order->has_status('cancelled')) { | ||
$this->vindi_settings->get_template( | ||
'bolepix-download.html.php', | ||
compact('vindi_order', 'order_to_iterate', 'order_id') | ||
); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
if (!defined('ABSPATH')) { | ||
exit; | ||
} | ||
?> | ||
|
||
<?php if ($is_trial) : ?> | ||
<div style="padding: 10px;border: 1px solid #f00; background-color: #fdd; color: #f00; margin: 10px 2px"> | ||
<h3 style="color: #f00"><?php _e('MODO DE TESTES', VINDI); ?></h3> | ||
<p> | ||
<?php _e( | ||
'Sua conta na Vindi está em <strong>Modo Trial</strong>. | ||
Este modo é proposto para a realização de testes e, portanto, | ||
nenhum pedido será efetivamente cobrado.', | ||
VINDI | ||
); ?> | ||
</p> | ||
</div> | ||
<?php endif; ?> | ||
<fieldset> | ||
<?php do_action('vindi_bolepix_form_start'); ?> | ||
|
||
<div class="vindi-invoice-description" style="padding: 20px 0; font-weight: bold;"> | ||
<?php | ||
_e('Após confirmar o pedido, use PIX ou Boleto Bancário para efetuar o pagamento.', VINDI); | ||
?> | ||
</div> | ||
<div class="clear"></div> | ||
|
||
<?php do_action('vindi_bolepix_form_end'); ?> | ||
|
||
<div class="clear"></div> | ||
</fieldset> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<?php | ||
if (!defined('ABSPATH')) { | ||
exit; | ||
} | ||
?> | ||
<?php if (isset($vindi_order)) : ?> | ||
<div class="vindi_payment_listing"> | ||
<div class="info_message"> | ||
<div class="icon"></div> | ||
<div class="message"> | ||
<p class="message_title"> | ||
<?php _e('Aqui estão as sua cobranças com Bolepix.', VINDI); ?> | ||
</p> | ||
<p class="message_description"> | ||
<?php | ||
_e( | ||
'Você pode pagar utilizando PIX ou Boleto Bancário. | ||
Após recebermos a confirmação do pagamento, seu pedido será processado.', | ||
VINDI | ||
); | ||
?> | ||
</p> | ||
</div> | ||
</div> | ||
<div class="charges"> | ||
<?php foreach ($order_to_iterate as $key => $subscription) : ?> | ||
<?php if (is_array($subscription) && array_key_exists('product', $subscription) | ||
&& !in_array($subscription['bill']['status'], array('paid', 'canceled'))) : ?> | ||
<div class="bolepix_charge charge"> | ||
<span class="bolepix_product_title product_title"> | ||
<?php echo $subscription['product']; ?> | ||
</span> | ||
<div> | ||
<div class="qr_code_viwer"> | ||
<object type="image/svg+xml" | ||
alt="QR Code image" | ||
data="<?php echo esc_url($subscription['bill']['pix_qr']); ?>"> | ||
</object> | ||
</div> | ||
<div style="display: flex; | ||
flex-direction: column; | ||
align-items: end; | ||
justify-content: end; | ||
position: relative; | ||
right: 75px;"> | ||
<a id="copy_vindi_bolepix_code" | ||
class="download_button copy_vindi_line" | ||
data-code="<?php echo esc_attr($subscription['bill']['pix_code']); ?>"> | ||
<?php _e('Copiar código PIX', VINDI); ?> | ||
</a> | ||
<a class="download_button" | ||
href="<?php echo esc_url($subscription['bill']['bank_slip_url']); ?>" | ||
target="_blank"> | ||
<?php _e('Baixar boleto', VINDI); ?> | ||
<svg color="#006DFF" | ||
style="padding: 0 5px;" | ||
xmlns="http://www.w3.org/2000/svg" | ||
viewBox="0 0 512 512"> | ||
<path d="M288 32c0-17.7-14.3-32-32-32s-32 | ||
14.3-32 32V274.7l-73.4-73.4c-12.5-12.5-32.8-12.5-45.3 | ||
0s-12.5 32.8 0 45.3l128 128c12.5 12.5 32.8 12.5 | ||
45.3 0l128-128c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 | ||
0L288 274.7V32zM64 352c-35.3 0-64 28.7-64 64v32c0 35.3 | ||
28.7 64 64 64H448c35.3 0 64-28.7 | ||
64-64V416c0-35.3-28.7-64-64-64H346.5l-45.3 | ||
45.3c-25 25-65.5 25-90.5 0L165.5 352H64zm368 | ||
56a24 24 0 1 1 0 48 24 24 0 1 1 0-48z"/> | ||
</svg> | ||
</a> | ||
</div> | ||
</div> | ||
</div> | ||
<?php endif; ?> | ||
<?php endforeach; ?> | ||
</div> | ||
</div> | ||
<?php endif; ?> |
Oops, something went wrong.