encrypt paypal buy now button html form - php

I've a classic paypal buynow button form in html. I need to encrypt the form to hide the parameters like amount or seller email data...
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="+++++++++">
<input type="hidden" name="lc" value="IT">
<input type="hidden" name="on0" value="DESCRIPTION">
<input type="hidden" name="os0" value="PAYMENT OBJECT n.<?php echo $_SESSION["ordernumber"]; ?>">
<input type="hidden" name="item_name" value="PAYMENT ORDER n. <?php echo $_SESSION["ordernumber"]; ?>">
<input type="hidden" name="item_number" value="VSTCB">
<input type="hidden" name="button_subtype" value="services">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="no_shipping" value="2">
<input type="hidden" name="amount" value="<?php echo $topaypal; ?>">
<input type="hidden" name="rm" value="1">
<input type="hidden" name="return" value="www.++++++.com/ok.php">
<input type="hidden" name="currency_code" value="EUR">
<input type="hidden" name="bn" value="PP-BuyNowBF:btn_buynowCC_LG.gif:NonHosted">
<input type="image" src="https://www.paypalobjects.com/it_IT/IT/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal è il metodo rapido e sicuro per pagare e farsi pagare online.">
<img alt="" border="0" src="https://www.paypalobjects.com/it_IT/i/scr/pixel.gif" width="1" height="1">
</form>
I've my private key and public certificate generated with openssl, and I've also the cert_Id of paypal and the relative paypal_public_certificate, but I'm not able at all to encrypt my html form, I've only found this command line on paypal site:
"PPEncrypt CertFile PrivKeyFile PPCertFile InputFile OutputFile"
Ther reference page for these information is on the paypal site at the address:
https://developer.paypal.com/docs/classic/paypal-payments-standard/integration-guide/encryptedwebpayments/
but I don't know how to use it...
does anyone know how to encrypt the form using the command line provided by paypal, a kind of step by step guide if it's possible?
many regards helping me

The command line "PPEncrypt CertFile PrivKeyFile PPCertFile InputFile OutputFile" breaks down to the following components:
PPEncrypt - PayPal's encryption algorithm
CertFile - The pathname to your own public certificate
PKCS12File - The pathname to the PKCS12-format of your own public certificate
PPCertFile - The pathname to a copy of the PayPal public certificate
Password - The passphrase to the PKCS12-format of your own public certificate
InputFile - The pathname to file containing the non-encrypted Website Payments HTML Form variables
OutputFile - A file name for the encrypted output
[Sandbox] The optional word Sandbox that lets you test payment buttons in the PayPal Sandbox that you protected with Encrypted Website Payments
However, you may want to opt for a button hosted by PayPal, as hosting means that you won't have to re-generate the certificates each time the form parameters are updated.
Hope this helps! :)

Related

I am trying to get custom date to pass to PayPal

I am trying to get this line of product info here to pass into PayPal form using the custom varible <input type="hidden" name="custom" value="SansburyTech|Purchase of a ToolCart|Dewalt Roller|SKU:164604646|Cost:163.50"> but its not happening?
Is there something I am doing wrong or overlooking? Here on PayPalDocs it says specifically: The following are pass-through variables: custom or item_number or item_number_x or invoice
Here is my complete HTML Paypal form as an example;
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" style="margin:0;padding:0;" target="PayPal">
<input type="hidden" name="business" value="">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="item_name" value="Toolcart">
<input type="hidden" name="item_number" value="Dewalt Roller">
<input
type="hidden"
name="custom"
value="SansburyTech|Purchase of a ToolCart|Dewalt Roller|SKU:164604646|Cost:163.50">
<input type="hidden" name="amount" value="244.50">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="receiver_email" value="">
<input type="hidden" name="return" value="https://toolcart.info/pickup">
<input type="hidden" name="no_note" value="0">
<input type="image" src="/wp-content/themes/toolcart-theme/images/paypal.png" class="img-fluid" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
Will be incredibly grateful for any answers!
~ Thank-you!
Converting my comment to an answer (for that sweet sweet karma).
The OP was looking for the custom variable to appear in the PayPal-generated e-mail messages that get sent back to the merchant account-holder (or to the customer). This won't work because PayPal does not include the custom variable in any e-mail messages: it's only included in IPN messages.
Usually the best solution is to pass only a unique identifier and store the rest in own your database.
But if you must pass multiple values in the arbitrary custom field, the pipes in your example seem problematic. Use base64 encoding or a different delimiter--JSON format is a common choice here, then you can simply decode it into an array when receiving the IPN.

Paypal payment works on sandbox but not live paypal?

We are facing some issue with paypal business account, under sandbox everything is working fine, bellow is the form we are using for live:
<form method="post" action="https://www.paypal.com/cgi-bin/webscr" id="paypalForm">
<input type="hidden" value="_xclick" name="cmd">
<input type="hidden" value="email#email.com" name="business">
<input type="hidden" value="1" name="quantity">
<input type="hidden" value="website" name="item_name">
<input type="hidden" value="MDAW" name="item_number">
<input type="hidden" value="0.3" name="amount">
<input type="hidden" value="0" name="shipping">
<input type="hidden" value="http://www.website.com/ipn.php" name="notify_url">
<input type="hidden" value="USD" name="currency_code">
<input type="hidden" value="http://website.com/orderconfirm.php" name="return">
<input type="hidden" value="12" name="custom"> <a class="btn btn-primary" href="selectpixel.php"><i class="fa fa-angle-double-left"></i> Back</a>
<button id="btnOrderForm" class="btn btn-success" type="button">Make Payment via PayPal</button>
</form>
Bellow is the IPN URL where we are receiving custom values correctly while go through sandbox:
http://www.website.com/ipn.php
But we're not sure what is happening with live paypal, we are not able to go back to our site and not even receive custom variable on ipn.php file even after successful transaction.
IPN url is same as sandbox and other then that everything is same.
When the user clicks a 'pay now' button, that will redirect you on paypal and then from payal after payment it messed in case of live paypal transaction, the user can pay successfully but it is not returing back to website and IPN is not hit back to http://website.com/ipn.php url for updating information.
Firstly, your link (http://www.website.com/ipn.php) showing "HTTP 404 - File not found" when access. So, you are quested to modify this page to the available one. You can go to the link (https://github.com/paypal/ipn-code-samples) for PayPal's latest IPN sample code, and then update accordingly to your IPN script page.
Secondly, you can refer to the link (https://developer.paypal.com/docs/classic/button-manager/integration-guide/ButtonManagerHTMLVariables/?mark=html) for the HTML variable for PayPal button. The variable "return" is for the function to redirect your customers to a page after they finish the payment. The variable "notify_url" is designed for PayPal IPN which is for the function to notify the back end of your web server about the transaction information. You can go to the link below for the detais about PayPal IPN (https://developer.paypal.com/webapps/developer/docs/classic/ipn/integration-guide/IPNIntro/)
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="email#email.com">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="item_name" value="Test_Item">
<input type="hidden" name="item_number" value="MDAW">
<input type="hidden" name="amount" value="0.3">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="quantity" value="1">
<input type="hidden" name="return" value="http://website.com/orderconfirm.php">
<input type="hidden" name="notify_url" value="http://website.com/orderconfirm.php">
<input type="hidden" name="button_subtype" value="products">
<input type="hidden" name="cn" value="Add special instructions to the seller">
<input type="hidden" name="no_shipping" value="2">
<input type="hidden" name="weight_unit" value="lbs">
<input type="hidden" name="bn" value="PP-BuyNowBF:btn_buynowCC_LG.gif:NonHosted">
<input type="image" src="https://www.sandbox.paypal.com/en_US/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.sandbox.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>

Paypal ipn - Empty IPN and wrong date. Used to work

I have a website with a simple ticket shop built into it using IPN. It has been working for the past month and I left it alone. I was working on another payment site on the same webhost and for the first time i specified the "notification_url". I noticed that I couldn't get any response from PayPal on my new build and left it there. I then checked to see that my orginal system was still working at least; It was not.
For some reason when i check my IPN history the "latest delivery atempt" is "1984/12/14 04:53:12 CET (UTC+1)". The worst thing is that it also sais "Notification url: ". Empty.
This aparently returned 200 and success allthough my access logs show no traffic to my ipn-page. I have logs running and i havn't modified either code. I can access the IPN url manualt and it will get logged. No html login and no restrictions.
Heres my payment form:
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="8TPEJKFGZEJBS">
<input type="hidden" name="lc" value="sv_SE">
<input type="hidden" name="item_name" value="'.$text.'">
<input type="hidden" name="item_number" value="'.$order_id.'">
<input type="hidden" name="amount" value="'.$cost.'">
<input type="hidden" name="currency_code" value="SEK">
<input type="hidden" name="button_subtype" value="services">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="rm" value="2">
<input type="hidden" name="return" value="http://mywebsite.com/?page=13&done">
<input type="hidden" name="cancel_return" value="http://mywebsite.com/? page=13&cancel">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="bn" value="PP-BuyNowBF:btn_paynowCC_LG.gif:NonHosted">
<input type="image" style="border: none;" src="images/buy.png" border="0" name="submit" alt="PayPal - Det tryggare, enklare sättet att betala online!">
<img alt="" border="0" src="https://www.paypalobjects.com/sv_SE/i/scr/pixel.gif" width="1" height="1">
</form>
What is wrong and what should i try to fix it?
You just need to add a field "notify_url" in your form. This URL is your IPN file url.
<input type="hidden" name="notify_url" value="http://mywebsite.com/?page=13&done">
For more details:
https://cms.paypal.com/cms_content/GB/en_GB/files/developer/PP_WebsitePaymentsStandard_IntegrationGuide.pdf

redirect to a page after paypal payment success

Is it possible to redirect the user to certain page after the payment is successful.
I have this form, and when the user fills the details, I want to redirect the user to my page when the payment is successful. Is it possiblt?
This is a sample of paypal payment code.
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="accounts#freelanceswitch.com">
<input type="hidden" name="item_name" value="Donation">
<input type="hidden" name="item_number" value="1">
<input type="hidden" name="amount" value="9.00">
<input type="hidden" name="no_shipping" value="0">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="lc" value="AU">
<input type="hidden" name="bn" value="PP-BuyNowBF">
<input type="hidden" name="return" value="http://net.tutsplus.com/payment-complete/">
<input type="image" src="https://www.paypal.com/en_AU/i/btn/btn_buynow_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online.">
<img alt="" border="0" src="https://www.paypal.com/en_AU/i/scr/pixel.gif" width="1" height="1">
</form>
Here <input type="hidden" name="return" value="http://net.tutsplus.com/payment-complete/"> specifies the return url. For more info - Go Here
Consider also the Auto return option: it allows you to set up an url for all buttons.
Log in and click the Profile subtab under My Account.
Click the Website Payment Preferences link under Selling Preferences.
Click the On radio button to enable Auto Return.
Enter the Return URL
The Return URL will be applied universally to all Auto Return payments. This can be overridden by mentioning separate return URLs in the payment buttons that you’ve created in your PayPal profile
More info in this answer.

unable to get paypal post pramenters in the return url

I have one code for passing some custom variables to PayPal and these were collected in the return page, but when trying to get these values it is not working
I have a PayPal form like this :
<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="image" src="submit.png" name="submit" alt="Make payments with PayPal - it's fast, free and secure!"/>
<input type="hidden" name="add" value="1"/>
<input type="hidden" name="custom" value="IP"/>
<input type="hidden" name="cmd" value="_cart"/>
<input type="hidden" name="business" value=""/>
<input type="hidden" name="item_name" value=""/>
<input type="hidden" name="item_number" value=""/>
<input type="hidden" name="amount" value=""/>
<input type="hidden" name="page_style" value=""/>
<input type="hidden" name="no_shipping" value="1"/>
<input type="hidden" name="return" value="index.php?action=success"/>
<input type="hidden" name="notify_url" value="index.php?action=ipn"/>
<input type="hidden" name="cancel_return" value=""/>
<input type="hidden" name="rm" value="2"/>
<input type="hidden" name="cn" value="Additional Information"/>
<input type="hidden" name="currency_code" value="AUD"/>
<input type="hidden" name="bn" value="PP-ShopCartBF"/>
</form>
I am successfully returning to the URL after payment. and there I am just trying to print the POST Variable for now and It is not giving me any values.I have tried by both enabling and disabling 'auto return'. In both case I don't get values. Please help me, thanks in advance.
The "notify_url" will be contacted by paypal asynchronously (directly), without you having anything to do with this transaction. So you will never see in your browser any results whatsoever. You should use some kind of logging in your script to see what is actually being sent. Check your web server's access log to see if paypal is actually contacting your script (and make sure it's not "localhost" you're trying from)
If I remember correctly only the transaction id is sent back to the return_url. The notify_url receives that id also. From there you should be able to communicate both pages to fill your needs.

Categories