Skip to content

Commit

Permalink
Option to whitelist specific payment method
Browse files Browse the repository at this point in the history
  • Loading branch information
wzul committed May 15, 2023
1 parent 3923271 commit 011ac5b
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 21 deletions.
17 changes: 17 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
*** Changelog ***

= 1.0.4 - 2023-02-24 =
* Fixed - Issue with payment when using with coupon code.

= 1.0.3 - 2023-02-17 =
* Changed - Reference will be autogenerated.

= 1.0.2 - 2023-02-14 =
* Changed - Reference value now using form title instead of transaction id.
* Changed - Platform value now set to fluentforms instead of API.

= 1.0.1 - 2023-01-10 =
* Fixed - Error when new forms created using global configuration.

= 1.0.0 - 2022-12-02 =
* New - Intial Release
4 changes: 2 additions & 2 deletions chip-for-fluent-forms.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Plugin Name: CHIP for Fluent Forms
* Plugin URI: https://wordpress.org/plugins/chip-for-fluent-forms/
* Description: CHIP - Better Payment & Business Solutions
* Version: 1.0.6
* Version: 1.0.7
* Author: Chip In Sdn Bhd
* Author URI: http://www.chip-in.asia
*
Expand All @@ -16,7 +16,7 @@

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

define('FF_CHIP_MODULE_VERSION', 'v1.0.6');
define('FF_CHIP_MODULE_VERSION', 'v1.0.7');

class Chip_Fluent_Forms {

Expand Down
32 changes: 32 additions & 0 deletions includes/admin/form-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,38 @@ function ff_chip_form_fields( $form ){
'dependency' => array( ['due-strict-' . $form->id, '==', 'true'], ['form-customize-' . $form->id, '==', 'true'] ),
'validate' => 'csf_validate_numeric',
),
array(
'id' => 'payment-method-whitelist-' . $form->id,
'type' => 'switcher',
'title' => __( 'Payment Method Whitelist', 'chip-for-fluent-forms' ),
'desc' => __( 'To allow whitelisting a payment method.', 'chip-for-fluent-forms' ),
'help' => __( 'Whether to enable payment method whitelisting.', 'chip-for-fluent-forms' ),
'dependency' => array( ['form-customize-' . $form->id, '==', 'true'] ),
),
array(
'id' => 'payment-method-fpx-' . $form->id,
'type' => 'switcher',
'title' => __( 'Enable FPX', 'chip-for-fluent-forms' ),
'desc' => __( 'To enable FPX payment method.', 'chip-for-fluent-forms' ),
'help' => __( 'Whether to enable FPX payment method.', 'chip-for-fluent-forms' ),
'dependency' => array( ['payment-method-whitelist-' . $form->id, '==', 'true'] ),
),
array(
'id' => 'payment-method-fpxb2b1-' . $form->id,
'type' => 'switcher',
'title' => __( 'Enable FPX B2B1', 'chip-for-fluent-forms' ),
'desc' => __( 'To enable FPX B2B1 payment method.', 'chip-for-fluent-forms' ),
'help' => __( 'Whether to enable FPX B2B1 payment method.', 'chip-for-fluent-forms' ),
'dependency' => array( ['payment-method-whitelist-' . $form->id, '==', 'true'] ),
),
array(
'id' => 'payment-method-card-' . $form->id,
'type' => 'switcher',
'title' => __( 'Enable Card', 'chip-for-fluent-forms' ),
'desc' => __( 'To enable Card payment method.', 'chip-for-fluent-forms' ),
'help' => __( 'Whether to enable Card payment method.', 'chip-for-fluent-forms' ),
'dependency' => array( ['payment-method-whitelist-' . $form->id, '==', 'true'] ),
),
array(
'type' => 'subheading',
'content' => __( 'Refund Synchronization', 'chip-for-fluent-forms' ),
Expand Down
31 changes: 31 additions & 0 deletions includes/admin/global-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,37 @@
'dependency' => array( ['due-strict', '==', 'true'] ),
'validate' => 'csf_validate_numeric',
),
array(
'id' => 'payment-method-whitelist',
'type' => 'switcher',
'title' => __( 'Payment Method Whitelist', 'chip-for-fluent-forms' ),
'desc' => __( 'To allow whitelisting a payment method.', 'chip-for-fluent-forms' ),
'help' => __( 'Whether to enable payment method whitelisting.', 'chip-for-fluent-forms' ),
),
array(
'id' => 'payment-method-fpx',
'type' => 'switcher',
'title' => __( 'Enable FPX', 'chip-for-fluent-forms' ),
'desc' => __( 'To enable FPX payment method.', 'chip-for-fluent-forms' ),
'help' => __( 'Whether to enable FPX payment method.', 'chip-for-fluent-forms' ),
'dependency' => array( ['payment-method-whitelist', '==', 'true'] ),
),
array(
'id' => 'payment-method-fpxb2b1',
'type' => 'switcher',
'title' => __( 'Enable FPX B2B1', 'chip-for-fluent-forms' ),
'desc' => __( 'To enable FPX B2B1 payment method.', 'chip-for-fluent-forms' ),
'help' => __( 'Whether to enable FPX B2B1 payment method.', 'chip-for-fluent-forms' ),
'dependency' => array( ['payment-method-whitelist', '==', 'true'] ),
),
array(
'id' => 'payment-method-card',
'type' => 'switcher',
'title' => __( 'Enable Card', 'chip-for-fluent-forms' ),
'desc' => __( 'To enable Card payment method.', 'chip-for-fluent-forms' ),
'help' => __( 'Whether to enable Card payment method.', 'chip-for-fluent-forms' ),
'dependency' => array( ['payment-method-whitelist', '==', 'true'] ),
),
);

$refund_global_fields = array(
Expand Down
32 changes: 30 additions & 2 deletions includes/class-purchase.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ private function create_purchase( $transaction, $submission, $form, $methodSetti
'submission_id' => $submission->id
), site_url('index.php'));

$params = apply_filters( 'ff_chip_create_purchase_params', array(
$params = array(
'success_callback' => $success_callback,
'success_redirect' => $success_redirect,
'failure_redirect' => $failure_redirect,
Expand All @@ -106,7 +106,30 @@ private function create_purchase( $transaction, $submission, $form, $methodSetti
'quantity' => '1',
]),
),
), $transaction, $submission, $form);
);

if ( $option['payment_whitelist'] ) {
$params['payment_method_whitelist'] = array();

if ( $option['payment_method_fpx'] ) {
$params['payment_method_whitelist'][] = 'fpx';
}

if ( $option['payment_method_fpxb2b1'] ) {
$params['payment_method_whitelist'][] = 'fpx_b2b1';
}

if ( $option['payment_method_card'] ) {
$params['payment_method_whitelist'][] = 'visa';
$params['payment_method_whitelist'][] = 'mastercard';
}

if ( empty( $params['payment_method_whitelist']) ) {
unset( $params['payment_method_whitelist'] );
}
}

$params = apply_filters( 'ff_chip_create_purchase_params', $params, $transaction, $submission, $form);

$chip = Chip_Fluent_Forms_API::get_instance( $option['secret_key'], $option['brand_id'] );
$payment = $chip->create_payment($params);
Expand Down Expand Up @@ -194,6 +217,11 @@ private function get_settings( $form_id ) {
'due_strict' => empty( $options['due-strict' . $postfix] ) ? false : $options['due-strict' . $postfix],
'due_time' => $options['due-strict-timing' . $postfix],
'refund' => empty( $options['refund' . $postfix] ) ? false : $options['refund' . $postfix],

'payment_whitelist' => empty( $options['payment-method-whitelist' . $postfix] ) ? false : $options['payment-method-whitelist' . $postfix],
'payment_method_fpx' => empty( $options['payment-method-fpx' . $postfix] ) ? false : $options['payment-method-fpx' . $postfix],
'payment_method_fpxb2b1' => empty( $options['payment-method-fpxb2b1' . $postfix] ) ? false : $options['payment-method-fpxb2b1' . $postfix],
'payment_method_card' => empty( $options['payment-method-card' . $postfix] ) ? false : $options['payment-method-card' . $postfix],
);
}

Expand Down
21 changes: 4 additions & 17 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Contributors: chipasia, wanzulnet
Tags: chip
Requires at least: 4.7
Tested up to: 6.2
Stable tag: 1.0.6
Stable tag: 1.0.7
Requires PHP: 7.1
License: GPLv3
License URI: http://www.gnu.org/licenses/gpl-3.0.html
Expand All @@ -27,28 +27,15 @@ This plugin will enable your Fluent Forms site to be integrated with CHIP as per

== Changelog ==

= 1.0.7 - 2023-05-15 =
* Added - Option to whitelist specific payment method.

= 1.0.6 - 2023-05-10 =
* Added - Add execution for processFormSubmissionData to ensure compatibility with Google Sheet

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

= 1.0.4 - 2023-02-24 =
* Fixed - Issue with payment when using with coupon code.

= 1.0.3 - 2023-02-17 =
* Changed - Reference will be autogenerated.

= 1.0.2 - 2023-02-14 =
* Changed - Reference value now using form title instead of transaction id.
* Changed - Platform value now set to fluentforms instead of API.

= 1.0.1 - 2023-01-10 =
* Fixed - Error when new forms created using global configuration.

= 1.0.0 - 2022-12-02 =
* New - Intial Release

== Installation ==

= Minimum Requirements =
Expand Down

0 comments on commit 011ac5b

Please sign in to comment.