Plugin Directory

Changeset 3101786


Ignore:
Timestamp:
06/12/2024 12:26:04 PM (22 months ago)
Author:
devcashfree
Message:

Update to version 4.7.0

Location:
cashfree
Files:
30 added
7 edited

Legend:

Unmodified
Added
Removed
  • cashfree/trunk/assets/js/checkout.js

    r3075227 r3101786  
    66            mode: wc_cashfree_checkout_params.environment,
    77        });
    8        
    9         return cashfree.checkout({
    10             paymentSessionId: wc_cashfree_checkout_params.payment_session_id,
    11             redirectTarget: "_self",
    12             platformName: "wc",
    13         });
     8        if(wc_cashfree_checkout_params.order_in_context) {
     9            let checkoutOptions = {
     10                paymentSessionId: wc_cashfree_checkout_params.payment_session_id,
     11                redirectTarget: "_modal",
     12            };
     13            cashfree.checkout(checkoutOptions).then((result) => {
     14                let in_context_form;
     15                if (result.error) {
     16                    // This will be true whenever user clicks on close icon inside the modal or any error happens during the payment
     17                    in_context_form = document.createElement('FORM');
     18                    in_context_form.method = 'POST';
     19                    in_context_form.action = wc_cashfree_checkout_params.callback_url;
     20                    document.body.appendChild(in_context_form);
     21                    in_context_form.submit();
     22                }
     23                if(result.paymentDetails){
     24                    // This will be called whenever the payment is completed irrespective of transaction status
     25                    in_context_form=document.createElement('FORM');
     26                    in_context_form.method='POST';
     27                    in_context_form.action=wc_cashfree_checkout_params.callback_url;
     28                    document.body.appendChild(in_context_form);
     29                    in_context_form.submit();
     30                }
     31            });
     32        } else {
     33            return cashfree.checkout({
     34                paymentSessionId: wc_cashfree_checkout_params.payment_session_id,
     35                redirectTarget: "_self",
     36                platformName: "wc",
     37            });
     38        }
    1439    }
    1540   
  • cashfree/trunk/cashfree.php

    r3096820 r3101786  
    22/**
    33 * Plugin Name: Cashfree
    4  * Version: 4.6.1
     4 * Version: 4.7.0
    55 * Plugin URI: https://github.com/cashfree/cashfree-woocommerce
    66 * Description: Payment gateway plugin by Cashfree Payments for Woocommerce sites.
  • cashfree/trunk/includes/gateways/class-wc-cashfree-gateway.php

    r3096820 r3101786  
    3838        $this->token_param = "{$this->id}-token";
    3939        $this->order_id_prefix_text = 'yes' === $this->get_option( 'order_id_prefix_text', 'yes' );
     40        $this->order_in_context = 'yes' === $this->get_option( 'order_in_context', 'yes' );
    4041
    4142        $this->load_dependencies();
     
    126127        $order   = wc_get_order( $order_id );
    127128        $pay_url = $order->get_checkout_payment_url( true );
    128         $redirect_url = add_query_arg( $this->token_param, $response['payment_session_id'], $pay_url );
     129        $redirect_url = add_query_arg( array($this->token_param => $response['payment_session_id'],
     130            'order_id' => $response['order_id']),
     131            $pay_url
     132        );
    129133
    130134        return array(
     
    363367            return;
    364368        }
    365 
     369       
    366370        $payment_session_id = wc_clean(wp_unslash($_GET[$this->token_param]));
    367371        $key = wc_clean(wp_unslash($_GET['key']));
     372        $order_id = wc_clean(wp_unslash($_GET['order_id']));
    368373        $cf_version = get_plugin_data(WC_CASHFREE_DIR_PATH . 'cashfree.php')['Version'];
    369 
    370374        wc_cashfree_js($this->settings);
    371375
     
    375379            'woo_version' => WC()->version,
    376380            'cf_version' => $cf_version,
     381            'order_in_context' => $this->order_in_context,
     382            'callback_url' => WC_Cashfree_Request_Checkout::get_callback_url('capture', $key, $this->id, $order_id)
    377383        ]);
    378384    }
  • cashfree/trunk/includes/http/class-wc-cashfree-adapter.php

    r3096820 r3101786  
    4040    public function checkout( $order_id ) {
    4141        require_once WC_CASHFREE_DIR_PATH . 'includes/request/class-wc-cashfree-request-checkout.php';
    42 
    4342        $cf_order_id = $order_id;
    4443
     
    8483                    'payment_session_id' => $cf_order->payment_session_id,
    8584                    'environment' => $env_value['environment'],
     85                    'order_id' => $cf_order_id,
    8686                );
    8787
     
    103103                'payment_session_id' => $result->payment_session_id,
    104104                'environment' => $env_value['environment'],
     105                'order_id' => $cf_order_id,
    105106            );
    106107
  • cashfree/trunk/includes/request/class-wc-cashfree-request-checkout.php

    r3038899 r3101786  
    5757            'order_meta' => array(
    5858                'notify_url' => self::get_notify_url( 'notify', $order->get_order_key(), $gateway ),
    59                 'return_url' => self::get_return_url('capture', $order->get_order_key(), $gateway)
     59                'return_url' => self::get_return_url('capture', $order->get_order_key(), $gateway->id)
    6060            ),
    6161            'cart_details' => array(
     
    101101     * @return string
    102102     */
    103     public static function get_return_url( $action, $order_key, $gateway ) {
     103    public static function get_return_url( $action, $order_key, $gateway_id ) {
    104104        $query_args = array(
    105105            'order_id'    => '{order_id}',
     
    107107            'action'      => $action
    108108        );
    109         $api_request_url = WC()->api_request_url( $gateway->id );
     109        $api_request_url = WC()->api_request_url( $gateway_id );
    110110        return add_query_arg( $query_args, $api_request_url );
    111111    }
     112
     113    public static function get_callback_url( $action, $order_key, $gateway_id, $order_id ) {
     114        $query_args = array(
     115            'order_id'    => $order_id,
     116            'order_key' => $order_key,
     117            'action'      => $action
     118        );
     119        $api_request_url = WC()->api_request_url( $gateway_id );
     120        return add_query_arg( $query_args, $api_request_url );
     121    }
    112122
    113123
  • cashfree/trunk/includes/settings/cashfree-payments.php

    r3038899 r3101786  
    7070        'desc_tip'    => true
    7171    ),
     72    'order_in_context' => array(
     73        'title'       => __('Cashfree Popup Checkout', 'cashfree'),
     74        'type'        =>  'checkbox',
     75        'label'       => __( 'Enable Cashfree Popup Checkout', 'cashfree' ),
     76        'default'     => __('no', 'cashfree'),
     77        'description' => __('Enable this option to open Cashfree Popup Checkout', 'cashfree'),
     78        'desc_tip'    => true
     79    ),
    7280    'enabledOffers'     => array(
    7381        'title'         => __( 'Widget Enable/Disable', 'cashfree' ),
  • cashfree/trunk/readme.txt

    r3096820 r3101786  
    44Tested up to: 6.5
    55Requires PHP: 5.6
    6 Stable tag: 4.6.1
    7 Version: 4.6.1
     6Stable tag: 4.7.0
     7Version: 4.7.0
    88License: GPLv3
    99License URI: https://www.gnu.org/licenses/gpl-3.0.html
     
    5050
    5151== Changelog ==
     52
     53= 4.7.0 =
     54* New Feature: Added support for processing payments in a popup checkout without redirecting the user to a new page.
    5255
    5356= 4.6.1 =
Note: See TracChangeset for help on using the changeset viewer.