Skip to content

Commit

Permalink
Version 5.4.2
Browse files Browse the repository at this point in the history
Misc: Remove Paystack fee and Paystack payout amount on the order details page
  • Loading branch information
tubiz committed Feb 13, 2019
1 parent c2cbfc6 commit ea43ed9
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 160 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

**Tested up to:** 5.0

**Stable tag:** 5.4.1
**Stable tag:** 5.4.2

**License:** GPLv2 or later

Expand Down Expand Up @@ -144,6 +144,9 @@ To configure the plugin, go to __WooCommerce > Settings__ from the left hand me

## Changelog

### 5.4.2 - February 13, 2019 =
* Misc: Remove Paystack fee and Paystack payout amount on the order details page

### 5.4.1 - February 1, 2019 ###
* Fix: Split payment not working properly when the split payment transaction charge setting field is empty

Expand Down Expand Up @@ -223,9 +226,8 @@ To configure the plugin, go to __WooCommerce > Settings__ from the left hand me

## Upgrade Notice

### 5.4.1 ###
* Fix: Split payment not working properly when the split payment transaction charge setting field is empty

### 5.4.2 ###
* Misc: Remove Paystack fee and Paystack payout amount on the order details page

## Screenshots ##

Expand Down
129 changes: 0 additions & 129 deletions includes/class-paystack.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,6 @@ public function __construct() {
add_action( 'admin_notices', array( $this, 'admin_notices' ) );
add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) );

add_action( 'woocommerce_admin_order_totals_after_total', array( $this, 'display_paystack_fee' ) );
add_action( 'woocommerce_admin_order_totals_after_total', array( $this, 'display_order_payout' ), 20 );

add_action( 'woocommerce_receipt_' . $this->id, array( $this, 'receipt_page' ) );

// Payment listener/API hook
Expand Down Expand Up @@ -620,87 +617,6 @@ public function admin_scripts() {

}


/**
* Displays the Paystack fee
*
* @since 5.4.0
*
* @param int $order_id
*/
public function display_paystack_fee( $order_id ) {

$order = wc_get_order( $order_id );

if ( $this->is_wc_lt( '3.0' ) ) {
$fee = get_post_meta( $order_id, '_paystack_fee', true );
$currency = get_post_meta( $order_id, '_paystack_currency', true );
} else {
$fee = $order->get_meta( '_paystack_fee', true );
$currency = $order->get_meta( '_paystack_currency', true );
}

if ( ! $fee || ! $currency ) {
return;
}

?>

<tr>
<td class="label paystack-fee">
<?php echo wc_help_tip( 'This represents the fee Paystack collects for the transaction.' ); ?>
<?php esc_html_e( 'Paystack Fee:' ); ?>
</td>
<td width="1%"></td>
<td class="total">
-&nbsp;<?php echo wc_price( $fee, array( 'currency' => $currency ) ); ?>
</td>
</tr>

<?php
}


/**
* Displays the net total of the transaction without the charges of Paystack.
*
* @since 5.4.0
*
* @param int $order_id
*/
public function display_order_payout( $order_id ) {

$order = wc_get_order( $order_id );

if ( $this->is_wc_lt( '3.0' ) ) {
$net = get_post_meta( $order_id, '_paystack_net', true );
$currency = get_post_meta( $order_id, '_paystack_currency', true );
} else {
$net = $order->get_meta( '_paystack_net', true );
$currency = $order->get_meta( '_paystack_currency', true );
}

if ( ! $net || ! $currency ) {
return;
}

?>

<tr>
<td class="label paystack-payout">
<?php echo wc_help_tip( 'This represents the net total that will be credited to your bank account for this order.' ); ?>
<?php esc_html_e( 'Paystack Payout:' ); ?>
</td>
<td width="1%"></td>
<td class="total">
<?php echo wc_price( $net, array( 'currency' => $currency ) ); ?>
</td>
</tr>

<?php
}


/**
* Process the payment
*/
Expand Down Expand Up @@ -816,21 +732,6 @@ public function process_token_payment( $token, $order_id ) {

$payment_currency = $paystack_response->data->currency;

$paystack_fee = $paystack_response->data->fees / 100;

$paystack_net = $paystack_response->data->amount - $paystack_response->data->fees;
$paystack_net = $paystack_net / 100;

if ( $this->is_wc_lt( '3.0' ) ) {
update_post_meta( $order_id, '_paystack_fee', $paystack_fee );
update_post_meta( $order_id, '_paystack_net', $paystack_net );
update_post_meta( $order_id, '_paystack_currency', $payment_currency );
} else {
$order->update_meta_data( '_paystack_fee', $paystack_fee );
$order->update_meta_data( '_paystack_net', $paystack_net );
$order->update_meta_data( '_paystack_currency', $payment_currency );
}

$gateway_symbol = get_woocommerce_currency_symbol( $payment_currency );

// check if the amount paid is equal to the order amount.
Expand Down Expand Up @@ -1013,21 +914,6 @@ public function verify_paystack_transaction() {

$payment_currency = $paystack_response->data->currency;

$paystack_fee = $paystack_response->data->fees / 100;

$paystack_net = $paystack_response->data->amount - $paystack_response->data->fees;
$paystack_net = $paystack_net / 100;

if ( $this->is_wc_lt( '3.0' ) ) {
update_post_meta( $order_id, '_paystack_fee', $paystack_fee );
update_post_meta( $order_id, '_paystack_net', $paystack_net );
update_post_meta( $order_id, '_paystack_currency', $payment_currency );
} else {
$order->update_meta_data( '_paystack_fee', $paystack_fee );
$order->update_meta_data( '_paystack_net', $paystack_net );
$order->update_meta_data( '_paystack_currency', $payment_currency );
}

$gateway_symbol = get_woocommerce_currency_symbol( $payment_currency );

// check if the amount paid is equal to the order amount.
Expand Down Expand Up @@ -1161,21 +1047,6 @@ public function process_webhooks() {

$payment_currency = $event->data->currency;

$paystack_fee = $event->data->fees / 100;

$paystack_net = $event->data->amount - $event->data->fees;
$paystack_net = $paystack_net / 100;

if ( $this->is_wc_lt( '3.0' ) ) {
update_post_meta( $order_id, '_paystack_fee', $paystack_fee );
update_post_meta( $order_id, '_paystack_net', $paystack_net );
update_post_meta( $order_id, '_paystack_currency', $payment_currency );
} else {
$order->update_meta_data( '_paystack_fee', $paystack_fee );
$order->update_meta_data( '_paystack_net', $paystack_net );
$order->update_meta_data( '_paystack_currency', $payment_currency );
}

$gateway_symbol = get_woocommerce_currency_symbol( $payment_currency );

// check if the amount paid is equal to the order amount.
Expand Down
21 changes: 0 additions & 21 deletions includes/class-wc-subscriptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ public function delete_renewal_meta( $renewal_order ) {
$order_id = $renewal_order->get_id();
}

delete_post_meta( $order_id, '_paystack_fee' );
delete_post_meta( $order_id, '_paystack_net' );
delete_post_meta( $order_id, '_paystack_currency' );

return $renewal_order;
}

Expand Down Expand Up @@ -142,23 +138,6 @@ public function process_subscription_payment( $order = '', $amount = 0 ) {

$paystack_ref = $paystack_response->data->reference;

$payment_currency = $paystack_response->data->currency;

$paystack_fee = $paystack_response->data->fees / 100;

$paystack_net = $paystack_response->data->amount - $paystack_response->data->fees;
$paystack_net = $paystack_net / 100;

if ( $this->is_wc_lt( '3.0' ) ) {
update_post_meta( $order_id, '_paystack_fee', $paystack_fee );
update_post_meta( $order_id, '_paystack_net', $paystack_net );
update_post_meta( $order_id, '_paystack_currency', $payment_currency );
} else {
$order->update_meta_data( '_paystack_fee', $paystack_fee );
$order->update_meta_data( '_paystack_net', $paystack_net );
$order->update_meta_data( '_paystack_currency', $payment_currency );
}

$order->payment_complete( $paystack_ref );

$message = sprintf( 'Payment via Paystack successful (Transaction Reference: %s)', $paystack_ref );
Expand Down
10 changes: 6 additions & 4 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Donate link: https://bosun.me/donate
Tags: paystack, woocommerce, payment gateway, tubiz plugins, verve, ghana, nigeria, mastercard, visa
Requires at least: 4.7
Tested up to: 5.0
Stable tag: 5.4.1
Stable tag: 5.4.2
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -123,6 +123,9 @@ To configure the plugin, go to __WooCommerce > Settings__ from the left hand me

== Changelog ==

= 5.4.2 - February 13, 2019 =
* Misc: Remove Paystack fee and Paystack payout amount on the order details page

= 5.4.1 - February 1, 2019 =
* Fix: Split payment not working properly when the split payment transaction charge setting field is empty

Expand Down Expand Up @@ -201,9 +204,8 @@ To configure the plugin, go to __WooCommerce > Settings__ from the left hand me

== Upgrade Notice ==

= 5.4.1 =
* Fix: Split payment not working properly when the split payment transaction charge setting field is empty

= 5.4.2 =
* Misc: Remove Paystack fee and Paystack payout amount on the order details page

== Screenshots ==

Expand Down
4 changes: 2 additions & 2 deletions woo-paystack.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Plugin Name: Paystack WooCommerce Payment Gateway
Plugin URI: https://paystack.com
Description: WooCommerce payment gateway for Paystack
Version: 5.4.1
Version: 5.4.2
Author: Tunbosun Ayinla
Author URI: https://bosun.me
License: GPL-2.0+
Expand All @@ -19,7 +19,7 @@
define( 'WC_PAYSTACK_MAIN_FILE', __FILE__ );
define( 'WC_PAYSTACK_URL', untrailingslashit( plugins_url( '/', __FILE__ ) ) );

define( 'WC_PAYSTACK_VERSION', '5.4.1' );
define( 'WC_PAYSTACK_VERSION', '5.4.2' );

function tbz_wc_paystack_init() {

Expand Down

0 comments on commit ea43ed9

Please sign in to comment.