Skip to content

Commit

Permalink
Merge pull request #93 from strangerstudios/dev
Browse files Browse the repository at this point in the history
Merge to master.
  • Loading branch information
andrewlimaza authored Nov 30, 2023
2 parents 202b83d + d1b72f2 commit 5d89e6f
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 33 deletions.
22 changes: 11 additions & 11 deletions classes/class.pmprogateway_payfast.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Based on the scripts by Ron Darby shared at
* https://www.payfast.co.za/shopping-carts/paid-memberships-pro/
* https://payfast.io/integration/shopping-carts/paid-memberships-pro/
*
* @author Ron Darby - PayFast
* @copyright 2009-2014 PayFast (Pty) Ltd
Expand Down Expand Up @@ -33,7 +33,7 @@ static function init() {

add_filter( 'pmpro_payment_option_fields', array( 'PMProGateway_PayFast', 'pmpro_payment_option_fields' ), 10, 2 );

if ( pmpro_getOption( 'gateway' ) == 'payfast' ) {
if ( get_option( 'pmpro_gateway' ) == 'payfast' ) {
add_filter( 'pmpro_include_billing_address_fields', '__return_false' );
add_filter( 'pmpro_include_payment_information_fields', '__return_false' );
add_filter( 'pmpro_billing_show_payment_method', '__return_false' );
Expand Down Expand Up @@ -175,7 +175,7 @@ static function pmpro_payment_option_fields( $values, $gateway ) { ?>
<label for="payfast_passphrase"><?php _e( 'PayFast PassPhrase', 'pmpro-payfast' ); ?>:</label>
</th>
<td>
<input id="payfast_passphrase" name="payfast_passphrase" value="<?php echo esc_attr( $values['payfast_passphrase'] ); ?>" /> &nbsp;<small><?php _e( 'A passphrase is required for recurring subscriptions.', 'pmpro-payfast' ); ?></small>
<input id="payfast_passphrase" name="payfast_passphrase" value="<?php echo esc_attr( $values['payfast_passphrase'] ); ?>" /> &nbsp;<small><?php _e( 'A passphrase is now required for all transactions.', 'pmpro-payfast' ); ?></small>
</td>
</tr>
<script>
Expand Down Expand Up @@ -228,7 +228,7 @@ static function pmpro_billing_before_submit_button() {
</script>
<?php
}
echo sprintf( __( "If you need to update your billing details, please login to your %s account to update these credentials. Selecting the update button below will automatically redirect you to PayFast.", 'pmpro-payfast'), "<a href='https://payfast.co.za' target='_blank'>PayFast</a>" );
echo sprintf( __( "If you need to update your billing details, please login to your %s account to update these credentials. Selecting the update button below will automatically redirect you to Payfast.", 'pmpro-payfast'), "<a href='https://payfast.io' target='_blank'>Payfast</a>" );
}

/**
Expand Down Expand Up @@ -374,11 +374,11 @@ function sendToPayFast( &$order ) {
$amount = round( (float) $amount + (float) $amount_tax, 2 );

// merchant details
$merchant_id = pmpro_getOption( 'payfast_merchant_id' );
$merchant_key = pmpro_getOption( 'payfast_merchant_key' );
$merchant_id = get_option( 'pmpro_payfast_merchant_id' );
$merchant_key = get_option( 'pmpro_payfast_merchant_key' );

// build PayFast Redirect
$environment = pmpro_getOption( 'gateway_environment' );
$environment = get_option( 'pmpro_gateway_environment' );
if ( 'sandbox' === $environment || 'beta-sandbox' === $environment ) {
$payfast_url = 'https://sandbox.payfast.co.za/eng/process';
} else {
Expand Down Expand Up @@ -452,7 +452,7 @@ function sendToPayFast( &$order ) {
}

// Remove last ampersand
$passPhrase = pmpro_getOption( 'payfast_passphrase' );
$passPhrase = get_option( 'pmpro_payfast_passphrase' );

// Add passphrase to URL.
if ( empty( $passPhrase ) ) {
Expand Down Expand Up @@ -507,10 +507,10 @@ function cancel( &$order ) {
$token = $order->paypal_token;

$hashArray = array();
$passphrase = pmpro_getOption( 'payfast_passphrase' );
$passphrase = get_option( 'pmpro_payfast_passphrase' );

$hashArray['version'] = 'v1';
$hashArray['merchant-id'] = pmpro_getOption( 'payfast_merchant_id' );
$hashArray['merchant-id'] = get_option( 'pmpro_payfast_merchant_id' );
$hashArray['passphrase'] = $passphrase;
$hashArray['timestamp'] = date( 'Y-m-d' ) . 'T' . date( 'H:i:s' );

Expand All @@ -524,7 +524,7 @@ function cancel( &$order ) {

$url = $domain . '/subscriptions/' . $token . '/cancel';

$environment = pmpro_getOption( 'gateway_environment' );
$environment = get_option( 'pmpro_gateway_environment' );

if ( 'sandbox' === $environment || 'beta-sandbox' === $environment ) {
$url = $url . '?testing=true';
Expand Down
Binary file modified img/payfast_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 6 additions & 6 deletions pmpro-payfast.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Plugin Name: Paid Memberships Pro - PayFast Gateway
Plugin URI: https://www.paidmembershipspro.com/add-ons/payfast-payment-gateway/
Description: Adds PayFast as a gateway option for Paid Memberships Pro.
Version: 1.4
Version: 1.4.1
Author: Paid Memberships Pro
Author URI: https://www.paidmembershipspro.com
Text Domain: pmpro-payfast
Expand Down Expand Up @@ -97,8 +97,8 @@ function pmpro_payfast_check_level_compat(){
function pmpro_payfast_pmpro_is_ready( $pmpro_is_ready ) {
global $pmpro_gateway_ready, $pmpro_pages_ready;

if ( empty($pmpro_gateway_ready) && 'payfast' === pmpro_getOption( 'gateway' ) ) {
if( pmpro_getOption( 'payfast_merchant_id' ) && pmpro_getOption( 'payfast_merchant_key' ) && pmpro_getOption( 'payfast_passphrase' ) ) {
if ( empty($pmpro_gateway_ready) && 'payfast' === get_option( 'pmpro_gateway' ) ) {
if( get_option( 'pmpro_payfast_merchant_id' ) && get_option( 'pmpro_payfast_merchant_key' ) && get_option( 'pmpro_payfast_passphrase' ) ) {
$pmpro_gateway_ready = true;
}
}
Expand All @@ -113,11 +113,11 @@ function pmpro_payfast_pmpro_is_ready( $pmpro_is_ready ) {
*/
function pmpro_payfast_check_billing_compat( $level = NULL ){

if( !function_exists( 'pmpro_getOption' ) ){
if( !function_exists( 'pmpro_init' ) ){
return;
}

$gateway = pmpro_getOption("gateway");
$gateway = get_option("pmpro_gateway");

if( $gateway == "payfast" ){

Expand Down Expand Up @@ -161,7 +161,7 @@ function pmpro_payfast_check_billing_compat( $level = NULL ){
* @since 0.9
*/
function pmpro_payfast_custom_trial_js_check() {
$gateway = pmpro_getOption( 'gateway' );
$gateway = get_option( 'pmpro_gateway' );

if ( $gateway !== 'payfast' ) {
return;
Expand Down
32 changes: 18 additions & 14 deletions readme.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
=== Paid Memberships Pro - PayFast Gateway Add On ===
=== Paid Memberships Pro - Payfast Gateway Add On ===
Contributors: strangerstudios, andrewza, paidmembershipspro
Tags: paid memberships pro, pmpro, payfast, gateway, credit card
Requires at least: 5.0
Tested up to: 6.1
Stable tag: 1.3.0
Tested up to: 6.4
Stable tag: 1.4.1

Add the South African payment processing service PayFast as a gateway option for Paid Memberships Pro.
Add the South African payment processing service Payfast as a gateway option for Paid Memberships Pro.

== Description ==

Add the South African payment processing service PayFast as a gateway option for Paid Memberships Pro.
Add the South African payment processing service Payfast as a gateway option for Paid Memberships Pro.

[PayFast](https://www.payfast.co.za/) is a payments processing service for South Africans and South African websites. Their payment gateway offers a secure and instant transfer of money between online buyers and sellers. Merchants can accept funds from local and international customers from anywhere in the world in ZAR.
[Payfast](https://www.payfast.io/) is a payments processing service for South Africans and South African websites. Their payment gateway offers a secure and instant transfer of money between online buyers and sellers. Merchants can accept funds from local and international customers from anywhere in the world in ZAR.

Fees are charged per-transaction [according to this fee schedule](https://www.payfast.co.za/fees/) and there are no setup or monthly fees.
Fees are charged per-transaction [according to this fee schedule](https://www.payfast.io/fees/) and there are no setup or monthly fees.

[youtube http://www.youtube.com/watch?v=aDjjSjmJ-j8]

Expand All @@ -22,13 +22,13 @@ Fees are charged per-transaction [according to this fee schedule](https://www.pa
1. Make sure you have the Paid Memberships Pro plugin installed and activated.
1. Upload the `pmpro-payfast` directory to the `/wp-content/plugins/` directory of your site.
1. Activate the plugin through the 'Plugins' menu in WordPress.
1. Go to Memberships -> Payment Settings in your WordPress dashboard to complete the PayFast settings.
1. Go to Memberships -> Payment Settings in your WordPress dashboard to complete the Payfast settings.

= Setup =
1. Register and validate your account with PayFast: https://www.payfast.co.za/user/register.
1. Log in to your PayFast account and select 'Settings' to retrieve your merchant details.
1. Register and validate your account with Payfast: https://registration.payfast.io/.
1. Log in to your Payfast account and select 'Settings' to retrieve your merchant details.
1. Log in to your WordPress dashboard and navigate to Memberships > Payment Settings.
1. Set your "Payment Gateway" to "PayFast". Fill out your merchant details and Security Passphrase (required in order to accept recurring payments).
1. Set your "Payment Gateway" to "Payfast". Fill out your merchant details and Security Passphrase (required in order to accept recurring payments).
1. Set your currency to "South African Rand".
1. Save your settings.

Expand All @@ -44,16 +44,20 @@ For immediate help, also post to our premium support site at https://www.paidmem

Please visit our premium support site at https://www.paidmembershipspro.com for more documentation and our support forums.

= I need to test PayFast in sandbox mode. =
= I need to test Payfast in sandbox mode. =

To test PayFast payments without being billed in sandbox mode requires a sandbox account from PayFast. For more information in creating a sandbox account - https://developers.payfast.co.za/documentation/#the-sandbox
To test Payfast payments without being billed in sandbox mode requires a sandbox account from PayFast. For more information in creating a sandbox account - https://developers.payfast.co.za/documentation/#the-sandbox


== Changelog ==
= 1.4.1 - 2023-11-30 =
* REFACTOR: Changed the checkout logo to the new Payfast logo
* REFACTOR: Moved to using get_option instead of the pmpro_getOption.

= 1.4 - 2022-12-01 =
* ENHANCEMENT: Added better support for MMPU when a member cancels their membership. (@dparker1005)
* BUG FIX/ENHANCEMENT: Fixed an issue where custom fields were not saving correctly during checkout. (@jarrydlong)
* BUG FIX: Fix fatal error during ITN service PayFast uses. (@louiswol94)
* BUG FIX: Fix fatal error during ITN service Payfast uses. (@louiswol94)
* REFACTOR: Removed redundant code and cleaned up code. (@mircobabini)

= 1.3.0 - 2021-12-15 =
Expand Down
4 changes: 2 additions & 2 deletions services/payfast_itn_handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
define( 'PMPROPF_SOFTWARE_VER', PMPRO_VERSION );
define( 'PMPROPF_MODULE_NAME', 'PayFast-PaidMembershipsPro' );
define( 'PMPROPF_MODULE_VER', '1.0' );
define( 'PMPROPF_DEBUG', pmpro_getOption( 'payfast_debug' ) );
define( 'PMPROPF_DEBUG', get_option( 'pmpro_payfast_debug' ) );

// Features
// - PHP
Expand Down Expand Up @@ -98,7 +98,7 @@
// Verify security signature
if ( ! $pfError && ! $pfDone ) {
pmpro_payfast_itnlog( __( 'Verify security signature', 'pmpro-payfast' ) );
$passPhrase = pmpro_getOption( 'payfast_passphrase' );
$passPhrase = get_option( 'pmpro_payfast_passphrase' );
$pfPassPhrase = empty( $passPhrase ) ? null : $passPhrase;
// If signature different, log for debugging
if ( ! pmpro_pfValidSignature( $pfData, $pfParamString, $pfPassPhrase ) ) {
Expand Down

0 comments on commit 5d89e6f

Please sign in to comment.