Skip to content

Commit a302c66

Browse files
committed
Added bearer of sub account charge
1 parent ff1e4a8 commit a302c66

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

admin/class-paystack-forms-admin.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,12 +425,17 @@ function kkd_pff_paystack_editor_add_subaccount_data() {
425425

426426
// Get the location data if its already been entered
427427
$subaccount = get_post_meta($post->ID, '_subaccount', true);
428+
$txnbearer = get_post_meta($post->ID, '_txnbearer', true);
428429

429430

430431
if ($subaccount == "") {$subaccount = '';}
431432
echo '<p>Sub Account code:</p>';
432433
echo '<input type="text" name="_subaccount" value="' . $subaccount . '" class="widefat" />';
433-
434+
echo '<p>Transaction Charge bearer:</p>';
435+
echo '<select class="form-control" name="_txnbearer" id="parent_id" style="width:100%;">
436+
<option value="account" '.kkd_pff_paystack_txncheck('account',$txnbearer).'>Merchant (default)</option>
437+
<option value="subaccount" '.kkd_pff_paystack_txncheck('subaccount',$txnbearer).'>Sub Account</option>
438+
</select>';
434439
}
435440
function kkd_pff_paystack_save_data($post_id, $post) {
436441

@@ -465,6 +470,7 @@ function kkd_pff_paystack_save_data($post_id, $post) {
465470
$form_meta['_useagreement'] = $_POST['_useagreement'];
466471
$form_meta['_agreementlink'] = $_POST['_agreementlink'];
467472
$form_meta['_subaccount'] = $_POST['_subaccount'];
473+
$form_meta['_txnbearer'] = $_POST['_txnbearer'];
468474

469475
// Add values of $form_meta as custom fields
470476

public/class-paystack-forms-public.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -886,6 +886,7 @@ function kkd_pff_paystack_submit_action() {
886886
$formamount = get_post_meta($_POST["pf-id"],'_amount',true);
887887
$recur = get_post_meta($_POST["pf-id"],'_recur',true);
888888
$subaccount = get_post_meta($_POST["pf-id"],'_subaccount',true);
889+
$txnbearer = get_post_meta($_POST["pf-id"],'_txnbearer',true);
889890

890891
$txncharge = get_post_meta($_POST["pf-id"],'_txncharge',true);
891892
$amount = (int)str_replace(' ', '', $_POST["pf-amount"]);
@@ -1062,7 +1063,8 @@ function kkd_pff_paystack_submit_action() {
10621063
'name' => $fullname,
10631064
'total' => $insert['amount']*100,
10641065
'custom_fields' => $fixedmetadata,
1065-
'subaccount' => $subaccount
1066+
'subaccount' => $subaccount,
1067+
'txnbearer' => $txnbearer
10661068
);
10671069
echo json_encode($response);
10681070

public/js/paystack-forms-public.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@
156156
firstname: firstName,
157157
lastname: lastName,
158158
subaccount:data.subaccount,
159-
bearer:'subaccount',
159+
bearer:data.txnbearer,
160160
ref: data.code,
161161
metadata: {'custom_fields': data.custom_fields},
162162
callback: function(response){
@@ -197,7 +197,9 @@
197197
firstname: firstName,
198198
lastname: lastName,
199199
ref: data.code,
200-
metadata: {'custom_fields': data.custom_fields},
200+
subaccount:data.subaccount,
201+
bearer:data.txnbearer,
202+
metadata: {'custom_fields': data.custom_fields},
201203
callback: function(response){
202204
$.blockUI({ message: 'Please wait...' });
203205
$.post($form.attr('action'), {'action':'kkd_pff_paystack_confirm_payment','code':response.trxref}, function(newdata) {

0 commit comments

Comments
 (0)