Skip to content

Commit

Permalink
Version 3.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
tubiz committed Jul 7, 2015
1 parent ef4d35a commit 4682639
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 65 deletions.
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

**Tested up to:** 4.2

**Stable tag:** 3.1.0
**Stable tag:** 3.2.0

**License:** GPLv2 or later

Expand Down Expand Up @@ -134,6 +134,12 @@ __*You can select the radio button next to the Voguepay Payment Gateway from the

## Changelog ##

### 3.2.0 ###
* New: Send customers to Voguepay immediately the "Make Payment" button is clicked.
* Refactor: Reduce the number of pages displayed before customers are sent to Voguepay by one. From the checkout page, customers are now redirected to Voguepay to make payment.
* Refactor: Remove process_payment function, not needed anymore.
* Fix: Customers not automatically redirected to Voguepay to make payment on some sites.

### 3.1.0 ###
* Fix: Use wc_get_order instead or declaring a new WC_Order class
* Fix: Removed all global $woocommerce variable
Expand Down Expand Up @@ -185,8 +191,8 @@ __*You can select the radio button next to the Voguepay Payment Gateway from the

## Upgrade Notice ##

### 3.1.0 ###
* Make plugin compatible with latest WordPress version
### 3.2.0 ###
* Fix an issue with automatic redirection to Voguepay not working on some sites. Customers are now redirected to Voguepay from the Checkout page once the "Make Payment" button is clicked.



Expand Down
12 changes: 9 additions & 3 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Donate link: http://bosun.me/donate
Tags: woocommerce, payment gateway, payment gateways, voguepay, interswitch, verve cards, tubiz plugins, verve, nigeria
Requires at least: 3.5
Tested up to: 4.2
Stable tag: 3.1.0
Stable tag: 3.2.0
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -126,6 +126,12 @@ __*You can select the radio button next to the Voguepay Payment Gateway from the

== Changelog ==

= 3.2.0 =
* New: Send customers to Voguepay immediately the "Make Payment" button is clicked.
* Refactor: Reduce the number of pages displayed before customers are sent to Voguepay by one. From the checkout page, customers are now redirected to Voguepay to make payment.
* Refactor: Remove process_payment function, not needed anymore.
* Fix: Customers not automatically redirected to Voguepay to make payment on some sites.

= 3.1.0 =
* Fix: Use wc_get_order instead or declaring a new WC_Order class
* Fix: Removed all global $woocommerce variable
Expand Down Expand Up @@ -179,8 +185,8 @@ __*You can select the radio button next to the Voguepay Payment Gateway from the

== Upgrade Notice ==

= 3.1.0 =
* Make plugin compatible with latest WordPress version
= 3.2.0 =
* Fix an issue with automatic redirection to Voguepay not working on some sites. Customers are now redirected to Voguepay from the Checkout page once the "Make Payment" button is clicked.



Expand Down
103 changes: 44 additions & 59 deletions voguepay-woocommerce-payment-gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Plugin Name: Voguepay WooCommerce Payment Gateway
Plugin URI: http://bosun.me/voguepay-woocommerce-payment-gateway
Description: Voguepay Woocommerce Payment Gateway allows you to accept payment on your Woocommerce store via Visa Cards, Mastercards, Verve Cards and eTranzact.
Version: 3.1.0
Version: 3.2.0
Author: Tunbosun Ayinla
Author URI: http://bosun.me/
License: GPL-2.0+
Expand All @@ -30,6 +30,7 @@ public function __construct(){
$this->id = 'tbz_voguepay_gateway';
$this->icon = apply_filters('woocommerce_vogueway_icon', plugins_url( 'assets/pay-via-voguepay.png' , __FILE__ ) );
$this->has_fields = false;
$this->order_button_text = 'Make Payment';
$this->payment_url = 'https://voguepay.com/pay/';
$this->notify_url = WC()->api_request_url( 'WC_Tbz_Voguepay_Gateway' );
$this->method_title = 'VoguePay Payment Gateway';
Expand All @@ -50,7 +51,6 @@ public function __construct(){
$this->storeId = $this->get_option( 'storeId' );

//Actions
add_action('woocommerce_receipt_tbz_voguepay_gateway', array($this, 'receipt_page'));
add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) );

// Payment listener/API hook
Expand Down Expand Up @@ -137,7 +137,7 @@ function init_form_fields(){
}

/**
* Get Voguepay Args for passing to Voguepay
* Get voguepay args
**/
function get_voguepay_args( $order ) {

Expand Down Expand Up @@ -171,77 +171,62 @@ function get_voguepay_args( $order ) {
}

/**
* Generate the VoguePay Payment button link
* Process the payment and return the result
**/
function generate_voguepay_form( $order_id ) {

$order = wc_get_order( $order_id );

$voguepay_args = $this->get_voguepay_args( $order );
function process_payment( $order_id ) {

$voguepay_args_array = array();
$response = $this->get_payment_link( $order_id );

foreach ($voguepay_args as $key => $value) {
$voguepay_args_array[] = '<input type="hidden" name="'.esc_attr( $key ).'" value="'.esc_attr( $value ).'" />';
if( 'success' == $response['result'] ) {
return array(
'result' => 'success',
'redirect' => $response['redirect']
);
}
else {
wc_add_notice( 'Unable to connect to the payment gateway, please try again.', 'error' );

wc_enqueue_js( '
$.blockUI({
message: "' . esc_js( __( 'Thank you for your order. We are now redirecting you to the gateway to make payment.', 'woocommerce' ) ) . '",
baseZ: 99999,
overlayCSS:
{
background: "#fff",
opacity: 0.6
},
css: {
padding: "20px",
zindex: "9999999",
textAlign: "center",
color: "#555",
border: "3px solid #aaa",
backgroundColor:"#fff",
cursor: "wait",
lineHeight: "24px",
}
});
jQuery("#submit_voguepay_payment_form").click();
' );

return '<form action="' . $this->payment_url . '" method="post" id="voguepay_payment_form" target="_top">
' . implode( '', $voguepay_args_array ) . '
<!-- Button Fallback -->
<div class="payment_buttons">
<input type="submit" class="button alt" id="submit_voguepay_payment_form" value="Make Payment" /> <a class="button cancel" href="' . esc_url( $order->get_cancel_order_url() ) . '">Cancel order &amp; restore cart</a>
</div>
<script type="text/javascript">
jQuery(".payment_buttons").hide();
</script>
</form>';
return array(
'result' => 'fail',
'redirect' => ''
);
}
}

/**
* Process the payment and return the result
* Get Voguepay payment link
**/
function process_payment( $order_id ) {
function get_payment_link( $order_id ){

$order = wc_get_order( $order_id );

return array(
'result' => 'success',
'redirect' => $order->get_checkout_payment_url( true )
);
}
$voguepay_args = $this->get_voguepay_args( $order );

/**
* Output for the order received page.
**/
function receipt_page( $order ) {
echo '<p>Thank you - your order is now pending payment. You should be automatically redirected to the gateway to make payment</p>';
$voguepay_redirect = 'https://voguepay.com/?p=linkToken&';
$voguepay_redirect .= http_build_query( $voguepay_args );

echo $this->generate_voguepay_form( $order );
}
$args = array(
'timeout' => 60,
'sslverify' => false
);

$voguepay_redirect = wp_remote_get( $voguepay_redirect, $args );

if ( is_wp_error($voguepay_redirect) || wp_remote_retrieve_response_code($voguepay_redirect) != 200 || $voguepay_redirect['body'] == -14 || $voguepay_redirect['body'] == -3 ) {

$response = array(
'result' => 'fail',
'redirect' => ''
);
}
else {
$response = array(
'result' => 'success',
'redirect' => $voguepay_redirect['body']
);
}
return $response;
}

/**
* Verify a successful Payment!
Expand Down

0 comments on commit 4682639

Please sign in to comment.