Skip to content

Commit

Permalink
Merge pull request #172 from culqi/feature/enable-rsa
Browse files Browse the repository at this point in the history
Feature/enable rsa
  • Loading branch information
JoseHCalderon authored Sep 6, 2023
2 parents 32e8fd8 + a0d622d commit 51e5d54
Show file tree
Hide file tree
Showing 35 changed files with 326 additions and 55 deletions.
4 changes: 4 additions & 0 deletions admin/assets/css/form.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
margin-bottom: 1rem;
}

.tool.custom-ml::after {
margin-left: -20px;
}

@media (max-width: 576px) {
#woocommerce_culqi_login_button {
margin-left: 0!important;
Expand Down
2 changes: 1 addition & 1 deletion admin/class-fullculqi-admin.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

#[\AllowDynamicProperties]
class FullCulqi_Admin {

public function __construct() {
Expand Down
2 changes: 1 addition & 1 deletion admin/class-fullculqi-entities.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

#[\AllowDynamicProperties]
abstract class FullCulqi_Entities {

function __construct() {
Expand Down
2 changes: 1 addition & 1 deletion admin/class-fullculqi-payments.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

#[\AllowDynamicProperties]
class FullCulqi_Payments extends FullCulqi_Entities {

protected $post_type = 'culqi_payments';
Expand Down
2 changes: 1 addition & 1 deletion admin/class-fullculqi-settings.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

#[\AllowDynamicProperties]
class FullCulqi_Settings {

public function __construct() {
Expand Down
4 changes: 4 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
2023-09-01 - version 3.0.7
Fix: Add RSA encrypt
Fix: Add dynamic logos

2023-08-10 - version 3.0.6
Fix: fix: 3ds-challengue

Expand Down
12 changes: 6 additions & 6 deletions includes/3rd-party/plugins/woocommerce/assets/images/cards.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 44 additions & 0 deletions includes/3rd-party/plugins/woocommerce/assets/images/cards_old.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions includes/3rd-party/plugins/woocommerce/assets/images/yape.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 22 additions & 4 deletions includes/3rd-party/plugins/woocommerce/assets/js/wc-checkout.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ Culqi3DS.publicKey = fullculqi_vars.public_key;
* @return mixed
*/
setSettings: function() {
console.log(fullculqi_vars.rsa_pk);
Culqi.publicKey = fullculqi_vars.public_key;
let args_settings = {
title: fullculqi_vars.commerce,
Expand All @@ -127,12 +128,19 @@ Culqi3DS.publicKey = fullculqi_vars.public_key;
culqiclientversion: fullculqi_vars.version_wc,
culqipluginversion: fullculqi_vars.version_plugin
};
if(fullculqi_vars.rsa_id && fullculqi_vars.rsa_pk) {
args_settings.xculqirsaid = fullculqi_vars.rsa_id;
args_settings.rsapublickey = fullculqi_vars.rsa_pk;
}
console.log(fullculqi_vars.multi_order+':: el orderid');
if( fullculqi_vars.multi_order != '' ) {
args_settings.order = fullculqi_vars.multi_order;
}
console.log(args_settings);
Culqi.settings( args_settings );
Culqi.client = {
email: fullculqi_vars.culqi_customer_email
};
},
/**
* Set Culqi Options
Expand Down Expand Up @@ -373,8 +381,9 @@ Culqi3DS.publicKey = fullculqi_vars.public_key;
}

}else{
jQuery('#loadingloginculqi').remove();
$('#fullculqi_notify').addClass('woocommerce-error').html( 'Ha ocurrido un error procesando el pago. Por favor intente nuevamente o comuníquese con su entidad bancaria.');
scrollToCulqiError();;
scrollToCulqiError();
}

}
Expand All @@ -401,9 +410,8 @@ Culqi3DS.publicKey = fullculqi_vars.public_key;
data : post_data,

success: function( response ) {

$( document.body ).trigger('fullculqi.checkout.success', [ post_data, response ]);

if( response.success ) {
$( document.body ).trigger('fullculqi.checkout.success', [ post_data, response ]);
var enviroment = fullculqi_vars.enviroment.split('|');
$('#fullculqi_notify').empty();
if(Culqi.token==null){
Expand All @@ -418,6 +426,16 @@ Culqi3DS.publicKey = fullculqi_vars.public_key;
//alert('stop');
location.href = fullculqi_vars.url_success;
}
} else {
jQuery('#loadingloginculqi').remove();
if(response.data && response.data.message) {
$('#fullculqi_notify').addClass('woocommerce-error').html(response.data.message);
scrollToCulqiError();
} else {
$('#fullculqi_notify').addClass('woocommerce-error').html( 'Ha ocurrido un error procesando el pago. Por favor intente nuevamente o comuníquese con su entidad bancaria.');
scrollToCulqiError();
}
}


},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* @since 1.0.0
* @package Includes / 3rd-party / plugins / WooCommerce
*/

#[\AllowDynamicProperties]
class FullCulqi_WC_Admin {

public function __construct() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* @since 1.0.0
* @package Includes / 3rd-party / plugins / WooCommerce
*/

#[\AllowDynamicProperties]
class FullCulqi_WC {

public $log;
Expand Down Expand Up @@ -186,6 +188,7 @@ public function update_order( $culqi_order ) {
* [old_update_order description]
* @return [type] [description]
*/
/*
public function old_update_order() {
$inputJSON = file_get_contents('php://input');
Expand All @@ -210,7 +213,7 @@ public function old_update_order() {
echo wp_send_json( ['result' => 'success' ] );
die();
}

*/
/**
* Notice Currency
* @return html
Expand Down
111 changes: 98 additions & 13 deletions includes/3rd-party/plugins/woocommerce/class-fullculqi-wc-method.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* @since 1.0.0
* @packkage Includes / Method Payment
*/

#[\AllowDynamicProperties]
class WC_Gateway_FullCulqi extends WC_Payment_Gateway {

/**
Expand All @@ -25,12 +27,9 @@ public function __construct() {
$this->multipayment = $this->get_option( 'multipayment', 'no' );
$this->multi_duration = $this->get_option( 'multi_duration', 24 );
$this->multi_status = $this->get_option( 'multi_status', 'wc-pending' );
$allowed_html = array(
'strong' => array(),
);

$this->description = wp_kses(__('Acepta pagos con tarjetas de <strong>débito y crédito; Yape, Cuotéalo BCP y PagoEfectivo</strong> (billeteras móviles, agentes y bodegas).', 'fullculqi'), $allowed_html);
$this->instructions = $this->get_option( 'instructions', $this->description );
$this->description = $this->get_description();
$this->instructions = $this->get_option( 'instructions', $this->get_description() );
$this->msg_fail = $this->get_option( 'msg_fail' );
$this->time_modal = $this->get_option( 'time_modal', 0 );

Expand Down Expand Up @@ -78,9 +77,10 @@ public function process_ajax($order_id) {

$pnames = [];
$order = new WC_Order( $order_id );
$culqi_customer_email = "";
if (version_compare(WC_VERSION, "2.7", "<")) {
$log = new FullCulqi_Logs( $order_id );

$culqi_customer_email = $order->billing_email;
$settings = fullculqi_get_settings();
//var_dump($settings); exit(1);
// Disabled from thirds
Expand Down Expand Up @@ -171,6 +171,7 @@ public function process_ajax($order_id) {
}
}else{
$log = new FullCulqi_Logs( $order->get_id() );
$culqi_customer_email = $order->get_billing_email();

$settings = fullculqi_get_settings();
//var_dump($settings); exit(1);
Expand Down Expand Up @@ -306,6 +307,8 @@ public function process_ajax($order_id) {
'url_actions' => site_url( $wc_action_url ),
'url_success' => $order->get_checkout_order_received_url(),
'public_key' => sanitize_text_field( $settings['public_key'] ),
'rsa_id' => sanitize_text_field( $settings['rsa_id'] ),
'rsa_pk' => sanitize_text_field( $settings['rsa_pk'] ),
'installments' => sanitize_title( $this->installments ),
'multipayment' => sanitize_title( $this->multipayment ),
'multi_order' => ((isset($settings['methods']['cuetealo']) and $settings['methods']['cuetealo']!='0') or (isset($settings['methods']['billetera']) and $settings['methods']['billetera']!='0') or (isset($settings['methods']['agente']) and $settings['methods']['agente']!='0') or (isset($settings['methods']['bancaMovil']) and $settings['methods']['bancaMovil']!='0')) ? $culqi_order_id : '',
Expand Down Expand Up @@ -335,6 +338,7 @@ public function process_ajax($order_id) {
'wpnonce' => wp_create_nonce( 'fullculqi' ),
'enviroment' => $settings['enviroment'],
'url' => $returnUrl3DS,
'culqi_customer_email' => $culqi_customer_email
];
do_action( 'fullculqi/method/enqueue_scripts/pay_page', $order );
//}
Expand Down Expand Up @@ -544,15 +548,75 @@ public function process_payment( $order_id = 0 ) {

public function get_title() {
if (is_checkout() && !is_wc_endpoint_url()) {
return '<img class="wc-culqi-title" src="' . esc_url($this->culqi_logo) . '" alt="' . esc_attr($this->title) . '" />';
return '<div class="wc-culqi-container"><img class="wc-culqi-title" src="' . esc_url($this->culqi_logo) . '" alt="' . esc_attr($this->title) . '" />';
} else {
return esc_attr($this->title);
}
}

public function get_description() {
$settings = fullculqi_get_settings();
$tarjeta = (isset($settings['methods']['tarjeta']) and $settings['methods']['tarjeta']!='0');
$yape = (isset($settings['methods']['yape']) and $settings['methods']['yape']!='0');
$billetera = (isset($settings['methods']['billetera']) and $settings['methods']['billetera']!='0');
$bancaMovil = (isset($settings['methods']['bancaMovil']) and $settings['methods']['bancaMovil']!='0');
$agente = (isset($settings['methods']['agente']) and $settings['methods']['agente']!='0');
$cuotealo = (isset($settings['methods']['cuetealo']) and $settings['methods']['cuetealo']!='0');
$txt_general = 'Acepta pagos con ';
$txt = '';
$txtPE = '';
if($tarjeta) {
$txt .= 'tarjetas de débito y crédito';
}
if($yape) {
if($tarjeta) {
$txt .= ', ';
}
$txt .= 'Yape';
}
if($billetera || $bancaMovil || $agente || $cuotealo) {
if($tarjeta || $yape) {
$txt .= ', ';
}
$txt .= 'Cuotéalo BCP y PagoEfectivo';
$txtPE = ' (billeteras móviles, agentes y bodegas)';
}
$txt = '<strong>'.$txt.'</strong>';
$txt = $txt_general. $txt. $txtPE;
$txt .= '.';
$allowed_html = array(
'strong' => array(),
);

return wp_kses(__($txt, 'fullculqi'), $allowed_html);
}

public function get_icon() {
// Return the icon image
return '<img class="wc-culqi-icon" src="' . esc_url($this->icon) . '" alt="'.$this->payment_methods.'" />';
$settings = fullculqi_get_settings();
$tarjeta = (isset($settings['methods']['tarjeta']) and $settings['methods']['tarjeta']!='0');
$yape = (isset($settings['methods']['yape']) and $settings['methods']['yape']!='0');
$billetera = (isset($settings['methods']['billetera']) and $settings['methods']['billetera']!='0');
$bancaMovil = (isset($settings['methods']['bancaMovil']) and $settings['methods']['bancaMovil']!='0');
$agente = (isset($settings['methods']['agente']) and $settings['methods']['agente']!='0');
$cuetealo = (isset($settings['methods']['cuetealo']) and $settings['methods']['cuetealo']!='0');
//
$cards_img = MPCULQI_WC_URL . 'assets/images/cards.svg';
$yape_img = MPCULQI_WC_URL . 'assets/images/yape.svg';
$pagoefectivo_img = MPCULQI_WC_URL . 'assets/images/pagoefectivo.svg';
$final_image = '<div class="wc-culqi-icon-container">';
if($tarjeta) {
$final_image .= '<img class="wc-culqi-icon" src="' . esc_url($cards_img) . '" alt="'.$this->payment_methods.'" />';
}
if($yape) {
$final_image .= '<img class="wc-culqi-icon" src="' . esc_url($yape_img) . '" alt="'.$this->payment_methods.'" />';
}
if($billetera || $bancaMovil || $agente || $cuetealo) {
$final_image .= '<img class="wc-culqi-icon" src="' . esc_url($pagoefectivo_img) . '" alt="'.$this->payment_methods.'" />';
}
$final_image .= '</div></div>';

return $final_image;
}


Expand Down Expand Up @@ -754,25 +818,46 @@ public function custom_checkout_js() {
if (is_checkout() && !is_wc_endpoint_url()) {
?>
<style>
.wc-culqi-icon {
.wc-culqi-container {
max-width: 431px;
width: calc(100% - 50px);
display: inline-flex !important;
align-items: center;
justify-content: space-between;
flex-wrap: wrap;
}
.wc-culqi-icon-container {
float: right;
height: 24px;
display: flex;
}
.wc-culqi-icon {
height: 24px !important;
margin-left: 8px !important;
}
.wc-culqi-title {
float: none !important;
display: inline-block;
height: 20px;
height: 20px !important;
margin-left: 0 !important;
}
div.payment_method_fullculqi {
padding-left: 5px !important;
}
div.payment_method_fullculqi p {
font-size: 12px;
}
label[for=payment_method_fullculqi] {
width: calc(100% - 30px);
}
@media only screen and (max-width: 480px) {
.wc-culqi-icon {
float: none;
margin-top: 20px;
height: 23px !important;
}
.wc-culqi-title {
height: 18px !important;
}
label[for=payment_method_fullculqi] {
width: 100%;
}
}
</style>
Expand Down
Loading

0 comments on commit 51e5d54

Please sign in to comment.