Forums / Addon Payment Modules / Adding Braintree payment module

Adding Braintree payment module

Views: 83,422

Results 161 to 180 of 214
29 Sep 2019, 8:31 AM
#161
marton_1 avatar

marton_1

Totally Zenned

Join Date:
Apr 2013
Location:
eglisau switzerland
Posts:
568
Plugin Contributions:
0

Adding Braintree payment module

marton_1:

I used to use Braintree but stopped it due to problems with Mastercard payments. I switched to Stripe but it has not been updated to handle the new EU PSD2 requirements so I cannot use Stripe any more.
I see the Braintree module has been updated since but it is not stated what has been fixed/changed. Is PSD2 supported?

Just heard that the PSD2 deadline has been pushed out from 14 September 2019 to March 2021, set by the Financial Conduct Authority.
Anyway my Stripe payment module does not work anymore so I would like to know what was fixed in Braintree with the last update.

29 Sep 2019, 8:55 AM
#162
marton_1 avatar

marton_1

Totally Zenned

Join Date:
Apr 2013
Location:
eglisau switzerland
Posts:
568
Plugin Contributions:
0

Re: Adding Braintree payment module

marton_1:

Just heard that the PSD2 deadline has been pushed out from 14 September 2019 to March 2021, set by the Financial Conduct Authority.
Anyway my Stripe payment module does not work anymore so I would like to know what was fixed in Braintree with the last update.

Seems the PSD2 deadline that has been pushed out from 14 September 2019 to March 2021 is only for the UK.
What a mess this is.....

22 Apr 2020, 12:57 AM
#163
lrfowler24 avatar

lrfowler24

New Zenner

Join Date:
Feb 2010
Posts:
74
Plugin Contributions:
0

Re: Adding Braintree payment module

why isnt braintree working?
I put in all the necessary info...
https://www.candygoround.com

12 Nov 2020, 3:31 PM
#164
marton_1 avatar

marton_1

Totally Zenned

Join Date:
Apr 2013
Location:
eglisau switzerland
Posts:
568
Plugin Contributions:
0

Re: Adding Braintree payment module

I see the plugin was updated in October but "Strong Customer Authentication" is not mentioned so I suppose it is not supported?

14 Dec 2020, 3:05 PM
#165
ianhg avatar

ianhg

Zen Follower

Join Date:
Jul 2007
Posts:
345
Plugin Contributions:
3

Re: Adding Braintree payment module

Zen cart 1.5.6 PHP7.3
I have just uploaded the latest version of the plugin Braintree API https://www.zen-cart.com/downloads.php?do=file&id=1781 . There a lot of PHP errors relating to PHP Warning: Use of undefined constant in includes/modules/payment/braintree_api.php
Lines 39; 45; 71; 72; 74; 76;80
I suspect there probably more.
Can anyone suggest best way to fix
Thanks

14 Dec 2020, 4:47 PM
#166
ianhg avatar

ianhg

Zen Follower

Join Date:
Jul 2007
Posts:
345
Plugin Contributions:
3

Re: Adding Braintree payment module

ianhg:

Zen cart 1.5.6 PHP7.3
I have just uploaded the latest version of the plugin Braintree API https://www.zen-cart.com/downloads.php?do=file&id=1781 . There a lot of PHP errors relating to PHP Warning: Use of undefined constant in includes/modules/payment/braintree_api.php
Lines 39; 45; 71; 72; 74; 76;80
I suspect there probably more.
Can anyone suggest best way to fix
Thanks


I seem to resolved a couple but am still getting the following:

[14-Dec-2020 16:40:16 UTC] Request URI: /ADMIN/modules.php?set=payment&module=braintree_api, IP address:
#1 braintree_api->__construct() called at [/var/www/vhosts/domain/httpdocs/ADMIN/modules.php:196]
--> PHP Warning: Use of undefined constant MODULE_PAYMENT_BRAINTREE_VERSION - assumed 'MODULE_PAYMENT_BRAINTREE_VERSION' (this will throw an Error in a future version of PHP) in /var/www/vhosts/domain/httpdocs/includes/modules/payment/braintree_api.php on line 45.

[14-Dec-2020 16:40:16 UTC] Request URI: /ADMIN/modules.php?set=payment&module=braintree_api, IP address:
#1 braintree_api->__construct() called at [/var/www/vhosts/domain/httpdocs/ADMIN/modules.php:196]
--> PHP Warning: Use of undefined constant MODULE_PAYMENT_BRAINTREE_DEBUGGING - assumed 'MODULE_PAYMENT_BRAINTREE_DEBUGGING' (this will throw an Error in a future version of PHP) in /var/www/vhosts/domain/httpdocs/includes/modules/payment/braintree_api.php on line 71.

[14-Dec-2020 16:40:16 UTC] Request URI: /ADMIN/modules.php?set=payment&module=braintree_api, IP address:
#1 braintree_api->__construct() called at [/var/www/vhosts/domain/httpdocs/ADMIN/modules.php:196]
--> PHP Warning: Use of undefined constant MODULE_PAYMENT_BRAINTREE_DEBUGGING - assumed 'MODULE_PAYMENT_BRAINTREE_DEBUGGING' (this will throw an Error in a future version of PHP) in /var/www/vhosts/domain/httpdocs/includes/modules/payment/braintree_api.php on line 71.

[14-Dec-2020 16:40:16 UTC] Request URI: /ADMIN/modules.php?set=payment&module=braintree_api, IP address:
#1 braintree_api->__construct() called at [/var/www/vhosts/domain/httpdocs/ADMIN/modules.php:196]
--> PHP Warning: Use of undefined constant MODULE_PAYMENT_BRAINTREE_DEBUGGING - assumed 'MODULE_PAYMENT_BRAINTREE_DEBUGGING' (this will throw an Error in a future version of PHP) in /var/www/vhosts/domain/httpdocs/includes/modules/payment/braintree_api.php on line 72.

 function __construct() {
        include_once(zen_get_file_directory(DIR_FS_CATALOG . DIR_WS_LANGUAGES . $_SESSION['language'] . '/modules/payment/', 'braintree_api.php', 'false'));        global $order;
        $this->code = 'braintree_api';        $this->title = MODULE_PAYMENT_BRAINTREE_TEXT_ADMIN_TITLE;        $this->codeVersion = (defined('MODULE_PAYMENT_BRAINTREE_VERSION')) ? MODULE_PAYMENT_BRAINTREE_VERSION : false;        $this->enabled = (defined('MODULE_PAYMENT_BRAINTREE_STATUS') && MODULE_PAYMENT_BRAINTREE_STATUS == 'True');
        // Set the title & description text based on the mode we're in        if (IS_ADMIN_FLAG === true) {            if (file_exists(DIR_FS_CATALOG . DIR_WS_FUNCTIONS . 'plugin_support.php')) {                require_once(DIR_FS_CATALOG . DIR_WS_FUNCTIONS . 'plugin_support.php');                $new_version_details = plugin_version_check_for_updates(1781,  MODULE_PAYMENT_BRAINTREE_VERSION);                if ($new_version_details !== FALSE) {                    $this->title .= '<span class="alert">' . ' - NOTE: A NEW VERSION OF THIS PLUGIN IS AVAILABLE. <a href="' . $new_version_details['link'] . '" target="_blank">[Details]</a>' . '</span>';                }            }            $this->description = sprintf(MODULE_PAYMENT_BRAINTREE_TEXT_ADMIN_DESCRIPTION, ($this->codeVersion) ? ' (rev' . $this->codeVersion . ')': '');            $this->title = MODULE_PAYMENT_BRAINTREE_TEXT_ADMIN_TITLE;
            if ($this->enabled) {
                if (MODULE_PAYMENT_BRAINTREE_SERVER == 'sandbox')                    $this->title .= '<strong><span class="alert"> (sandbox active)</span></strong>';                if   (MODULE_PAYMENT_BRAINTREE_DEBUGGING == 'Log File' || MODULE_PAYMENT_BRAINTREE_DEBUGGING == 'Log and Email')                    $this->title .= '<strong> (Debug)</strong>';                if (!function_exists('curl_init'))                    $this->title .= '<strong><span class="alert"> CURL NOT FOUND. Cannot Use.</span></strong>';            }        } else {
            $this->description = MODULE_PAYMENT_BRAINTREE_TEXT_DESCRIPTION;            $this->title = MODULE_PAYMENT_BRAINTREE_TEXT_TITLE; //cc        }
        if ((!defined('BRAINTREE_OVERRIDE_CURL_WARNING') || (defined('BRAINTREE_OVERRIDE_CURL_WARNING') && BRAINTREE_OVERRIDE_CURL_WARNING != 'True')) && !function_exists('curl_init'))            $this->enabled = false;
        $this->enableDebugging = (MODULE_PAYMENT_BRAINTREE_DEBUGGING == 'Log File' || MODULE_PAYMENT_BRAINTREE_DEBUGGING == 'Log and Email');        $this->emailAlerts = (MODULE_PAYMENT_BRAINTREE_DEBUGGING == 'Log and Email');        $this->sort_order = (defined('MODULE_PAYMENT_BRAINTREE_SORT_ORDER')) ? MODULE_PAYMENT_BRAINTREE_SORT_ORDER : null;        $this->order_pending_status = (defined('MODULE_PAYMENT_BRAINTREE_ORDER_PENDING_STATUS_ID')) && MODULE_PAYMENT_BRAINTREE_ORDER_PENDING_STATUS_ID;
        if (defined('MODULE_PAYMENT_BRAINTREE_ORDER_STATUS_ID') && (int) MODULE_PAYMENT_BRAINTREE_ORDER_STATUS_ID > 0) {            $this->order_status = MODULE_PAYMENT_BRAINTREE_ORDER_STATUS_ID;        }
        $this->zone = (defined('MODULE_PAYMENT_BRAINTREE_ZONE')) && (int) MODULE_PAYMENT_BRAINTREE_ZONE;
        if (is_object($order))            $this->update_status();
        if (!(PROJECT_VERSION_MAJOR > 1 || (PROJECT_VERSION_MAJOR == 1 && substr(PROJECT_VERSION_MINOR, 0, 3) >= 5)))            $this->enabled = false;

Suggestions welcome thanks

14 Dec 2020, 5:25 PM
#167
carlwhat avatar

carlwhat

zennedOut

Join Date:
Nov 2005
Location:
los angeles
Posts:
2,973
Plugin Contributions:
8

Re: Adding Braintree payment module

ian,
have you tried un-installing and reinstalling the module?

if you are still having errors, have you looked at your ZC configuration table for these config values? if MODULE_PAYMENT_BRAINTREE_VERSION is not in the configuration table, that's a problem that this is complaining about.

best.

author of square Webpay, now with Apple Pay and Google Pay.
mXworks
donations: venmo or paypal accepted.
premium consistent excellent support. available for hire.

14 Dec 2020, 6:47 PM
#168
ianhg avatar

ianhg

Zen Follower

Join Date:
Jul 2007
Posts:
345
Plugin Contributions:
3

Re: Adding Braintree payment module

carlwhat:

ian,
have you tried un-installing and reinstalling the module?

if you are still having errors, have you looked at your ZC configuration table for these config values? if MODULE_PAYMENT_BRAINTREE_VERSION is not in the configuration table, that's a problem that this is complaining about.

best.
Yes tried un-installing and reinstalled same PHP warnings
Any ideas on the MODULE_PAYMENT_BRAINTREE_DEBUGGING
Thanks for a speedy response.

14 Dec 2020, 6:58 PM
#169
carlwhat avatar

carlwhat

zennedOut

Join Date:
Nov 2005
Location:
los angeles
Posts:
2,973
Plugin Contributions:
8

Re: Adding Braintree payment module

ianhg:

Yes tried un-installing and reinstalled same PHP warnings
Any ideas on the MODULE_PAYMENT_BRAINTREE_DEBUGGING
Thanks for a speedy response.

have you looked at the configuration table using phpMyAdmin (or some other tool)? specifically what does:

SELECT *
FROM `configuration`
WHERE `configuration_key` LIKE '%BRAINTREE%'

result in? (please change the table name to include a prefix if you have one.)

also have you defined:

MODULE_PAYMENT_BRAINTREE_STATUS

somewhere in your code? that could cause you to not install all of these config values.

author of square Webpay, now with Apple Pay and Google Pay.
mXworks
donations: venmo or paypal accepted.
premium consistent excellent support. available for hire.

14 Dec 2020, 7:17 PM
#170
ianhg avatar

ianhg

Zen Follower

Join Date:
Jul 2007
Posts:
345
Plugin Contributions:
3

Re: Adding Braintree payment module

carlwhat:

have you looked at the configuration table using phpMyAdmin (or some other tool)? specifically what does:

SELECT *
FROM configuration
WHERE configuration_key LIKE '%BRAINTREE%'

> 
> result in?  (please change the table name to include a prefix if you have one.)
> 
> also have you defined:
> 
> MODULE_PAYMENT_BRAINTREE_STATUS
> 
> somewhere in your code?  that could cause you to not install all of these config values.
Hi Carl
Yes DATABASE shows MODULE_PAYMENT_BRAINTREE_STATUS and MODULE_PAYMENT_BRAINTREE_DEBUUGING also MODULE_PAYMENT_BRAINTREE_VERSION
It just keep throwing the PHP errors
[14-Dec-2020 16:40:16 UTC] Request URI: /ADMIN/modules.php?set=payment&module=braintree_api, IP address:  
#1 braintree_api->__construct() called at [/var/www/vhosts/domain/httpdocs/ADMIN/modules.php:196]
--> PHP Warning: Use of undefined constant MODULE_PAYMENT_BRAINTREE_VERSION - assumed 'MODULE_PAYMENT_BRAINTREE_VERSION' (this will throw an Error in a future version of PHP) in /var/www/vhosts/domain/httpdocs/includes/modules/payment/braintree_api.php on line 45.


[14-Dec-2020 16:40:16 UTC] Request URI: /ADMIN/modules.php?set=payment&module=braintree_api, IP address:  
#1 braintree_api->__construct() called at [/var/www/vhosts/domain/httpdocs/ADMIN/modules.php:196]
--> PHP Warning: Use of undefined constant MODULE_PAYMENT_BRAINTREE_DEBUGGING - assumed 'MODULE_PAYMENT_BRAINTREE_DEBUGGING' (this will throw an Error in a future version of PHP) in /var/www/vhosts/domain/httpdocs/includes/modules/payment/braintree_api.php on line 71.


[14-Dec-2020 16:40:16 UTC] Request URI: /ADMIN/modules.php?set=payment&module=braintree_api, IP address:  
#1 braintree_api->__construct() called at [/var/www/vhosts/domain/httpdocs/ADMIN/modules.php:196]
--> PHP Warning: Use of undefined constant MODULE_PAYMENT_BRAINTREE_DEBUGGING - assumed 'MODULE_PAYMENT_BRAINTREE_DEBUGGING' (this will throw an Error in a future version of PHP) in /var/www/vhosts/domain/httpdocs/includes/modules/payment/braintree_api.php on line 71.


[14-Dec-2020 16:40:16 UTC] Request URI: /ADMIN/modules.php?set=payment&module=braintree_api, IP address:  
#1 braintree_api->__construct() called at [/var/www/vhosts/domain/httpdocs/ADMIN/modules.php:196]
--> PHP Warning: Use of undefined constant MODULE_PAYMENT_BRAINTREE_DEBUGGING - assumed 'MODULE_PAYMENT_BRAINTREE_DEBUGGING' (this will throw an Error in a future version of PHP) in /var/www/vhosts/domain/httpdocs/includes/modules/payment/braintree_api.php on line 72.
 

There were others but I managed to fix them.
LIne 80 $this->zone = (defined('MODULE_PAYMENT_BRAINTREE_ZONE')) && (int) MODULE_PAYMENT_BRAINTREE_ZONE;
was $this->zone = (int) MODULE_PAYMENT_BRAINTREE_ZONE;I tried fixing the above but without any luck.. Thanks again for your time appreciated
14 Dec 2020, 8:18 PM
#171
carlwhat avatar

carlwhat

zennedOut

Join Date:
Nov 2005
Location:
los angeles
Posts:
2,973
Plugin Contributions:
8

Re: Adding Braintree payment module

ian,
are u using the latest version? or have you modified some of the code? my line numbers do not match to yours.

in the __ construct function, you can try changing a couple of lines to:

$this->enabled = defined('MODULE_PAYMENT_BRAINTREE_STATUS') && (MODULE_PAYMENT_BRAINTREE_STATUS == 'True');

// Set the title & description text based on the mode we're in
if ($this->enabled && IS_ADMIN_FLAG === true) {

that may help you out.

author of square Webpay, now with Apple Pay and Google Pay.
mXworks
donations: venmo or paypal accepted.
premium consistent excellent support. available for hire.

14 Dec 2020, 8:57 PM
#172
ianhg avatar

ianhg

Zen Follower

Join Date:
Jul 2007
Posts:
345
Plugin Contributions:
3

Re: Adding Braintree payment module

carlwhat:

ian,
are u using the latest version? or have you modified some of the code? my line numbers do not match to yours.

in the __ construct function, you can try changing a couple of lines to:

$this->enabled = defined('MODULE_PAYMENT_BRAINTREE_STATUS') && (MODULE_PAYMENT_BRAINTREE_STATUS == 'True');

// Set the title & description text based on the mode we're in
if ($this->enabled && IS_ADMIN_FLAG === true) {

> 
> that may help you out.
Thanks Carl
I downloaded the latest API plugin from Zen Cart . This is the code I have that is a problem as you can see the MODULE_PAYMENT_BRAINTREE_STATUS is already there as you suggested. Thank you
```php
 function __construct() {
        include_once(zen_get_file_directory(DIR_FS_CATALOG . DIR_WS_LANGUAGES . $_SESSION['language'] . '/modules/payment/', 'braintree_api.php', 'false'));        global $order;
        $this->code = 'braintree_api';        $this->title = MODULE_PAYMENT_BRAINTREE_TEXT_ADMIN_TITLE;        $this->codeVersion = (defined('MODULE_PAYMENT_BRAINTREE_VERSION')) ? MODULE_PAYMENT_BRAINTREE_VERSION : false;        $this->enabled = (defined('MODULE_PAYMENT_BRAINTREE_STATUS') && MODULE_PAYMENT_BRAINTREE_STATUS == 'True');
        // Set the title & description text based on the mode we're in        if (IS_ADMIN_FLAG === true) {            if (file_exists(DIR_FS_CATALOG . DIR_WS_FUNCTIONS . 'plugin_support.php')) {                require_once(DIR_FS_CATALOG . DIR_WS_FUNCTIONS . 'plugin_support.php');                $new_version_details = plugin_version_check_for_updates(1781,  MODULE_PAYMENT_BRAINTREE_VERSION);                if ($new_version_details !== FALSE) {                    $this->title .= '<span class="alert">' . ' - NOTE: A NEW VERSION OF THIS PLUGIN IS AVAILABLE. <a href="' . $new_version_details['link'] . '" target="_blank">[Details]</a>' . '</span>';                }            }            $this->description = sprintf(MODULE_PAYMENT_BRAINTREE_TEXT_ADMIN_DESCRIPTION, ($this->codeVersion) ? ' (rev' . $this->codeVersion . ')': '');            $this->title = MODULE_PAYMENT_BRAINTREE_TEXT_ADMIN_TITLE;
            if ($this->enabled) {
                if (MODULE_PAYMENT_BRAINTREE_SERVER == 'sandbox')                    $this->title .= '<strong><span class="alert"> (sandbox active)</span></strong>';                if   (MODULE_PAYMENT_BRAINTREE_DEBUGGING == 'Log File' || MODULE_PAYMENT_BRAINTREE_DEBUGGING == 'Log and Email')                    $this->title .= '<strong> (Debug)</strong>';                if (!function_exists('curl_init'))                    $this->title .= '<strong><span class="alert"> CURL NOT FOUND. Cannot Use.</span></strong>';            }        } else {
            $this->description = MODULE_PAYMENT_BRAINTREE_TEXT_DESCRIPTION;            $this->title = MODULE_PAYMENT_BRAINTREE_TEXT_TITLE; //cc        }
        if ((!defined('BRAINTREE_OVERRIDE_CURL_WARNING') || (defined('BRAINTREE_OVERRIDE_CURL_WARNING') && BRAINTREE_OVERRIDE_CURL_WARNING != 'True')) && !function_exists('curl_init'))            $this->enabled = false;
        $this->enableDebugging = (MODULE_PAYMENT_BRAINTREE_DEBUGGING == 'Log File' || MODULE_PAYMENT_BRAINTREE_DEBUGGING == 'Log and Email');        $this->emailAlerts = (MODULE_PAYMENT_BRAINTREE_DEBUGGING == 'Log and Email');        $this->sort_order = (defined('MODULE_PAYMENT_BRAINTREE_SORT_ORDER')) ? MODULE_PAYMENT_BRAINTREE_SORT_ORDER : null;        $this->order_pending_status = (defined('MODULE_PAYMENT_BRAINTREE_ORDER_PENDING_STATUS_ID')) && MODULE_PAYMENT_BRAINTREE_ORDER_PENDING_STATUS_ID;
        if (defined('MODULE_PAYMENT_BRAINTREE_ORDER_STATUS_ID') && (int) MODULE_PAYMENT_BRAINTREE_ORDER_STATUS_ID > 0) {            $this->order_status = MODULE_PAYMENT_BRAINTREE_ORDER_STATUS_ID;        }
        $this->zone = (defined('MODULE_PAYMENT_BRAINTREE_ZONE')) && (int) MODULE_PAYMENT_BRAINTREE_ZONE;
        if (is_object($order))            $this->update_status();
        if (!(PROJECT_VERSION_MAJOR > 1 || (PROJECT_VERSION_MAJOR == 1 && substr(PROJECT_VERSION_MINOR, 0, 3) >= 5)))            $this->enabled = false; 
14 Dec 2020, 9:13 PM
#173
ianhg avatar

ianhg

Zen Follower

Join Date:
Jul 2007
Posts:
345
Plugin Contributions:
3

Re: Adding Braintree payment module

Its the MODULE_PAYMENT_BRAINTREE_DEBUGGING and MODULE_PAYMENT_BRAINTREE_VERSION that are showing a problem $new_version_details = plugin_version_check_for_updates(1781, MODULE_PAYMENT_BRAINTREE_VERSION)
even though I have this before ```php
$this->codeVersion = (defined('MODULE_PAYMENT_BRAINTREE_VERSION')) ? MODULE_PAYMENT_BRAINTREE_VERSION : false;

Just not too sure how fix undefined constant, just want to stop the PHP errors. 
Thanks
14 Dec 2020, 9:40 PM
#174
carlwhat avatar

carlwhat

zennedOut

Join Date:
Nov 2005
Location:
los angeles
Posts:
2,973
Plugin Contributions:
8

Re: Adding Braintree payment module

ianhg:

Its the MODULE_PAYMENT_BRAINTREE_DEBUGGING and MODULE_PAYMENT_BRAINTREE_VERSION that are showing a problem $new_version_details = plugin_version_check_for_updates(1781, MODULE_PAYMENT_BRAINTREE_VERSION)
even though I have this before ```php
$this->codeVersion = (defined('MODULE_PAYMENT_BRAINTREE_VERSION')) ? MODULE_PAYMENT_BRAINTREE_VERSION : false;

> Just not too sure how fix undefined constant, just want to stop the PHP errors. 
> Thanks

ian,
a few things:- when posting your code, try and keep the line feed or carriage returns.  your post a couple above is a little hard to read.
- the errors that you are seeing are warnings and should not affect processing.
- warnings can be turned off by going to configuration -> logging.
- these warnings only occur when you are first installing the module and are of little consequence.
- i can not vouch for how the rest of the module works.
- if you want the warnings to disappear, you can replace the whole construct function to the code i have listed below.  this has worked in my limited testing.
- hope that helps!

```php
    function __construct() {

        include_once(zen_get_file_directory(DIR_FS_CATALOG . DIR_WS_LANGUAGES . $_SESSION['language'] . '/modules/payment/', 'braintree_api.php', 'false'));
        global $order;

        $this->code = 'braintree_api';
        $this->title = MODULE_PAYMENT_BRAINTREE_TEXT_ADMIN_TITLE;
        $this->codeVersion = (defined('MODULE_PAYMENT_BRAINTREE_VERSION')) ? MODULE_PAYMENT_BRAINTREE_VERSION : false;
        $this->enabled = defined('MODULE_PAYMENT_BRAINTREE_STATUS') && (MODULE_PAYMENT_BRAINTREE_STATUS == 'True');

        // Set the title & description text based on the mode we're in
        if ($this->enabled && IS_ADMIN_FLAG === true) {
            if (file_exists(DIR_FS_CATALOG . DIR_WS_FUNCTIONS . 'plugin_support.php')) {
                require_once(DIR_FS_CATALOG . DIR_WS_FUNCTIONS . 'plugin_support.php');
                $new_version_details = plugin_version_check_for_updates(1781, MODULE_PAYMENT_BRAINTREE_VERSION);
                if ($new_version_details !== FALSE) {
                    $this->title .= '<span class="alert">' . ' - NOTE: A NEW VERSION OF THIS PLUGIN IS AVAILABLE. <a href="' . $new_version_details['link'] . '" target="_blank">[Details]</a>' . '</span>';
                }
            }
            $this->description = sprintf(MODULE_PAYMENT_BRAINTREE_TEXT_ADMIN_DESCRIPTION, ($this->codeVersion) ? ' (rev' . $this->codeVersion . ')': '');
            $this->title = MODULE_PAYMENT_BRAINTREE_TEXT_ADMIN_TITLE;

            if ($this->enabled) {

                if (MODULE_PAYMENT_BRAINTREE_SERVER == 'sandbox')
                    $this->title .= '<strong><span class="alert"> (sandbox active)</span></strong>';
                if (MODULE_PAYMENT_BRAINTREE_DEBUGGING == 'Log File' || MODULE_PAYMENT_BRAINTREE_DEBUGGING == 'Log and Email')
                    $this->title .= '<strong> (Debug)</strong>';
                if (!function_exists('curl_init'))
                    $this->title .= '<strong><span class="alert"> CURL NOT FOUND. Cannot Use.</span></strong>';
            }
        } else {

            $this->description = MODULE_PAYMENT_BRAINTREE_TEXT_DESCRIPTION;
            $this->title = MODULE_PAYMENT_BRAINTREE_TEXT_TITLE; //cc
        }

        if ((!defined('BRAINTREE_OVERRIDE_CURL_WARNING') || (defined('BRAINTREE_OVERRIDE_CURL_WARNING') && BRAINTREE_OVERRIDE_CURL_WARNING != 'True')) && !function_exists('curl_init'))
            $this->enabled = false;

        if (empty($this->enabled) || !$this->enabled) {
        	return;
        }

        $this->enableDebugging = (MODULE_PAYMENT_BRAINTREE_DEBUGGING == 'Log File' || MODULE_PAYMENT_BRAINTREE_DEBUGGING == 'Log and Email');
        $this->emailAlerts = (MODULE_PAYMENT_BRAINTREE_DEBUGGING == 'Log and Email');
        $this->sort_order = MODULE_PAYMENT_BRAINTREE_SORT_ORDER;
        $this->order_pending_status = MODULE_PAYMENT_BRAINTREE_ORDER_PENDING_STATUS_ID;

        if ((int) MODULE_PAYMENT_BRAINTREE_ORDER_STATUS_ID > 0) {
            $this->order_status = MODULE_PAYMENT_BRAINTREE_ORDER_STATUS_ID;
        }

        $this->zone = (int) MODULE_PAYMENT_BRAINTREE_ZONE;

        if (is_object($order))
            $this->update_status();

        if (!(PROJECT_VERSION_MAJOR > 1 || (PROJECT_VERSION_MAJOR == 1 && substr(PROJECT_VERSION_MINOR, 0, 3) >= 5)))
            $this->enabled = false;

        // debug setup
        if (!defined('DIR_FS_LOGS')) {
            $log_dir = 'cache/';
        } else {
            $log_dir = DIR_FS_LOGS;
        }

        if (!@is_writable($log_dir))
            $log_dir = DIR_FS_CATALOG . $log_dir;
        if (!@is_writable($log_dir))
            $log_dir = DIR_FS_SQL_CACHE;
        // Regular mode:
        if ($this->enableDebugging)
            $this->_logLevel = 2;
        // DEV MODE:
        if (defined('BRAINTREE_DEV_MODE') && BRAINTREE_DEV_MODE == 'true')
            $this->_logLevel = 3;
    }

author of square Webpay, now with Apple Pay and Google Pay.
mXworks
donations: venmo or paypal accepted.
premium consistent excellent support. available for hire.

14 Dec 2020, 9:45 PM
#175
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: Adding Braintree payment module

Note: while the difference may seem moot to you, "warnings" are different from "errors". Warnings are giving a heads-up that something might be wrong or might be treated more severely in the future. Errors mean something is broken and things probably aren't working.

Without having used or tested it, I'm thinking you can probably solve all of this with fewer changes. Most of those "not defined" situations are because the module hasn't been "installed" yet. After clicking "Install", most of those will go away.

Setting the $enabled to false by default, and then exiting ("early return") if the critical STATUS is not defined, should suffice:
https://share.getcloudapp.com/mXu5KRz1

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

14 Dec 2020, 9:51 PM
#176
ianhg avatar

ianhg

Zen Follower

Join Date:
Jul 2007
Posts:
345
Plugin Contributions:
3

Re: Adding Braintree payment module

DrByte:

Note: while the difference may seem moot to you, "warnings" are different from "errors". Warnings are giving a heads-up that something might be wrong or might be treated more severely in the future. Errors mean something is broken and things probably aren't working.
Thank you I will try to use the correct terminology ,appreciate the help.

14 Dec 2020, 9:52 PM
#177
ianhg avatar

ianhg

Zen Follower

Join Date:
Jul 2007
Posts:
345
Plugin Contributions:
3

Re: Adding Braintree payment module

carlwhat:

ian,
a few things:

  • when posting your code, try and keep the line feed or carriage returns. your post a couple above is a little hard to read.
  • the errors that you are seeing are warnings and should not affect processing.
  • warnings can be turned off by going to configuration -> logging.
  • these warnings only occur when you are first installing the module and are of little consequence.
  • i can not vouch for how the rest of the module works.
  • if you want the warnings to disappear, you can replace the whole construct function to the code i have listed below. this has worked in my limited testing.
  • hope that helps!
function __construct() {

    include_once(zen_get_file_directory(DIR_FS_CATALOG . DIR_WS_LANGUAGES . $_SESSION['language'] . '/modules/payment/', 'braintree_api.php', 'false'));
    global $order;

    $this->code = 'braintree_api';
    $this->title = MODULE_PAYMENT_BRAINTREE_TEXT_ADMIN_TITLE;
    $this->codeVersion = (defined('MODULE_PAYMENT_BRAINTREE_VERSION')) ? MODULE_PAYMENT_BRAINTREE_VERSION : false;
    $this->enabled = defined('MODULE_PAYMENT_BRAINTREE_STATUS') && (MODULE_PAYMENT_BRAINTREE_STATUS == 'True');

    // Set the title & description text based on the mode we're in
    if ($this->enabled && IS_ADMIN_FLAG === true) {
        if (file_exists(DIR_FS_CATALOG . DIR_WS_FUNCTIONS . 'plugin_support.php')) {
            require_once(DIR_FS_CATALOG . DIR_WS_FUNCTIONS . 'plugin_support.php');
            $new_version_details = plugin_version_check_for_updates(1781, MODULE_PAYMENT_BRAINTREE_VERSION);
            if ($new_version_details !== FALSE) {
                $this->title .= '<span class="alert">' . ' - NOTE: A NEW VERSION OF THIS PLUGIN IS AVAILABLE. <a href="' . $new_version_details['link'] . '" target="_blank">[Details]</a>' . '</span>';
            }
        }
        $this->description = sprintf(MODULE_PAYMENT_BRAINTREE_TEXT_ADMIN_DESCRIPTION, ($this->codeVersion) ? ' (rev' . $this->codeVersion . ')': '');
        $this->title = MODULE_PAYMENT_BRAINTREE_TEXT_ADMIN_TITLE;

        if ($this->enabled) {

            if (MODULE_PAYMENT_BRAINTREE_SERVER == 'sandbox')
                $this->title .= '<strong><span class="alert"> (sandbox active)</span></strong>';
            if (MODULE_PAYMENT_BRAINTREE_DEBUGGING == 'Log File' || MODULE_PAYMENT_BRAINTREE_DEBUGGING == 'Log and Email')
                $this->title .= '<strong> (Debug)</strong>';
            if (!function_exists('curl_init'))
                $this->title .= '<strong><span class="alert"> CURL NOT FOUND. Cannot Use.</span></strong>';
        }
    } else {

        $this->description = MODULE_PAYMENT_BRAINTREE_TEXT_DESCRIPTION;
        $this->title = MODULE_PAYMENT_BRAINTREE_TEXT_TITLE; //cc
    }

    if ((!defined('BRAINTREE_OVERRIDE_CURL_WARNING') || (defined('BRAINTREE_OVERRIDE_CURL_WARNING') && BRAINTREE_OVERRIDE_CURL_WARNING != 'True')) && !function_exists('curl_init'))
        $this->enabled = false;

    if (empty($this->enabled) || !$this->enabled) {
        return;
    }

    $this->enableDebugging = (MODULE_PAYMENT_BRAINTREE_DEBUGGING == 'Log File' || MODULE_PAYMENT_BRAINTREE_DEBUGGING == 'Log and Email');
    $this->emailAlerts = (MODULE_PAYMENT_BRAINTREE_DEBUGGING == 'Log and Email');
    $this->sort_order = MODULE_PAYMENT_BRAINTREE_SORT_ORDER;
    $this->order_pending_status = MODULE_PAYMENT_BRAINTREE_ORDER_PENDING_STATUS_ID;

    if ((int) MODULE_PAYMENT_BRAINTREE_ORDER_STATUS_ID > 0) {
        $this->order_status = MODULE_PAYMENT_BRAINTREE_ORDER_STATUS_ID;
    }

    $this->zone = (int) MODULE_PAYMENT_BRAINTREE_ZONE;

    if (is_object($order))
        $this->update_status();

    if (!(PROJECT_VERSION_MAJOR > 1 || (PROJECT_VERSION_MAJOR == 1 && substr(PROJECT_VERSION_MINOR, 0, 3) >= 5)))
        $this->enabled = false;

    // debug setup
    if (!defined('DIR_FS_LOGS')) {
        $log_dir = 'cache/';
    } else {
        $log_dir = DIR_FS_LOGS;
    }

    if (!@is_writable($log_dir))
        $log_dir = DIR_FS_CATALOG . $log_dir;
    if (!@is_writable($log_dir))
        $log_dir = DIR_FS_SQL_CACHE;
    // Regular mode:
    if ($this->enableDebugging)
        $this->_logLevel = 2;
    // DEV MODE:
    if (defined('BRAINTREE_DEV_MODE') && BRAINTREE_DEV_MODE == 'true')
        $this->_logLevel = 3;
}
Thank you Carl Appreciate the help and guide lines, much appreciated.
17 Feb 2021, 4:11 PM
#178
lindasdd avatar

lindasdd

Zen Follower

Join Date:
Jun 2007
Posts:
474
Plugin Contributions:
0

Re: Adding Braintree payment module

Numinix (the original author's of this plugin) have put out a new version here: https://bitbucket.org/numinix/braintree/src/master/

I mention it because the new version has a ton of changes (not much documentation on what those changes are for)

Couple notes:

  • it will trigger some php warnings
  • it will cause Console errors if you are not using the Braintree 3D Secure
  • sandbox testing will cause a whitepage and an authentication error log (I did not take the time to debug)
  • version number is not updated
17 Feb 2021, 4:46 PM
#179
carlwhat avatar

carlwhat

zennedOut

Join Date:
Nov 2005
Location:
los angeles
Posts:
2,973
Plugin Contributions:
8

Re: Adding Braintree payment module

lindasdd:

Numinix (the original author's of this plugin) have put out a new version here: https://bitbucket.org/numinix/braintree/src/master/

I mention it because the new version has a ton of changes (not much documentation on what those changes are for)

Couple notes:

  • it will trigger some php warnings
  • it will cause Console errors if you are not using the Braintree 3D Secure
  • sandbox testing will cause a whitepage and an authentication error log (I did not take the time to debug)
  • version number is not updated

the comments that i posted here on numinix still apply:

https://www.zen-cart.com/showthread.php?76557-Fast-and-Easy-Checkout&p=1374966#post1374966

mind you, this is an open bitbucket repo, i'm not sure if it is released or what, so i am hesitant, but:

https://bitbucket.org/numinix/braintree/src/master/catalog_php7/includes/modules/payment/braintree_api.php

line 36 should be named __construct. am i wrong?

makes no sense to me.... else their testing is just non-existent....

best.

author of square Webpay, now with Apple Pay and Google Pay.
mXworks
donations: venmo or paypal accepted.
premium consistent excellent support. available for hire.

24 Feb 2021, 2:23 PM
#180
lindasdd avatar

lindasdd

Zen Follower

Join Date:
Jun 2007
Posts:
474
Plugin Contributions:
0

Re: Adding Braintree payment module

carlwhat:

the comments that i posted here on numinix still apply:

https://www.zen-cart.com/showthread.php?76557-Fast-and-Easy-Checkout&p=1374966#post1374966

mind you, this is an open bitbucket repo, i'm not sure if it is released or what, so i am hesitant, but:

https://bitbucket.org/numinix/braintree/src/master/catalog_php7/includes/modules/payment/braintree_api.php

line 36 should be named __construct. am i wrong?

makes no sense to me.... else their testing is just non-existent....

best.

I am not utilizing the Braintree version they put out for the reasons you mention (and other PHP fixes that are in the version I added to the plugin bank).

I mention the new version by the original author to provide as much info about the plugin as possible. Although I am using the plugin in a high volume Zen-Cart 1.5.7b store and don't know of issues, I am not an adept enough programmer to know if a change in 1.5.7 broke an aspect of the plugin (unless it totally breaks the plugin or throws an error log).