The blow code in my payment.php file and I am taking data from config in admin using filter in wordpress..
function wpjb_payment_clickandpledge($list,$html) {
global $wpjobboard;
global $gclass;
global $html;
include_once dirname(__FILE__)."/clickandpledge_payment.class.php";
$cnp = new Payment_ClickandPledge();
$list[$cnp->getEngine()] = get_class($cnp);
return $list;
}
add_filter('wpjb_payments_list', 'wpjb_payment_clickandpledge');
In code add_filter function used to get payment gateway list enabled in admin area..in that my custom gateway also display ..but now in that after details i need form to enter payment details like credit or other payments , I have one class file which is having my form and it is assigned to $html variable inside the function called function render() ...Now i want to add my $html to add_filter('wpjb_payments_list', 'wpjb_payment_clickandpledge'); for this hooks how can do this below is my class file
class Payment_ClickandPledge extends Wpjb_Payment_Abstract{
public function render() {
$data = $this->_data;$id = $this->_data->id; $availableCurrencies = array();$paymentMethods = array();
$merchant = $this->getMerchant();
<form action="" method="POST" id="payment-form"><h3>'.__("Click & Pledge", "wpjobboard").'</h3>
<div class="payment-errors"></div><div class="htmlholder"> ';
if(count($paymentMethods) > 0) {$html .= '<span style="width:980px" id="payment_methods">';foreach($paymentMethods as $pkey => $pval) {
if($pkey == $defaultpayment) {
$html .= '<input type="radio" id="cnp_payment_method_selection_'.$pkey.'" name="cnp_payment_method_selection" class="cnp_payment_method_selection" style="margin: 0 0 0 0;" value="'.$pkey.'" checked> <b>'.$pval.'</b> ';
} else {$html .= '<input type="radio" id="cnp_payment_method_selection_'.$pkey.'" name="cnp_payment_method_selection" class="cnp_payment_method_selection" style="margin: 0 0 0 0;" value="'.$pkey.'"> <b>'.$pval.'</b> ';
}}$html .= '</span>';}
$cdivdisplay = ($defaultpayment == 'CreditCard') ? 'block' : 'none';$recurringhtml = '';
$merchant['wpjobboard_clickandpledge_isRecurring'].'############';
if(isset($merchant['wpjobboard_clickandpledge_isRecurring']) && $merchant['wpjobboard_clickandpledge_isRecurring'] == 1) {
if($merchant['wpjobboard_clickandpledge_RecurringLabel'] != '') {
$recurringhtml .= '<br><div class="form-row" id="clickandpledge_isRecurring_div"><label>
<span>'.__($merchant['wpjobboard_clickandpledge_RecurringLabel'], "wpjobboard").'</span> <input type="checkbox" name="clickandpledge_isRecurring" id="clickandpledge_isRecurring"/></label></div>';} else {
$recurringhtml .= '<br><div class="form-row" id="clickandpledge_isRecurring_div"><label><span>'.__('Is this Recurring Payment?', "wpjobboard").'</span><input type="checkbox" name="clickandpledge_isRecurring" id="clickandpledge_isRecurring"/></label>
</div>';}$RecurringMethod = array();
if(isset($merchant['wpjobboard_clickandpledge_RecurringMethod_Subscription']) && is_array($merchant['wpjobboard_clickandpledge_RecurringMethod_Subscription']) && count($merchant['wpjobboard_clickandpledge_RecurringMethod_Subscription']) > 0) { array_push($RecurringMethod, 'Subscription');}
if(isset($merchant['wpjobboard_clickandpledge_RecurringMethod_Installment']) && is_array($merchant['wpjobboard_clickandpledge_RecurringMethod_Installment']) && count($merchant['wpjobboard_clickandpledge_RecurringMethod_Installment']) > 0) {
array_push($RecurringMethod, 'Installment');}
if(count($RecurringMethod) == 0) {array_push($RecurringMethod, 'Subscription');
array_push($RecurringMethod, 'Installment');}if(count($RecurringMethod) > 0) {
if(count($RecurringMethod) == 1) {$recurringhtml .= '<input type="hidden" name="clickandpledge_RecurringMethod" id="clickandpledge_RecurringMethod" value="'.$RecurringMethod[0].'">';
} else {$recurringhtml .= '<br><div class="form-row" id="clickandpledge_RecurringMethod_div"><label>
<span>'.__("Recurring Method", "wpjobboard").'</span>
<select id="clickandpledge_RecurringMethod" name="clickandpledge_RecurringMethod">';
foreach ($RecurringMethod as $r) {$recurringhtml .= '<option value="'.$r.'">'.$r.'</option>';}
$recurringhtml .= '</select></label> </div>';}} else {
$recurringhtml .= '<div class="form-row" id="clickandpledge_RecurringMethod_div"><label>
<span>'.__("Recurring Method", "wpjobboard").'</span>
<select id="clickandpledge_RecurringMethod" name="clickandpledge_RecurringMethod">
<option value="Subscription">Subscription</option>
<option value="Installment">Installment</option></select></label> </div>';}
if(isset($merchant['wpjobboard_clickandpledge_indefinite']) && is_array($merchant['wpjobboard_clickandpledge_indefinite']) && count($merchant['wpjobboard_clickandpledge_indefinite']) > 0) {
$recurringhtml .= '<br><div class="form-row" id="clickandpledge_indefinite_div">
<label><span>'.__("Indefinite Recurring", "wpjobboard").'</span>
<input type="checkbox" name="clickandpledge_indefinite" id="clickandpledge_indefinite"/></label></div>';}
if(isset($merchant['wpjobboard_clickandpledge_Periodicity']) && is_array($merchant['wpjobboard_clickandpledge_Periodicity']) && count($merchant['wpjobboard_clickandpledge_Periodicity']) > 0) {
$recurringhtml .= '<br><div class="form-row" id="clickandpledge_Periodicity_div">
<label><span>'.__("Every", "wpjobboard").'</span> <select id="clickandpledge_Periodicity" name="clickandpledge_Periodicity">';
foreach ($merchant['wpjobboard_clickandpledge_Periodicity'] as $r) {$recurringhtml .= '<option value="'.$r.'">'.$r.'</option>';
} $recurringhtml .= '</select></label> <span id="clickandpledge_Installment_div"><input type="text" name="clickandpledge_Installment" id="clickandpledge_Installment" class="required" title="Installments" style="width:100px;" maxlength="3"/> <font color="#FF0000">*</font> payments</span>
</div> <script>jQuery("#clickandpledge_Installment").keypress(function(e) {
var a = [];var k = e.which;for (i = 48; i < 58; i++) a.push(i);if (!(a.indexOf(k)>=0))e.preventDefault();
});</script>';} else {$Periodicity = array();$Periodicity['Week'] = 'Week';$Periodicity['2 Weeks'] = '2 Weeks';
$Periodicity['2 Months'] = '2 Months';$Periodicity['Quarter'] = 'Quarter';
$Periodicity['6 Months'] = '6 Months';
$Periodicity['Year'] = 'Year';
$recurringhtml .= '<br><div class="form-row" id="clickandpledge_Periodicity_div">
<label><span>'.__("Every", "wpjobboard").'</span> <select id="clickandpledge_Periodicity" name="clickandpledge_Periodicity">';
foreach ($Periodicity as $k => $v) {
$recurringhtml .= '<option value="'.$k.'">'.$v.'</option>';
}
$recurringhtml .= '</select>
</label>
<span id="clickandpledge_Installment_div"><input type="text" name="clickandpledge_Installment" id="clickandpledge_Installment" class="required" title="Installments" style="width:100px;" maxlength="3"/> <font color="#FF0000">*</font> payments</span> </div>
'; } }
$clickandpledgename_CreditCard = '<div class="form-row cnp_payment_style" > <label>
<span>'.__("Name <font color='red'>*</font>", "wpjobboard").'</span>
<input type="text" size="20" data-clickandpledge="number" name="clickandpledge_FirstName_CreditCard" id="clickandpledge_FirstName_CreditCard" class="required NameOnCard" placeholder="First Name"/><input type="text" size="20" data-clickandpledge="number" name="clickandpledge_LastName_CreditCard" id="clickandpledge_LastName_CreditCard" class="required NameOnCard" placeholder="Last Name"/> </label></div> ';
$clickandpledgename_eCheck = '<div class="form-row cnp_payment_style" >
<label> <span>'.__("Name <font color='red'>*</font>", "wpjobboard").'</span><input type="text" size="20" data-clickandpledge="number" name="clickandpledge_FirstName_eCheck" id="clickandpledge_FirstName_eCheck" class="required NameOnCard" placeholder="First Name"/>
<input type="text" size="20" data-clickandpledge="number" name="clickandpledge_LastName_eCheck" id="clickandpledge_LastName_eCheck" class="required NameOnCard" placeholder="Last Name"/></label> </div> ';
$clickandpledgename_Invoice = '<div class="form-row cnp_payment_style" ><label> <span>'.__("Name <font color='red'>*</font>", "wpjobboard").'</span><input type="text" size="20" data-clickandpledge="number" name="clickandpledge_FirstName_Invoice" id="clickandpledge_FirstName_Invoice" class="required NameOnCard" placeholder="First Name"/>
<input type="text" size="20" data-clickandpledge="number" name="clickandpledge_LastName_Invoice" id="clickandpledge_LastName_Invoice" class="required NameOnCard" placeholder="Last Name"/> </label> </div> ';
$clickandpledgename_PO = '<div class="form-row cnp_payment_style" ><label>
<span>'.__("Name <font color='red'>*</font>", "wpjobboard").'</span> <input type="text" size="20" data-clickandpledge="number" name="clickandpledge_FirstName_PO" id="clickandpledge_FirstName_PO" class="required NameOnCard" placeholder="First Name"/>
<input type="text" size="20" data-clickandpledge="number" name="clickandpledge_LastName_PO" id="clickandpledge_LastName_PO" class="required NameOnCard" placeholder="Last Name"/> </label> </div> ';
$html .= '<div style="display:'.$cdivdisplay.'" id="cnp_CreditCard_div">';
$html .= $clickandpledgename_CreditCard;
$html .= '<div class="form-row">
<label>
<span>'.__("Name On Card <font color='red'>*</font>", "wpjobboard").'</span>
<input type="text" size="20" data-clickandpledge="number" name="clickandpledge_nameOnCard" id="clickandpledge_nameOnCard" class="required NameOnCard" placeholder="Name On Card"/></label> </div><div class="form-row"> <label>
<span>'.__("Card Number <font color='red'>*</font>", "wpjobboard").'</span>
<input type="text" size="20" data-clickandpledge="number" name="clickandpledge_cardNumber" id="clickandpledge_cardNumber" class="required creditcard" placeholder="Card Number"/></label> </div> <div class="form-row"><label>
<span>'.__("CVV <font color='red'>*</font>", "wpjobboard").'</span>
<input type="text" size="4" data-clickandpledge="cvc" maxlength="4" name="clickandpledge_cvc" id="clickandpledge_cvc" class="required Cvv2" placeholder="CVV"/>
</label> </div><div class="form-row">
<label><span>'.__("Expiration (MM/YYYY) <font color='red'>*</font>", "wpjobboard").'</span></label>
<select name="clickandpledge_cardExpMonth" id="clickandpledge_cardExpMonth" class="required">'.$this->getMonths().'</select> <span> / </span>
<select name="clickandpledge_cardExpYear" id="clickandpledge_cardExpYear" class="required" data-clickandpledge="exp-year">'.$this->getYears().'</select> </div>';
$html .= $recurringhtml;
$html .= '</div>'; //CreditCard Div End
some other payment types will come here
$listing_id = '';
if(isset($_POST['listing']) && $_POST['listing'] != '')
$listing_id = $_POST['listing'];
elseif(isset($_POST['listing_type']) && $_POST['listing_type'] != '')
$listing_id = $_POST['listing_type'];
$varArray = array('clickandpledge_AccountID'=>$merchant['wpjobboard_clickandpledge_'.$selectedCurrency.'_AccountID'],
'clickandpledge_AccountGuid'=>$merchant['wpjobboard_clickandpledge_'.$selectedCurrency.'_AccountGuid'],'clickandpledge_OrderMode' => $merchant['wpjobboard_clickandpledge_'.$selectedCurrency.'_OrderMode'],
'clickandpledge_Amount' => $this->_data->payment_sum+$this->_data->payment_discount, 'clickandpledge_Discount' => $this->_data->payment_discount, 'clickandpledge_OrganizationInformation' => htmlspecialchars($merchant['wpjobboard_clickandpledge_OrganizationInformation']),'clickandpledge_TermsCondition' => htmlspecialchars($merchant['wpjobboard_clickandpledge_TermsCondition']),
'clickandpledge_email_customer' => (is_array($merchant['wpjobboard_clickandpledge_emailcustomer']) && count($merchant['wpjobboard_clickandpledge_emailcustomer']) > 0) ? $merchant['wpjobboard_clickandpledge_emailcustomer'][0] : '',
'clickandpledge_maxrecurrings_Subscription' => $merchant['wpjobboard_clickandpledge_maxrecurrings_Subscription'],
'clickandpledge_maxrecurrings_Installment' => $merchant['wpjobboard_clickandpledge_maxrecurrings_Installment'],
'clickandpledge_listing_id' => $listing_id,
'clickandpledge_coupon_code' => (isset($_POST['coupon'])) ? $_POST['coupon'] : '',
);
foreach($varArray as $k=>$v)
{
$html.= '<input type="hidden" name="'.$k.'" id="'.$k.'" value="'.$v.'" />';
}
$html .= '<button type="submit">'.__("Submit Payment", "wpjobboard").'</button></div></form>';} else {
if(count($availableCurrencies) > 0) {
$html = 'Selected currency <b>'.$selectedCurrency.'</b> not supported by Click & Pledge. We are supporting <b>'.implode(',', $availableCurrencies).'</b> only. Please contact administrator.';} else {
$html = 'Selected currency <b>'.$selectedCurrency.'</b> not supported by Click & Pledge. Please contact administrator.';
}}return $html; }
public function getMonths() {
$str = ''; for ($i = 1; $i <= 12; $i++) {
if(date('m') == sprintf('%02d', $i)) {
$str .= '<option value="'.sprintf('%02d', $i).'" selected>'.sprintf('%02d', $i).' ('.strftime('%B', mktime(0, 0, 0, $i, 1, 2000)).')</option>';
} else {
$str .= '<option value="'.sprintf('%02d', $i).'">'.sprintf('%02d', $i).' ('.strftime('%B', mktime(0, 0, 0, $i, 1, 2000)).')</option>';
} }return $str; } public function getYears() { $str = '';
for ($i = date('Y'); $i < date('Y') + 11; $i++) {
$str .= '<option value="'.strftime('%Y', mktime(0, 0, 0, 1, 1, $i)).'">'.strftime('%Y', mktime(0, 0, 0, 1, 1, $i)).'</option>';
}
return $str; }
public function number_format($number, $decimals = 2,$decsep = '', $ths_sep = '') {
$parts = explode('.', $number);
if(count($parts) > 1) {
return $parts[0].'.'.substr($parts[1],0,$decimals);
} else {return $number;}} }