Skip to content

Commit

Permalink
Merge pull request #3 from RBAtkins0n/master
Browse files Browse the repository at this point in the history
1.0.2 - June 10, 2019
  • Loading branch information
appinlet authored Jun 10, 2019
2 parents c88360d + 958614c commit 0947af7
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 32 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# PaySubs_WooCommerce
## DPO PayGate PaySubs2 WooCommerce plugin v1.0.1 for WooCommerce v3.5.7
## DPO PayGate PaySubs2 WooCommerce plugin v1.0.2 for WooCommerce v3.6.4

This is the DPO PayGate PaySubs2 plugin for WooCommerce. Please feel free to contact the DPO PayGate support team at support@paygate.co.za should you require any assistance.

## Installation
Please navigate to the [releases page](https://github.com/PayGate/PaySubs2_WooCommerce/releases), download the latest release (v1.0.2) and unzip. You will them be able to follow the integration guide PDF which is included in the zip.
[![How To Setup DPO | PayGate PayWeb for WooCommerce](https://www.appinlet.com/wp-content/uploads/2019/04/WooCommerce-PaySubs2-Integration.jpg)](https://www.youtube.com/watch?v=Ko5eessWrWU "How To Setup DPO | PayGate PaySubs2 for WooCommerce")

Please navigate to the [releases page](https://github.com/PayGate/PaySubs2_WooCommerce/releases), download the latest release (v1.0.1) and unzip. You will them be able to follow the integration guide PDF which is included in the zip.

## Collaboration

Please submit pull requests with any tweaks, features or fixes you would like to share.
Expand Down
5 changes: 5 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
= 1.0.2 - June 10, 2019 =

* Add PROCESS_NOW and PROCESS_NOW_AMOUNT functionality.
* Add product price toggle for AMOUNT / PROCESS_NOW_AMOUNT

= 1.0.1 - April 11, 2019 =

* Allow for either iFrame or Redirect implementation
Expand Down
84 changes: 65 additions & 19 deletions classes/paysubs2.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class WC_Gateway_PaySubs2 extends WC_Payment_Gateway
const TEST_PAYGATE_ID = '10011072130';
const TEST_SECRET_KEY = 'secret';

public $version = '3.5.5';
public $version = '3.6.4';

public $id = 'paysubs2';

Expand Down Expand Up @@ -204,36 +204,36 @@ public function init_form_fields()
{

$this->form_fields = array(
'enabled' => array(
'enabled' => array(
'title' => __( 'Enable/Disable', 'paysubs2' ),
'label' => __( 'Enable PaySubs2 Payment Gateway', 'paysubs2' ),
'type' => 'checkbox',
'description' => __( 'This controls whether or not this gateway is enabled within WooCommerce.', 'paysubs2' ),
'desc_tip' => true,
'default' => 'no',
),
'title' => array(
'title' => array(
'title' => __( 'Title', 'paysubs2' ),
'type' => 'text',
'description' => __( 'This controls the title which the user sees during checkout.', 'paysubs2' ),
'desc_tip' => false,
'default' => __( 'Recurring Payment Gateway', 'paysubs2' ),
),
'paygate_id' => array(
'paygate_id' => array(
'title' => __( 'PayGate ID', 'paysubs2' ),
'type' => 'text',
'description' => __( 'This is the PayGate ID, received from PayGate.', 'paysubs2' ),
'desc_tip' => true,
'default' => '',
),
'encryption_key' => array(
'encryption_key' => array(
'title' => __( 'Encryption Key', 'paysubs2' ),
'type' => 'text',
'description' => __( 'This is the Encryption Key set in the PayGate Back Office.', 'paysubs2' ),
'desc_tip' => true,
'default' => '',
),
'frequency' => array(
'frequency' => array(
'title' => __( 'Payment Frequency', 'woocommerce_gateway_paysubs' ),
'label' => __( 'Choose Payment Frequency', 'woocommerce_gateway_paysubs' ),
'type' => 'select',
Expand Down Expand Up @@ -350,7 +350,7 @@ public function init_form_fields()
'429' => 'Every 3rd month on last day of the month',
),
),
'subsenddate' => array(
'subsenddate' => array(
'title' => __( 'Subs End Date', 'woocommerce_gateway_paysubs' ),
'label' => __( 'Choose Subs End Date', 'woocommerce_gateway_paysubs' ),
'type' => 'select',
Expand Down Expand Up @@ -384,7 +384,7 @@ public function init_form_fields()
'+100 year' => 'Expire in 100 years',
),
),
'payment_type' => array(
'payment_type' => array(
'title' => __( 'Implementation', 'woocommerce_gateway_paysubs' ),
'label' => __( 'Choose Payment Type', 'woocommerce_gateway_paysubs' ),
'type' => 'select',
Expand All @@ -395,23 +395,53 @@ public function init_form_fields()
'iframe' => 'iFrame',
),
),
'testmode' => array(
'title' => __( 'Test mode', 'paysubs2' ),
'specify_amount' => array(
'title' => __( 'Enable Specify Amount', 'woocommerce_gateway_paysubs' ),
'type' => 'checkbox',
'description' => __( 'Uses a PaySubs2 test account. Request test cards from PayGate.', 'paysubs2' ),
'description' => __( 'Choose if a specific value can be used for the AMOUNT or PROCESS_NOW_AMOUNT', 'woocommerce_gateway_paysubs' ),
'desc_tip' => true,
'default' => 'no',
),
'specify_amount_value' => array(
'title' => __( 'Enable Specific Amount', 'woocommerce_gateway_paysubs' ),
'type' => 'checkbox',
'description' => __( 'Choose if a specific value can be used for the AMOUNT or PROCESS_NOW_AMOUNT', 'woocommerce_gateway_paysubs' ),
'desc_tip' => true,
'default' => 'no',

'title' => __( 'Set Specific Amount (cents)', 'woocommerce_gateway_paysubs' ),
'type' => 'text',
'description' => __( 'Sets a specific amount in cents (if Specific Amount is enabled).', 'woocommerce_gateway_paysubs' ),
'default' => '10000',
),
'product_price' => array(
'title' => __( 'Product Price', 'woocommerce_gateway_paysubs' ),
'label' => __( 'Choose Product Price', 'woocommerce_gateway_paysubs' ),
'type' => 'select',
'description' => 'Choose if product price should be passed as the AMOUNT or the PROCESS_NOW_AMOUNT (if Specific Amount is enabled).',
'default' => 'process_now_amount',
'options' => array(
'amount' => 'AMOUNT (recurring amount)',
'process_now_amount' => 'PROCESS_NOW_AMOUNT (initial amount)',
),
),
'testmode' => array(
'title' => __( 'Test mode', 'woocommerce_gateway_paysubs' ),
'type' => 'checkbox',
'description' => __( 'Uses a PaySubs2 test account. Request test cards from PayGate.', 'woocommerce_gateway_paysubs' ),
'desc_tip' => true,
'default' => 'yes',
),
'description' => array(
'title' => __( 'Description', 'paysubs2' ),
'description' => array(
'title' => __( 'Description', 'woocommerce_gateway_paysubs' ),
'type' => 'textarea',
'description' => __( 'This controls the description which the user sees during checkout.', 'paysubs2' ),
'description' => __( 'This controls the description which the user sees during checkout.', 'woocommerce_gateway_paysubs' ),
'default' => 'Pay via Credit or Debit Card',
),
'button_text' => array(
'title' => __( 'Order Button Text', 'paysubs2' ),
'button_text' => array(
'title' => __( 'Order Button Text', 'woocommerce_gateway_paysubs' ),
'type' => 'text',
'description' => __( 'Changes the text that appears on the Place Order button.', 'paysubs2' ),
'description' => __( 'Changes the text that appears on the Place Order button.', 'woocommerce_gateway_paysubs' ),
'default' => 'Proceed to PayGate',
),
);
Expand Down Expand Up @@ -537,8 +567,24 @@ public function fetch_payment_params( $order_id )
$data['SUBS_FREQUENCY'] = $this->settings['frequency'];
}

$data['PROCESS_NOW'] = 'YES';
$data['PROCESS_NOW_AMOUNT'] = $order->get_total() * 100;
$data['PROCESS_NOW'] = 'YES';
if ( $this->settings['specify_amount'] == 'yes' ) {
// Specify Amount is enabled
$specify_amount_value = $this->settings['specify_amount_value'];

if ( $this->settings['product_price'] == 'amount' ) {
// Product Price set to AMOUNT
$data['AMOUNT'] = $order->get_total() * 100;
$data['PROCESS_NOW_AMOUNT'] = $specify_amount_value;
} else {
// Product Price set to PROCESS_NOW_AMOUNT
$data['AMOUNT'] = $specify_amount_value;
$data['PROCESS_NOW_AMOUNT'] = $order->get_total() * 100;
}
} else {
// Specify Amount is disabled
$data['PROCESS_NOW_AMOUNT'] = $order->get_total() * 100;
}

$checksum = md5( implode( '|', $data ) . '|' . $this->encryption_key );
$data['CHECKSUM'] = $checksum;
Expand Down
16 changes: 10 additions & 6 deletions classes/updater.class.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

// Prevent loading this file directly and/or if the class is already defined
if ( !defined( 'ABSPATH' ) || class_exists( 'WPGitHubUpdater' ) || class_exists( 'WP_GitHub_Updater_PS2' ) ) {
if ( !defined( 'ABSPATH' ) || class_exists( 'WPGitHubUpdaterPS2' ) || class_exists( 'WP_GitHub_Updater_PS2' ) ) {
return;
}

Expand Down Expand Up @@ -431,14 +431,18 @@ public function get_description()
*/
public function get_changelog()
{
$_changelog = $this->remote_get( $this->config['raw_url'] . '/changelog.txt' );
if ( is_wp_error( $_changelog ) ) {
return 'Could not get changelog from server.';
$_changelog = '';
if ( !is_wp_error( $this->config ) ) {
$_changelog = $this->remote_get( $this->config['raw_url'] . '/changelog.txt' );
}
if ( !is_wp_error( $_changelog ) ) {
$_changelog = nl2br( $_changelog['body'] );
} else {
$_changelog = '';
}

$_changelog = nl2br( $_changelog['body'] );
// return
return ( !empty( $_changelog ) ? $_changelog : 'Could not get changelog from server.' );

}

/**
Expand Down
8 changes: 4 additions & 4 deletions gateway-paygate.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
* Plugin Name: PayGate PaySubs2 plugin for WooCommerce
* Plugin URI: https://github.com/PayGate/PaySubs2_WooCommerce
* Description: Accept payments for WooCommerce using PayGate's PaySubs2 service
* Version: 1.0.1
* Tested: 5.1.0
* Version: 1.0.2
* Tested: 5.2.1
* Author: PayGate (Pty) Ltd
* Author URI: https://www.paygate.co.za/
* Developer: App Inlet (Pty) Ltd
* Developer URI: https://www.appinlet.com/
*
* WC requires at least: 2.6
* WC tested up to: 3.5
* WC tested up to: 3.6
*
* Copyright: © 2019 PayGate (Pty) Ltd.
* License: GNU General Public License v3.0
Expand Down Expand Up @@ -53,7 +53,7 @@ function woocommerce_paysubs2_init()
'homepage' => 'https://github.com/PayGate/PaySubs2_WooCommerce',
'sslverify' => true,
'requires' => '4.0',
'tested' => '5.1.0',
'tested' => '5.2.1',
'readme' => 'README.md',
'access_token' => '',
);
Expand Down

0 comments on commit 0947af7

Please sign in to comment.