Plugin Directory

Changeset 3162067


Ignore:
Timestamp:
10/03/2024 11:41:22 AM (15 months ago)
Author:
andrewza
Message:

V1.5.4 fatal error fix for PMPro 3.2

Location:
pmpro-payfast
Files:
6 edited
1 copied

Legend:

Unmodified
Added
Removed
  • pmpro-payfast/tags/1.5.4/classes/class.pmprogateway_payfast.php

    r3159730 r3162067  
    1616class PMProGateway_PayFast extends PMProGateway {
    1717
    18     function __construct( $gateway = null ) {
    19         return parent::__construct( $gateway );
     18    function __construct( $gateway = NULL ) {
     19        $this->gateway = $gateway;
     20        $this->gateway_environment = get_option( 'pmpro_gateway_environment' );
     21
     22        return $this->gateway;
    2023    }
    2124
     
    325328        $order->ProfileStartDate = date_i18n( 'Y-m-d', current_time( 'timestamp' ) );
    326329
     330        // Get the level amount so we can set the initial payment amount.
     331        $level = $order->getMembershipLevelAtCheckout();
     332
    327333        // taxes on initial payment
    328         $initial_payment     = $order->InitialPayment;
     334        $initial_payment     = $order->subtotal;
    329335        $initial_payment_tax = $order->getTaxForPrice( $initial_payment );
    330336        $initial_payment     = round( (float) $initial_payment + (float) $initial_payment_tax, 2 );
    331337
    332338        // taxes on the amount
    333         $amount          = $order->PaymentAmount;
     339        $amount          = empty( $level->billing_amount ) ? 0 : $level->billing_amount;
    334340        $amount_tax      = $order->getTaxForPrice( $amount );
    335341        $order->subtotal = $amount;
     
    348354        }
    349355
     356        $user = get_userdata( $order->user_id );
     357        $nameparts = pnp_split_full_name( $order->billing->name );
     358
    350359        $data = array(
    351360            'merchant_id'   => $merchant_id,
     
    354363            'cancel_url'    => pmpro_url( 'levels' ),
    355364            'notify_url'    => admin_url( 'admin-ajax.php' ) . '?action=pmpro_payfast_itn_handler',
    356             'name_first'    => $order->FirstName,
    357             'name_last'     => $order->LastName,
    358             'email_address' => $order->Email,
     365            'name_first'    => empty( $nameparts['fname'] ) ? '' : $nameparts['fname'],
     366            'name_last'     => empty( $nameparts['lname'] ) ? '' : $nameparts['lname'],
     367            'email_address' => $user->user_email,
    359368            'm_payment_id'  => $order->code,
    360369            'amount'        => $initial_payment,
     
    364373
    365374        $cycles = $order->membership_level->billing_limit;
    366 
    367         if( ! empty( $order->BillingFrequency ) ) {
     375        if( ! empty( $level->cycle_number ) ) {
    368376            // convert PMPro cycle_number and period into a PayFast frequency
    369             switch ( $order->BillingPeriod ) {
     377            switch ( $level->cycle_period ) {
    370378                case 'Day':
    371379                    $frequency = '1';
     
    385393        // Add subscription data
    386394        if ( ! empty( $frequency ) ) {
    387             // $data['m_subscription_id'] = /*$order->getRandomCode()*/$order->code;
    388             $data['custom_str1']       = $order->ProfileStartDate;
     395            $data['custom_str1']       = pmpro_calculate_profile_start_date( $order, 'Y-m-d' );
    389396            $data['subscription_type'] = 1;
    390             $data['billing_date']      = apply_filters( 'pmpro_profile_start_date', $order->ProfileStartDate, $order );
     397            $data['billing_date']      = apply_filters( 'pmpro_profile_start_date', $data['custom_str1'], $order );
    391398            $data['recurring_amount']  = $amount;
    392399            $data['frequency']         = $frequency;
     
    405412        $order->payment_transaction_id      = $order->code;
    406413        $order->subscription_transaction_id = $order->code;
    407         $order->subtotal = $order->InitialPayment;
    408414        $order->tax = $initial_payment_tax;
    409415        $order->total = $initial_payment;       
  • pmpro-payfast/tags/1.5.4/pmpro-payfast.php

    r3159730 r3162067  
    44Plugin URI: https://www.paidmembershipspro.com/add-ons/payfast-payment-gateway/
    55Description: Adds PayFast as a gateway option for Paid Memberships Pro.
    6 Version: 1.5.3
     6Version: 1.5.4
    77Author: Paid Memberships Pro
    88Author URI: https://www.paidmembershipspro.com
  • pmpro-payfast/tags/1.5.4/readme.txt

    r3159750 r3162067  
    44Requires at least: 5.0
    55Tested up to: 6.6
    6 Stable tag: 1.5.3
     6Stable tag: 1.5.4
    77License: GPLv2
    88License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    5353
    5454== Changelog ==
     55= 1.5.4 - 2024-10-03 =
     56* BUG FIX: Fixed a fatal issue with Paid Memberships Pro V3.2+ and improved compatibility with 3.2+.
     57
    5558= 1.5.3 - 2024-09-30 =
    5659* BUG FIX/ENHANCEMENT: Added better support for User Fields not saving correctly during checkout. (@andrewlimaza)
  • pmpro-payfast/trunk/classes/class.pmprogateway_payfast.php

    r3159730 r3162067  
    1616class PMProGateway_PayFast extends PMProGateway {
    1717
    18     function __construct( $gateway = null ) {
    19         return parent::__construct( $gateway );
     18    function __construct( $gateway = NULL ) {
     19        $this->gateway = $gateway;
     20        $this->gateway_environment = get_option( 'pmpro_gateway_environment' );
     21
     22        return $this->gateway;
    2023    }
    2124
     
    325328        $order->ProfileStartDate = date_i18n( 'Y-m-d', current_time( 'timestamp' ) );
    326329
     330        // Get the level amount so we can set the initial payment amount.
     331        $level = $order->getMembershipLevelAtCheckout();
     332
    327333        // taxes on initial payment
    328         $initial_payment     = $order->InitialPayment;
     334        $initial_payment     = $order->subtotal;
    329335        $initial_payment_tax = $order->getTaxForPrice( $initial_payment );
    330336        $initial_payment     = round( (float) $initial_payment + (float) $initial_payment_tax, 2 );
    331337
    332338        // taxes on the amount
    333         $amount          = $order->PaymentAmount;
     339        $amount          = empty( $level->billing_amount ) ? 0 : $level->billing_amount;
    334340        $amount_tax      = $order->getTaxForPrice( $amount );
    335341        $order->subtotal = $amount;
     
    348354        }
    349355
     356        $user = get_userdata( $order->user_id );
     357        $nameparts = pnp_split_full_name( $order->billing->name );
     358
    350359        $data = array(
    351360            'merchant_id'   => $merchant_id,
     
    354363            'cancel_url'    => pmpro_url( 'levels' ),
    355364            'notify_url'    => admin_url( 'admin-ajax.php' ) . '?action=pmpro_payfast_itn_handler',
    356             'name_first'    => $order->FirstName,
    357             'name_last'     => $order->LastName,
    358             'email_address' => $order->Email,
     365            'name_first'    => empty( $nameparts['fname'] ) ? '' : $nameparts['fname'],
     366            'name_last'     => empty( $nameparts['lname'] ) ? '' : $nameparts['lname'],
     367            'email_address' => $user->user_email,
    359368            'm_payment_id'  => $order->code,
    360369            'amount'        => $initial_payment,
     
    364373
    365374        $cycles = $order->membership_level->billing_limit;
    366 
    367         if( ! empty( $order->BillingFrequency ) ) {
     375        if( ! empty( $level->cycle_number ) ) {
    368376            // convert PMPro cycle_number and period into a PayFast frequency
    369             switch ( $order->BillingPeriod ) {
     377            switch ( $level->cycle_period ) {
    370378                case 'Day':
    371379                    $frequency = '1';
     
    385393        // Add subscription data
    386394        if ( ! empty( $frequency ) ) {
    387             // $data['m_subscription_id'] = /*$order->getRandomCode()*/$order->code;
    388             $data['custom_str1']       = $order->ProfileStartDate;
     395            $data['custom_str1']       = pmpro_calculate_profile_start_date( $order, 'Y-m-d' );
    389396            $data['subscription_type'] = 1;
    390             $data['billing_date']      = apply_filters( 'pmpro_profile_start_date', $order->ProfileStartDate, $order );
     397            $data['billing_date']      = apply_filters( 'pmpro_profile_start_date', $data['custom_str1'], $order );
    391398            $data['recurring_amount']  = $amount;
    392399            $data['frequency']         = $frequency;
     
    405412        $order->payment_transaction_id      = $order->code;
    406413        $order->subscription_transaction_id = $order->code;
    407         $order->subtotal = $order->InitialPayment;
    408414        $order->tax = $initial_payment_tax;
    409415        $order->total = $initial_payment;       
  • pmpro-payfast/trunk/pmpro-payfast.php

    r3159730 r3162067  
    44Plugin URI: https://www.paidmembershipspro.com/add-ons/payfast-payment-gateway/
    55Description: Adds PayFast as a gateway option for Paid Memberships Pro.
    6 Version: 1.5.3
     6Version: 1.5.4
    77Author: Paid Memberships Pro
    88Author URI: https://www.paidmembershipspro.com
  • pmpro-payfast/trunk/readme.txt

    r3159750 r3162067  
    44Requires at least: 5.0
    55Tested up to: 6.6
    6 Stable tag: 1.5.3
     6Stable tag: 1.5.4
    77License: GPLv2
    88License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    5353
    5454== Changelog ==
     55= 1.5.4 - 2024-10-03 =
     56* BUG FIX: Fixed a fatal issue with Paid Memberships Pro V3.2+ and improved compatibility with 3.2+.
     57
    5558= 1.5.3 - 2024-09-30 =
    5659* BUG FIX/ENHANCEMENT: Added better support for User Fields not saving correctly during checkout. (@andrewlimaza)
Note: See TracChangeset for help on using the changeset viewer.