Changeset 2904623
- Timestamp:
- 04/26/2023 02:33:23 PM (3 years ago)
- Location:
- paytm-payments/trunk
- Files:
-
- 12 added
- 1 deleted
- 5 edited
-
assets/277 (deleted)
-
assets/279 (added)
-
assets/279/css (added)
-
assets/279/css/admin (added)
-
assets/279/css/admin/paytm-payments.css (added)
-
assets/279/css/paytm-payments.css (added)
-
assets/279/images (added)
-
assets/279/images/paytm_logo_invert.svg (added)
-
assets/279/images/paytm_logo_paymodes.svg (added)
-
assets/279/js (added)
-
assets/279/js/admin (added)
-
assets/279/js/admin/paytm-payments.js (added)
-
assets/279/js/paytm-payments.js (added)
-
class.paytm.php (modified) (4 diffs)
-
includes/PaytmConstants.php (modified) (2 diffs)
-
includes/PaytmHelper.php (modified) (2 diffs)
-
readme.txt (modified) (2 diffs)
-
woo-paytm.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
paytm-payments/trunk/class.paytm.php
r2834199 r2904623 19 19 $invertLogo = isset($getPaytmSetting['invertLogo'])?$getPaytmSetting['invertLogo']:"0"; 20 20 if ($invertLogo == 1) { 21 $this->icon= esc_url( plugin_dir_url(__FILE__) ."assets/".PaytmConstants::PLUGIN_VERSION_FOLDER."/images/paytm_logo_invert.svg");22 } else { 23 $this->icon= esc_url( plugin_dir_url(__FILE__) ."assets/".PaytmConstants::PLUGIN_VERSION_FOLDER."/images/paytm_logo_paymodes.svg");21 $this->icon= esc_url("https://staticpg.paytm.in/pg_plugins_logo/paytm_logo_invert.svg"); 22 } else { 23 $this->icon= esc_url("https://staticpg.paytm.in/pg_plugins_logo/paytm_logo_paymodes.svg"); 24 24 } 25 25 $this->has_fields= false; … … 50 50 } 51 51 add_action('woocommerce_receipt_' . $this->id, array($this, 'receipt_page')); 52 if (is_admin() ) {53 wp_enqueue_style('paytmadminWoopayment', plugin_dir_url(__FILE__) . 'assets/'.PaytmConstants::PLUGIN_VERSION_FOLDER.'/css/admin/paytm-payments.css', array(), time(), '');54 }55 56 if (!is_admin() ) {57 wp_enqueue_script('paytm-script', plugin_dir_url(__FILE__) . 'assets/'.PaytmConstants::PLUGIN_VERSION_FOLDER.'/js/paytm-payments.js', array('jquery'), time(), true);58 }59 52 } 60 53 … … 729 722 if ($_POST['environment'] == 0) { 730 723 $url = PaytmConstants::WEBHOOK_STAGING_URL; 731 $clientId = PaytmConstants::WEBHOOK_STAGING_CLIENTID;732 $key = base64_decode(PaytmConstants::WEBHOOK_STAGING_KEY);733 724 } else { 734 725 $url = PaytmConstants::WEBHOOK_PRODUCTION_URL; 735 $clientId = PaytmConstants::WEBHOOK_PRODUCTION_CLIENTID; 736 $key = base64_decode(PaytmConstants::WEBHOOK_PRODUCTION_KEY); 737 } 738 $environment = sanitize_text_field($_POST['environment']); 739 $jwtToken = PaytmHelper::createJWTToken($key, $clientId, $environment); 726 } 727 $environment = sanitize_text_field($_POST['environment']); 740 728 $mid = sanitize_text_field($_POST['mid']); 729 $mkey = sanitize_text_field($_POST['mkey']); 741 730 if ($_POST['is_webhook']==1) { 742 $webhookUrl = sanitize_text_field($_POST['webhookUrl']);731 $webhookUrl = sanitize_text_field($_POST['webhookUrl']); 743 732 } else { 744 733 $webhookUrl = esc_url("https://www.dummyUrl.com"); //set this when unchecked 745 734 } 746 747 $curl = curl_init(); 748 749 curl_setopt_array( 750 $curl, array( 751 CURLOPT_URL => $url.'api/v1/merchant/putMerchantInfo', 752 CURLOPT_RETURNTRANSFER => true, 753 CURLOPT_ENCODING => '', 754 CURLOPT_MAXREDIRS => 10, 755 CURLOPT_TIMEOUT => 0, 756 CURLOPT_FOLLOWLOCATION => true, 757 CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, 758 CURLOPT_CUSTOMREQUEST => 'PUT', 759 CURLOPT_POSTFIELDS =>'{ 760 "mid": "'.$mid.'", 761 "queryParam": "notificationUrls", 762 "paymentNotificationUrl": "'.$webhookUrl.'" 763 }', 764 CURLOPT_HTTPHEADER => array( 765 'x-client-token: '.$jwtToken.'', 766 'Content-Type: application/json', 767 'x-client-id: '.$clientId.'' 768 ), 769 ) 770 ); 771 772 $response = curl_exec($curl); 773 774 $res = json_decode($response); 775 if (isset($res->success)) { 735 $paytmParams = array( 736 "mid" => $mid, 737 "queryParam" => "notificationUrls", 738 "paymentNotificationUrl" => $webhookUrl 739 740 ); 741 $checksum = PaytmChecksum::generateSignature(json_encode($paytmParams, JSON_UNESCAPED_SLASHES), $mkey); 742 $res= PaytmHelper::executecUrl($url.'api/v1/external/putMerchantInfo', $paytmParams, $method ='PUT',['x-checksum'=>$checksum]); 743 // print_r($res); 744 if (isset($res['success'])) { 776 745 $message = true; 777 746 $success = $response; 778 747 $showMsg = false; 779 } elseif (isset($res ->E_400)) {748 } elseif (isset($res['E_400'])) { 780 749 $message = "Your webhook has already been configured"; 781 750 $success = $response; … … 793 762 function paytm_enqueue_script() 794 763 { 764 wp_enqueue_style('paytmadminWoopayment', plugin_dir_url(__FILE__) . 'assets/'.PaytmConstants::PLUGIN_VERSION_FOLDER.'/css/admin/paytm-payments.css', array(), time(), ''); 795 765 wp_enqueue_script('paytm-script', plugin_dir_url(__FILE__) . 'assets/'.PaytmConstants::PLUGIN_VERSION_FOLDER.'/js/admin/paytm-payments.js', array('jquery'), time(), true); 796 766 } 797 add_action('admin_enqueue_scripts', 'paytm_enqueue_script'); 767 768 if (current_user_can( 'manage_options' ) && isset( $_GET['page'] ) && $_GET['page'] === 'wc-settings' ) { 769 add_action('admin_enqueue_scripts', 'paytm_enqueue_script'); 770 } -
paytm-payments/trunk/includes/PaytmConstants.php
r2833893 r2904623 24 24 CONST TIMEOUT= 10; 25 25 26 CONST LAST_UPDATED= "202 21214";27 CONST PLUGIN_VERSION= "2.7. 7";28 CONST PLUGIN_VERSION_FOLDER= "27 7";26 CONST LAST_UPDATED= "20230426"; 27 CONST PLUGIN_VERSION= "2.7.9"; 28 CONST PLUGIN_VERSION_FOLDER= "279"; 29 29 30 30 CONST CUSTOM_CALLBACK_URL= ""; … … 66 66 CONST ERROR_CURL_WARNING= "Your server is unable to connect with us. Please contact to Paytm Support."; 67 67 68 CONST WEBHOOK_STAGING_URL= "https://boss-stage.paytm.in/"; 69 CONST WEBHOOK_STAGING_KEY = 'DSqy6pGOhBR9CUhUFQygzlkG1+x66C6zV+M8bnGiwpEH+MvNsWmaJLirjxMVpRH+9c9XjZxse+wSYuNYmkG4uA=='; 70 CONST WEBHOOK_STAGING_CLIENTID = '54b88dbc-fdd0-4f6f-af09-4ee76e90135a'; 71 72 CONST WEBHOOK_PRODUCTION_URL= "https://boss-ext.paytm.in/"; 73 CONST WEBHOOK_PRODUCTION_KEY = 'jF5tDDCJ8/bRot8X5DAGVHiC+KwW9SQuckYya12NZ2/EWVBhU7Cj45A4lOSvo797uJ4M3LB5mTjiC0nhDYKZGg=='; 74 CONST WEBHOOK_PRODUCTION_CLIENTID = 'f7484d06-f307-4e10-b661-0191f5efe031'; 68 CONST WEBHOOK_STAGING_URL= "https://boss-stage-internal.paytm.in/"; 69 CONST WEBHOOK_PRODUCTION_URL= "https://boss-internal.paytm.in/"; 75 70 76 71 } -
paytm-payments/trunk/includes/PaytmHelper.php
r2834199 r2904623 82 82 } 83 83 84 public static function executecUrl($apiURL, $requestParamList)84 /* public static function executecUrlOld($apiURL, $requestParamList) //not in use 85 85 { 86 86 $jsonResponse = wp_remote_post( … … 96 96 $responseParamList['request'] = $requestParamList; 97 97 return $responseParamList; 98 }*/ 99 100 public static function executecUrl($apiURL, $requestParamList, $method ='POST', $extraHeaders = array()){ 101 $headers = array("Content-Type"=> "application/json"); 102 if (!empty($extraHeaders)) { 103 $headers = array_merge($headers, $extraHeaders); 104 } 105 $args = array( 106 'headers' => $headers, 107 'body' => json_encode($requestParamList, JSON_UNESCAPED_SLASHES), 108 'method' => $method 109 ); 110 111 $result = wp_remote_request( $apiURL, $args ); 112 $response_body = wp_remote_retrieve_body($result); 113 return $responseParamList['request'] = json_decode($response_body, true); 98 114 } 99 115 100 public static function createJWTToken($key,$clientId,$environment)101 {102 // Create token header as a JSON string103 $header = json_encode(['alg' => 'HS512','typ' => 'JWT']);104 /* Create token payload as a JSON string */105 $time = time();106 $payload = json_encode(['client-id' => $clientId,'iat'=>$time]);107 108 // Encode Header to Base64Url String109 $base64UrlHeader = str_replace(['+', '/', '='], ['-', '_', ''], base64_encode($header));110 111 // Encode Payload to Base64Url String112 $base64UrlPayload = str_replace(['+', '/', '='], ['-', '_', ''], base64_encode($payload));113 114 // Create Signature Hash115 $signature = hash_hmac('SHA512', $base64UrlHeader . "." . $base64UrlPayload, $key, true);116 117 // Encode Signature to Base64Url String118 $base64UrlSignature = str_replace(['+', '/', '='], ['-', '_', ''], base64_encode($signature));119 120 // Create JWT121 $jwt = $base64UrlHeader . "." . $base64UrlPayload . "." . $base64UrlSignature;122 123 return $jwt;124 }125 116 } 126 117 endif; -
paytm-payments/trunk/readme.txt
r2833893 r2904623 4 4 Requires PHP: 5.6 5 5 Requires at least: 4.0.1 6 Tested up to: 6. 1.17 Stable tag: 2.7. 76 Tested up to: 6.2 7 Stable tag: 2.7.9 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 99 99 100 100 == Changelog == 101 101 102 = 2.7.9 = 103 * Compatible and tested with Woocommerce version upto 7.5.1 104 * Optimize JS and CSS 105 * Updated Security 106 102 107 = 2.7.7 = 103 108 * Compatible and tested with Woocommerce version upto 7.2.0 -
paytm-payments/trunk/woo-paytm.php
r2833893 r2904623 4 4 * Plugin URI: https://github.com/Paytm/ 5 5 * Description: This plugin allow you to accept payments using Paytm. This plugin will add a Paytm Payment option on WooCommerce checkout page, when user choses Paytm as Payment Method, he will redirected to Paytm website to complete his transaction and on completion his payment, paytm will send that user back to your website along with transactions details. This plugin uses server-to-server verification to add additional security layer for validating transactions. Admin can also see payment status for orders by navigating to WooCommerce > Orders from menu in admin. 6 * Version: 2.7. 76 * Version: 2.7.9 7 7 * Author: Paytm 8 8 * Author URI: https://business.paytm.com/payment-gateway 9 9 * Tags: Paytm, Paytm Payments, PayWithPaytm, Paytm WooCommerce, Paytm Plugin, Paytm Payment Gateway 10 10 * Requires at least: 4.0.1 11 * Tested up to: 6. 1.111 * Tested up to: 6.2 12 12 * Requires PHP: 5.6 13 13 * Text Domain: Paytm Payments 14 14 * WC requires at least: 2.0.0 15 * WC tested up to: 7. 2.015 * WC tested up to: 7.5.1 16 16 */ 17 17 … … 77 77 wp_enqueue_script('paytm-script', plugin_dir_url(__FILE__) . 'assets/'.PaytmConstants::PLUGIN_VERSION_FOLDER.'/js/paytm-payments.js', array('jquery'), time(), true); 78 78 } 79 add_action('wp_head', 'paytmWoopayment_enqueue_style'); 79 80 function paytmWoopayment_js_css(){ 81 if ( class_exists( 'WooCommerce' ) ) { 82 if( is_cart() || is_checkout() ) { 83 add_action('wp_head', 'paytmWoopayment_enqueue_style'); 84 } 85 } 86 } 87 88 add_action( 'wp_enqueue_scripts', 'paytmWoopayment_js_css' ); 89 80 90 81 91 if (PaytmConstants::SAVE_PAYTM_RESPONSE) {
Note: See TracChangeset
for help on using the changeset viewer.