Changeset 3042319
- Timestamp:
- 02/28/2024 06:52:06 AM (2 years ago)
- Location:
- valorpos
- Files:
-
- 18 edited
- 1 copied
-
tags/7.6.0 (copied) (copied from valorpos/trunk)
-
tags/7.6.0/README.txt (modified) (3 diffs)
-
tags/7.6.0/admin/class-wc-valorpay-admin.php (modified) (1 diff)
-
tags/7.6.0/admin/partials/wc-valorpay-admin-order-refund.php (modified) (1 diff)
-
tags/7.6.0/includes/class-wc-valorpay-api.php (modified) (5 diffs)
-
tags/7.6.0/includes/class-wc-valorpay-gateway-addons.php (modified) (1 diff)
-
tags/7.6.0/includes/class-wc-valorpay-gateway.php (modified) (3 diffs)
-
tags/7.6.0/languages/wc-valorpay.pot (modified) (6 diffs)
-
tags/7.6.0/public/class-wc-valorpay-public.php (modified) (1 diff)
-
tags/7.6.0/wc-valorpay.php (modified) (3 diffs)
-
trunk/README.txt (modified) (3 diffs)
-
trunk/admin/class-wc-valorpay-admin.php (modified) (1 diff)
-
trunk/admin/partials/wc-valorpay-admin-order-refund.php (modified) (1 diff)
-
trunk/includes/class-wc-valorpay-api.php (modified) (5 diffs)
-
trunk/includes/class-wc-valorpay-gateway-addons.php (modified) (1 diff)
-
trunk/includes/class-wc-valorpay-gateway.php (modified) (3 diffs)
-
trunk/languages/wc-valorpay.pot (modified) (6 diffs)
-
trunk/public/class-wc-valorpay-public.php (modified) (1 diff)
-
trunk/wc-valorpay.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
valorpos/tags/7.6.0/README.txt
r3002583 r3042319 5 5 Tested up to: 6.3.1 6 6 Requires PHP: 7.0 7 Stable tag: 7. 5.07 Stable tag: 7.6.0 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 18 18 19 19 Software Systems and Payment Devices from Valor are the best around for smart hassle-free transactions. Cost-efficient and super smart. With value-added features and reliable service support to match, you’d want Valor to be your partner for growth, always. 20 21 **WARNING:** The issue of tax price being calculated twice has been resolved in versions 7.3 and above. Please ensure that you are using version 7.3 or later to avoid encountering this problem. 20 22 21 23 == Installation == … … 40 42 41 43 == Changelog == 44 45 = 7.6.0 = 46 * Added support for High Performance Order Storage, Ecommerce device identifier, and allowing a subscription product with a $0 initial payment has been added. 42 47 43 48 = 7.5.0 = -
valorpos/tags/7.6.0/admin/class-wc-valorpay-admin.php
r2980555 r3042319 74 74 * class. 75 75 */ 76 global $post; 77 78 // Get admin screen id. 76 77 // Get admin screen id. 79 78 $screen = get_current_screen(); 80 79 $screen_id = isset( $screen->id ) ? $screen->id : ''; 81 80 82 if ( 'shop_order' === $screen_id) {81 if ( in_array( $screen_id, array( 'shop_order', 'woocommerce_page_wc-orders' ), true ) ) { 83 82 // Load order . 84 $order = wc_get_order( $post->ID);83 $order = wc_get_order(); 85 84 // Load JS file only for valor payment method . 86 if ( WC_ValorPay_Gateway::GATEWAY_ID === $order->get_payment_method() ) {85 if ( $order && WC_ValorPay_Gateway::GATEWAY_ID === $order->get_payment_method() ) { 87 86 wp_register_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/wc-valorpay-refund.js', array( 'jquery' ), $this->version, false ); 88 87 wp_enqueue_script( $this->plugin_name ); -
valorpos/tags/7.6.0/admin/partials/wc-valorpay-admin-order-refund.php
r2883367 r3042319 48 48 <div class="inner"> 49 49 <button id="btn-valor-otp" class="button button-primary button-large button-valor-submit"><?php echo esc_html_e( 'Submit', 'woocommerce' ); ?></button> 50 <button id="btn-valor-resend" class="button button-primary button-large button-valor-resend" style="display: none;"><?php echo esc_html_e( 'Resend OTP', 'w oocommerce' ); ?></button>50 <button id="btn-valor-resend" class="button button-primary button-large button-valor-resend" style="display: none;"><?php echo esc_html_e( 'Resend OTP', 'wc-valorpay' ); ?></button> 51 51 <span id="valor-resend-load" class="spinner" style="display: none;"></span> 52 52 </div> -
valorpos/tags/7.6.0/includes/class-wc-valorpay-api.php
r3002583 r3042319 48 48 */ 49 49 const WC_VALORPAY_BIN_LOOKUP_ACTION = 'binLookup'; 50 /** 51 * Card token action 52 */ 53 const WC_VALORPAY_CARD_TOKEN_ACTION = 'cardToken'; 54 /** 55 * Ecommerce Channel ID 56 */ 57 const WC_VALORPAY_ECOMM_CHANNEL = 'woocommerce'; 50 58 51 59 /** … … 199 207 $response = $this->post_transaction( wp_json_encode( $payload ), 'bin_lookup' ); 200 208 return $response; 209 } 210 211 /** 212 * Generate card token 213 * 214 * @since 7.6.0 215 * 216 * @param WC_Order $order Order Detail. 217 * @param array $card_detail Card detail. 218 */ 219 public function generate_card_token( $order, $card_detail ) { 220 $client_token_response = $this->create_checkout_page_token(); 221 if ( is_wp_error( $client_token_response ) || ! is_object( $client_token_response ) || ! isset( $client_token_response->clientToken ) ) { // phpcs:ignore 222 $order->add_order_note( __( 'Payment error: Unable to generate client token.', 'wc-valorpay' ) ); 223 return array( 224 'error' => __( 'Sorry, we\'re unable to create a card token right now.', 'wc-valorpay' ), 225 ); 226 } 227 $client_token = $client_token_response->clientToken; // phpcs:ignore 228 $args = array( 229 'txn_type' => self::WC_VALORPAY_CARD_TOKEN_ACTION, 230 'epi' => $this->gateway->epi, 231 'client_token' => $client_token, 232 'pan' => $card_detail['card_num'], 233 'expirydate' => $card_detail['card_expiry'], 234 ); 235 $request_url = add_query_arg( $args, $this->get_valorpay_url() ); 236 $api_args = array( 237 'headers' => array( 238 'Content-Type' => 'application/json', 239 ), 240 'method' => 'POST', 241 'timeout' => 70, 242 ); 243 $api_response = wp_remote_post( $request_url, $api_args ); 244 if ( is_wp_error( $api_response ) || empty( $api_response['body'] ) ) { 245 $order->add_order_note( __( 'Payment error: Unable to generate card token.', 'wc-valorpay' ) ); 246 return array( 247 'error' => __( 'Sorry, we\'re unable to create a card token right now.', 'wc-valorpay' ), 248 ); 249 } 250 $parsed_response = json_decode( preg_replace( '/\xEF\xBB\xBF/', '', $api_response['body'] ), true ); 251 if ( ! isset( $parsed_response['cardToken'] ) ) { 252 $order->add_order_note( __( 'Payment error: Unable to generate card token.', 'wc-valorpay' ) ); 253 return array( 254 'error' => __( 'Sorry, we\'re unable to create a card token right now.', 'wc-valorpay' ), 255 ); 256 } 257 return array( 258 'token' => $parsed_response['cardToken'], 259 ); 201 260 } 202 261 … … 277 336 'status' => 'Y', 278 337 'terms_checked' => $valorpay_terms, 338 'ecomm_channel' => self::WC_VALORPAY_ECOMM_CHANNEL, 279 339 ) + $surcharge_data; 280 340 … … 306 366 'epi' => $this->gateway->epi, 307 367 'ip' => WC_Geolocation::get_ip_address(), 308 'sales_refund' => 1,309 368 'ref_txn_id' => $order->get_transaction_id(), 310 'rrn' => $valorpay_order_meta['rrn'],311 369 'auth_code' => $valorpay_order_meta['approval_code'], 312 370 'surchargeIndicator' => ( 'yes' === $this->gateway->surcharge_indicator ) ? 1 : 0, 313 371 'otp' => $order->get_meta( '_valorpay_2fa_otp' ), 314 372 'uuid' => $order->get_meta( '_valorpay_otp_uuid' ), 315 ); 316 delete_post_meta( $order->get_id(), '_valorpay_2fa_otp' ); 317 delete_post_meta( $order->get_id(), '_valorpay_otp_uuid' ); 373 'ecomm_channel' => self::WC_VALORPAY_ECOMM_CHANNEL, 374 ); 375 $order->delete_meta_data( '_valorpay_2fa_otp' ); 376 $order->delete_meta_data( '_valorpay_otp_uuid' ); 377 $order->save(); 318 378 } elseif ( 'send_otp' === $transaction_type ) { 319 379 $data = array( … … 390 450 'surchargeIndicator' => $surcharge_indicator, 391 451 'surchargeAmount' => sprintf( '%.2f', $surcharge ), 452 'ecomm_channel' => self::WC_VALORPAY_ECOMM_CHANNEL, 392 453 ); 393 454 -
valorpos/tags/7.6.0/includes/class-wc-valorpay-gateway-addons.php
r3002598 r3042319 61 61 'post_meta' => array( 62 62 '_valorpay_card_token' => array( 63 'value' => get_post_meta( $subscription->id,'_valorpay_card_token', true ),63 'value' => $subscription->get_meta( '_valorpay_card_token', true ), 64 64 'label' => __( 'ValorPay Card Token', 'wc-valorpay' ), 65 65 ), 66 66 '_valorpay_card_type' => array( 67 'value' => get_post_meta( $subscription->id,'_valorpay_card_type', true ),67 'value' => $subscription->get_meta( '_valorpay_card_type', true ), 68 68 'label' => __( 'ValorPay Card Type', 'wc-valorpay' ), 69 69 ), -
valorpos/tags/7.6.0/includes/class-wc-valorpay-gateway.php
r3002583 r3042319 702 702 703 703 $valorpay_api = new WC_ValorPay_API( $this ); 704 // Check if subscription order or if order total is zero, then add the card token to subscriptions. 705 if ( class_exists( 'WC_Subscriptions_Order' ) && WC_Subscriptions_Order::order_contains_subscription( $order->get_id() ) && '0.00' === $amount ) { 706 if ( $card ) { 707 $subscription_payload = new stdClass(); 708 $subscription_payload->token = $card->get_token(); 709 $subscription_payload->expiry_date = $card->get_expiry_month() . substr( $card->get_expiry_year(), -2 ); 710 $is_debit_card = 'D' === WC()->session->get( 'valor_card_type' ); 711 } else { 712 $card_number = str_replace( ' ', '', ( isset( $_POST['wc_valorpay-card-number'] ) ) ? sanitize_text_field( wp_unslash( $_POST['wc_valorpay-card-number'] ) ) : '' ); // phpcs:ignore 713 $exp_date_array = explode( '/', sanitize_text_field( wp_unslash( $_POST['wc_valorpay-card-expiry'] ) ) ); // phpcs:ignore 714 $exp_month = trim( $exp_date_array[0] ); 715 $exp_year = trim( $exp_date_array[1] ); 716 $exp_date = $exp_month . substr( $exp_year, -2 ); 717 $card_detail = array( 718 'card_num' => $card_number, 719 'card_expiry' => $exp_date, 720 ); 721 $card_token_response = $valorpay_api->generate_card_token( $order, $card_detail ); 722 if ( isset( $card_token_response['error'] ) ) { 723 throw new Exception( $card_token_response['error'] ); 724 } 725 $subscription_payload = new stdClass(); 726 $subscription_payload->token = $card_token_response['token']; 727 $subscription_payload->expiry_date = $exp_month . substr( $exp_year, -2 ); 728 $is_debit_card = 'D' === WC()->session->get( 'valor_card_type' ); 729 } 730 $this->update_subscription_card_token( $order, $subscription_payload, $is_debit_card ); 731 $order->payment_complete(); 732 $order->add_order_note( __( 'Valor Pay: Card token added to subscription.', 'wc-valorpay' ) ); 733 return array( 734 'result' => 'success', 735 'redirect' => $this->get_return_url( $order ), 736 ); 737 } 704 738 // Call the sale or authorization API. 705 739 $response = $valorpay_api->purchase( $order, $amount, $card ); … … 728 762 $exp_year = trim( $exp_date_array[1] ); 729 763 $exp_date = $exp_month . substr( $exp_year, -2 ); 730 $response->card_type = $valorpay_api->get_card_type( str_replace( ' ', '', sanitize_text_field( wp_unslash( $_POST['wc_valorpay-card-number'] ) ) ) ); // phpcs:ignore764 $response->card_type = isset( $response->card_brand ) && $response->card_brand ? $response->card_brand : $valorpay_api->get_card_type( str_replace( ' ', '', sanitize_text_field( wp_unslash( $_POST['wc_valorpay-card-number'] ) ) ) ); // phpcs:ignore 731 765 $this->save_card( $response, $exp_date, ( 'D' === WC()->session->get( 'valor_card_type' ) ) ? 1 : 0 ); 732 766 } … … 739 773 'approval_code' => $response->approval_code, 740 774 ); 741 add_post_meta( $order_id, '_valorpay_transaction', $tran_meta ); 775 $order->add_meta_data( '_valorpay_transaction', $tran_meta ); 776 $order->save(); 742 777 $is_debit_card = 'D' === WC()->session->get( 'valor_card_type' ); 743 778 if ( class_exists( 'WC_Subscriptions_Order' ) && WC_Subscriptions_Order::order_contains_subscription( $order->get_id() ) ) { -
valorpos/tags/7.6.0/languages/wc-valorpay.pot
r3002583 r3042319 1 # Copyright (C) 202 3Valor Paytech LLC1 # Copyright (C) 2024 Valor Paytech LLC 2 2 # This file is distributed under the GPL-2.0+. 3 3 msgid "" 4 4 msgstr "" 5 "Project-Id-Version: Valor Pay 7. 5.0\n"5 "Project-Id-Version: Valor Pay 7.6.0\n" 6 6 "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/valorpos\n" 7 7 "Last-Translator: Valor Paytech LLC <isv@valorpaytech.com>\n" … … 10 10 "Content-Type: text/plain; charset=UTF-8\n" 11 11 "Content-Transfer-Encoding: 8bit\n" 12 "POT-Creation-Date: 202 3-11-20T06:34:41+00:00\n"13 "PO-Revision-Date: 202 3-11-20T06:34:41+00:00\n"12 "POT-Creation-Date: 2024-02-20T10:51:04+05:30\n" 13 "PO-Revision-Date: 2024-02-20T10:51:04+05:30\n" 14 14 "X-Generator: WP-CLI 2.7.1\n" 15 15 "X-Domain: wc-valorpay\n" … … 33 33 msgstr "" 34 34 35 #: admin/class-wc-valorpay-admin.php:11 935 #: admin/class-wc-valorpay-admin.php:118 36 36 msgid "Are you sure you want to remove?" 37 37 msgstr "" 38 38 39 #: admin/class-wc-valorpay-admin.php:13 839 #: admin/class-wc-valorpay-admin.php:137 40 40 msgid "Settings" 41 41 msgstr "" 42 42 43 #: admin/class-wc-valorpay-admin.php:19 744 #: admin/class-wc-valorpay-admin.php:29 243 #: admin/class-wc-valorpay-admin.php:196 44 #: admin/class-wc-valorpay-admin.php:291 45 45 msgid "Invalid Request." 46 46 msgstr "" 47 47 48 #: admin/class-wc-valorpay-admin.php:20 749 #: admin/class-wc-valorpay-admin.php:27 550 #: admin/class-wc-valorpay-admin.php:30 648 #: admin/class-wc-valorpay-admin.php:206 49 #: admin/class-wc-valorpay-admin.php:274 50 #: admin/class-wc-valorpay-admin.php:305 51 51 msgid "Error Occurred." 52 52 msgstr "" 53 53 54 #: admin/class-wc-valorpay-admin.php:24 254 #: admin/class-wc-valorpay-admin.php:241 55 55 msgid "Order Id Missing." 56 56 msgstr "" 57 57 58 #: admin/class-wc-valorpay-admin.php:24 658 #: admin/class-wc-valorpay-admin.php:245 59 59 msgid "Enter a valid refund amount." 60 60 msgstr "" 61 61 62 62 #. translators: 1: Email Address, 2: Mobile Number 63 #: admin/class-wc-valorpay-admin.php:2 7063 #: admin/class-wc-valorpay-admin.php:269 64 64 msgid "OTP sent to your registered Email Address %1$s and Mobile Number %2$s" 65 65 msgstr "" 66 66 67 #: admin/class-wc-valorpay-admin.php:29 767 #: admin/class-wc-valorpay-admin.php:296 68 68 msgid "Enter Valid OTP." 69 69 msgstr "" … … 123 123 msgstr "" 124 124 125 #: includes/class-wc-valorpay-api.php:420 126 #: includes/class-wc-valorpay-api.php:425 127 #: includes/class-wc-valorpay-api.php:433 128 #: includes/class-wc-valorpay-api.php:437 125 #: admin/partials/wc-valorpay-admin-order-refund.php:50 126 msgid "Resend OTP" 127 msgstr "" 128 129 #: includes/class-wc-valorpay-api.php:222 130 msgid "Payment error: Unable to generate client token." 131 msgstr "" 132 133 #: includes/class-wc-valorpay-api.php:224 134 #: includes/class-wc-valorpay-api.php:247 135 #: includes/class-wc-valorpay-api.php:254 136 msgid "Sorry, we're unable to create a card token right now." 137 msgstr "" 138 139 #: includes/class-wc-valorpay-api.php:245 140 #: includes/class-wc-valorpay-api.php:252 141 msgid "Payment error: Unable to generate card token." 142 msgstr "" 143 144 #: includes/class-wc-valorpay-api.php:481 145 #: includes/class-wc-valorpay-api.php:486 146 #: includes/class-wc-valorpay-api.php:494 147 #: includes/class-wc-valorpay-api.php:498 129 148 msgid "There was a problem connecting to the payment gateway." 130 149 msgstr "" … … 457 476 msgstr "" 458 477 478 #: includes/class-wc-valorpay-gateway.php:732 479 msgid "Valor Pay: Card token added to subscription." 480 msgstr "" 481 459 482 #. translators: 1: Error Message, 2: Amount, 3: Line Break, 4: Approval Code, 5: Line Break, 6: RRN Number. 460 #: includes/class-wc-valorpay-gateway.php:7 15483 #: includes/class-wc-valorpay-gateway.php:749 461 484 msgid "Valor Pay %1$s for %2$s.%3$s <strong>Approval Code:</strong> %4$s.%5$s <strong>RRN:</strong> %6$s" 462 485 msgstr "" 463 486 464 487 #. translators: %s: API Error Message. 465 #: includes/class-wc-valorpay-gateway.php:7 55466 #: includes/class-wc-valorpay-gateway.php:7 58488 #: includes/class-wc-valorpay-gateway.php:790 489 #: includes/class-wc-valorpay-gateway.php:793 467 490 msgid "Payment error: %s" 468 491 msgstr "" 469 492 470 #: includes/class-wc-valorpay-gateway.php:7 60493 #: includes/class-wc-valorpay-gateway.php:795 471 494 msgid "Unable to process the transaction using Valor Pay, please try again." 472 495 msgstr "" 473 496 474 497 #. translators: 1: Disable Time, 2: Unblock IP URL, 3: Customer IP. 475 #: includes/class-wc-valorpay-gateway.php:8 51498 #: includes/class-wc-valorpay-gateway.php:886 476 499 msgid "Valor Pay method is disabled for %1$s. <a target=\"_blank\" href=\"%2$s\">To Unblock IP</a> %3$s" 477 500 msgstr "" 478 501 479 #: includes/class-wc-valorpay-gateway.php:9 14502 #: includes/class-wc-valorpay-gateway.php:949 480 503 msgid "Refund failed." 481 504 msgstr "" 482 505 483 506 #. translators: 1: Amount, 2: Line Break, 3: Approval code, 4: Line Break, 5: RRN Code 484 #: includes/class-wc-valorpay-gateway.php:9 26507 #: includes/class-wc-valorpay-gateway.php:961 485 508 msgid "Valor Pay Refund for %1$s.%2$s <strong>Approval Code:</strong> %3$s.%4$s <strong>RRN:</strong> %5$s" 486 509 msgstr "" 487 510 488 #: includes/class-wc-valorpay-gateway.php:9 46511 #: includes/class-wc-valorpay-gateway.php:981 489 512 msgid "You can only add a new card when placing an order." 490 513 msgstr "" … … 528 551 #: public/class-wc-valorpay-public.php:97 529 552 msgid "Unable to process payment. Please try again." 553 msgstr "" 554 555 #: public/class-wc-valorpay-public.php:209 556 msgid "Valor Pay is disabled due to multiple payment failures." 530 557 msgstr "" 531 558 -
valorpos/tags/7.6.0/public/class-wc-valorpay-public.php
r3002583 r3042319 207 207 $elapsed = round( abs( $current_time - $failed_time ) / MINUTE_IN_SECONDS, 2 ); 208 208 if ( $elapsed <= $valorpay->disable_payment_decline_time ) { 209 wc_add_notice( __( 'Valor Pay is disabled due to multiple payment failures.', 'w oocommerce' ), 'notice' );209 wc_add_notice( __( 'Valor Pay is disabled due to multiple payment failures.', 'wc-valorpay' ), 'notice' ); 210 210 $payment_failed_tracker[ $customer_ip ]['block_payment'] = true; 211 211 } else { -
valorpos/tags/7.6.0/wc-valorpay.php
r3002583 r3042319 16 16 * Plugin URI: https://valorpaytech.com 17 17 * Description: Adds the Valor Payment Gateway to WooCommerce. 18 * Version: 7. 5.018 * Version: 7.6.0 19 19 * Author: Valor Paytech LLC 20 20 * Author URI: https://valorpaytech.com … … 37 37 * Rename this for your plugin and update it as you release new versions. 38 38 */ 39 define( 'WC_VALORPAY_VERSION', '7. 5.0' );39 define( 'WC_VALORPAY_VERSION', '7.6.0' ); 40 40 // Directory i.e. /home/user/public_html... 41 41 define( 'WC_VALORPAY_DIR', plugin_dir_path( __FILE__ ) ); … … 90 90 } 91 91 run_wc_valorpay(); 92 93 add_action( 94 'before_woocommerce_init', 95 function() { 96 if ( class_exists( '\Automattic\WooCommerce\Utilities\FeaturesUtil' ) ) { 97 \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true ); 98 } 99 } 100 ); -
valorpos/trunk/README.txt
r3002583 r3042319 5 5 Tested up to: 6.3.1 6 6 Requires PHP: 7.0 7 Stable tag: 7. 5.07 Stable tag: 7.6.0 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 18 18 19 19 Software Systems and Payment Devices from Valor are the best around for smart hassle-free transactions. Cost-efficient and super smart. With value-added features and reliable service support to match, you’d want Valor to be your partner for growth, always. 20 21 **WARNING:** The issue of tax price being calculated twice has been resolved in versions 7.3 and above. Please ensure that you are using version 7.3 or later to avoid encountering this problem. 20 22 21 23 == Installation == … … 40 42 41 43 == Changelog == 44 45 = 7.6.0 = 46 * Added support for High Performance Order Storage, Ecommerce device identifier, and allowing a subscription product with a $0 initial payment has been added. 42 47 43 48 = 7.5.0 = -
valorpos/trunk/admin/class-wc-valorpay-admin.php
r2980555 r3042319 74 74 * class. 75 75 */ 76 global $post; 77 78 // Get admin screen id. 76 77 // Get admin screen id. 79 78 $screen = get_current_screen(); 80 79 $screen_id = isset( $screen->id ) ? $screen->id : ''; 81 80 82 if ( 'shop_order' === $screen_id) {81 if ( in_array( $screen_id, array( 'shop_order', 'woocommerce_page_wc-orders' ), true ) ) { 83 82 // Load order . 84 $order = wc_get_order( $post->ID);83 $order = wc_get_order(); 85 84 // Load JS file only for valor payment method . 86 if ( WC_ValorPay_Gateway::GATEWAY_ID === $order->get_payment_method() ) {85 if ( $order && WC_ValorPay_Gateway::GATEWAY_ID === $order->get_payment_method() ) { 87 86 wp_register_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/wc-valorpay-refund.js', array( 'jquery' ), $this->version, false ); 88 87 wp_enqueue_script( $this->plugin_name ); -
valorpos/trunk/admin/partials/wc-valorpay-admin-order-refund.php
r2883367 r3042319 48 48 <div class="inner"> 49 49 <button id="btn-valor-otp" class="button button-primary button-large button-valor-submit"><?php echo esc_html_e( 'Submit', 'woocommerce' ); ?></button> 50 <button id="btn-valor-resend" class="button button-primary button-large button-valor-resend" style="display: none;"><?php echo esc_html_e( 'Resend OTP', 'w oocommerce' ); ?></button>50 <button id="btn-valor-resend" class="button button-primary button-large button-valor-resend" style="display: none;"><?php echo esc_html_e( 'Resend OTP', 'wc-valorpay' ); ?></button> 51 51 <span id="valor-resend-load" class="spinner" style="display: none;"></span> 52 52 </div> -
valorpos/trunk/includes/class-wc-valorpay-api.php
r3002583 r3042319 48 48 */ 49 49 const WC_VALORPAY_BIN_LOOKUP_ACTION = 'binLookup'; 50 /** 51 * Card token action 52 */ 53 const WC_VALORPAY_CARD_TOKEN_ACTION = 'cardToken'; 54 /** 55 * Ecommerce Channel ID 56 */ 57 const WC_VALORPAY_ECOMM_CHANNEL = 'woocommerce'; 50 58 51 59 /** … … 199 207 $response = $this->post_transaction( wp_json_encode( $payload ), 'bin_lookup' ); 200 208 return $response; 209 } 210 211 /** 212 * Generate card token 213 * 214 * @since 7.6.0 215 * 216 * @param WC_Order $order Order Detail. 217 * @param array $card_detail Card detail. 218 */ 219 public function generate_card_token( $order, $card_detail ) { 220 $client_token_response = $this->create_checkout_page_token(); 221 if ( is_wp_error( $client_token_response ) || ! is_object( $client_token_response ) || ! isset( $client_token_response->clientToken ) ) { // phpcs:ignore 222 $order->add_order_note( __( 'Payment error: Unable to generate client token.', 'wc-valorpay' ) ); 223 return array( 224 'error' => __( 'Sorry, we\'re unable to create a card token right now.', 'wc-valorpay' ), 225 ); 226 } 227 $client_token = $client_token_response->clientToken; // phpcs:ignore 228 $args = array( 229 'txn_type' => self::WC_VALORPAY_CARD_TOKEN_ACTION, 230 'epi' => $this->gateway->epi, 231 'client_token' => $client_token, 232 'pan' => $card_detail['card_num'], 233 'expirydate' => $card_detail['card_expiry'], 234 ); 235 $request_url = add_query_arg( $args, $this->get_valorpay_url() ); 236 $api_args = array( 237 'headers' => array( 238 'Content-Type' => 'application/json', 239 ), 240 'method' => 'POST', 241 'timeout' => 70, 242 ); 243 $api_response = wp_remote_post( $request_url, $api_args ); 244 if ( is_wp_error( $api_response ) || empty( $api_response['body'] ) ) { 245 $order->add_order_note( __( 'Payment error: Unable to generate card token.', 'wc-valorpay' ) ); 246 return array( 247 'error' => __( 'Sorry, we\'re unable to create a card token right now.', 'wc-valorpay' ), 248 ); 249 } 250 $parsed_response = json_decode( preg_replace( '/\xEF\xBB\xBF/', '', $api_response['body'] ), true ); 251 if ( ! isset( $parsed_response['cardToken'] ) ) { 252 $order->add_order_note( __( 'Payment error: Unable to generate card token.', 'wc-valorpay' ) ); 253 return array( 254 'error' => __( 'Sorry, we\'re unable to create a card token right now.', 'wc-valorpay' ), 255 ); 256 } 257 return array( 258 'token' => $parsed_response['cardToken'], 259 ); 201 260 } 202 261 … … 277 336 'status' => 'Y', 278 337 'terms_checked' => $valorpay_terms, 338 'ecomm_channel' => self::WC_VALORPAY_ECOMM_CHANNEL, 279 339 ) + $surcharge_data; 280 340 … … 306 366 'epi' => $this->gateway->epi, 307 367 'ip' => WC_Geolocation::get_ip_address(), 308 'sales_refund' => 1,309 368 'ref_txn_id' => $order->get_transaction_id(), 310 'rrn' => $valorpay_order_meta['rrn'],311 369 'auth_code' => $valorpay_order_meta['approval_code'], 312 370 'surchargeIndicator' => ( 'yes' === $this->gateway->surcharge_indicator ) ? 1 : 0, 313 371 'otp' => $order->get_meta( '_valorpay_2fa_otp' ), 314 372 'uuid' => $order->get_meta( '_valorpay_otp_uuid' ), 315 ); 316 delete_post_meta( $order->get_id(), '_valorpay_2fa_otp' ); 317 delete_post_meta( $order->get_id(), '_valorpay_otp_uuid' ); 373 'ecomm_channel' => self::WC_VALORPAY_ECOMM_CHANNEL, 374 ); 375 $order->delete_meta_data( '_valorpay_2fa_otp' ); 376 $order->delete_meta_data( '_valorpay_otp_uuid' ); 377 $order->save(); 318 378 } elseif ( 'send_otp' === $transaction_type ) { 319 379 $data = array( … … 390 450 'surchargeIndicator' => $surcharge_indicator, 391 451 'surchargeAmount' => sprintf( '%.2f', $surcharge ), 452 'ecomm_channel' => self::WC_VALORPAY_ECOMM_CHANNEL, 392 453 ); 393 454 -
valorpos/trunk/includes/class-wc-valorpay-gateway-addons.php
r3002598 r3042319 61 61 'post_meta' => array( 62 62 '_valorpay_card_token' => array( 63 'value' => get_post_meta( $subscription->id,'_valorpay_card_token', true ),63 'value' => $subscription->get_meta( '_valorpay_card_token', true ), 64 64 'label' => __( 'ValorPay Card Token', 'wc-valorpay' ), 65 65 ), 66 66 '_valorpay_card_type' => array( 67 'value' => get_post_meta( $subscription->id,'_valorpay_card_type', true ),67 'value' => $subscription->get_meta( '_valorpay_card_type', true ), 68 68 'label' => __( 'ValorPay Card Type', 'wc-valorpay' ), 69 69 ), -
valorpos/trunk/includes/class-wc-valorpay-gateway.php
r3002583 r3042319 702 702 703 703 $valorpay_api = new WC_ValorPay_API( $this ); 704 // Check if subscription order or if order total is zero, then add the card token to subscriptions. 705 if ( class_exists( 'WC_Subscriptions_Order' ) && WC_Subscriptions_Order::order_contains_subscription( $order->get_id() ) && '0.00' === $amount ) { 706 if ( $card ) { 707 $subscription_payload = new stdClass(); 708 $subscription_payload->token = $card->get_token(); 709 $subscription_payload->expiry_date = $card->get_expiry_month() . substr( $card->get_expiry_year(), -2 ); 710 $is_debit_card = 'D' === WC()->session->get( 'valor_card_type' ); 711 } else { 712 $card_number = str_replace( ' ', '', ( isset( $_POST['wc_valorpay-card-number'] ) ) ? sanitize_text_field( wp_unslash( $_POST['wc_valorpay-card-number'] ) ) : '' ); // phpcs:ignore 713 $exp_date_array = explode( '/', sanitize_text_field( wp_unslash( $_POST['wc_valorpay-card-expiry'] ) ) ); // phpcs:ignore 714 $exp_month = trim( $exp_date_array[0] ); 715 $exp_year = trim( $exp_date_array[1] ); 716 $exp_date = $exp_month . substr( $exp_year, -2 ); 717 $card_detail = array( 718 'card_num' => $card_number, 719 'card_expiry' => $exp_date, 720 ); 721 $card_token_response = $valorpay_api->generate_card_token( $order, $card_detail ); 722 if ( isset( $card_token_response['error'] ) ) { 723 throw new Exception( $card_token_response['error'] ); 724 } 725 $subscription_payload = new stdClass(); 726 $subscription_payload->token = $card_token_response['token']; 727 $subscription_payload->expiry_date = $exp_month . substr( $exp_year, -2 ); 728 $is_debit_card = 'D' === WC()->session->get( 'valor_card_type' ); 729 } 730 $this->update_subscription_card_token( $order, $subscription_payload, $is_debit_card ); 731 $order->payment_complete(); 732 $order->add_order_note( __( 'Valor Pay: Card token added to subscription.', 'wc-valorpay' ) ); 733 return array( 734 'result' => 'success', 735 'redirect' => $this->get_return_url( $order ), 736 ); 737 } 704 738 // Call the sale or authorization API. 705 739 $response = $valorpay_api->purchase( $order, $amount, $card ); … … 728 762 $exp_year = trim( $exp_date_array[1] ); 729 763 $exp_date = $exp_month . substr( $exp_year, -2 ); 730 $response->card_type = $valorpay_api->get_card_type( str_replace( ' ', '', sanitize_text_field( wp_unslash( $_POST['wc_valorpay-card-number'] ) ) ) ); // phpcs:ignore764 $response->card_type = isset( $response->card_brand ) && $response->card_brand ? $response->card_brand : $valorpay_api->get_card_type( str_replace( ' ', '', sanitize_text_field( wp_unslash( $_POST['wc_valorpay-card-number'] ) ) ) ); // phpcs:ignore 731 765 $this->save_card( $response, $exp_date, ( 'D' === WC()->session->get( 'valor_card_type' ) ) ? 1 : 0 ); 732 766 } … … 739 773 'approval_code' => $response->approval_code, 740 774 ); 741 add_post_meta( $order_id, '_valorpay_transaction', $tran_meta ); 775 $order->add_meta_data( '_valorpay_transaction', $tran_meta ); 776 $order->save(); 742 777 $is_debit_card = 'D' === WC()->session->get( 'valor_card_type' ); 743 778 if ( class_exists( 'WC_Subscriptions_Order' ) && WC_Subscriptions_Order::order_contains_subscription( $order->get_id() ) ) { -
valorpos/trunk/languages/wc-valorpay.pot
r3002583 r3042319 1 # Copyright (C) 202 3Valor Paytech LLC1 # Copyright (C) 2024 Valor Paytech LLC 2 2 # This file is distributed under the GPL-2.0+. 3 3 msgid "" 4 4 msgstr "" 5 "Project-Id-Version: Valor Pay 7. 5.0\n"5 "Project-Id-Version: Valor Pay 7.6.0\n" 6 6 "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/valorpos\n" 7 7 "Last-Translator: Valor Paytech LLC <isv@valorpaytech.com>\n" … … 10 10 "Content-Type: text/plain; charset=UTF-8\n" 11 11 "Content-Transfer-Encoding: 8bit\n" 12 "POT-Creation-Date: 202 3-11-20T06:34:41+00:00\n"13 "PO-Revision-Date: 202 3-11-20T06:34:41+00:00\n"12 "POT-Creation-Date: 2024-02-20T10:51:04+05:30\n" 13 "PO-Revision-Date: 2024-02-20T10:51:04+05:30\n" 14 14 "X-Generator: WP-CLI 2.7.1\n" 15 15 "X-Domain: wc-valorpay\n" … … 33 33 msgstr "" 34 34 35 #: admin/class-wc-valorpay-admin.php:11 935 #: admin/class-wc-valorpay-admin.php:118 36 36 msgid "Are you sure you want to remove?" 37 37 msgstr "" 38 38 39 #: admin/class-wc-valorpay-admin.php:13 839 #: admin/class-wc-valorpay-admin.php:137 40 40 msgid "Settings" 41 41 msgstr "" 42 42 43 #: admin/class-wc-valorpay-admin.php:19 744 #: admin/class-wc-valorpay-admin.php:29 243 #: admin/class-wc-valorpay-admin.php:196 44 #: admin/class-wc-valorpay-admin.php:291 45 45 msgid "Invalid Request." 46 46 msgstr "" 47 47 48 #: admin/class-wc-valorpay-admin.php:20 749 #: admin/class-wc-valorpay-admin.php:27 550 #: admin/class-wc-valorpay-admin.php:30 648 #: admin/class-wc-valorpay-admin.php:206 49 #: admin/class-wc-valorpay-admin.php:274 50 #: admin/class-wc-valorpay-admin.php:305 51 51 msgid "Error Occurred." 52 52 msgstr "" 53 53 54 #: admin/class-wc-valorpay-admin.php:24 254 #: admin/class-wc-valorpay-admin.php:241 55 55 msgid "Order Id Missing." 56 56 msgstr "" 57 57 58 #: admin/class-wc-valorpay-admin.php:24 658 #: admin/class-wc-valorpay-admin.php:245 59 59 msgid "Enter a valid refund amount." 60 60 msgstr "" 61 61 62 62 #. translators: 1: Email Address, 2: Mobile Number 63 #: admin/class-wc-valorpay-admin.php:2 7063 #: admin/class-wc-valorpay-admin.php:269 64 64 msgid "OTP sent to your registered Email Address %1$s and Mobile Number %2$s" 65 65 msgstr "" 66 66 67 #: admin/class-wc-valorpay-admin.php:29 767 #: admin/class-wc-valorpay-admin.php:296 68 68 msgid "Enter Valid OTP." 69 69 msgstr "" … … 123 123 msgstr "" 124 124 125 #: includes/class-wc-valorpay-api.php:420 126 #: includes/class-wc-valorpay-api.php:425 127 #: includes/class-wc-valorpay-api.php:433 128 #: includes/class-wc-valorpay-api.php:437 125 #: admin/partials/wc-valorpay-admin-order-refund.php:50 126 msgid "Resend OTP" 127 msgstr "" 128 129 #: includes/class-wc-valorpay-api.php:222 130 msgid "Payment error: Unable to generate client token." 131 msgstr "" 132 133 #: includes/class-wc-valorpay-api.php:224 134 #: includes/class-wc-valorpay-api.php:247 135 #: includes/class-wc-valorpay-api.php:254 136 msgid "Sorry, we're unable to create a card token right now." 137 msgstr "" 138 139 #: includes/class-wc-valorpay-api.php:245 140 #: includes/class-wc-valorpay-api.php:252 141 msgid "Payment error: Unable to generate card token." 142 msgstr "" 143 144 #: includes/class-wc-valorpay-api.php:481 145 #: includes/class-wc-valorpay-api.php:486 146 #: includes/class-wc-valorpay-api.php:494 147 #: includes/class-wc-valorpay-api.php:498 129 148 msgid "There was a problem connecting to the payment gateway." 130 149 msgstr "" … … 457 476 msgstr "" 458 477 478 #: includes/class-wc-valorpay-gateway.php:732 479 msgid "Valor Pay: Card token added to subscription." 480 msgstr "" 481 459 482 #. translators: 1: Error Message, 2: Amount, 3: Line Break, 4: Approval Code, 5: Line Break, 6: RRN Number. 460 #: includes/class-wc-valorpay-gateway.php:7 15483 #: includes/class-wc-valorpay-gateway.php:749 461 484 msgid "Valor Pay %1$s for %2$s.%3$s <strong>Approval Code:</strong> %4$s.%5$s <strong>RRN:</strong> %6$s" 462 485 msgstr "" 463 486 464 487 #. translators: %s: API Error Message. 465 #: includes/class-wc-valorpay-gateway.php:7 55466 #: includes/class-wc-valorpay-gateway.php:7 58488 #: includes/class-wc-valorpay-gateway.php:790 489 #: includes/class-wc-valorpay-gateway.php:793 467 490 msgid "Payment error: %s" 468 491 msgstr "" 469 492 470 #: includes/class-wc-valorpay-gateway.php:7 60493 #: includes/class-wc-valorpay-gateway.php:795 471 494 msgid "Unable to process the transaction using Valor Pay, please try again." 472 495 msgstr "" 473 496 474 497 #. translators: 1: Disable Time, 2: Unblock IP URL, 3: Customer IP. 475 #: includes/class-wc-valorpay-gateway.php:8 51498 #: includes/class-wc-valorpay-gateway.php:886 476 499 msgid "Valor Pay method is disabled for %1$s. <a target=\"_blank\" href=\"%2$s\">To Unblock IP</a> %3$s" 477 500 msgstr "" 478 501 479 #: includes/class-wc-valorpay-gateway.php:9 14502 #: includes/class-wc-valorpay-gateway.php:949 480 503 msgid "Refund failed." 481 504 msgstr "" 482 505 483 506 #. translators: 1: Amount, 2: Line Break, 3: Approval code, 4: Line Break, 5: RRN Code 484 #: includes/class-wc-valorpay-gateway.php:9 26507 #: includes/class-wc-valorpay-gateway.php:961 485 508 msgid "Valor Pay Refund for %1$s.%2$s <strong>Approval Code:</strong> %3$s.%4$s <strong>RRN:</strong> %5$s" 486 509 msgstr "" 487 510 488 #: includes/class-wc-valorpay-gateway.php:9 46511 #: includes/class-wc-valorpay-gateway.php:981 489 512 msgid "You can only add a new card when placing an order." 490 513 msgstr "" … … 528 551 #: public/class-wc-valorpay-public.php:97 529 552 msgid "Unable to process payment. Please try again." 553 msgstr "" 554 555 #: public/class-wc-valorpay-public.php:209 556 msgid "Valor Pay is disabled due to multiple payment failures." 530 557 msgstr "" 531 558 -
valorpos/trunk/public/class-wc-valorpay-public.php
r3002583 r3042319 207 207 $elapsed = round( abs( $current_time - $failed_time ) / MINUTE_IN_SECONDS, 2 ); 208 208 if ( $elapsed <= $valorpay->disable_payment_decline_time ) { 209 wc_add_notice( __( 'Valor Pay is disabled due to multiple payment failures.', 'w oocommerce' ), 'notice' );209 wc_add_notice( __( 'Valor Pay is disabled due to multiple payment failures.', 'wc-valorpay' ), 'notice' ); 210 210 $payment_failed_tracker[ $customer_ip ]['block_payment'] = true; 211 211 } else { -
valorpos/trunk/wc-valorpay.php
r3002583 r3042319 16 16 * Plugin URI: https://valorpaytech.com 17 17 * Description: Adds the Valor Payment Gateway to WooCommerce. 18 * Version: 7. 5.018 * Version: 7.6.0 19 19 * Author: Valor Paytech LLC 20 20 * Author URI: https://valorpaytech.com … … 37 37 * Rename this for your plugin and update it as you release new versions. 38 38 */ 39 define( 'WC_VALORPAY_VERSION', '7. 5.0' );39 define( 'WC_VALORPAY_VERSION', '7.6.0' ); 40 40 // Directory i.e. /home/user/public_html... 41 41 define( 'WC_VALORPAY_DIR', plugin_dir_path( __FILE__ ) ); … … 90 90 } 91 91 run_wc_valorpay(); 92 93 add_action( 94 'before_woocommerce_init', 95 function() { 96 if ( class_exists( '\Automattic\WooCommerce\Utilities\FeaturesUtil' ) ) { 97 \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true ); 98 } 99 } 100 );
Note: See TracChangeset
for help on using the changeset viewer.