Plugin Directory

Changeset 2747397


Ignore:
Timestamp:
06/24/2022 06:03:04 AM (4 years ago)
Author:
devcashfree
Message:

Updated to v4.3.3

Location:
cashfree
Files:
28 added
12 edited

Legend:

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

    r2742179 r2747397  
    44        let dismissflag = true;
    55        //Set env
    6         const  env  =  wc_cashfree_checkout_params.environment; //or production
     6        const  env = wc_cashfree_checkout_params.environment; //or production
     7
    78        //Create Success Callback
    89        const  successCallback  =  function (data) {
     
    1011            woocommerceFormSubmit(data, wc_cashfree_checkout_params.capture_url);
    1112        }
     13
    1214        //Create Failure Callback
    1315        const  failureCallback  =  function (data) {
    1416            woocommerceFormSubmit(data, wc_cashfree_checkout_params.cancel_url);
    1517        }
     18
    1619        //Create Dismiss Callback
    1720        const  dismissCallback  =  function () {
     
    6568            pippin_form.submit();
    6669        }
    67         Pippin.setOrderMetaPlatform("wc");
     70        Pippin.setOrderMetaPlatform("wc-" + wc_cashfree_checkout_params.woo_version);
    6871        Pippin(env, wc_cashfree_checkout_params.token, successCallback, failureCallback, dismissCallback);
    6972    }
  • cashfree/trunk/cashfree.php

    r2742179 r2747397  
    22/**
    33 * Plugin Name: Cashfree
    4  * Version: 4.3.2
     4 * Version: 4.3.3
    55 * Plugin URI: https://github.com/cashfree/cashfree-woocommerce
    66 * Description: Payment gateway plugin by Cashfree for Woocommerce sites.
  • cashfree/trunk/includes/gateways/class-wc-cashfree-gateway.php

    r2742179 r2747397  
    1616     * @var WC_Cashfree_Adapter
    1717     */
     18
    1819    protected $adapter;
    1920
     
    2122     * Constructor.
    2223     */
     24
    2325    public function __construct() {
    2426        $this->has_fields = true;
     
    100102    public function payment_fields() {
    101103        wc_cashfree_script( 'wc-cashfree-js' );
     104        wc_get_cashfree_template( 'payment-fields.php', array( 'gateway' => $this ) );
    102105    }
    103106
     
    116119            return array( 'result' => 'failure' );
    117120        }
     121
    118122        if($this->in_context === true) {
    119123            $order        = wc_get_order( $order_id );
     
    134138     *
    135139     * @param array $data post data.
    136      * @param string $order_key      Order key.
     140     * @param string $order_key Order key.
    137141     */
    138142    public function capture( $data, $order_key ) {
     
    144148       
    145149        $order = $this->get_order( $order_id, $order_key );
    146 
    147150        if ( $order && $order->needs_payment() || $order->has_status('processing')) {
    148151            try {
     
    150153                if ($response->payment_status === 'SUCCESS') {
    151154                    $order->payment_complete( $response->cf_payment_id );
     155                    $order->add_order_note(
     156                        sprintf(
     157                            __( 'Cashfree payment successful <br/>Transaction Id: %1$s.', 'cashfree' ),
     158                            $response->cf_payment_id
     159                        )
     160                    );
    152161                    wp_safe_redirect( $this->get_return_url( $order ) );
    153162                    exit;
     
    164173                $order->add_order_note(
    165174                    sprintf( /* translators: %1$s: transaction id %2$s: error code */
    166                         __( 'Cashfree capture %1$s. ID: %2$s. Code: %3$s.', 'cashfree' ),
     175                        __( 'Cashfree capture %1$s. ID: %2$s. Error: %3$s.', 'cashfree' ),
    167176                        $order_status,
    168177                        $order->get_id(),
     
    174183        wc_add_notice( __( 'Cashfree capture error.', 'cashfree' ), 'error' );
    175184        wp_safe_redirect( wc_get_checkout_url() );
     185        exit;
    176186    }
    177187
     
    179189     * Cancel a checkout.
    180190     *
    181      * @param array $post_data post data.
    182      * @param string $order_key      Order key.
    183      */
    184     public function cancel( $post_data, $order_key ) {
    185         $order_id = $post_data['orderId'];
     191     * @param array $data post data.
     192     * @param string $order_key   Order key.
     193     */
     194    public function cancel( $data, $order_key ) {
     195        $order_id = $data['orderId'];
    186196        $order = $this->get_order( $order_id, $order_key );
    187197
    188198        if ( $order && $order->needs_payment() ) {
    189             if($post_data['transaction_status'] === 'CANCELLED') {
     199            if($data['transaction_status'] === 'CANCELLED') {
    190200                $order_status = 'cancelled';
    191             } elseif($post_data['transaction_status'] === 'FAILED') {
     201            } elseif($data['transaction_status'] === 'FAILED') {
    192202                $order_status = 'failed';
    193203            } else {
     
    201211                    $order_status,
    202212                    $order->get_id(),
    203                     $post_data['transaction_msg']
     213                    $data['transaction_msg']
    204214                )
    205215            );
    206216        }
    207         wc_add_notice( __( $post_data['transaction_msg'], 'cashfree' ), 'error');
     217        wc_add_notice( __( $data['transaction_msg'], 'cashfree' ), 'error');
    208218        wp_safe_redirect( wc_get_checkout_url() );
     219        exit;
    209220    }
    210221
     
    217228    public function dismiss( $post_data, $order_key ) {
    218229        wp_safe_redirect( wc_get_checkout_url() );
     230        exit;
    219231    }
    220232
     
    222234     * Webhook a checkout.
    223235     *
    224      * @param array $post_data post data.
     236     * @param array $data post data.
    225237     * @param string $order_key Order key.
    226238     */
    227     public function notify( $post_data, $order_key ) {
    228         if($post_data['txStatus'] === 'SUCCESS') {
    229             $order_id = $post_data['orderId'];
     239    public function notify( $data, $order_key ) {
     240        if($data['txStatus'] === 'SUCCESS') {
     241            $order_id = $data['orderId'];
    230242            $order = $this->get_order( $order_id, $order_key );
    231243
    232244            if ( $order && $order->needs_payment() ) {
    233245                try {
    234                     $post_data['order_status'] = 'PAID';
    235                     $post_data['transaction_msg'] = $post_data['txMsg'];
    236                     $this->adapter->notify( $post_data );
    237                     $order->payment_complete( $post_data['referenceId'] );
     246                    $data['order_status'] = 'PAID';
     247                    $data['transaction_msg'] = $data['txMsg'];
     248                    $this->adapter->notify( $data );
     249                    $order->payment_complete( $data['referenceId'] );
     250                    $order->add_order_note(
     251                        sprintf(
     252                            __( 'Webhook - Cashfree payment successful <br/>Transaction Id: %1$s.', 'cashfree' ),
     253                            $data['referenceId']
     254                        )
     255                    );
    238256                } catch ( Exception $e ) {
    239257                    WC_Cashfree::log( 'notify : ' . $e->getMessage(), 'critical' );
     
    299317                    'capture_url'   => WC_Cashfree_Request_Checkout::get_url( 'capture', wc_clean( wp_unslash( $_GET[ 'key' ] ) ), $this->id ),
    300318                    'cancel_url'    => WC_Cashfree_Request_Checkout::get_url( 'cancel', wc_clean( wp_unslash( $_GET[ 'key' ] ) ), $this->id ),
    301                     'dismiss_url'   => WC_Cashfree_Request_Checkout::get_url( 'dismiss', wc_clean( wp_unslash( $_GET[ 'key' ] ) ), $this->id ) )
     319                    'dismiss_url'   => WC_Cashfree_Request_Checkout::get_url( 'dismiss', wc_clean( wp_unslash( $_GET[ 'key' ] ) ), $this->id ),
     320                    'woo_version'   => WC()->version )
    302321            );
    303322        }
     
    307326     * Get order instance.
    308327     *
    309      * @param string $transaction_id Transaction id.
    310      * @param string $order_key      Order key.
     328     * @param string $order_id Order id.
     329     * @param string $order_key Order key.
    311330     *
    312331     * @return bool|WC_Order|WC_Order_Refund
  • cashfree/trunk/includes/gateways/class-wc-cashfree-payments.php

    r2742179 r2747397  
    1616    public function __construct() {
    1717        $this->id                 = WC_Cashfree::PAYMENT_GATEWAY_ID;
    18         $this->method_title       = __( 'Cashfree Payments', 'cashfree' );
    19         $this->method_description = __( 'Accept payments using credit and debit cards.', 'cashfree' );
    20         $this->order_button_text  = __( 'Pay Now', 'cashfree' );
    2118        $this->icon               = "https://cashfreelogo.cashfree.com/wix/cflogo.svg";
    22 
     19        $this->method_description = __( 'Pay securely via Card/Net Banking/Wallet via Cashfree.', 'cashfree' );
    2320        parent::__construct();
    2421    }
  • cashfree/trunk/includes/http/class-wc-cashfree-adapter.php

    r2742179 r2747397  
    5454            ];
    5555
    56             //Order Cart save   
     56            //Save cart details
    5757            try {
    5858                $this->cashfreeCheckoutCartSave( $order_id );               
     
    187187    }
    188188
     189    // Get config values for gateway environment
    189190    public function getCurlValue() {
    190191        if ( $this->gateway->settings['sandbox'] != 'yes' ) {
     
    202203    }
    203204
     205    // Post request for gateway
    204206    private function curlPostRequest($curlUrl, $data, $idemKey = "") {
    205207        $headers = array(
     
    232234    }
    233235
     236    // Get request for gateway
    234237    private function curlGetRequest($curlUrl) {
    235238
  • cashfree/trunk/includes/request/class-wc-cashfree-request-checkout.php

    r2742179 r2747397  
    4646            "order_meta"        => array(
    4747            "notify_url"        => self::get_url( 'notify', $order->get_order_key(), $gateway->id ),
    48             "return_url"        => self::get_return_url('capture', $order->get_order_key(), $gateway->id)
     48            "return_url"        => self::get_return_url('capture', $order->get_order_key(), $gateway)
    4949            )
    5050        );
    51 
    5251        return $data;
    5352    }
    5453
    5554    /**
    56      * Create Api URL.
     55     * Create Api callback URLs.
    5756     *
    5857     * @param string $action     Action to perform.
     
    7372
    7473    /**
    75      * Create Api URL.
     74     * Create Api return URL.
    7675     *
    77      * @param string $gateway_id Cashfree gateway id.
     76     * @param string $gateway Cashfree gateway.
    7877     *
    7978     * @return string
    8079     */
    81     public static function get_return_url( $action, $order_key, $gateway_id ) {
     80    public static function get_return_url( $action, $order_key, $gateway ) {
    8281        return add_query_arg(
    8382            array(
     
    8786                'action'      => $action
    8887            ),
    89             WC()->api_request_url( $gateway_id )
     88            WC()->api_request_url( $gateway->id )
    9089        );
     90    }
     91
     92    /**
     93     * Create Api webhooks URL.
     94     *
     95     * @param string $gateway Cashfree gateway.
     96     *
     97     * @return string
     98     */
     99    public static function get_notify_url( $action, $order_key, $gateway ) {
     100        $wc_notify_url =  add_query_arg(
     101            array(
     102                'order_key' => $order_key,
     103                'action'      => $action
     104            ),
     105            WC()->api_request_url( $gateway->id )
     106        );
     107
     108        $redirectData = base64_encode("notify_url=".$wc_notify_url."&platform=woo");
     109        if ( $gateway->settings['sandbox'] != 'yes' ) {
     110            $prefixUrl = 'https://payments.cashfree.com';
     111        } else {
     112            $prefixUrl = 'https://payments-test.cashfree.com';
     113        }
     114        $query_params = $prefixUrl."/pgbillpayuiapi/integrations/webhook?redirectData=".$redirectData;
     115        return $query_params;
    91116    }
    92117
     
    94119     * Get valid phone number
    95120     *
    96      * @param object $order     array.
     121     * @param object $order  array.
    97122     *
    98123     * @return string
  • cashfree/trunk/includes/settings/cashfree-payments.php

    r2742179 r2747397  
    2020        'desc_tip'      => true,
    2121    ),
    22     'description'       => array(
    23         'title'         => __( 'Description', 'cashfree' ),
    24         'type'          => 'text',
    25         'desc_tip'      => true,
    26         'description'   => __( 'This controls the description which the user sees during checkout.', 'cashfree' ),
    27         'default'       => __( 'Pay securely via Card/Net Banking/Wallet via Cashfree.', 'cashfree' ),
     22    'description' => array(
     23        'title'       => __( 'Description', 'cashfree' ),
     24        'type'        => 'textarea',
     25        'description' => __( 'Payment method description that the customer will see on your checkout.', 'cashfree' ),
     26        'default'     => __( 'Pay securely via Card/Net Banking/Wallet via Cashfree.', 'cashfree' ),
    2827    ),
    2928    'app_id'            => array(
  • cashfree/trunk/includes/wc-cashfree-functions.php

    r2742179 r2747397  
    55
    66defined( 'ABSPATH' ) || exit;
     7
     8function wc_get_cashfree_template( $template_name, $args = array(), $template_path = '' ) {
     9    wc_get_template( $template_name, $args, $template_path, WC_CASHFREE_DIR_PATH . 'templates/' );
     10}
    711
    812/**
  • cashfree/trunk/readme.txt

    r2742179 r2747397  
    22Contributors: devcashfree
    33Requires at least: 4.4
    4 Tested up to: 5.9
     4Tested up to: 6.0
    55Requires PHP: 5.6
    6 Stable tag: 4.3.2
    7 Version: 4.3.2
     6Stable tag: 4.3.3
     7Version: 4.3.3
    88License: GPLv3
    99License URI: https://www.gnu.org/licenses/gpl-3.0.html
     
    3333
    3434== Changelog ==
     35
     36= 4.3.3 =
     37* Add description of gateway on checkout page
     38* Add transaction detail on order notes
    3539
    3640= 4.3.2 =
Note: See TracChangeset for help on using the changeset viewer.