custom payment
-
last part of code not working
<?php /** * Tokoo Child * * @package tokoo-child */ /** * Include all your custom code here */ /** * 1st part */ add_filter( 'wcfm_marketplace_withdrwal_payment_methods', function( $payment_methods ) { $payment_methods['bkash'] = 'Bkash'; return $payment_methods; }); /** * 2nd part */ add_filter( 'wcfm_marketplace_settings_fields_withdrawal_payment_keys', function( $payment_keys, $wcfm_withdrawal_options ) { $gateway_bkash = 'bkash'; $withdrawal_bkash_bkash_no = isset( $wcfm_withdrawal_options[$gateway_bkash.'_bkash_no'] ) ? $wcfm_withdrawal_options[$gateway_bkash.'_bkash_no'] : ''; $withdrawal_bkash_bkash_type = isset( $wcfm_withdrawal_options[$gateway_bkash.'_bkash_type'] ) ? $wcfm_withdrawal_options[$gateway_bkash.'_bkash_type'] : ''; $payment_bkash_keys = array( "withdrawal_".$gateway_bkash."_bkash_no" => array('label' => __('Bkash Account Number', 'wc-multivendor-marketplace'), 'name' => 'wcfm_withdrawal_options['.$gateway_bkash.'_bkash_no]', 'type' => 'text', 'class' => 'wcfm-text wcfm_ele withdrawal_mode withdrawal_mode_live withdrawal_mode_'.$gateway_bkash, 'label_class' => 'wcfm_title withdrawal_mode withdrawal_mode_live withdrawal_mode_'.$gateway_bkash, 'value' => $withdrawal_bkash_bkash_no ), "withdrawal_".$gateway_bkash."_bkash_type" => array('label' => __('Bkash Account Type', 'wc-multivendor-marketplace'), 'name' => 'wcfm_withdrawal_options['.$gateway_bkash.'_bkash_type]', 'type' => 'text', 'class' => 'wcfm-text wcfm_ele withdrawal_mode withdrawal_mode_live withdrawal_mode_'.$gateway_bkash, 'label_class' => 'wcfm_title withdrawal_mode withdrawal_mode_live withdrawal_mode_'.$gateway_bkash, 'value' => $withdrawal_bkash_bkash_type ) ); $payment_keys = array_merge( $payment_keys, $payment_bkash_keys ); return $payment_keys; }, 50, 2); /** * 3rd part */ add_filter( 'wcfm_marketplace_settings_fields_withdrawal_payment_test_keys', function( $payment_test_keys, $wcfm_withdrawal_options ) { $gateway_bkash = 'bkash'; $withdrawal_bkash_test_bkash_no = isset( $wcfm_withdrawal_options[$gateway_bkash.'_test_bkash_no'] ) ? $wcfm_withdrawal_options[$gateway_bkash.'_test_bkash_no'] : ''; $withdrawal_bkash_test_bkash_type = isset( $wcfm_withdrawal_options[$gateway_bkash.'_test_bkash_type'] ) ? $wcfm_withdrawal_options[$gateway_bkash.'_test_bkash_type'] : ''; $payment_bkash_test_keys = array( "withdrawal_".$gateway_bkash."_test_bkash_no" => array('label' => __('Bkash Account Number', 'wc-multivendor-marketplace'), 'name' => 'wcfm_withdrawal_options['.$gateway_bkash.'_test_bkash_no]', 'type' => 'text', 'class' => 'wcfm-text wcfm_ele withdrawal_mode withdrawal_mode_test withdrawal_mode_'.$gateway_bkash, 'label_class' => 'wcfm_title withdrawal_mode withdrawal_mode_test withdrawal_mode_'.$gateway_bkash, 'value' => $withdrawal_bkash_test_bkash_no ), "withdrawal_".$gateway_bkash."_test_bkash_type" => array('label' => __('Bkash Account Type', 'wc-multivendor-marketplace'), 'name' => 'wcfm_withdrawal_options['.$gateway_bkash.'_test_bkash_type]', 'type' => 'text', 'class' => 'wcfm-text wcfm_ele withdrawal_mode withdrawal_mode_test withdrawal_mode_'.$gateway_bkash, 'label_class' => 'wcfm_title withdrawal_mode withdrawal_mode_test withdrawal_mode_'.$gateway_bkash, 'value' => $withdrawal_bkash_test_bkash_type ) ); $payment_test_keys = array_merge( $payment_test_keys, $payment_bkash_test_keys ); return $payment_test_keys; }, 50, 2); /** * 4rt part */ add_filter( 'wcfm_marketplace_settings_fields_withdrawal_charges', function( $withdrawal_charges, $wcfm_withdrawal_options, $withdrawal_charge ) { $gateway_bkash = 'bkash'; $withdrawal_charge_bkash = isset( $withdrawal_charge[$gateway_bkash] ) ? $withdrawal_charge[$gateway_bkash] : array(); $payment_withdrawal_charges = array( "withdrawal_charge_".$gateway_bkash => array( 'label' => __('Brain Tree Charge', 'wc-multivendor-marketplace'), 'type' => 'multiinput', 'name' => 'wcfm_withdrawal_options[withdrawal_charge]['.$gateway_bkash.']', 'class' => 'withdraw_charge_block withdraw_charge_'.$gateway_bkash, 'label_class' => 'wcfm_title wcfm_ele wcfm_fill_ele withdraw_charge_block withdraw_charge_'.$gateway_bkash, 'value' => $withdrawal_charge_bkash, 'custom_attributes' => array( 'limit' => 1 ), 'options' => array( "percent" => array('label' => __('Percent Charge(%)', 'wc-multivendor-marketplace'), 'type' => 'number', 'class' => 'wcfm-text wcfm_ele withdraw_charge_field withdraw_charge_percent withdraw_charge_percent_fixed', 'label_class' => 'wcfm_title wcfm_ele withdraw_charge_field withdraw_charge_percent withdraw_charge_percent_fixed', 'attributes' => array( 'min' => '0.1', 'step' => '0.1') ), "fixed" => array('label' => __('Fixed Charge', 'wc-multivendor-marketplace'), 'type' => 'number', 'class' => 'wcfm-text wcfm_ele withdraw_charge_field withdraw_charge_fixed withdraw_charge_percent_fixed', 'label_class' => 'wcfm_title wcfm_ele withdraw_charge_field withdraw_charge_fixed withdraw_charge_percent_fixed', 'attributes' => array( 'min' => '0.1', 'step' => '0.1') ), "tax" => array('label' => __('Charge Tax', 'wc-multivendor-marketplace'), 'type' => 'number', 'class' => 'wcfm-text wcfm_ele', 'label_class' => 'wcfm_title wcfm_ele', 'attributes' => array( 'min' => '0.1', 'step' => '0.1'), 'hints' => __( 'Tax for withdrawal charge, calculate in percent.', 'wc-multivendor-marketplace' ) ), ) ) ); $withdrawal_charges = array_merge( $withdrawal_charges, $payment_withdrawal_charges ); return $withdrawal_charges; }, 50, 3); /** * 5th part */ add_filter( 'wcfm_marketplace_settings_fields_billing', function( $vendor_billing_fileds, $vendor_id ) { $gateway_bkash = 'bkash'; $vendor_data = get_user_meta( $vendor_id, 'wcfmmp_profile_settings', true ); if( !$vendor_data ) $vendor_data = array(); $bkash = isset( $vendor_data['payment'][$gateway_bkash]['email'] ) ? esc_attr( $vendor_data['payment'][$gateway_bkash]['email'] ) : '' ; $vendor_bkash_billing_fileds = array( $gateway_bkash => array('label' => __('Bkash Tree Email', 'wc-frontend-manager'), 'name' => 'payment['.$gateway_bkash.'][email]', 'type' => 'text', 'class' => 'wcfm-text wcfm_ele paymode_field paymode_'.$gateway_bkash, 'label_class' => 'wcfm_title wcfm_ele paymode_field paymode_'.$gateway_bkash, 'value' => $bkash ), ); $vendor_billing_fileds = array_merge( $vendor_billing_fileds, $vendor_bkash_billing_fileds ); return $vendor_billing_fileds; }, 50, 2); /** * 5th part */ class WCFMmp_Gateway_bkash_Tree { public $id; public $message = array(); public $gateway_title; public $payment_gateway; public $withdrawal_id; public $vendor_id; public $withdraw_amount = 0; public $currency; public $transaction_mode; private $reciver_email; public $test_mode = false; public $bkash_no; public $client_secret; public function __construct() { $this->id = 'bkash_tree'; $this->gateway_title = __('bkash Tree', 'wc-multivendor-marketplace'); $this->payment_gateway = $this->id; } public function gateway_logo() { global $WCFMmp; return $WCFMmp->plugin_url . 'assets/images/'.$this->id.'.png'; } public function process_payment( $withdrawal_id, $vendor_id, $withdraw_amount, $withdraw_charges, $transaction_mode = 'auto' ) { global $WCFM, $WCFMmp; $this->withdrawal_id = $withdrawal_id; $this->vendor_id = $vendor_id; $this->withdraw_amount = $withdraw_amount; $this->currency = get_woocommerce_currency(); $this->transaction_mode = $transaction_mode; $this->reciver_email = $WCFMmp->wcfmmp_vendor->get_vendor_payment_account( $this->vendor_id, $this->id ); $withdrawal_test_mode = isset( $WCFMmp->wcfmmp_withdrawal_options['test_mode'] ) ? 'yes' : 'no'; $this->bkash_no = isset( $WCFMmp->wcfmmp_withdrawal_options[$this->id.'_bkash_no'] ) ? $WCFMmp->wcfmmp_withdrawal_options[$this->id.'_bkash_no'] : ''; $this->client_secret = isset( $WCFMmp->wcfmmp_withdrawal_options[$this->id.'_bkash_type'] ) ? $WCFMmp->wcfmmp_withdrawal_options[$this->id.'_bkash_type'] : ''; if ( $withdrawal_test_mode == 'yes') { $this->test_mode = true; $this->bkash_no = isset( $WCFMmp->wcfmmp_withdrawal_options[$this->id.'_test_bkash_no'] ) ? $WCFMmp->wcfmmp_withdrawal_options[$this->id.'_test_bkash_no'] : ''; $this->client_secret = isset( $WCFMmp->wcfmmp_withdrawal_options[$this->id.'_test_bkash_type'] ) ? $WCFMmp->wcfmmp_withdrawal_options[$this->id.'_test_bkash_type'] : ''; } if ( $this->validate_request() ) { // Updating withdrawal meta $WCFMmp->wcfmmp_withdraw->wcfmmp_update_withdrawal_meta( $this->withdrawal_id, 'withdraw_amount', $this->withdraw_amount ); $WCFMmp->wcfmmp_withdraw->wcfmmp_update_withdrawal_meta( $this->withdrawal_id, 'currency', $this->currency ); $WCFMmp->wcfmmp_withdraw->wcfmmp_update_withdrawal_meta( $this->withdrawal_id, 'reciver_email', $this->reciver_email ); return array( 'status' => true, 'message' => __('New transaction has been initiated', 'wc-multivendor-marketplace') ); } else { return $this->message; } } public function validate_request() { global $WCFMmp; return true; } }
The page I need help with: [log in to see the link]
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘custom payment’ is closed to new replies.