Changeset 2747397
- Timestamp:
- 06/24/2022 06:03:04 AM (4 years ago)
- Location:
- cashfree
- Files:
-
- 28 added
- 12 edited
-
assets/banner-772x250.png (modified) (previous)
-
assets/icon-256x256.png (modified) (previous)
-
assets/img/logo.png (modified) (previous)
-
tags/4.3.3 (added)
-
tags/4.3.3/LICENSE (added)
-
tags/4.3.3/README.md (added)
-
tags/4.3.3/assets (added)
-
tags/4.3.3/assets/js (added)
-
tags/4.3.3/assets/js/checkout.js (added)
-
tags/4.3.3/cashfree.php (added)
-
tags/4.3.3/includes (added)
-
tags/4.3.3/includes/class-wc-cashfree-api.php (added)
-
tags/4.3.3/includes/gateways (added)
-
tags/4.3.3/includes/gateways/class-wc-cashfree-gateway.php (added)
-
tags/4.3.3/includes/gateways/class-wc-cashfree-payments.php (added)
-
tags/4.3.3/includes/http (added)
-
tags/4.3.3/includes/http/class-wc-cashfree-adapter.php (added)
-
tags/4.3.3/includes/request (added)
-
tags/4.3.3/includes/request/class-wc-cashfree-request-billing.php (added)
-
tags/4.3.3/includes/request/class-wc-cashfree-request-checkout.php (added)
-
tags/4.3.3/includes/request/class-wc-cashfree-request-items.php (added)
-
tags/4.3.3/includes/request/class-wc-cashfree-request-shipping.php (added)
-
tags/4.3.3/includes/settings (added)
-
tags/4.3.3/includes/settings/cashfree-payments.php (added)
-
tags/4.3.3/includes/wc-cashfree-functions.php (added)
-
tags/4.3.3/includes/wc-cashfree-scripts.php (added)
-
tags/4.3.3/readme.txt (added)
-
tags/4.3.3/templates (added)
-
tags/4.3.3/templates/payment-fields.php (added)
-
trunk/assets/js/checkout.js (modified) (3 diffs)
-
trunk/cashfree.php (modified) (1 diff)
-
trunk/includes/gateways/class-wc-cashfree-gateway.php (modified) (15 diffs)
-
trunk/includes/gateways/class-wc-cashfree-payments.php (modified) (1 diff)
-
trunk/includes/http/class-wc-cashfree-adapter.php (modified) (4 diffs)
-
trunk/includes/request/class-wc-cashfree-request-checkout.php (modified) (4 diffs)
-
trunk/includes/settings/cashfree-payments.php (modified) (1 diff)
-
trunk/includes/wc-cashfree-functions.php (modified) (1 diff)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/templates (added)
-
trunk/templates/payment-fields.php (added)
Legend:
- Unmodified
- Added
- Removed
-
cashfree/trunk/assets/js/checkout.js
r2742179 r2747397 4 4 let dismissflag = true; 5 5 //Set env 6 const env = wc_cashfree_checkout_params.environment; //or production 6 const env = wc_cashfree_checkout_params.environment; //or production 7 7 8 //Create Success Callback 8 9 const successCallback = function (data) { … … 10 11 woocommerceFormSubmit(data, wc_cashfree_checkout_params.capture_url); 11 12 } 13 12 14 //Create Failure Callback 13 15 const failureCallback = function (data) { 14 16 woocommerceFormSubmit(data, wc_cashfree_checkout_params.cancel_url); 15 17 } 18 16 19 //Create Dismiss Callback 17 20 const dismissCallback = function () { … … 65 68 pippin_form.submit(); 66 69 } 67 Pippin.setOrderMetaPlatform("wc ");70 Pippin.setOrderMetaPlatform("wc-" + wc_cashfree_checkout_params.woo_version); 68 71 Pippin(env, wc_cashfree_checkout_params.token, successCallback, failureCallback, dismissCallback); 69 72 } -
cashfree/trunk/cashfree.php
r2742179 r2747397 2 2 /** 3 3 * Plugin Name: Cashfree 4 * Version: 4.3. 24 * Version: 4.3.3 5 5 * Plugin URI: https://github.com/cashfree/cashfree-woocommerce 6 6 * Description: Payment gateway plugin by Cashfree for Woocommerce sites. -
cashfree/trunk/includes/gateways/class-wc-cashfree-gateway.php
r2742179 r2747397 16 16 * @var WC_Cashfree_Adapter 17 17 */ 18 18 19 protected $adapter; 19 20 … … 21 22 * Constructor. 22 23 */ 24 23 25 public function __construct() { 24 26 $this->has_fields = true; … … 100 102 public function payment_fields() { 101 103 wc_cashfree_script( 'wc-cashfree-js' ); 104 wc_get_cashfree_template( 'payment-fields.php', array( 'gateway' => $this ) ); 102 105 } 103 106 … … 116 119 return array( 'result' => 'failure' ); 117 120 } 121 118 122 if($this->in_context === true) { 119 123 $order = wc_get_order( $order_id ); … … 134 138 * 135 139 * @param array $data post data. 136 * @param string $order_key Order key.140 * @param string $order_key Order key. 137 141 */ 138 142 public function capture( $data, $order_key ) { … … 144 148 145 149 $order = $this->get_order( $order_id, $order_key ); 146 147 150 if ( $order && $order->needs_payment() || $order->has_status('processing')) { 148 151 try { … … 150 153 if ($response->payment_status === 'SUCCESS') { 151 154 $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 ); 152 161 wp_safe_redirect( $this->get_return_url( $order ) ); 153 162 exit; … … 164 173 $order->add_order_note( 165 174 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' ), 167 176 $order_status, 168 177 $order->get_id(), … … 174 183 wc_add_notice( __( 'Cashfree capture error.', 'cashfree' ), 'error' ); 175 184 wp_safe_redirect( wc_get_checkout_url() ); 185 exit; 176 186 } 177 187 … … 179 189 * Cancel a checkout. 180 190 * 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']; 186 196 $order = $this->get_order( $order_id, $order_key ); 187 197 188 198 if ( $order && $order->needs_payment() ) { 189 if($ post_data['transaction_status'] === 'CANCELLED') {199 if($data['transaction_status'] === 'CANCELLED') { 190 200 $order_status = 'cancelled'; 191 } elseif($ post_data['transaction_status'] === 'FAILED') {201 } elseif($data['transaction_status'] === 'FAILED') { 192 202 $order_status = 'failed'; 193 203 } else { … … 201 211 $order_status, 202 212 $order->get_id(), 203 $ post_data['transaction_msg']213 $data['transaction_msg'] 204 214 ) 205 215 ); 206 216 } 207 wc_add_notice( __( $ post_data['transaction_msg'], 'cashfree' ), 'error');217 wc_add_notice( __( $data['transaction_msg'], 'cashfree' ), 'error'); 208 218 wp_safe_redirect( wc_get_checkout_url() ); 219 exit; 209 220 } 210 221 … … 217 228 public function dismiss( $post_data, $order_key ) { 218 229 wp_safe_redirect( wc_get_checkout_url() ); 230 exit; 219 231 } 220 232 … … 222 234 * Webhook a checkout. 223 235 * 224 * @param array $ post_data post data.236 * @param array $data post data. 225 237 * @param string $order_key Order key. 226 238 */ 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']; 230 242 $order = $this->get_order( $order_id, $order_key ); 231 243 232 244 if ( $order && $order->needs_payment() ) { 233 245 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 ); 238 256 } catch ( Exception $e ) { 239 257 WC_Cashfree::log( 'notify : ' . $e->getMessage(), 'critical' ); … … 299 317 'capture_url' => WC_Cashfree_Request_Checkout::get_url( 'capture', wc_clean( wp_unslash( $_GET[ 'key' ] ) ), $this->id ), 300 318 '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 ) 302 321 ); 303 322 } … … 307 326 * Get order instance. 308 327 * 309 * @param string $ transaction_id Transactionid.310 * @param string $order_key Order key.328 * @param string $order_id Order id. 329 * @param string $order_key Order key. 311 330 * 312 331 * @return bool|WC_Order|WC_Order_Refund -
cashfree/trunk/includes/gateways/class-wc-cashfree-payments.php
r2742179 r2747397 16 16 public function __construct() { 17 17 $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' );21 18 $this->icon = "https://cashfreelogo.cashfree.com/wix/cflogo.svg"; 22 19 $this->method_description = __( 'Pay securely via Card/Net Banking/Wallet via Cashfree.', 'cashfree' ); 23 20 parent::__construct(); 24 21 } -
cashfree/trunk/includes/http/class-wc-cashfree-adapter.php
r2742179 r2747397 54 54 ]; 55 55 56 // Order Cart save56 //Save cart details 57 57 try { 58 58 $this->cashfreeCheckoutCartSave( $order_id ); … … 187 187 } 188 188 189 // Get config values for gateway environment 189 190 public function getCurlValue() { 190 191 if ( $this->gateway->settings['sandbox'] != 'yes' ) { … … 202 203 } 203 204 205 // Post request for gateway 204 206 private function curlPostRequest($curlUrl, $data, $idemKey = "") { 205 207 $headers = array( … … 232 234 } 233 235 236 // Get request for gateway 234 237 private function curlGetRequest($curlUrl) { 235 238 -
cashfree/trunk/includes/request/class-wc-cashfree-request-checkout.php
r2742179 r2747397 46 46 "order_meta" => array( 47 47 "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) 49 49 ) 50 50 ); 51 52 51 return $data; 53 52 } 54 53 55 54 /** 56 * Create Api URL.55 * Create Api callback URLs. 57 56 * 58 57 * @param string $action Action to perform. … … 73 72 74 73 /** 75 * Create Api URL.74 * Create Api return URL. 76 75 * 77 * @param string $gateway _id Cashfree gateway id.76 * @param string $gateway Cashfree gateway. 78 77 * 79 78 * @return string 80 79 */ 81 public static function get_return_url( $action, $order_key, $gateway _id) {80 public static function get_return_url( $action, $order_key, $gateway ) { 82 81 return add_query_arg( 83 82 array( … … 87 86 'action' => $action 88 87 ), 89 WC()->api_request_url( $gateway _id )88 WC()->api_request_url( $gateway->id ) 90 89 ); 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; 91 116 } 92 117 … … 94 119 * Get valid phone number 95 120 * 96 * @param object $order array.121 * @param object $order array. 97 122 * 98 123 * @return string -
cashfree/trunk/includes/settings/cashfree-payments.php
r2742179 r2747397 20 20 'desc_tip' => true, 21 21 ), 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' ), 28 27 ), 29 28 'app_id' => array( -
cashfree/trunk/includes/wc-cashfree-functions.php
r2742179 r2747397 5 5 6 6 defined( 'ABSPATH' ) || exit; 7 8 function 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 } 7 11 8 12 /** -
cashfree/trunk/readme.txt
r2742179 r2747397 2 2 Contributors: devcashfree 3 3 Requires at least: 4.4 4 Tested up to: 5.94 Tested up to: 6.0 5 5 Requires PHP: 5.6 6 Stable tag: 4.3. 27 Version: 4.3. 26 Stable tag: 4.3.3 7 Version: 4.3.3 8 8 License: GPLv3 9 9 License URI: https://www.gnu.org/licenses/gpl-3.0.html … … 33 33 34 34 == Changelog == 35 36 = 4.3.3 = 37 * Add description of gateway on checkout page 38 * Add transaction detail on order notes 35 39 36 40 = 4.3.2 =
Note: See TracChangeset
for help on using the changeset viewer.