Problems, need help? Have a tip or advice? Post it here.
30 posts Page 3 of 3
Hi Simon. I took a little more time troubleshooting your problem and this is what I learned. When I used seller='<cms:show pp_email />' with single quotes, I got the same mistake you did. <cms:show pp_email /> gets passed through literally as the email address.

When I used seller="<cms:show pp_email />" with double quotes, the default email - seller_1272492192_biz@gmail.com - gets passed through to PayPal. That's because I never defined pp_email, so the variable is empty. The expected behavior when the variable is empty is to use the email address from the config file.

This is what I think is happening to you. For whatever reason, pp_email is empty when you pass it to the 'seller' parameter, probably because it is out of scope. Be sure you are using the cms:pages tag properly so that you are in the right context when calling <cms:show pp_email />.

I hope that helps.
Hi Tim,

I've edited the code and changed the <cms:show pp_email /> to press@tsmsport.co.uk
Now it must be that it's not getting the sellers email address correctly through the editable pp_email.

It'll leave blank because it can't find the editable pp_email as its outside of the index.php clone page it's set within.

its now working out the pages code to get the product you are checking out with to show the correct email address submitted within the products clone page

I don't really need the checkout part. Or the cart as such. I just need the buy now button on the clone page. In fact it'll be better if I didn't run the cart. Due to multi adding. I'll have to look at a code within the checkout to get the information needed like

Product title
Total price
Sellers email

With that processing attached
@Simon,

I think @tim's modifications if applied to <cms:paypal_button />, instead of the cart, should be what you are looking for.

Please check http://docs.couchcms.com/concepts/paypal.html and try to implement the default version of <cms:paypal_button /> (buyer is hardcoded to single value). If that works for you, let me know and I'll modify the code a little to support multiple buyers.
@kk

Thanks. I'll take a look and try implement the code. I've contacted @Tim to find out what modifications are needed to be made within the config.php file as we are no longer using the cart.php

What file will need to be edited. I've setup the button and paypal_processor but it's still using the business PayPal email rather than the sellers


@tim I'm totally unsure what needs editing for the modification as we are no longer using the cart page. Will be the config.php file? As that is totally different to the cart.php page?

Hopefully I'll be able to get this sorted

Thanks again, Simon
Alright, Simon. Instead of sending you a ready-made modification, let's walk through the process and you can modify the file yourself. It'll be fun and easy and might be interesting to others curious about working with customizing Couch.

Fire up your trusty text editor and open couch/tags.php. Search for "paypal_button". You'll find exactly one instance on line 4627.
Code: Select all
        //////Will try and move the following to 'plugins', once the architecture is in place
        function paypal_button( $params, $node ){
            global $CTX, $FUNCS, $PAGE;
            if( count($node->children) ) {die("ERROR: Tag \"".$node->name."\" is a self closing tag");}

            extract( $FUNCS->get_named_vars(
                        array(
                              'image'=>'',
                              'processor'=>'',
                              'show_shipping'=>'0',
                              'return_url'=>'',
                              'cancel_url'=>'',
                              'custom'=>''
                              ),
                        $params)
                   );
            $image = trim( $image );
            $processor = trim( $processor );
            $show_shipping = ( $show_shipping==1 ) ? 1 : 0;
            $return_url = trim( $return_url );
            $cancel_url = trim( $cancel_url );

            $item_name = $CTX->get('k_page_title');
            $item_number = $CTX->get('k_page_id');
            $amount = $CTX->get('pp_price');
            $downloads = $CTX->get('pp_download'); //defunct?..will prevent paypal from asking the shipping address

            $return_url = ( $return_url ) ? $return_url : K_SITE_URL . $PAGE->link;
            $cancel_url = ( $cancel_url ) ? $cancel_url : $return_url;
            $processor = ( $processor ) ? $processor : $return_url;
            $sep = ( strpos($processor, '?')===false ) ? '?' : '&';
            $notify_url = $processor . $sep . 'paypal_ipn=1';

            // Paypal does not support zero cost transactions. Don't display buttom if amount not given.
            if( $amount ){
                if( K_PAYPAL_USE_SANDBOX ){
                    $paypal_url = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
                }
                else{
                    $paypal_url = 'https://www.paypal.com/cgi-bin/webscr';
                }

                if( !$image ) $image=0;
                if( $FUNCS->is_natural($image) ){
                    $arr_btns = array( 'x-click-but23.gif','x-click-but9.gif', 'x-click-but01.gif',
                                      'x-click-but3.gif', 'x-click-butcc.gif', 'x-click-but5.gif',
                                      'btn_buynow_SM.gif', 'btn_buynow_LG.gif', 'btn_buynowCC_LG.gif' );
                    $image_src = 'https://www.paypal.com/en_US/i/btn/'.$arr_btns[$image];
                }
                else{
                    $image_src = $image;
                }

                $html .= '<form action="'.$paypal_url.'" method="post">';
                $html .= '<input type="hidden" name="cmd" value="_xclick"/>';
                $html .= '<input type="hidden" name="business" value="'.K_PAYPAL_EMAIL.'"/>';
                $html .= '<input type="hidden" name="item_name" value="'.$item_name.'"/>';
                $html .= '<input type="hidden" name="item_number" value="'.$item_number.'"/>';
                $html .= '<input type="hidden" name="amount" value="'.$amount.'"/>';
                $html .= '<input type="hidden" name="undefined_quantity" value="1"/>';
                //if( strlen(trim($downloads)) ){
                if( !$show_shipping ){
                    //don't prompt customer for shipping address if product is downloadable
                    $html .= '<input type="hidden" name="no_shipping" value="1"/>';
                }
                $html .= '<input type="hidden" name="no_note" value="1"/>';
                $html .= '<input type="hidden" name="currency_code" value="'.K_PAYPAL_CURRENCY.'"/>';
                $html .= '<input type="hidden" name="rm" value="2"/>';
                $html .= '<input type="hidden" name="custom" value="'.$custom.'">';
                $html .= '<input type="hidden" name="return" value="'.$return_url.'"/>';
                $html .= '<input type="hidden" name="cancel_return" value="'.$cancel_url.'"/>';
                $html .= '<input type="hidden" value="'.$notify_url.'" name="notify_url"/>';
                $html .= '<input type="image" border="0" alt="Make payments with PayPal - it\'s fast, free and secure!"';
                $html .= ' name="submit" src="'.$image_src.'"/>';
                $html .= '<img width="1" height="1" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" alt=""/>';
                $html .= '</form>';

            }

            return $html;
        }

We'll start by adding the 'seller' parameter to the array of parameters. Change this:
Code: Select all
            extract( $FUNCS->get_named_vars(
                        array(
                              'image'=>'',
                              'processor'=>'',
                              'show_shipping'=>'0',
                              'return_url'=>'',
                              'cancel_url'=>'',
                              'custom'=>''
                              ),
                        $params)
                   );

to this:
Code: Select all
            extract( $FUNCS->get_named_vars(
                        array(
                              'image'=>'',
                              'processor'=>'',
                              'show_shipping'=>'0',
                              'return_url'=>'',
                              'cancel_url'=>'',
                              'seller'=>'',
                              'custom'=>''
                              ),
                        $params)
                   );

Next scroll down to where you find the place where the business email is being set:
Code: Select all
                $html .= '<input type="hidden" name="business" value="'.K_PAYPAL_EMAIL.'"/>';

Change it to:
Code: Select all
                if( $seller !='' ){
                    $html .= '<input type="hidden" name="business" value="'.$seller.'"/>';
                }
                else{
                $html .= '<input type="hidden" name="business" value="'.K_PAYPAL_EMAIL.'"/>';
                }

and it's done! The whole thing looks like this:
Code: Select all
        //////Will try and move the following to 'plugins', once the architecture is in place
        function paypal_button( $params, $node ){
            global $CTX, $FUNCS, $PAGE;
            if( count($node->children) ) {die("ERROR: Tag \"".$node->name."\" is a self closing tag");}

            extract( $FUNCS->get_named_vars(
                        array(
                              'image'=>'',
                              'processor'=>'',
                              'show_shipping'=>'0',
                              'return_url'=>'',
                              'cancel_url'=>'',
                              'seller'=>'',
                              'custom'=>''
                              ),
                        $params)
                   );
            $image = trim( $image );
            $processor = trim( $processor );
            $show_shipping = ( $show_shipping==1 ) ? 1 : 0;
            $return_url = trim( $return_url );
            $cancel_url = trim( $cancel_url );

            $item_name = $CTX->get('k_page_title');
            $item_number = $CTX->get('k_page_id');
            $amount = $CTX->get('pp_price');
            $downloads = $CTX->get('pp_download'); //defunct?..will prevent paypal from asking the shipping address

            $return_url = ( $return_url ) ? $return_url : K_SITE_URL . $PAGE->link;
            $cancel_url = ( $cancel_url ) ? $cancel_url : $return_url;
            $processor = ( $processor ) ? $processor : $return_url;
            $sep = ( strpos($processor, '?')===false ) ? '?' : '&';
            $notify_url = $processor . $sep . 'paypal_ipn=1';

            // Paypal does not support zero cost transactions. Don't display buttom if amount not given.
            if( $amount ){
                if( K_PAYPAL_USE_SANDBOX ){
                    $paypal_url = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
                }
                else{
                    $paypal_url = 'https://www.paypal.com/cgi-bin/webscr';
                }

                if( !$image ) $image=0;
                if( $FUNCS->is_natural($image) ){
                    $arr_btns = array( 'x-click-but23.gif','x-click-but9.gif', 'x-click-but01.gif',
                                      'x-click-but3.gif', 'x-click-butcc.gif', 'x-click-but5.gif',
                                      'btn_buynow_SM.gif', 'btn_buynow_LG.gif', 'btn_buynowCC_LG.gif' );
                    $image_src = 'https://www.paypal.com/en_US/i/btn/'.$arr_btns[$image];
                }
                else{
                    $image_src = $image;
                }

                $html .= '<form action="'.$paypal_url.'" method="post">';
                $html .= '<input type="hidden" name="cmd" value="_xclick"/>';
                if( $seller !='' ){
                    $html .= '<input type="hidden" name="business" value="'.$seller.'"/>';
                }
                else{
                $html .= '<input type="hidden" name="business" value="'.K_PAYPAL_EMAIL.'"/>';
                }
                $html .= '<input type="hidden" name="item_name" value="'.$item_name.'"/>';
                $html .= '<input type="hidden" name="item_number" value="'.$item_number.'"/>';
                $html .= '<input type="hidden" name="amount" value="'.$amount.'"/>';
                $html .= '<input type="hidden" name="undefined_quantity" value="1"/>';
                //if( strlen(trim($downloads)) ){
                if( !$show_shipping ){
                    //don't prompt customer for shipping address if product is downloadable
                    $html .= '<input type="hidden" name="no_shipping" value="1"/>';
                }
                $html .= '<input type="hidden" name="no_note" value="1"/>';
                $html .= '<input type="hidden" name="currency_code" value="'.K_PAYPAL_CURRENCY.'"/>';
                $html .= '<input type="hidden" name="rm" value="2"/>';
                $html .= '<input type="hidden" name="custom" value="'.$custom.'">';
                $html .= '<input type="hidden" name="return" value="'.$return_url.'"/>';
                $html .= '<input type="hidden" name="cancel_return" value="'.$cancel_url.'"/>';
                $html .= '<input type="hidden" value="'.$notify_url.'" name="notify_url"/>';
                $html .= '<input type="image" border="0" alt="Make payments with PayPal - it\'s fast, free and secure!"';
                $html .= ' name="submit" src="'.$image_src.'"/>';
                $html .= '<img width="1" height="1" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" alt=""/>';
                $html .= '</form>';

            }

            return $html;
        }

Let us know how it goes.

UPDATE:
A potential problem was discovered with changing the seller email in this way. The process_paypal tag will fail to validate properly because it expects the IPN to return the email from the config file. See viewtopic.php?p=22001#p22001 for a discussion and workaround.
Hi,
Thank you all

Thank you so much for all your help. I have now done and dusted this off the websites check list and finally have everything sorted. I did have a few issues Tim but seam to of resolved them.

Thanks again, i wounder if i can finally get the rest done too.

The only down full
The only issue i'm having is the paypal button. it's the styling side of things that id like to change. Rather than it being an image id like it to be a styling?
When it comes to styling the button, the most straightforward option would be to use your own custom image for the button. http://docs.couchcms.com/tags-reference ... utton.html

If you really, really want to use CSS instead, I would look at the generated html and just figure out how to apply CSS to it. Since you've now seen how the button html is generated, you could also muck around with it to adjust the output to better suit your needs.

Also, I noticed that I forgot something when modifying the code for the PayPal button. It will work without it but just in case, let's sanitize the seller parameter like all of the others so as to avoid potential problems.
Code: Select all
            extract( $FUNCS->get_named_vars(
                        array(
                              'image'=>'',
                              'processor'=>'',
                              'show_shipping'=>'0',
                              'return_url'=>'',
                              'cancel_url'=>'',
                              'seller'=>'',
                              'custom'=>''
                              ),
                        $params)
                   );
            $image = trim( $image );
            $processor = trim( $processor );
            $show_shipping = ( $show_shipping==1 ) ? 1 : 0;
            $return_url = trim( $return_url );
            $cancel_url = trim( $cancel_url );
            $seller = trim( $seller );
Hi Tim, i think i've solved the styling issue using whats within the source code.
Now my next question :lol: i want to add a shipping address, seams thats something that needs to be addressed really as it dont state on the invoice when a payment is made.

so,

Within the members clone page i have
shipping_address as a editable. Now i want to include that when paying with paypal. As only registered users can buy online. What would you suggest? I've looked at one of my recent payments to ebay via paypal and it has the send to section within the invoice. could i get that to work?


Here's my button work around code to support the CSS

Code: Select all
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
                        <input type="hidden" name="cmd" value="_xclick"/>
                        <input type="hidden" name="business" value="<cms:show pp_email />"/>
                        <input type="hidden" name="item_name" value="<cms:show k_page_title />"/>
                        <input type="hidden" name="item_number" value="<cms:show k_page_id />"/>
                        <input type="hidden" name="amount" value="<cms:number_format pp_price />"/>
                        <input type="hidden" name="undefined_quantity" value="1"/>
                        <input type="hidden" name="no_shipping" value="1"/>
                        <input type="hidden" name="no_note" value="1"/>
                        <input type="hidden" name="currency_code" value="GBP"/>
                        <input type="hidden" name="rm" value="2"/>
                        <input type="hidden" name="custom" value="">
                        <input type="hidden" name="return" value="http://www.torza.co.uk/selling/p_index.php?p=<cms:show k_page_id />"/>
                        <input type="hidden" name="cancel_return" value="http://www.torza.co.uk/selling/p_index.php?p=<cms:show k_page_id />"/>
                        <input type="hidden" value="http://www.torza.co.uk/selling/p_index.php?p=<cms:show k_page_id />&paypal_ipn=1" name="notify_url"/>
                                                <input type="submit" value="Buy Now" />
                        </form>
Typically, the buyer indicates their shipping address and all other details while on the PayPal site. These details, including the shipping address are returned by the IPN, and you access them with the paypal_processor tag.

From the docs (http://docs.couchcms.com/tags-reference ... utton.html):
show_shipping
If the product being sold is not downloadable and requires a shipping address, set this parameter to '1'. This will make PayPal prompt the buyer for a shipping address.

What's not clear to me is how as a developer you access the shipping address. The docs for the paypal_processor tag do not list the shipping address as one of the variables that are returned.

We're going to have to bring in @KK to answer this one.
Hi Tim,

I've now set show_address and this has worked. Its aloud me once on the payment side of things to either use the current address that's currently setup on paypal or select a new address. So think that will be fine for the use i need. :lol:
30 posts Page 3 of 3