Skip to content

Commit 011ac5b

Browse files
committed
Option to whitelist specific payment method
1 parent 3923271 commit 011ac5b

File tree

6 files changed

+116
-21
lines changed

6 files changed

+116
-21
lines changed

changelog.txt

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
*** Changelog ***
2+
3+
= 1.0.4 - 2023-02-24 =
4+
* Fixed - Issue with payment when using with coupon code.
5+
6+
= 1.0.3 - 2023-02-17 =
7+
* Changed - Reference will be autogenerated.
8+
9+
= 1.0.2 - 2023-02-14 =
10+
* Changed - Reference value now using form title instead of transaction id.
11+
* Changed - Platform value now set to fluentforms instead of API.
12+
13+
= 1.0.1 - 2023-01-10 =
14+
* Fixed - Error when new forms created using global configuration.
15+
16+
= 1.0.0 - 2022-12-02 =
17+
* New - Intial Release

chip-for-fluent-forms.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Plugin Name: CHIP for Fluent Forms
55
* Plugin URI: https://wordpress.org/plugins/chip-for-fluent-forms/
66
* Description: CHIP - Better Payment & Business Solutions
7-
* Version: 1.0.6
7+
* Version: 1.0.7
88
* Author: Chip In Sdn Bhd
99
* Author URI: http://www.chip-in.asia
1010
*
@@ -16,7 +16,7 @@
1616

1717
if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
1818

19-
define('FF_CHIP_MODULE_VERSION', 'v1.0.6');
19+
define('FF_CHIP_MODULE_VERSION', 'v1.0.7');
2020

2121
class Chip_Fluent_Forms {
2222

includes/admin/form-settings.php

+32
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,38 @@ function ff_chip_form_fields( $form ){
7070
'dependency' => array( ['due-strict-' . $form->id, '==', 'true'], ['form-customize-' . $form->id, '==', 'true'] ),
7171
'validate' => 'csf_validate_numeric',
7272
),
73+
array(
74+
'id' => 'payment-method-whitelist-' . $form->id,
75+
'type' => 'switcher',
76+
'title' => __( 'Payment Method Whitelist', 'chip-for-fluent-forms' ),
77+
'desc' => __( 'To allow whitelisting a payment method.', 'chip-for-fluent-forms' ),
78+
'help' => __( 'Whether to enable payment method whitelisting.', 'chip-for-fluent-forms' ),
79+
'dependency' => array( ['form-customize-' . $form->id, '==', 'true'] ),
80+
),
81+
array(
82+
'id' => 'payment-method-fpx-' . $form->id,
83+
'type' => 'switcher',
84+
'title' => __( 'Enable FPX', 'chip-for-fluent-forms' ),
85+
'desc' => __( 'To enable FPX payment method.', 'chip-for-fluent-forms' ),
86+
'help' => __( 'Whether to enable FPX payment method.', 'chip-for-fluent-forms' ),
87+
'dependency' => array( ['payment-method-whitelist-' . $form->id, '==', 'true'] ),
88+
),
89+
array(
90+
'id' => 'payment-method-fpxb2b1-' . $form->id,
91+
'type' => 'switcher',
92+
'title' => __( 'Enable FPX B2B1', 'chip-for-fluent-forms' ),
93+
'desc' => __( 'To enable FPX B2B1 payment method.', 'chip-for-fluent-forms' ),
94+
'help' => __( 'Whether to enable FPX B2B1 payment method.', 'chip-for-fluent-forms' ),
95+
'dependency' => array( ['payment-method-whitelist-' . $form->id, '==', 'true'] ),
96+
),
97+
array(
98+
'id' => 'payment-method-card-' . $form->id,
99+
'type' => 'switcher',
100+
'title' => __( 'Enable Card', 'chip-for-fluent-forms' ),
101+
'desc' => __( 'To enable Card payment method.', 'chip-for-fluent-forms' ),
102+
'help' => __( 'Whether to enable Card payment method.', 'chip-for-fluent-forms' ),
103+
'dependency' => array( ['payment-method-whitelist-' . $form->id, '==', 'true'] ),
104+
),
73105
array(
74106
'type' => 'subheading',
75107
'content' => __( 'Refund Synchronization', 'chip-for-fluent-forms' ),

includes/admin/global-settings.php

+31
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,37 @@
8282
'dependency' => array( ['due-strict', '==', 'true'] ),
8383
'validate' => 'csf_validate_numeric',
8484
),
85+
array(
86+
'id' => 'payment-method-whitelist',
87+
'type' => 'switcher',
88+
'title' => __( 'Payment Method Whitelist', 'chip-for-fluent-forms' ),
89+
'desc' => __( 'To allow whitelisting a payment method.', 'chip-for-fluent-forms' ),
90+
'help' => __( 'Whether to enable payment method whitelisting.', 'chip-for-fluent-forms' ),
91+
),
92+
array(
93+
'id' => 'payment-method-fpx',
94+
'type' => 'switcher',
95+
'title' => __( 'Enable FPX', 'chip-for-fluent-forms' ),
96+
'desc' => __( 'To enable FPX payment method.', 'chip-for-fluent-forms' ),
97+
'help' => __( 'Whether to enable FPX payment method.', 'chip-for-fluent-forms' ),
98+
'dependency' => array( ['payment-method-whitelist', '==', 'true'] ),
99+
),
100+
array(
101+
'id' => 'payment-method-fpxb2b1',
102+
'type' => 'switcher',
103+
'title' => __( 'Enable FPX B2B1', 'chip-for-fluent-forms' ),
104+
'desc' => __( 'To enable FPX B2B1 payment method.', 'chip-for-fluent-forms' ),
105+
'help' => __( 'Whether to enable FPX B2B1 payment method.', 'chip-for-fluent-forms' ),
106+
'dependency' => array( ['payment-method-whitelist', '==', 'true'] ),
107+
),
108+
array(
109+
'id' => 'payment-method-card',
110+
'type' => 'switcher',
111+
'title' => __( 'Enable Card', 'chip-for-fluent-forms' ),
112+
'desc' => __( 'To enable Card payment method.', 'chip-for-fluent-forms' ),
113+
'help' => __( 'Whether to enable Card payment method.', 'chip-for-fluent-forms' ),
114+
'dependency' => array( ['payment-method-whitelist', '==', 'true'] ),
115+
),
85116
);
86117

87118
$refund_global_fields = array(

includes/class-purchase.php

+30-2
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ private function create_purchase( $transaction, $submission, $form, $methodSetti
8181
'submission_id' => $submission->id
8282
), site_url('index.php'));
8383

84-
$params = apply_filters( 'ff_chip_create_purchase_params', array(
84+
$params = array(
8585
'success_callback' => $success_callback,
8686
'success_redirect' => $success_redirect,
8787
'failure_redirect' => $failure_redirect,
@@ -106,7 +106,30 @@ private function create_purchase( $transaction, $submission, $form, $methodSetti
106106
'quantity' => '1',
107107
]),
108108
),
109-
), $transaction, $submission, $form);
109+
);
110+
111+
if ( $option['payment_whitelist'] ) {
112+
$params['payment_method_whitelist'] = array();
113+
114+
if ( $option['payment_method_fpx'] ) {
115+
$params['payment_method_whitelist'][] = 'fpx';
116+
}
117+
118+
if ( $option['payment_method_fpxb2b1'] ) {
119+
$params['payment_method_whitelist'][] = 'fpx_b2b1';
120+
}
121+
122+
if ( $option['payment_method_card'] ) {
123+
$params['payment_method_whitelist'][] = 'visa';
124+
$params['payment_method_whitelist'][] = 'mastercard';
125+
}
126+
127+
if ( empty( $params['payment_method_whitelist']) ) {
128+
unset( $params['payment_method_whitelist'] );
129+
}
130+
}
131+
132+
$params = apply_filters( 'ff_chip_create_purchase_params', $params, $transaction, $submission, $form);
110133

111134
$chip = Chip_Fluent_Forms_API::get_instance( $option['secret_key'], $option['brand_id'] );
112135
$payment = $chip->create_payment($params);
@@ -194,6 +217,11 @@ private function get_settings( $form_id ) {
194217
'due_strict' => empty( $options['due-strict' . $postfix] ) ? false : $options['due-strict' . $postfix],
195218
'due_time' => $options['due-strict-timing' . $postfix],
196219
'refund' => empty( $options['refund' . $postfix] ) ? false : $options['refund' . $postfix],
220+
221+
'payment_whitelist' => empty( $options['payment-method-whitelist' . $postfix] ) ? false : $options['payment-method-whitelist' . $postfix],
222+
'payment_method_fpx' => empty( $options['payment-method-fpx' . $postfix] ) ? false : $options['payment-method-fpx' . $postfix],
223+
'payment_method_fpxb2b1' => empty( $options['payment-method-fpxb2b1' . $postfix] ) ? false : $options['payment-method-fpxb2b1' . $postfix],
224+
'payment_method_card' => empty( $options['payment-method-card' . $postfix] ) ? false : $options['payment-method-card' . $postfix],
197225
);
198226
}
199227

readme.txt

+4-17
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Contributors: chipasia, wanzulnet
33
Tags: chip
44
Requires at least: 4.7
55
Tested up to: 6.2
6-
Stable tag: 1.0.6
6+
Stable tag: 1.0.7
77
Requires PHP: 7.1
88
License: GPLv3
99
License URI: http://www.gnu.org/licenses/gpl-3.0.html
@@ -27,28 +27,15 @@ This plugin will enable your Fluent Forms site to be integrated with CHIP as per
2727

2828
== Changelog ==
2929

30+
= 1.0.7 - 2023-05-15 =
31+
* Added - Option to whitelist specific payment method.
32+
3033
= 1.0.6 - 2023-05-10 =
3134
* Added - Add execution for processFormSubmissionData to ensure compatibility with Google Sheet
3235

3336
= 1.0.5 - 2023-04-29 =
3437
* Added - Add filter "ff_chip_create_purchase_params", "ff_chip_handle_paid_data" and action "ff_chip_after_purchase_create"
3538

36-
= 1.0.4 - 2023-02-24 =
37-
* Fixed - Issue with payment when using with coupon code.
38-
39-
= 1.0.3 - 2023-02-17 =
40-
* Changed - Reference will be autogenerated.
41-
42-
= 1.0.2 - 2023-02-14 =
43-
* Changed - Reference value now using form title instead of transaction id.
44-
* Changed - Platform value now set to fluentforms instead of API.
45-
46-
= 1.0.1 - 2023-01-10 =
47-
* Fixed - Error when new forms created using global configuration.
48-
49-
= 1.0.0 - 2022-12-02 =
50-
* New - Intial Release
51-
5239
== Installation ==
5340

5441
= Minimum Requirements =

0 commit comments

Comments
 (0)