Forums / Addon Payment Modules / Adding Braintree payment module

Adding Braintree payment module

Views: 83,422

Results 141 to 160 of 214
1 Sep 2017, 6:25 AM
#141
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 have been using Paypal Express for years and it always worked well, I use the Zen Cart built in PayPal Express.

Now since installing the Braintree module, it seems that PayPal Express is now running over the Braintree Payment module since I now get PayPal messages over Braintree.

Now I have a new problem, PayPal Express does not display the correct price?!

If, for example, I order an item for 29.90 then I have a low price extra of 5.00 and delivery of 9.00 so the total is 43.90.
When I initiate PayPal Express then PayPal displays the price to pay is 34.55!
When I actually approve the payment then PayPal takes the correct 43.90?

I do not see where the 34.55 comes from, if PayPal somehow missed the delivery cost of 9.00 then the price would be 34.90.

If I do not use the PayPal express button on the Shopping Cart page but go through longer payment process then PayPal displays and works correctly.

My ideal solution would be to continue to use the Zen Cart built in PayPal Express module, is there some way I can configure this?
I suppose I could deconfigure the PayPal Express button on the Shopping Cart page but then I would lose a valuable function :(

I started using Braintree because credit card payments over PayPal were losing me customers because PayPal demanded some customers to open an account which they did not want to do!

I am using v155d with the standard Green Responsive template on a Unix server.
my web site here in English language!

BTW, thanks to whoever suggested I set up a Zen Cart test site on my Web host server; it was a bit tedious but it works well (other than confusing the google adwords statistics!)

Nobody commented, would be nice to hear a comment? Even simply from an existing Braintree user who does not have this problem with PayPalExpress?

1 Sep 2017, 7:16 AM
#142
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:

Nobody commented, would be nice to hear a comment? Even simply from an existing Braintree user who does not have this problem with PayPalExpress?

Problem over.

I went into the Braintree Control Panel and turned off PayPal and then set it up again and now the prices are showing correctly :)

4 Sep 2017, 7:05 PM
#143
marton_1 avatar

marton_1

Totally Zenned

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

Re: Adding Braintree payment module

Now I am getting this log message for Paypal "update_status
Module disabled due to zone restriction. Billing address is not within the Payment Zone selected in the module settings."

I have selected the same payment zone as I used successfully for several years with the built in Paypal express module, it is named EuropeandCH and the detailed setting ls in the picture below.
Customers from Switzerland (Schweiz) are now being rejected.
Suggestions welcomed

5 Sep 2017, 11:14 AM
#144
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:

Now I am getting this log message for Paypal "update_status
Module disabled due to zone restriction. Billing address is not within the Payment Zone selected in the module settings."

I have selected the same payment zone as I used successfully for several years with the built in Paypal express module, it is named EuropeandCH and the detailed setting ls in the picture below.
Customers from Switzerland (Schweiz) are now being rejected.
Suggestions welcomed

Now I had three customers rejected by PayPal "due to zone restriction". I tried ordering myself with PayPal on my live site using my Swiss details and it worked OK.
I asked Braintree and they claim it is not their problem!

Here is a typical zen cart log message [HTML]Sep-02-2017 23:20:54 (1504387254)
update_status

Sep-02-2017 23:20:54 (1504387254)
update_status
Module disabled due to zone restriction. Billing address is not within the Payment Zone selected in the module settings.

Anybody know where does this 150xxxx number come from? Is it a PayPal number and can I trace it somehow?

5 Sep 2017, 11:53 AM
#145
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 someone with a USA address did some testing on my web site, thank you!

USA is not a valid zone for my site so will not work correctly!

5 Sep 2017, 2:53 PM
#146
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:

Now I had three customers rejected by PayPal "due to zone restriction". I tried ordering myself with PayPal on my live site using my Swiss details and it worked OK.
I asked Braintree and they claim it is not their problem!

Here is a typical zen cart log message [HTML]Sep-02-2017 23:20:54 (1504387254)
update_status

Anybody know where does this 150xxxx number come from? Is it a PayPal number and can I trace it somehow?

I will move this question to the PayPal Express checkout forum, please ignore here.

16 Sep 2017, 8:34 PM
#147
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 no longer get these Zone failure messages, I compared the Braintree Module braintree_api.php with the Paypalwpp module and changed anything that was different from the Paypalwpp, see comments with "MH".

    /**
     *  Sets payment module status based on zone restrictions etc
     */
    function update_status() {
        global $order, $db;

        // if store is not running in SSL, cannot offer credit card module, for PCI reasons
				
        if (IS_ADMIN_FLAG === false && (!defined('ENABLE_SSL') || ENABLE_SSL != 'true')) {
            $this->enabled = False;
            $this->zcLog('update_status', 'Module disabled because SSL is not enabled on this site.');
        }
       
        // check other reasons for the module to be deactivated:
				[B]// added "&& isset($order->billing['country']['id'])) {" from paypalwpp MH[/B]
        if ($this->enabled && (int) $this->zone > 0 [B]&& isset($order->billing['country']['id']))[/B] {

            $check_flag = false;

            $sql = "SELECT zone_id
                FROM " . TABLE_ZONES_TO_GEO_ZONES . "
                WHERE geo_zone_id = :zoneId
                AND zone_country_id = :countryId
                ORDER BY zone_id";

            $sql = $db->bindVars($sql, ':zoneId', $this->zone, 'integer');
            $sql = $db->bindVars($sql, ':countryId', $order->billing['country']['id'], 'integer');
            $check = $db->Execute($sql);

            while (!$check->EOF) {

                if ($check->fields['zone_id'] < 1) {
                    $check_flag = true;
                    break;
                } else if ($check->fields['zone_id'] == $order->billing['zone_id']) {
                    $check_flag = true;
                    break;
                }

                $check->MoveNext();
            }

            if (!$check_flag) {
                $this->enabled = false;
                $this->zcLog('update_status', 'Module disabled due to zone restriction. Billing address is not within the Payment Zone selected in the module settings.');
            }
            [B]// added one } from next section MH[/B]
						[B]}[/B]
            // module cannot be used for purchase > $10,000 USD
            $order_amount = $this->calc_order_amount($order->info['total'], 'USD');

            if ($order_amount > 10000) {
                $this->enabled = false;
                $this->zcLog('update_status', 'Module disabled because purchase price (' . $order_amount . ') exceeds Braintree-imposed maximum limit of 10,000 USD.');
            }

            if ($order->info['total'] == 0) {
                $this->enabled = false;
                /* $this->zcLog('update_status', 'Module disabled because purchase amount is set to 0.00.' . "\n" . print_r($order, true)); */
            }
        }
   [B] // removed one } from this section MH[/B]
16 Sep 2017, 9:01 PM
#148
marton_1 avatar

marton_1

Totally Zenned

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

Re: Adding Braintree payment module

My Mastercard customers are being rejected with the message the first four characters of the credit card number are incorrect.

Here in Switzerland the first four characters of the credit card number are 5487.

I assume the credit card number is pre-checked before being sent to Braintree?

Where are the numbers for this checking stored?

BTW, Visa works OK.

17 Sep 2017, 7:22 AM
#149
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:

My Mastercard customers are being rejected with the message the first four characters of the credit card number are incorrect.

Here in Switzerland the first four characters of the credit card number are 5487.

I assume the credit card number is pre-checked before being sent to Braintree?

Where are the numbers for this checking stored?

BTW, Visa works OK.

The actual message I receive is

braintree_api
CC validation results: Die ersten 4 Ziffer der Kreditkartennummer, die Sie angegeben haben, lauten: . Ist diese Nummer richtig, können wir diese Kreditkarte nicht akzeptieren. Bitte korrigieren Sie ggf. die eingegebene Nummer oder setzen Sie sich mit Ihren Kreditinstitut in Verbindung.(-1)

So the first four numbers of the credit card are not displayed; is this some sort of security thing or does it mean the module lost the actual numbers somewhere?

17 Sep 2017, 12:36 PM
#150
drbyte avatar

drbyte

Sensei

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

Re: Adding Braintree payment module

When the form data is submitted to your server, the payment module takes the card number and passes it to the cc_validation class to be sure that it matches the card types that you've configured your store to accept in Admin->Configuration->Credit Cards.

But, since the error message you quoted isn't showing any of the rejected digits, it's possible that the value is blank when being submitted.

Or, it could be that the translation logic in your language files is missing the placeholder that displays the card number. (First test for that is to switch to english and see if the same message also doesn't show the digits.)

.
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.

17 Sep 2017, 1:02 PM
#151
marton_1 avatar

marton_1

Totally Zenned

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

Re: Adding Braintree payment module

DrByte:

When the form data is submitted to your server, the payment module takes the card number and passes it to the cc_validation class to be sure that it matches the card types that you've configured your store to accept in Admin->Configuration->Credit Cards.

But, since the error message you quoted isn't showing any of the rejected digits, it's possible that the value is blank when being submitted.

Or, it could be that the translation logic in your language files is missing the placeholder that displays the card number. (First test for that is to switch to english and see if the same message also doesn't show the digits.)

Thanks for your reply.
I switched to English but there are still no digits shown in the error message for Mastercard.

Visa card payments work correctly.

The actual message

braintree_api
CC validation results: The credit card number starting with was not entered correctly, or we do not accept that kind of card. Please try again or use another credit card.(-1)

17 Sep 2017, 1:10 PM
#152
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:

Thanks for your reply.
I switched to English but there are still no digits shown in the error message for Mastercard.

Visa card payments work correctly.

The actual message

When I wrote "Visa card payments work correctly." I meant the payment is made OK not that an error message for Visa card is shown correctly!

18 Sep 2017, 11:21 PM
#153
marton_1 avatar

marton_1

Totally Zenned

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

Re: Adding Braintree payment module

To summarise, valid Mastercards are being rejected. The error message is the first four digits are wrong.
I have tested three different genuine cards with the four digits 5487 and all were rejected.

Visa cards are not rejected and payment is made so I assume it is a data issue not a coding issue?

There is a subsidiary problem that the error message does not does not show the incorrect digits; just a blank.
I entered a Visa card with incorrect first four digits, it was rejected and the error message again did not show the incorrect digits

19 Sep 2017, 10:50 PM
#154
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:

To summarise, valid Mastercards are being rejected. The error message is the first four digits are wrong.
I have tested three different genuine cards with the four digits 5487 and all were rejected.

Visa cards are not rejected and payment is made so I assume it is a data issue not a coding issue?

There is a subsidiary problem that the error message does not does not show the incorrect digits; just a blank.
I entered a Visa card with incorrect first four digits, it was rejected and the error message again did not show the incorrect digits

Forgot to say that in sandbox mode using the Mastercard test number everything works OK

21 Sep 2017, 6:52 PM
#155
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:

To summarise, valid Mastercards are being rejected. The error message is the first four digits are wrong.
I have tested three different genuine cards with the four digits 5487 and all were rejected.

Visa cards are not rejected and payment is made so I assume it is a data issue not a coding issue?

There is a subsidiary problem that the error message does not does not show the incorrect digits; just a blank.
I entered a Visa card with incorrect first four digits, it was rejected and the error message again did not show the incorrect digits

marton_1:

Forgot to say that in sandbox mode using the Mastercard test number everything works OK

Also forgot to say that I receive the error message that does not does not show the incorrect first four digits but my customer does not receive any sort of error message. On the last step (3 of 3) when they confirm the order they are just sent back to page 2 of 3- "Payment Information" without any explanation!

26 Sep 2017, 12:10 PM
#156
marton_1 avatar

marton_1

Totally Zenned

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

Re: Adding Braintree payment module

As mentioned Visa cards work correctly. I tried entering a Visa card with an incorrect Card Verification Value and as the administrator I got the message

braintree_api
CC validation results: The credit card number starting with was not entered correctly, or we do not accept that kind of card. Please try again or use another credit card.(-1)
Of course this is not a useful error message, as the customer I did not receive any sort of error message and was just sent back to page 2 of 3- "Payment Information" without any explanation!

I tried commenting out the credit card check in braintree_api.php but then the correct Visa card does not work any more; at least as the customer I did get a detailed error message on page 2 of 3- "Payment Information"
This is the code but probably I did not comment it correctly; I commented out the whole section starting "This is the credit card check"

 
       /**
     * This is the credit card check done between checkout_payment and
     * checkout_confirmation (called from checkout_confirmation).
     * Evaluates the Credit Card Type for acceptance and the validity of the Credit Card Number & Expiration Date
     */
    function pre_confirmation_check() {
        global $messageStack, $order;

        include(DIR_WS_CLASSES . 'cc_validation.php');
        $cc_validation = new cc_validation();
        $result = $cc_validation->validate($_POST['braintree_cc_number'], $_POST['braintree_cc_expires_month'], $_POST['braintree_cc_expires_year'], (isset($_POST['braintree_cc_issue_month']) ? $_POST['braintree_cc_issue_month'] : ''), (isset($_POST['braintree_cc_issue_year']) ? $_POST['braintree_cc_issue_year'] : ''));
        $error = '';

        switch ($result) {
            case 1:
                break;
            case -1:
                $error = MODULE_PAYMENT_BRAINTREE_TEXT_BAD_CARD; //sprintf(TEXT_CCVAL_ERROR_UNKNOWN_CARD, substr($cc_validation->cc_number, 0, 4));
                if ($_POST['braintree_cc_number'] == '')
                    $error = str_replace('\n', '', MODULE_PAYMENT_BRAINTREE_TEXT_JS_CC_NUMBER); // yes, those are supposed to be single-quotes.
                break;
            case -2:
            case -3:
            case -4:
                $error = TEXT_CCVAL_ERROR_INVALID_DATE;
                break;
            case false:
                $error = TEXT_CCVAL_ERROR_INVALID_NUMBER;
                break;
        }
    
        $_POST['braintree_cc_checkcode'] = preg_replace('/[^0-9]/i', '', $_POST['braintree_cc_checkcode']);
        if (isset($_POST['braintree_cc_issuenumber']))
            $_POST['braintree_cc_issuenumber'] = preg_replace('/[^0-9]/i', '', $_POST['braintree_cc_issuenumber']);

        if (($result === false) || ($result < 1)) {
            $messageStack->add_session($this->code, $error . '<!-- [' . $this->code . '] -->' . '<!-- result: ' . $result . ' -->', 'error');
            zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL', true, false));
        }
        
        $this->cc_card_type = $cc_validation->cc_type;
        $this->cc_card_number = $cc_validation->cc_number;
        $this->cc_expiry_month = $cc_validation->cc_expiry_month;
        $this->cc_expiry_year = $cc_validation->cc_expiry_year;
        $this->cc_checkcode = $_POST['braintree_cc_checkcode'];
    }
 
    /**
     * Display Credit Card Information for review on the Checkout Confirmation Page
     */
29 Sep 2017, 8:48 AM
#157
marton_1 avatar

marton_1

Totally Zenned

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

Re: Adding Braintree payment module

Decided to abandon this Braintree gateway and return to Paypal Express, problem here is credit card customers are sometime asked to open a PayPal account and then I lose the sale :(

Anyway looks like the Braintree gateway is not updated for MasterCard 2-series BIN.

I tried payeez, I filled in the new customer form on their local web site some two months ago but they never did reply.

Square does not offer credit card service in Switzerland.

Anybody have good experience of a Zen Cart credit card gateway in Switzerland?

10 Mar 2019, 1:19 PM
#158
juvar avatar

juvar

New Zenner

Join Date:
Jun 2009
Posts:
7
Plugin Contributions:
0

Re: Adding Braintree payment module

Is there a support to Paypal transaction in this Braintree payment module? I see many files related to it in modules directory, but in store front there is only card payment method visible. For example in directory "/includes/modules/payment/braintree/lib/Braintree" there is files PayPalAccount.php and PayPalAccountGateway.php. How to get it visible in checkout?

Other question is about this code in "braintree_api.php":

        // store the Braintree order meta data -- used for later matching and back-end processing activities
        $braintree_order = array('order_id' => $insert_id,
            'txn_type' => $this->transactiontype,
            'module_name' => $this->code,
            'module_mode' => 'USA',

I live in Finland and have plans to sell products in EU area. Do I need to change that hard coded "USA"-line? Test transaction in sandbox mode is working.

Thank you.

12 Jul 2019, 11:58 AM
#159
gernot avatar

gernot

Zen Follower

Join Date:
Feb 2017
Location:
Tokyo, Japan
Posts:
334
Plugin Contributions:
0

Re: Adding Braintree payment module

Hi juvar,
I would suggest testing it (and maybe taking the trouble to peruse the Braintree API docs on their site).

I'm going to try this module too, although I am specifically interested in the credit card option: Paypal express checkout does not permit guest checkout for Japan-issued credit cards (I am in Japan).
Alternatives would be Stripe (still waiting for their Japan sales team to get back to me on any service restrictions), and Square (waiting for their sales team, same question), among others.

Zen Cart 1.5.6c modified for Japanese language support. Upgraded incrementally from initial 1.5.5d. Currently planning direct upgrade to 2.1.0

29 Sep 2019, 8:20 AM
#160
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 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?