_agents.js
1 year ago
_calendar.js
3 months ago
_chart.js
9 months ago
_customers.js
1 year ago
_customers_import.js
9 months ago
_delete-confirm.js
1 week ago
_orders.js
9 months ago
_processes.js
1 year ago
_razorpay_connect.js
1 month ago
_steps.js
9 months ago
_stripe_connect.js
1 year ago
main.js
2 weeks ago
updates.js
3 months ago
_stripe_connect.js
77 lines
| 1 | /* |
| 2 | * Copyright (c) 2024 LatePoint LLC. All rights reserved. |
| 3 | */ |
| 4 | |
| 5 | class LatepointStripeConnectAdmin { |
| 6 | |
| 7 | // Init |
| 8 | constructor(){ |
| 9 | this.ready(); |
| 10 | } |
| 11 | |
| 12 | ready() { |
| 13 | jQuery(document).ready(() => { |
| 14 | jQuery('.stripe-connect-status-wrapper').on('click', '.payment-start-connecting', function(){ |
| 15 | let $link = jQuery(this); |
| 16 | $link.addClass('os-loading'); |
| 17 | var data = { |
| 18 | action: 'latepoint_route_call', |
| 19 | route_name: $link.data('route-name'), |
| 20 | params: { env: $link.data('env') }, |
| 21 | layout: 'none', |
| 22 | return_format: 'json' |
| 23 | } |
| 24 | jQuery.ajax({ |
| 25 | type : "post", |
| 26 | dataType : "json", |
| 27 | url : latepoint_timestamped_ajaxurl(), |
| 28 | data : data, |
| 29 | success: (data) => { |
| 30 | window.location.href = data.url; |
| 31 | } |
| 32 | }); |
| 33 | return false; |
| 34 | }); |
| 35 | |
| 36 | if(jQuery('.stripe-connect-status-wrapper').length){ |
| 37 | jQuery('.stripe-connect-status-wrapper').each((index, elem) => { |
| 38 | let $wrapper = jQuery(elem); |
| 39 | var data = { |
| 40 | action: 'latepoint_route_call', |
| 41 | route_name: $wrapper.data('route-name'), |
| 42 | params: { env: $wrapper.data('env') }, |
| 43 | layout: 'none', |
| 44 | return_format: 'json' |
| 45 | } |
| 46 | jQuery.ajax({ |
| 47 | type : "post", |
| 48 | dataType : "json", |
| 49 | url : latepoint_timestamped_ajaxurl(), |
| 50 | data : data, |
| 51 | success: (data) => { |
| 52 | this.reload_connect_status_wrapper($wrapper, data); |
| 53 | } |
| 54 | }); |
| 55 | }) |
| 56 | } |
| 57 | }); |
| 58 | } |
| 59 | |
| 60 | |
| 61 | reload_connect_status_wrapper($elem, data){ |
| 62 | if(data.status === 'success'){ |
| 63 | if($elem.hasClass('.stripe-connect-status-wrapper')){ |
| 64 | $elem.html(data.message); |
| 65 | }else{ |
| 66 | $elem.closest('.stripe-connect-status-wrapper').html(data.message); |
| 67 | } |
| 68 | }else{ |
| 69 | alert(data.message); |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | |
| 74 | } |
| 75 | |
| 76 | |
| 77 | window.latepointStripeConnectAdmin = new LatepointStripeConnectAdmin(); |