Plugin Directory

Changeset 2749467


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

Updated to v1.2.4

Location:
cashfree-gravity-forms
Files:
14 added
3 edited

Legend:

Unmodified
Added
Removed
  • cashfree-gravity-forms/trunk/cashfree.php

    r2655878 r2749467  
    44Plugin URI: https://wordpress.org/plugins/cashfree-gravity-forms
    55Description: Integrates Gravity Forms with Cashfree Payments, enabling end users to purchase goods and services through Gravity Forms.
    6 Version: 1.2.3
    7 Stable tag: 1.2.3
     6Version: 1.2.4
     7Stable tag: 1.2.4
    88Author: Dev Cashfree
    99Author URI: https://cashfree.com
  • cashfree-gravity-forms/trunk/class-gf-cashfree.php

    r2655870 r2749467  
    470470
    471471    /**
     472     * @param array $entry
     473     * @param $form
     474     * @return bool|void
     475     */
     476    public function generate_cashfree_order($entry, $form)
     477    {
     478        $feed = $this->get_payment_feed($entry);
     479        $submissionData = $this->get_submission_data($feed, $form, $entry);
     480
     481        //gravity form method to get value of payment_amount key from entry
     482        $paymentAmount = rgar($entry, 'payment_amount');
     483
     484        //Check if gravity form is executed without any payment
     485        if (!$feed || empty($submissionData['payment_amount'])) {
     486            return true;
     487        }
     488
     489        //It will be null first time in the entry
     490        if (empty($paymentAmount) === true) {
     491            $paymentAmount = GFCommon::get_order_total($form, $entry);
     492            gform_update_meta($entry['id'], 'payment_amount', $paymentAmount);
     493            $entry['payment_amount'] = $paymentAmount;
     494        }
     495
     496        gform_update_meta($entry['id'], self::CASHFREE_ORDER_ID, $entry['id'].'_'.time());
     497
     498        $entry[self::CASHFREE_ORDER_ID] = $entry['id'].'_'.time();
     499
     500        GFAPI::update_entry($entry);
     501
     502        setcookie(self::CASHFREE_ORDER_ID, $entry[self::CASHFREE_ORDER_ID],
     503            time() + self::COOKIE_DURATION, COOKIEPATH, COOKIE_DOMAIN, false, true);
     504
     505        echo $this->generate_cashfree_form($entry, $form);
     506
     507    }
     508
     509    /**
    472510     * Generate cashfree form for payment
    473511     * @param $entry
     
    522560
    523561    /**
    524      * Submit payment request
    525      * @param $redirectUrl
    526      * @param $data
    527      */
    528     public function generate_order_form($redirectUrl, $data)
    529     {
    530         $html = '<body onload="document.createElement('."'form'".').submit.call(document.getElementById('."'cashfreeform'".'))">
    531         <form id ='."'cashfreeform'".' name='."'cashfreeform'".' action="'.$redirectUrl.'" method="POST">';
    532 
    533         foreach ($data as $key => $value) {
    534             $html .= '<input type="hidden" name="'.$key.'" value="'.$value.'">';
    535         }
    536             $html .= '<input type="hidden" name="submit" id="submit" value="Continue"/></form></body>';
    537            
    538             $allowed_html = array(
    539                 'body'      => array(
    540                     'onload'  => array(),
    541                 ),
    542                 'form'      => array(
    543                     'id'  => array(),
    544                     'name'  => array(),
    545                     'action'  => array(),
    546                     'method'  => array(),
    547                 ),
    548                 'input'      => array(
    549                     'type'  => array(),
    550                     'name'  => array(),
    551                     'id'  => array(),
    552                     'value'  => array(),
    553                 ),
    554             );
    555         echo wp_kses( $html, $allowed_html );
    556     }
    557 
    558     /**
    559562     * Generate Signature
    560563     * @param $data
     
    588591
    589592    /**
    590      * @param $entry
    591      * @param $form
    592      * @return bool|void
    593      */
    594     public function generate_cashfree_order($entry, $form)
    595     {
    596         $feed = $this->get_payment_feed($entry);
    597         $submissionData = $this->get_submission_data($feed, $form, $entry);
    598 
    599         //Check if gravity form is executed without any payment
    600         if (!$feed || empty($submissionData['payment_amount'])) {
    601             return true;
    602         }
    603         //gravity form method to get value of payment_amount key from entry
    604         $paymentAmount = rgar($entry, 'payment_amount');
    605 
    606         //It will be null first time in the entry
    607         if (empty($paymentAmount) === true) {
    608             $paymentAmount = GFCommon::get_order_total($form, $entry);
    609             gform_update_meta($entry['id'], 'payment_amount', $paymentAmount);
    610             $entry['payment_amount'] = $paymentAmount;
    611         }
    612 
    613         gform_update_meta($entry['id'], self::CASHFREE_ORDER_ID, $entry['id'].'_'.time());
    614 
    615         $entry[self::CASHFREE_ORDER_ID] = $entry['id'].'_'.time();
    616 
    617         GFAPI::update_entry($entry);
    618 
    619         setcookie(self::CASHFREE_ORDER_ID, $entry[self::CASHFREE_ORDER_ID],
    620             time() + self::COOKIE_DURATION, COOKIEPATH, COOKIE_DOMAIN, false, true);
    621 
    622         return $this->generate_cashfree_form($entry, $form);
    623 
     593     * Submit payment request
     594     * @param $redirectUrl
     595     * @param $data
     596     */
     597    public function generate_order_form($redirectUrl, $data)
     598    {
     599        $html = '<body onload="onLoadSubmit()">';
     600         
     601        $html .= <<<EOT
     602<form method="post" id="cashfreeform" name="cashfreeform" action="{$redirectUrl}">
     603EOT;
     604        foreach ($data as $key => $value) {
     605        $html .= <<<EOT
     606        <input type="hidden" name="{$key}" value="{$value}">
     607EOT;
     608        }
     609        $html .= <<<EOT
     610        </form>
     611        </body>
     612        <script language="javascript">
     613                function onLoadSubmit() {
     614                    document.cashfreeform.submit();
     615                }
     616        </script>
     617EOT;
     618        $allowed_html = array(
     619            'script' => array(
     620                'language' => array(),
     621            ),
     622            'body'      => array(
     623                'onload'  => array(),
     624            ),
     625            'form'      => array(
     626                'id'  => array(),
     627                'name'  => array(),
     628                'action'  => array(),
     629                'method'  => array(),
     630            ),
     631            'input'      => array(
     632                'type'  => array(),
     633                'name'  => array(),
     634                'id'  => array(),
     635                'value'  => array(),
     636            ),
     637            'button'      => array(
     638                'type'  => array(),
     639            ),
     640        );
     641        return wp_kses( $html, $allowed_html );
    624642    }
    625643
     
    762780        }
    763781    }
    764 
    765782}
  • cashfree-gravity-forms/trunk/readme.txt

    r2655878 r2749467  
    66Requires at least: 3.9.2
    77Tested up to: 5.8
    8 Stable tag: 1.2.3
     8Stable tag: 1.2.4
    99Requires PHP: 7.0
    1010License: GPLv2 or later
     
    4747== Changelog ==
    4848
     49= 1.2.4 =
     50* Bugfix for confliction in plugin
     51
    4952= 1.2.3 =
    5053* Adding assets for payment information.
Note: See TracChangeset for help on using the changeset viewer.