uShop English (U.S.) for 179!

uStorekeeper English (U.S.) for 149!

 Products
       uTest
       uReserve
       uShop
       uStorekeeper
       uGolf
       uDirectory
       uSignIn
 Tech Support
       Support Policy
       Knowledge Base
            uTest
            uReserve
            uShop
            uStorekeeper
            uGolf
            uDirectory
            uSignIn
       Documentation
       Reference Sites
 Legal
       Software Piracy
       Legal Notices
       Privacy Policy
       Licensing
 Miscellaneous
       Reseller Info
       Contact Us
       Site Map
Proposed Paypal Solution

Knowledge Base Lobby : uShop Support Conference : Programmer Tips
Nov-18-17 09:04 AM EST
Original Message
Proposed Paypal Solution
Author Brian Levine on 04-01-2002 at 09:15 (EST)
I have a proposal for a Paypal solution. However, I need some information as to where to add the code and how to retrieve some needed data.
I am suggesting using the Custom Payment option for Paypal. A button would be added to the header of the payment receipts page, with a prompt for the buyer to click to complete the transaction.

The following code will generate the button that will link to Paypal, sending the store's paypal id, purchase total, and order number:

(note: brackets removed so that HTML displays)
form action="https://www.paypal.com/cgi-bin/webscr" method="post"
input type="hidden" name="cmd" value="_xclick"
input type="hidden" name="business" value="paypal@animecollectibles.com"
input type="hidden" name="item_name" value="Anime Collectibles Order Total"
input type="hidden" name="item_number" value="01234567"
input type="hidden" name="amount" value="39.95"
input type="image" src="http://images.paypal.com/images/x-click-but01.gif" border="0" name="submit" alt="Click to Pay using Paypal"
/form

In order to work correctly, the values for item_number (order number) and amount (order total) would have to be generated and passed as values. I am assuming that all of this would take place in the ushop_lib.pl script.

What I need to know is where the receipts page gets generated and the data elements that hold these two values. The rest would be fairly straightforward to implement.
E-MAIL AUTHOR | TABLE OF CONTENTS

Table Of Contents
  Proposed Paypal Solution - more Brian Levine, 2002-04-01 11:05:32 (1)
            Proposed Paypal Solution - Even More Brian Levine, 2002-04-03 08:10:30 (2)
                 Further Comment Brian Levine, 2002-04-03 11:20:14 (3)
            RE: Proposed Paypal Solution - more Bill Weiner, 2002-04-04 00:11:01 (5)
  RE: Proposed Paypal Solution Bill Weiner, 2002-04-03 23:59:42 (4)
            Paypal Solution - Somethings Wrong Brian Levine, 2002-04-04 09:26:56 (6)
                 RE: Paypal Solution - Somethings Wrong Bill Weiner, 2002-04-05 06:24:47 (7)
                 Paypal Solution - Still Not Working Brian Levine, 2002-04-05 09:45:03 (8)
                      RE: Paypal Solution - Still Not Working Bill Weiner, 2002-04-06 12:57:53 (9)
                           RE: Paypal Solution - Still Not Working Bill Weiner, 2002-04-06 12:59:16 (10)

Messages In This Discussion
         1. Proposed Paypal Solution - more
        Author Brian Levine on 04-01-2002 at 11:05 (EST)
Okay, I have tried replacing the code in ushop.pl as follows:

(brackets removed for display purposes only)
# Replace the USHOP INSTRUCTIONS.
$order_form_html =~ s/USHOP INSTRUCTIONS/
$order_instructions/g;

replaced by:

(brackets removed for display purposes only)
# Replace the USHOP INSTRUCTIONS.
#$order_form_html =~ s/USHOP INSTRUCTIONS/$order_instructions/g;
if (($payment_method eq "custom_payment") && ($settings[52] =~ /yes/i))
{
$order_instructions = "form action="https://www.paypal.com/cgi-bin/webscr" method="post"";
$order_instructions .= "input type="hidden" name="cmd" value="_xclick"";
$order_instructions .= "input type="hidden" name="business" value="paypal@mystore.com"";
$order_instructions .= "input type="hidden" name="item_name" value="My Store Order Total"";
$order_instructions .= "input type="hidden" name="item_number" value="$order_number"";
$order_instructions .= "input type="hidden" name="amount" value="$totals_total"";
$order_instructions .= "input type="image" src="http://images.paypal.com/images/x-click-but01.gif" border="0" name="submit" alt="Click to Pay using Paypal"";
$order_instructions .= "/form";
}
$order_form_html =~ s/USHOP INSTRUCTIONS/$order_instructions/g;

Everything looks okay (and the HTML minus the variables works from a test page). However, when I run this and then click the Paypal button from the receipts page, it prompts for the uShop password, rather than links to Paypal.

Any clues as to what I am doing wrong?
TABLE OF CONTENTS
                 2. Proposed Paypal Solution - Even More
                Author Brian Levine on 04-03-2002 at 08:10 (EST)
Just to clarify, everything looks correct in my code changes to ushop.pl, and works from a test program, but when implemented from my site, instead of launching a link to Paypal, it brings up the uShop Enter Password screen.

Anxiously awaiting your reply.
TABLE OF CONTENTS
                         3. Further Comment
                        Author Brian Levine on 04-03-2002 at 11:20 (EST)
By the way, I already changed the tags to uppercase, to no avail.
TABLE OF CONTENTS
                 5. RE: Proposed Paypal Solution - more
                Author Bill Weiner on 04-04-2002 at 00:11 (EST)
So you're trying to add the PayPal HTML to the final "Thank You" page that gets generated by the "complete_order" subroutine? If you want to use the "Custom Payment" option, then you might want to consider putting it in the "get_custom_payment_button_html" subroutine instead.

Anyway, the uShop Login (a.k.a. "Password") page will be displayed whenever data is posted to the ushop.pl script with the "command" field set to a command the ushop.pl script does not recognize. So it sounds like your PayPal HTML is actually being posted to the URL of your ushop.pl script... or perhaps PayPal is redirecting back to your ushop.pl script... with a "command" that is not recognized by uShop.

Take a look at first big "if"..."elsif" statement at the top of the ushop.pl script and see how if the "command" field is not recognized... it last "else" will display the uShop Login screen.

That should help you understand why the uShop Login screen is being displayed.
TABLE OF CONTENTS
         4. RE: Proposed Paypal Solution
        Author Bill Weiner on 04-03-2002 at 23:59 (EST)
In the "get_custom_payment_button_html" subroutine of the ushop.pl script, the order number can be accessed via the $order_number variable and the order total can be accesses via the $totals_total variable.

FYI. The "get_custom_payment_button_html" subroutine is called from the "get_review_page_buttons" subroutine in the ushop-lib.pl script.

Also FYI. The final order processing steps (including the generation of the final receipt page) are initiated from the "complete_order" subroutine in the ushop.pl script. That method may need to be modified to handle any Approved/Declined response that you receive back from the external payment processing system.
TABLE OF CONTENTS
                 6. Paypal Solution - Somethings Wrong
                Author Brian Levine on 04-04-2002 at 09:26 (EST)
The problem with modifying the get_custom_payment_button method is that while it successfully launches the Paypal payment page, the uShop order never gets completed as the action points to the paypal site rather than posting back to the ushop.pl script.

Here is the funny part about putting the paypal button in the receipts instructions. Here is the code for the button (minus brackets for display only):

$order_instructions = "form action="https://www.paypal.com/cgi-bin/webscr" method="post"";
$order_instructions .= "input type="hidden" name="cmd" value="_xclick"";
$order_instructions .= "input type="hidden" name="business" value="paypal@mystore.com"";
$order_instructions .= "input type="hidden" name="item_name" value="My Store Order Total"";
$order_instructions .= "input type="hidden" name="item_number" value="$order_number"";
$order_instructions .= "input type="hidden" name="amount" value="$totals_total"";
$order_instructions .= "input type="image" src="http://images.paypal.com/images/x-click-but01.gif" border="0" name="submit" alt="Click to Pay using Paypal"";
$order_instructions .= "/form";

Note that the action clearly points to the paypal.com site. But when clicked on, here is the line that gets generated:

http://www.mystore.com/cgi-bin/ushop/ushop.pl?cmd=_xclick&business=paypal@mystore.com&item_name=My+Store+Order+Total&item_number=04042002-002438667&amount=40.424&submit.x=36&submit.y=16

Somehow, it points back to the ushop.pl script. How is this even possible?

One more point...Paypal requires that the payment be formatted to 2 decimal places, but the $totals_total field is formatted to 3 decimal places. Is this correct?
TABLE OF CONTENTS
                         7. RE: Paypal Solution - Somethings Wrong
                        Author Bill Weiner on 04-05-2002 at 06:24 (EST)
So in which subroutine are you actually making your changes? If it is the "complete_order" subroutine, then any HTML that you are setting those $order_instructions to should be output as is. If you are modifying some other subroutine, you should make sure that your FORM is not within another FORM that uShop is already outputting. For instance the first Order Form page that uShop outputs starts it's FORM near the very top... so you wouldn't want your FORM to be contained within uShop's FORM. I would suggest that you just view the source of the HTML page that has your PAYPAL button on it and see where the problem is.

In regard to formatting the total to 2 decimal places, here's a way to do that:

$totals_total = &strip_letters($totals_total);
$formatted_total = sprintf("%.2f",$totals_total);

And then use $formatted_total.
TABLE OF CONTENTS
                         8. Paypal Solution - Still Not Working
                        Author Brian Levine on 04-05-2002 at 09:45 (EST)
I am indeed adding my HTML to the order instructions section of complete_order. When I save the page source (before hitting the button), it does indeed display the correct URL for the paypal site in the form action. However, when I click on the button, it somehow goes back to processing ushop.pl (sigh...)

Their is a tag that exists around the entire page for the receipts page, but there is no action associated with it.

I've run out of ideas.
TABLE OF CONTENTS
                                 9. RE: Paypal Solution - Still Not Working
                                Author Bill Weiner on 04-06-2002 at 12:57 (EST)
If the FORM at the top of your "order_template.html" page is throwing off your subFORM, then you may be able to create a different "order_template.html" page for use just as the final "Thank you" page. In this special template page, perhaps called "brians_order_template.html", you could try litterally specifying your PAYPAL URL in the FORM part of the template. Then DON'T put the FORM part in the $order_instructions. Perhaps that would resolved the problem for you.

NOTE: You can specify to use your "brians_order_template.html" template for the "Thank You Page" via the uShop Control Panel... under GENERAL SETTINGS - ORDER FORM SETTINGS - Order Form Template 3.
TABLE OF CONTENTS
                                         10. RE: Paypal Solution - Still Not Working
                                        Author Bill Weiner on 04-06-2002 at 12:59 (EST)
Or as perhaps an easier option, you may be able to just edit your regular "order_template.html" page and move the FORM tag down below where the instructions (USHOP INSTRUCTIONS) get inserted.
TABLE OF CONTENTS

© 2003 Microburst Technologies, Inc.