Changeset 2749467
- Timestamp:
- 06/29/2022 07:06:03 AM (4 years ago)
- Location:
- cashfree-gravity-forms
- Files:
-
- 14 added
- 3 edited
-
assets/banner-772x250.png (added)
-
assets/icon-256x256.png (added)
-
tags/1.2.4 (added)
-
tags/1.2.4/README.md (added)
-
tags/1.2.4/cashfree.php (added)
-
tags/1.2.4/class-gf-cashfree.php (added)
-
tags/1.2.4/includes (added)
-
tags/1.2.4/includes/css (added)
-
tags/1.2.4/includes/css/style.css (added)
-
tags/1.2.4/includes/images (added)
-
tags/1.2.4/includes/images/cflogo.svg (added)
-
tags/1.2.4/includes/js (added)
-
tags/1.2.4/includes/js/script.js (added)
-
tags/1.2.4/readme.txt (added)
-
trunk/cashfree.php (modified) (1 diff)
-
trunk/class-gf-cashfree.php (modified) (4 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
cashfree-gravity-forms/trunk/cashfree.php
r2655878 r2749467 4 4 Plugin URI: https://wordpress.org/plugins/cashfree-gravity-forms 5 5 Description: Integrates Gravity Forms with Cashfree Payments, enabling end users to purchase goods and services through Gravity Forms. 6 Version: 1.2. 37 Stable tag: 1.2. 36 Version: 1.2.4 7 Stable tag: 1.2.4 8 8 Author: Dev Cashfree 9 9 Author URI: https://cashfree.com -
cashfree-gravity-forms/trunk/class-gf-cashfree.php
r2655870 r2749467 470 470 471 471 /** 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 /** 472 510 * Generate cashfree form for payment 473 511 * @param $entry … … 522 560 523 561 /** 524 * Submit payment request525 * @param $redirectUrl526 * @param $data527 */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 /**559 562 * Generate Signature 560 563 * @param $data … … 588 591 589 592 /** 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}"> 603 EOT; 604 foreach ($data as $key => $value) { 605 $html .= <<<EOT 606 <input type="hidden" name="{$key}" value="{$value}"> 607 EOT; 608 } 609 $html .= <<<EOT 610 </form> 611 </body> 612 <script language="javascript"> 613 function onLoadSubmit() { 614 document.cashfreeform.submit(); 615 } 616 </script> 617 EOT; 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 ); 624 642 } 625 643 … … 762 780 } 763 781 } 764 765 782 } -
cashfree-gravity-forms/trunk/readme.txt
r2655878 r2749467 6 6 Requires at least: 3.9.2 7 7 Tested up to: 5.8 8 Stable tag: 1.2. 38 Stable tag: 1.2.4 9 9 Requires PHP: 7.0 10 10 License: GPLv2 or later … … 47 47 == Changelog == 48 48 49 = 1.2.4 = 50 * Bugfix for confliction in plugin 51 49 52 = 1.2.3 = 50 53 * Adding assets for payment information.
Note: See TracChangeset
for help on using the changeset viewer.