Avoid zero values on Paypal checkout page (SOLUTION)

First of all I would like to congratulate because of this engine, it is a very nice product, a love it from the first 5 seconds :slight_smile:

I had a problem with Paypal, exactly the same:
“Right now it takes them to a direct paypal login with no additional options and automatically inserting a " 0 " in the username field.”
I read about this problem here: https://community2.invoiceplane.com/t/credit-card-invoice-payment-without-a-paypal-account/424

My solution
edit this file: /application/modules/guest/controllers/payment_handler.php

Find this part (somewhere in the 55. line (in v1.4.8)):

        $params = array(
            'description' => trans('invoice') . ' ' . $invoice->invoice_number,
            'amount' => $invoice->invoice_balance,
            'currency' => $this->mdl_settings->setting('merchant_currency_code'),
            'return_url' => site_url('guest/payment_handler/payment_return/' . $invoice_url_key . '/r'),

and extend this array:

        $params = array(
            'description' => trans('invoice') . ' ' . $invoice->invoice_number,
            'amount' => $invoice->invoice_balance,
            'currency' => $this->mdl_settings->setting('merchant_currency_code'),
            'return_url' => site_url('guest/payment_handler/payment_return/' . $invoice_url_key . '/r'),
            'cancel_url' => site_url('guest/payment_handler/payment_cancel/' . $invoice_url_key . '/c'),
            'name' => '',
            'address1' => '',
            'address2' => '',
            'city' => '',
            'region' => '',
            'country' => '',
            'postcode' => '',
            'phone' => '',
            'email' => ''
        );

Good luck!

ps: If you want to know more about the problem source look into this file:
/application/libraries/merchant/merchant_paypal_express.php
Goto 84. line and check this:

    protected function _build_authorize_or_purchase()
    {
            $this->require_params('return_url');

            $request = $this->_new_request('SetExpressCheckout');
            $prefix = 'PAYMENTREQUEST_0_';
            $this->_add_request_details($request, 'Authorization', $prefix);

            // pp express specific fields
            $request['SOLUTIONTYPE'] = $this->setting('solution_type');
            $request['LANDINGPAGE'] = $this->setting('landing_page');
            $request['NOSHIPPING'] = 1; //XXX
            $request['ALLOWNOTE'] = 0;
            $request['RETURNURL'] = $this->param('return_url');
            $request['CANCELURL'] = $this->param('cancel_url');
            $request[$prefix.'SHIPTONAME'] = $this->param('name');
            $request[$prefix.'SHIPTOSTREET'] = $this->param('address1');
            $request[$prefix.'SHIPTOSTREET2'] = $this->param('address2');
            $request[$prefix.'SHIPTOCITY'] = $this->param('city');
            $request[$prefix.'SHIPTOSTATE'] = $this->param('region');
            $request[$prefix.'SHIPTOCOUNTRYCODE'] = $this->param('country');
            $request[$prefix.'SHIPTOZIP'] = $this->param('postcode');
            $request[$prefix.'SHIPTOPHONENUM'] = $this->param('phone');
            $request['EMAIL'] = $this->param('email');

            return $request;
    }

Furthermore, you can learn more about paypal API here:
https://developer.paypal.com/docs/classic/api/merchant/SetExpressCheckout_API_Operation_NVP/

Cheers,
Gabor

1 Like