5
5
* Description: Hyperswitch checkout plugin for WooCommerce
6
6
* Author: Hyperswitch
7
7
* Author URI: https://hyperswitch.io/
8
- * Version: 1.6.0
8
+ * Version: 1.6.1
9
9
* License: GPLv2 or later
10
10
*
11
11
* WC requires at least: 4.0.0
32
32
exit ; // Exit if accessed directly
33
33
}
34
34
35
- define ( 'HYPERSWITCH_CHECKOUT_PLUGIN_VERSION ' , '1.6.0 ' );
35
+ define ( 'HYPERSWITCH_CHECKOUT_PLUGIN_VERSION ' , '1.6.1 ' );
36
36
define ( 'HYPERSWITCH_PLUGIN_URL ' , untrailingslashit ( plugins_url ( basename ( plugin_dir_path ( __FILE__ ) ), basename ( __FILE__ ) ) ) );
37
37
38
38
require_once __DIR__ . '/includes/hyperswitch-webhook.php ' ;
@@ -321,6 +321,11 @@ public function init_form_fields() {
321
321
'type ' => 'password ' ,
322
322
'description ' => __ ( 'Find this on Developers > API Keys section of Hyperswitch Dashboard ' , 'hyperswitch-checkout ' )
323
323
),
324
+ 'profile_id ' => array (
325
+ 'title ' => 'Business Profile ID ' ,
326
+ 'type ' => 'text ' ,
327
+ 'description ' => __ ( 'Find this on Settings > Business profiles section of Hyperswitch Dashboard ' , 'hyperswitch-checkout ' )
328
+ ),
324
329
'enable_webhook ' => array (
325
330
'title ' => __ ( 'Enable Webhook ' , 'hyperswitch-checkout ' ),
326
331
'type ' => 'checkbox ' ,
@@ -411,7 +416,7 @@ function receipt_page( $payment_id ) {
411
416
$ woocommerce ->add_error ( __ ( "Something went wrong. Please contact support for assistance. " , 'hyperswitch-checkout ' ) );
412
417
$ woocommerce ->set_messages ();
413
418
}
414
- $ redirect_url = get_permalink ( woocommerce_get_page_id ( 'cart ' ) );
419
+ $ redirect_url = get_permalink ( wc_get_page_id ( 'cart ' ) );
415
420
wp_redirect ( $ redirect_url );
416
421
exit ;
417
422
}
@@ -462,6 +467,7 @@ function create_payment_intent( $order_id, $client_secret = null ) {
462
467
global $ woocommerce ;
463
468
$ order = wc_get_order ( $ order_id );
464
469
$ apiKey = $ this ->get_option ( 'api_key ' );
470
+ $ profileId = $ this ->get_option ( 'profile_id ' );
465
471
$ publishable_key = $ this ->get_option ( 'publishable_key ' );
466
472
if ( isset ( $ client_secret ) ) {
467
473
$ payment_id = "" ;
@@ -579,8 +585,8 @@ function create_payment_intent( $order_id, $client_secret = null ) {
579
585
$ customer_logged_in = str_starts_with ( $ customer_id , "cust " );
580
586
581
587
$ metadata = array (
582
- "customer_created " => $ customer_created ,
583
- "customer_logged_in " => $ customer_logged_in ,
588
+ "customer_created " => $ customer_created ? " true " : " false " ,
589
+ "customer_logged_in " => $ customer_logged_in ? " true " : " false " ,
584
590
);
585
591
586
592
if ( $ order ) {
@@ -599,6 +605,9 @@ function create_payment_intent( $order_id, $client_secret = null ) {
599
605
$ payload ["capture_method " ] = $ capture_method ;
600
606
$ payload ["amount " ] = $ amount ;
601
607
$ payload ["currency " ] = $ currency ;
608
+ if ( isset ( $ profileId ) ) {
609
+ $ payload ["profile_id " ] = $ profileId ;
610
+ }
602
611
603
612
$ args = array (
604
613
'body ' => wp_json_encode ( $ payload ),
0 commit comments