demo_rzp_settings_in.php
1 week ago
enqueue.php
2 years ago
functions.php
1 week ago
rzp_menu_links.php
4 years ago
rzp_settings.php
2 years ago
rzp_tab.php
2 years ago
functions.php
361 lines
| 1 | <?php |
| 2 | if (!defined('ABSPATH')) exit; // Exit if accessed directly |
| 3 | |
| 4 | |
| 5 | function cf7rzp_get_payment_more_info($post_id){ |
| 6 | |
| 7 | $res = []; |
| 8 | $post_id = sanitize_text_field(is_numeric($_GET['post_id'])?$_GET['post_id']:exit); |
| 9 | |
| 10 | $post = get_post($post_id); |
| 11 | $status = $post->post_status; |
| 12 | |
| 13 | $post_meta = get_post_meta($post_id); |
| 14 | $order_id = $post_meta['cf7rzp_order_id'][0]; |
| 15 | $item_id = $post_meta['item_id'][0]; |
| 16 | $item_name = $post_meta['item_name'][0]; |
| 17 | $item_price = $post_meta['item_price'][0]; |
| 18 | $form_id = $post_meta['cf7_id'][0]; |
| 19 | $gateway = $post_meta['gateway'][0]; |
| 20 | $mode = $post_meta['mode'][0]; |
| 21 | $rzp_order_id = $post_meta['rzp_order_id'][0]; |
| 22 | $rzp_payment_id = $post_meta['rzp_payment_id'][0]; |
| 23 | $failure_reason = $post_meta['failure_reason'][0]; |
| 24 | |
| 25 | $res['order_id'] = $order_id; |
| 26 | $res['item_id'] = $item_id; |
| 27 | $res['item_name'] = $item_name; |
| 28 | $res['item_price'] = $item_price; |
| 29 | $res['form_name'] = get_the_title($form_id); |
| 30 | $res['gateway'] = $gateway; |
| 31 | $res['mode'] = $mode; |
| 32 | $res['rzp_order_id'] = $rzp_order_id; |
| 33 | $res['status'] = $status; |
| 34 | $res['status_label'] = cf7rzp_get_payment_status_label($status); |
| 35 | |
| 36 | $dt = get_the_date( 'Y-m-d H:i:s', $post_id); |
| 37 | $dt = new DateTime($dt, new DateTimeZone('UTC')); |
| 38 | $dt->setTimezone(new DateTimeZone('Asia/Kolkata')); |
| 39 | $res['created_at'] = $dt->format('F j, Y | h:i:s a'); |
| 40 | |
| 41 | |
| 42 | |
| 43 | if($status == "cf7rzp_success") |
| 44 | $res['rzp_payment_id'] = $rzp_payment_id; |
| 45 | |
| 46 | if($status == "cf7rzp_failure") |
| 47 | $res['failure_reason'] = $failure_reason; |
| 48 | |
| 49 | echo json_encode($res); |
| 50 | wp_die(); |
| 51 | } |
| 52 | add_action( 'wp_ajax_nopriv_cf7rzp_get_payment_more_info', 'cf7rzp_get_payment_more_info' ); |
| 53 | add_action( 'wp_ajax_cf7rzp_get_payment_more_info', 'cf7rzp_get_payment_more_info' ); |
| 54 | |
| 55 | if ( !is_plugin_active( 'integrate-razorpay-contact-form-7-premium-addon/integrate-razorpay-contact-form-7-premium-addon.php' ) ) { |
| 56 | add_filter( 'plugin_action_links_' . CF7RZP_DIR_NAME.'/integrate-razorpay-for-contact-form-7.php', 'cf7rzp_plugin_action_links' ); |
| 57 | add_filter('cf7rzp_admin_rzp_tab', 'cf7rzppa_admin_rzp_tabdemo'); |
| 58 | add_action( 'admin_menu', 'cf7rzppa_admin_menu', 20 ); |
| 59 | } |
| 60 | function cf7rzp_plugin_action_links( $links ) { |
| 61 | $settings_link = '<a href="/wp-admin/admin.php?page=cf7rzp_settings">Settings</a>'; |
| 62 | $premium_link = '<a href="https://cf7rzppa.codolin.com?utm_source=plugin_user&utm_medium=plugin&utm_campaign=upsell" target="_blank" style="font-weight: bold; color: #6f00d1;font-size:14px;">Get Pro</a>'; |
| 63 | array_push( $links, $settings_link, $premium_link ); |
| 64 | |
| 65 | return $links; |
| 66 | } |
| 67 | function cf7rzppa_admin_rzp_tabdemo($rzp_tab_output) { |
| 68 | |
| 69 | $rzp_tab_output_style = ""; |
| 70 | |
| 71 | $rzp_tab_output .= $rzp_tab_output_style; |
| 72 | |
| 73 | $rzp_tab_output .= "<tbody class='cf7rzppa-demo-rzp-settings'> |
| 74 | <tr><td> </td></tr> |
| 75 | <tr class='premium-link'><td><a href='https://cf7rzppa.codolin.com?utm_source=plugin_user&utm_medium=plugin&utm_campaign=upsell' target='_blank'>Unlock with Premium</a></td></tr>"; |
| 76 | |
| 77 | $rzp_tab_output .= "<tr><td style='background: #e4e4e4;text-align: center;' colspan='3'><h2 style='color:green;font-weight:bold;'>Premium Settings</h2></td></tr>"; |
| 78 | |
| 79 | $rzp_tab_output .= "<tr><td> </td></tr>"; |
| 80 | |
| 81 | $rzp_tab_output .= "<td><label><b>Pre-defined Pricing Options: </b></label></td>"; |
| 82 | $rzp_tab_output .= "<td><input name='' value='1' class='cf7rzppa_price_enable_checkbox' type='checkbox' CHECKED></td> |
| 83 | <td>[ Enabling will override the Item price ]</td> |
| 84 | </tr> "; |
| 85 | |
| 86 | $rzp_tab_output .= "<tr><td> </td></tr>"; |
| 87 | |
| 88 | $rzp_tab_output .= "<tr> |
| 89 | <td>Pre-defined Pricing Form Field: </td> |
| 90 | <td><input type='text' name='' value='variable-price'> <br/>Example: variable-price</td> |
| 91 | <td>[ The Form field in contact form 7 that should be used for pre-defined pricing. Allowed form fields: radio buttons | drop-down menu(single select) | checkboxes(single select) ]</td> |
| 92 | </tr>"; |
| 93 | |
| 94 | $rzp_tab_output .= "<tr><td> </td></tr>"; |
| 95 | |
| 96 | $rzp_tab_output .= "<tr> |
| 97 | <td>Pre-defined Pricing Value: </td> |
| 98 | <td><input type='text' name='' value='100|200|300'> <br/>Example: 100|200|300</td> |
| 99 | <td>[ Enter pre-defined price value seperated by pipline'|' symbol. <span>Price mapping to options is based on order it is entered.</span> ]</td> |
| 100 | </tr>"; |
| 101 | |
| 102 | $rzp_tab_output .= "<tr><td> </td></tr>"; |
| 103 | |
| 104 | $end_user_pricing_html = " |
| 105 | <tr><td colspan='3' style='border-top:1px solid;'> </td></tr> |
| 106 | <tr> |
| 107 | <td><b>User-defined Pricing: </b></td> |
| 108 | <td><input name='' value='1' class='cf7rzppa_price_enable_checkbox' type='checkbox'></td> |
| 109 | <td>[ Enabling will override the Item price ]</td> |
| 110 | </tr> |
| 111 | <tr><td> </td></tr> |
| 112 | <tr> |
| 113 | <td>User-defined Pricing Form Field: </td> |
| 114 | <td><input type='text' name='' value='enduser-price'> <br/>Example: enduser-price</td> |
| 115 | <td>[ The Form field in contact form 7 that should be used for user-defined pricing. Allowed form fields: number | text ]</td> |
| 116 | </tr> |
| 117 | <tr><td> </td></tr> |
| 118 | "; |
| 119 | $rzp_tab_output .= $end_user_pricing_html; |
| 120 | |
| 121 | $form_data_collection_html = " |
| 122 | <tr><td colspan='3' style='border-top:1px solid;'> </td></tr> |
| 123 | <tr> |
| 124 | <td><b>Enable FormData Collection: </b></td> |
| 125 | <td><input name='' value='1' type='checkbox' CHECKED></td> |
| 126 | <td>[ Enabling will collect user submitted form data ]</td> |
| 127 | </tr> |
| 128 | <tr><td> </td></tr> |
| 129 | "; |
| 130 | $rzp_tab_output .= $form_data_collection_html; |
| 131 | |
| 132 | $order_shortcode_html = " |
| 133 | <tr><td colspan='3' style='border-top:1px solid;'> </td></tr> |
| 134 | <tr> |
| 135 | <td><b>Enable Order Shortcode: </b></td> |
| 136 | <td><input name='' value='1' type='checkbox' CHECKED></td> |
| 137 | <td>[ Enabling will allow to use order related shortcodes in \"Thank You Page\" ]</td> |
| 138 | </tr> |
| 139 | <tr><td> </td></tr> |
| 140 | <tr> |
| 141 | <td><b>[cf7rzppa-order]</b></td> |
| 142 | <td><b>Shortcode Usage in \"Thank You\" Page:</b></td> |
| 143 | <td></td> |
| 144 | </tr> |
| 145 | <tr> |
| 146 | <td></td> |
| 147 | <td colspan='3'> |
| 148 | <ul style='list-style-type:square;padding-left:17px;'> |
| 149 | <li><code>[cf7rzppa-order]</code> - By default display \"Order Id\" if no \"data\" attribute passed.</li> |
| 150 | <li><code>[cf7rzppa-order data=\"order_id\"]</code> - Display \"Order Id\"</li> |
| 151 | <li><code>[cf7rzppa-order data=\"item_id\"]</code> - Display order related \"Item Id\"</li> |
| 152 | <li><code>[cf7rzppa-order data=\"item_name\"]</code> - Display order related \"Item Name\"</li> |
| 153 | <li><code>[cf7rzppa-order data=\"item_price\"]</code> - Display order related \"Item Price\"</li> |
| 154 | </ul> |
| 155 | </td> |
| 156 | <td></td> |
| 157 | </tr> |
| 158 | <tr><td> </td></tr> |
| 159 | "; |
| 160 | $rzp_tab_output .= $order_shortcode_html; |
| 161 | |
| 162 | $export_csv_html = " |
| 163 | <tr><td colspan='3' style='border-top:1px solid;'> </td></tr> |
| 164 | <tr> |
| 165 | <td><b>Enable \"Export CSV\": </b></td> |
| 166 | <td><input name='' value='1' type='checkbox' CHECKED></td> |
| 167 | <td>[ Enabling will allow \"export/download\" of \"Order/Payment\" data and its associated \"User submitted form\" data as CSV file wrt this contact form. ]</td> |
| 168 | </tr> |
| 169 | <tr><td> </td></tr> |
| 170 | "; |
| 171 | $rzp_tab_output .= $export_csv_html; |
| 172 | |
| 173 | $custom_orderid_prefix_html = " |
| 174 | <tr><td colspan='3' style='border-top:1px solid;'> </td></tr> |
| 175 | <tr> |
| 176 | <td><b>Custom OrderId Prefix: </b></td> |
| 177 | <td><input name='' value='1' type='checkbox'></td> |
| 178 | <td>[ Enabling will override the default OrderId prefix. ]</td> |
| 179 | </tr> |
| 180 | <tr><td> </td></tr> |
| 181 | <tr> |
| 182 | <td>OrderId Prefix: </td> |
| 183 | <td><input type='text' name='' value=''> <br/>Example: YOURPRODUCTCODE_</td> |
| 184 | <td>[ Enter your custom OrderId Prefix that should replace default prefix: \"cf7rzp_\" ]</td> |
| 185 | </tr> |
| 186 | <tr><td> </td></tr> |
| 187 | "; |
| 188 | $rzp_tab_output .= $custom_orderid_prefix_html; |
| 189 | |
| 190 | $order_success_redirect_html = " |
| 191 | <tr><td colspan='3' style='border-top:1px solid;'> </td></tr> |
| 192 | <tr> |
| 193 | <td><b>Order Success Redirect: </b></td> |
| 194 | <td><input name='' value='1' type='checkbox'></td> |
| 195 | <td>[ Enabling will override the default Return/Success Url. ]</td> |
| 196 | </tr> |
| 197 | <tr><td> </td></tr> |
| 198 | <tr> |
| 199 | <td>Order Success Redirect Url: </td> |
| 200 | <td><input type='text' name='' value=''> <br/>Example: http://example.com/thankyou.</td> |
| 201 | <td>[ If the customer makes succesful Razorpay Payment, where are they redirected to after. |
| 202 | It can be either Internal Thank You page url or External url. ]</td> |
| 203 | </tr> |
| 204 | <tr><td> </td></tr> |
| 205 | "; |
| 206 | $rzp_tab_output .= $order_success_redirect_html; |
| 207 | |
| 208 | $rzp_payment_popup_settings_html = " |
| 209 | <tr><td colspan='3' style='border-top:1px solid;'> </td></tr> |
| 210 | <tr> |
| 211 | <td></td> |
| 212 | <td colspan='3' style='font-size:14px;text-decoration:underline;'><b>Razorpay Payment Popup Settings:</b></td> |
| 213 | <td></td> |
| 214 | </tr> |
| 215 | <tr><td> </td></tr> |
| 216 | <tr> |
| 217 | <td><b>Enable Logo: </b></td> |
| 218 | <td><input name='' value='' type='checkbox'></td> |
| 219 | <td>[ Enabling will override the Global settings. ]</td> |
| 220 | </tr> |
| 221 | <tr><td> </td></tr> |
| 222 | <tr> |
| 223 | <td>Logo (URL): </td> |
| 224 | <td><input type='text' name='' value=''> <br/> </td> |
| 225 | <td>[ This will be displayed in Razorpay Payment Popup. Choose a square image of minimum dimensions 256x256 px. ]</td> |
| 226 | </tr> |
| 227 | <tr> |
| 228 | <td></td> |
| 229 | <td colspan='3'><br/>Example: https://cdn.razorpay.com/logos/FFATTsJeURNMxx_medium.png</td> |
| 230 | <td></td> |
| 231 | </tr> |
| 232 | <tr><td> </td></tr> |
| 233 | <tr><td colspan='3' style='border-top:1px dashed;'> </td></tr> |
| 234 | <tr> |
| 235 | <td><b>Enable Theme Color: </b></td> |
| 236 | <td><input name='' value='' type='checkbox'></td> |
| 237 | <td>[ Enabling will override the Global settings. ]</td> |
| 238 | </tr> |
| 239 | <tr><td> </td></tr> |
| 240 | <tr> |
| 241 | <td>Theme Color: </td> |
| 242 | <td><input type='text' name='' value=''> <br/>Example: #cccccc </td> |
| 243 | <td>[ Enter a HEX color code to change the Razorpay Payment Popup Theme color. <a href=\"https://htmlcolorcodes.com/\" target=\"_blank\">HEX Color Picker</a> ]</td> |
| 244 | </tr> |
| 245 | <tr><td> </td></tr> |
| 246 | <tr><td colspan='3' style='border-top:1px dashed;'> </td></tr> |
| 247 | <tr> |
| 248 | <td><b>Enable Theme Backdrop Color: </b></td> |
| 249 | <td><input name='' value='' type='checkbox'></td> |
| 250 | <td>[ Enabling will override the Global settings. ]</td> |
| 251 | </tr> |
| 252 | <tr><td> </td></tr> |
| 253 | <tr> |
| 254 | <td>Theme Backdrop Color: </td> |
| 255 | <td><input type='text' name='' value=''> <br/>Example: #000000 </td> |
| 256 | <td>[ Enter a HEX color code to change the Razorpay Payment Popup Theme backdrop color. <a href=\"https://htmlcolorcodes.com/\" target=\"_blank\">HEX Color Picker</a> ]</td> |
| 257 | </tr> |
| 258 | <tr><td> </td></tr> |
| 259 | "; |
| 260 | $rzp_tab_output .= $rzp_payment_popup_settings_html; |
| 261 | |
| 262 | $autofill_customer_info_html = " |
| 263 | <tr><td colspan='3' style='border-top:1px solid;'> </td></tr> |
| 264 | <tr> |
| 265 | <td colspan='3' style='text-align:center;font-size:14px;text-decoration:underline;'><b>Autofill Customer Information In Razorpay Payment Popup:</b></td> |
| 266 | </tr> |
| 267 | <tr><td> </td></tr> |
| 268 | <tr> |
| 269 | <td><b>Autofill Customer Name: </b></td> |
| 270 | <td><input name='' value='' type='checkbox'></td> |
| 271 | <td>[ Enabling will autofill customer name. ]</td> |
| 272 | </tr> |
| 273 | <tr><td> </td></tr> |
| 274 | <tr> |
| 275 | <td>Customer Name Form Field: </td> |
| 276 | <td><input type='text' name='' value=''> <br/> Example: your-name </td> |
| 277 | <td>[ The Form field in contact form 7 that should be used for autofilling customer name in Razorpay Payment Popup. ]</td> |
| 278 | </tr> |
| 279 | <tr><td> </td></tr> |
| 280 | <tr><td colspan='3' style='border-top:1px dashed;'> </td></tr> |
| 281 | <tr> |
| 282 | <td><b>Autofill Customer Email: </b></td> |
| 283 | <td><input name='' value='' type='checkbox'></td> |
| 284 | <td>[ Enabling will autofill customer email. ]</td> |
| 285 | </tr> |
| 286 | <tr><td> </td></tr> |
| 287 | <tr> |
| 288 | <td>Customer Email Form Field: </td> |
| 289 | <td><input type='text' name='' value=''> <br/>Example: your-email </td> |
| 290 | <td>[ The Form field in contact form 7 that should be used for autofilling customer email in Razorpay Payment Popup. ]</td> |
| 291 | </tr> |
| 292 | <tr><td> </td></tr> |
| 293 | <tr><td colspan='3' style='border-top:1px dashed;'> </td></tr> |
| 294 | <tr> |
| 295 | <td><b>Autofill Customer Phone: </b></td> |
| 296 | <td><input name='' value='' type='checkbox'></td> |
| 297 | <td>[ Enabling will autofill customer phone. ]</td> |
| 298 | </tr> |
| 299 | <tr><td> </td></tr> |
| 300 | <tr> |
| 301 | <td>Customer Phone Form Field: </td> |
| 302 | <td><input type='text' name='' value=''> <br/>Example: your-phone</td> |
| 303 | <td>[ The Form field in contact form 7 that should be used for autofilling customer phone in Razorpay Payment Popup. ]</td> |
| 304 | </tr> |
| 305 | <tr><td> </td></tr> |
| 306 | "; |
| 307 | $rzp_tab_output .= $autofill_customer_info_html; |
| 308 | |
| 309 | $email_notify_html = " |
| 310 | <tr><td colspan='3' style='border-top:1px solid;'> </td></tr> |
| 311 | <tr> |
| 312 | <td><b>Enable Email Notification: </b></td> |
| 313 | <td><input name='' value='' type='checkbox'></td> |
| 314 | <td>[ Enabling this option will stop the default email from being sent after form submission. Instead, it allows the use of <b>CF7RZP Mail Tags</b> in the \"Mail\" Tab's \"Message Body\" settings and sends an email notification only after a successful payment, including order details based on the configured mail tags. ]</td> |
| 315 | </tr> |
| 316 | <tr><td> </td></tr> |
| 317 | <tr> |
| 318 | <td></td> |
| 319 | <td><b>Available CF7RZP Mail Tags:</b></td> |
| 320 | <td></td> |
| 321 | </tr> |
| 322 | <tr> |
| 323 | <td></td> |
| 324 | <td colspan='3'> |
| 325 | <ul style='list-style-type:square;padding-left:17px;'> |
| 326 | <li><code>[cf7rzppa-order-id]</code> - Display \"Order Id\"</li> |
| 327 | <li><code>[cf7rzppa-order-item-id]</code> - Display order related \"Item Id\"</li> |
| 328 | <li><code>[cf7rzppa-order-item-name]</code> - Display order related \"Item Name\"</li> |
| 329 | <li><code>[cf7rzppa-order-item-price]</code> - Display order related \"Item Price\"</li> |
| 330 | </ul> |
| 331 | </td> |
| 332 | <td></td> |
| 333 | </tr> |
| 334 | <tr><td> </td></tr> |
| 335 | "; |
| 336 | |
| 337 | $rzp_tab_output .= $email_notify_html; |
| 338 | |
| 339 | $rzp_tab_output .= '</tbody></table>'; |
| 340 | |
| 341 | return $rzp_tab_output; |
| 342 | } |
| 343 | |
| 344 | function cf7rzppa_admin_menu() { |
| 345 | add_submenu_page( |
| 346 | 'wpcf7', |
| 347 | 'CF7RZP Premium', |
| 348 | 'CF7RZP Premium', |
| 349 | 'manage_options', |
| 350 | 'cf7rzp-get-premium', |
| 351 | 'get_premium', |
| 352 | 5 |
| 353 | ); |
| 354 | } |
| 355 | |
| 356 | add_action('cf7rzp_admin_demo_rzp_settings_in', 'cf7rzppa_admin_demo_rzp_settings_in'); |
| 357 | function cf7rzppa_admin_demo_rzp_settings_in($options) { |
| 358 | include_once('demo_rzp_settings_in.php'); |
| 359 | } |
| 360 | |
| 361 |