Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.12.0 Adição de compatibilidade com novas funcionalidades do WooCommerce Cielo PRO #103

Merged
merged 9 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
uses: mathieudutour/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
custom_tag: "1.11.5"
custom_tag: "1.12.0"

# Generate new release
- name: Generate new Release
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 1.12.0 - 22/10/2024
* Adição de compatibilidade com novas funcionalidades do WooCommerce Cielo PRO.

# 1.11.5 - 10/10/2024
* Correção em validação de nonce;
* Alteração em placeholders.
Expand Down
30 changes: 28 additions & 2 deletions README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,37 @@ Donate link: https://www.linknacional.com.br/wordpress/woocommerce/cielo/
Tags: woocommerce, payment, paymethod, card, credit
Requires at least: 5.7
Tested up to: 6.6
Stable tag: 1.11.5
Stable tag: 1.12.0
Requires PHP: 7.2
License: GPLv3 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
License URI: https://www.gnu.org/licenses/gpl-3.0.html

Payment Gateway for Cielo API on WooCommerce.

== Description ==

The **Cielo API Payment Gateway for WooCommerce** is a payment plugin for WooCommerce that allows you to integrate your online store with Cielo, one of Brazil's leading payment solutions. With this plugin, you can offer your customers the ability to pay with **credit** and **debit cards**, with **3DS support**, ensuring secure and fast transactions.

The plugin is easy to configure and enables the use of the main cards accepted by Cielo, integrating natively with WooCommerce and streamlining the checkout experience in your store.

**Main Features:**
- Support for **credit and debit cards**;
- Integration with **3DS** for secure transactions;
- Intuitive configuration directly in WooCommerce;
- Compatible with the main card brands accepted by Cielo.

**PRO Version**
In addition to the free version's features, the **Cielo API Payment Gateway for WooCommerce PRO** offers a range of advanced features to expand your store’s payment options and transaction management:

- **Full and partial refunds** directly from the WooCommerce dashboard;
- Support for **international currency payments**;
- **Recurring payments**, ideal for subscriptions and payment plans;
- Integration with **Pix**, an instant payment solution;
- The ability to offer **installments up to 18x**;
- Configuration of the **maximum number of installments** and **minimum installment amount**, providing greater flexibility in offering payment terms.

With the [PRO version](https://www.linknacional.com.br/wordpress/woocommerce/cielo/), you'll have access to a robust and complete solution to manage all types of transactions, providing a more convenient and personalized shopping experience for your customers.

**Dependencies**

Payment Gateway for Cielo API on WooCommerce plugin is dependent on WooCommerce plugin, please make sure WooCommerce is installed and properly configured before starting Payment Gateway for Cielo API on WooCommerce installation.
Expand Down Expand Up @@ -71,6 +93,10 @@ Payment Gateway for Cielo API on WooCommerce plugin is dependent on WooCommerce
7. Debit card front page with payment fields.

== Changelog ==
= 1.12.0 =
**22/10/2024**
* Add compatibility with new WooCommerce Cielo PRO features.

= 1.11.5 =
**10/10/2024**
* Fix nonce validation;
Expand Down
251 changes: 126 additions & 125 deletions includes/LknWCGatewayCieloCredit.php
Original file line number Diff line number Diff line change
Expand Up @@ -300,130 +300,132 @@ public function payment_fields(): void {

echo wp_kses_post(wpautop($this->description)); ?>

<fieldset
id="wc-<?php echo esc_attr($this->id); ?>-cc-form"
class="wc-credit-card-form wc-payment-form"
style="background:transparent;"
>

<?php do_action('woocommerce_credit_card_form_start', $this->id); ?>
<input
type="hidden"
name="nonce_lkn_cielo_credit"
class="nonce_lkn_cielo_credit"
value="<?php echo esc_attr($nonce); ?>"
/>

<div class="form-row form-row-wide">
<label
for="lkn_cc_cardholder_name"><?php esc_html_e('Card Holder Name', 'lkn-wc-gateway-cielo'); ?>
<span class="required">*</span></label>
<input
id="lkn_cc_cardholder_name"
name="lkn_cc_cardholder_name"
type="text"
autocomplete="cc-name"
required
placeholder="<?php echo $placeholderEnabled ? esc_attr('John Doe') : ''; ?>"
data-placeholder="<?php echo $placeholderEnabled ? esc_attr('John Doe') : ''; ?>"
<fieldset
id="wc-<?php echo esc_attr($this->id); ?>-cc-form"
class="wc-credit-card-form wc-payment-form"
style="background:transparent;"
>
</div>

<div class="form-row form-row-wide">
<label
for="lkn_ccno"><?php esc_html_e('Card Number', 'lkn-wc-gateway-cielo'); ?>
<span class="required">*</span></label>
<input
id="lkn_ccno"
name="lkn_ccno"
type="tel"
inputmode="numeric"
class="lkn-card-num"
maxlength="24"
required
placeholder="<?php echo $placeholderEnabled ? esc_attr('XXXX XXXX XXXX XXXX') : ''; ?>"
data-placeholder="<?php echo $placeholderEnabled ? esc_attr('XXXX XXXX XXXX XXXX') : ''; ?>"
>
</div>
<div class="form-row form-row-wide">
<label
for="lkn_cc_expdate"><?php esc_html_e('Expiry Date', 'lkn-wc-gateway-cielo'); ?>
<span class="required">*</span></label>
<input
id="lkn_cc_expdate"
name="lkn_cc_expdate"
type="tel"
inputmode="numeric"
class="lkn-card-exp"
maxlength="7"
required
placeholder="<?php echo $placeholderEnabled ? esc_attr('MM/YY') : ''; ?>"
data-placeholder="<?php echo $placeholderEnabled ? esc_attr('MM/YY') : ''; ?>"
>
</div>
<div class="form-row form-row-wide">
<label
for="lkn_cc_cvc"><?php esc_html_e('Security Code', 'lkn-wc-gateway-cielo'); ?>
<span class="required">*</span></label>
<input
id="lkn_cc_cvc"
name="lkn_cc_cvc"
type="tel"
inputmode="numeric"
class="lkn-cvv"
maxlength="8"
required
placeholder="<?php echo $placeholderEnabled ? esc_attr('CVV') : ''; ?>"
data-placeholder="<?php echo $placeholderEnabled ? esc_attr('CVV') : ''; ?>"
>
</div>
<?php
if ('yes' === $activeInstallment) {
?>
<input
id="lkn_cc_installment_total"
type="hidden"
value="<?php echo esc_attr($total_cart); ?>"
>
<input
id="lkn_cc_no_login_checkout"
type="hidden"
value="<?php echo esc_attr($noLoginCheckout); ?>"
>
<input
id="lkn_cc_installment_limit"
type="hidden"
value="<?php echo esc_attr($installmentLimit); ?>"
>
<input
id="lkn_cc_installment_interest"
type="hidden"
value="<?php echo esc_attr(wp_json_encode($installments)); ?>"
>

<div class="form-row form-row-wide">
<select
id="lkn_cc_installments"
name="lkn_cc_installments"
>
<option
value="1"
selected="1"
>1 x R$0,00 sem juros</option>
</select>
</div>
<?php
} ?>
<div id="lkn-cc-notice"></div>
<div class="clear"></div>

<?php do_action('woocommerce_credit_card_form_end', $this->id); ?>

<div class="clear"></div>

</fieldset>

<?php
<?php do_action('woocommerce_credit_card_form_start', $this->id); ?>
<input
type="hidden"
name="nonce_lkn_cielo_credit"
class="nonce_lkn_cielo_credit"
value="<?php echo esc_attr($nonce); ?>"
/>

<div class="form-row form-row-wide">
<label
for="lkn_cc_cardholder_name"><?php esc_html_e('Card Holder Name', 'lkn-wc-gateway-cielo'); ?>
<span class="required">*</span></label>
<input
id="lkn_cc_cardholder_name"
name="lkn_cc_cardholder_name"
type="text"
autocomplete="cc-name"
required
placeholder="<?php echo $placeholderEnabled ? esc_attr('John Doe') : ''; ?>"
data-placeholder="<?php echo $placeholderEnabled ? esc_attr('John Doe') : ''; ?>"
>
</div>

<div class="form-row form-row-wide">
<label
for="lkn_ccno"><?php esc_html_e('Card Number', 'lkn-wc-gateway-cielo'); ?>
<span class="required">*</span></label>
<input
id="lkn_ccno"
name="lkn_ccno"
type="tel"
inputmode="numeric"
class="lkn-card-num"
maxlength="24"
required
placeholder="<?php echo $placeholderEnabled ? esc_attr('XXXX XXXX XXXX XXXX') : ''; ?>"
data-placeholder="<?php echo $placeholderEnabled ? esc_attr('XXXX XXXX XXXX XXXX') : ''; ?>"
>
</div>
<div class="form-row form-row-wide">
<label
for="lkn_cc_expdate"><?php esc_html_e('Expiry Date', 'lkn-wc-gateway-cielo'); ?>
<span class="required">*</span></label>
<input
id="lkn_cc_expdate"
name="lkn_cc_expdate"
type="tel"
inputmode="numeric"
class="lkn-card-exp"
maxlength="7"
required
placeholder="<?php echo $placeholderEnabled ? esc_attr('MM/YY') : ''; ?>"
data-placeholder="<?php echo $placeholderEnabled ? esc_attr('MM/YY') : ''; ?>"
>
</div>
<div class="form-row form-row-wide">
<label
for="lkn_cc_cvc"><?php esc_html_e('Security Code', 'lkn-wc-gateway-cielo'); ?>
<span class="required">*</span></label>
<input
id="lkn_cc_cvc"
name="lkn_cc_cvc"
type="tel"
inputmode="numeric"
class="lkn-cvv"
maxlength="8"
required
placeholder="<?php echo $placeholderEnabled ? esc_attr('CVV') : ''; ?>"
data-placeholder="<?php echo $placeholderEnabled ? esc_attr('CVV') : ''; ?>"
>
</div>
<?php
if ('yes' === $activeInstallment) {
?>
<input
id="lkn_cc_installment_total"
type="hidden"
value="<?php echo esc_attr($total_cart); ?>"
>
<input
id="lkn_cc_no_login_checkout"
type="hidden"
value="<?php echo esc_attr($noLoginCheckout); ?>"
>
<input
id="lkn_cc_installment_limit"
type="hidden"
value="<?php echo esc_attr($installmentLimit); ?>"
>
<input
id="lkn_cc_installment_interest"
type="hidden"
value="<?php echo esc_attr(wp_json_encode($installments)); ?>"
>

<div class="form-row form-row-wide">
<select
id="lkn_cc_installments"
name="lkn_cc_installments"
>
<option
value="1"
selected="1"
>1 x R$0,00 sem juros</option>
</select>
</div>
<?php
} ?>
<div id="lkn-cc-notice"></div>
<div class="clear"></div>

<?php do_action('woocommerce_credit_card_form_end', $this->id); ?>

<div class="clear"></div>

</fieldset>

<?php

do_action('lkn_wc_cielo_remove_cardholder_name', $this);
}

/**
Expand All @@ -442,14 +444,12 @@ public function validate_fields() {
$ccnum = sanitize_text_field($_POST['lkn_ccno']);
$expDate = sanitize_text_field($_POST['lkn_cc_expdate']);
$cvv = sanitize_text_field($_POST['lkn_cc_cvc']);
$cardName = sanitize_text_field($_POST['lkn_cc_cardholder_name']);

$validCcNumber = $this->validate_card_number($ccnum, true);
$validExpDate = $this->validate_exp_date($expDate, true);
$validCvv = $this->validate_cvv($cvv, true);
$validCardHolder = $this->validate_card_holder_name($cardName, true);

if (true === $validCcNumber && true === $validExpDate && true === $validCvv && true === $validCardHolder) {
if (true === $validCcNumber && true === $validExpDate && true === $validCvv) {
return true;
}

Expand Down Expand Up @@ -484,6 +484,7 @@ public function process_payment($order_id) {
$cardExpShort = $cardExpSplit[0] . '/' . $cardExpSplit[1];
$cardCvv = sanitize_text_field($_POST['lkn_cc_cvc']);
$cardName = sanitize_text_field($_POST['lkn_cc_cardholder_name']);
$cardName = apply_filters('lkn_wc_cielo_get_cardholder_name', $cardName, $this, $order);
$installments = 1;

// POST parameters
Expand Down
Loading
Loading