I have paypal "add to cart" buttons set-up throughout my site and a "view cart" button at the top of every page.
The code for the view cart button is:
<form target='paypal' action='https://www.paypal.com/cgi-bin/webscr' method='post'>
<input type='hidden' class='displaynone' name='cmd' value='_cart' />
<input type='hidden' class='displaynone' name='business' value='XXXXXXX123' />
<input type='hidden' class='displaynone' name='display' value='1' />
<input type='submit' class='paypalcart' value='View Cart' />
</form>
Currently, clicking "view cart" opens up a new browser tab and displays the items added on a paypal website.
Instead, I'd like clicking the "view cart" button to take the user to my page www.example.com/cart and then have the contents of the paypal cart displayed on that page in a <div> or <iframe> (or something else).
Any suggestions?
Thanks very much.
You need to build a custom cart into your website instead of using the PayPal cart. There are a number of ways to do this. Are you using WordPress, by chance? If so, I'd recommend installing WooCommerce, and then the PayPal for WooCommerce plugin.
If you're using some other type of framework you may be able to find a nice shopping cart solution for it. Otherwise, you'd just have to build it yourself.
Then you can either use the cart upload method to send cart details to PayPal for checkout, or you could go with the Express Checkout (which I would recommend) if you're familiar with web service API's.
You can use Minicart Js. Source which really dont suit your requirement, but it does'nt redirect to paypal site when you click "Add to Cart" instead opens lightbox inside your own website eventually when you click "Checkout" it takes you to paypal checkout page.
Sample Demo
Related
I am trying to make a program that can scrape a site and search for PayPal buy now button redirection links.
I can scrape the site but I realize that when you hit the button, it does not contain the URL that you will be redirected to make purchase. How would I go about finding the button redirection link, or even how would I have the site scrape and click on the button to at least have the redirect site appear? Would I somehow have to make the scraper hit the form and submit?
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top"><input name="cmd" type="hidden" value="_s-xclick" /><br />
<input name="hosted_button_id" type="hidden" value="PUEGWVJXLH4FQ" /><br />
<input alt="PayPal - The safer, easier way to pay online!" name="submit" src="https://www.paypalobjects.com/en_US/i/btn/btn_buynowCC_LG.gif" type="image" /><br />
<img loading="lazy" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" alt="" width="1" height="1" border="0" /></form>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">_______________________________________________________</p>
</form>
Go to https://www.paypal.co/buttons, log in, and (after logging in) create a new simple Buy Now button with no dropdown options nor text fields (which require HTML) -- and once the button is created and you are viewing the generated code, switch over to the "E-mail" tab above it.
The link in that E-mail tab will have a hosted button ID, which you can swap out / use to dynamically generate the Buy Now "redirection link" you're asking for. When loaded in a browser, that link will initiate a checkout, same as clicking the button.
There are several other types of PayPal payment buttons, including:
Unhosted Buy Now buttons (which are not saved at PayPal, and do not have a hosted_button_id). These buttons use a redirection link or form post that will include HTML variables to set up the payment.
Newer smart buttons, generated via https://www.paypal.com/buttons/smart or similar -- these do not have redirection URL, and instead use JS to open a mini window for payment approval.
Another way to construct a working URL is to begin with the form's action parameter https://www.paypal.com/cgi-bin/webscr, add ? to begin a GET string, and add all the inputs from the form that have a name, in with the syntax name=value, separated by '&' .... so for example:
https://www.paypal.com/cgi-bin/webscr?hosted_button_id=PUEGWVJXLH4FQ&anothername=anothervalue&...
I want to create a form for paypal payment. like this form.
what i want is to make a simple paypal button. after clicking on that button this form will appear. but the problem is when ever I create get payment button , from my paypal account I end up with this kind of form.
how to get that form in paypal? thanks in advance.
in addition i got a project code. this code is a paypal button link up with a form like my first image.
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="ZEFZFYBY2SZB8">
<input type="image" src="https://www.paypal.com/en_US/i/btn/btn_paynowCC_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_US/i/scr/pixel.gif" width="1" height="1">
</form>
when i make a button from my paypal account. after click that button i end up with the form like my second image. how do i create the form like first image.
Please Describe what kind of Script or CMS you are using is it PHP or HTML or .... ?
for Creating a button Login to your Paypal Account on Seller preferences and make the botton or find information Here
if you are using Wordpress and Woocommerce you can install plugins Here
if you are using PHP Scripts you can find Code Integration Here
UPDATE
Regarding your Type of Form you wanted you can download either one of the plugins written by Scott Paterson Below
https://en-gb.wordpress.org/plugins/contact-form-7-paypal-add-on/
https://en-gb.wordpress.org/plugins/easy-paypal-donation/
The First Plugin is the Form that you referred on your comments below
just leave the price and form empty
See following link which guides you to get started with using Paypal Payment Gateway :
https://phppot.com/php/paypal-payment-gateway-integration-in-php/
I want to add a buy now button to my website. I already have a cart system and I need to send all the items to checkout with Paypal buy now button.
A few years back I remember using the buy button with a form and I could set multiple items by specifying multiple hidden inputs like:
<input type="hidden" name="item_name_1" value="item name 1">
<input type="hidden" name="item_name_2" value="item name 2">
...
<input type="hidden" name="item_name_n" value="item name n">
Now with the new buy button JS API I can't seem to do that anymore.
Am I missing something here? How can I add a buy button for multiple items?
You can still use an HTML form to create the buttons and use the Upload command.
The JavaScript buttons aren't currently available to work with the Upload command unless you modify the associated JavaScript file. The Mini-Cart does kind of use the Upload feature. If you want to take a look at that it may offer you the functionality you're after. There should be a link to it from the "PayPal payment buttons" page.
I've set up my PayPal button and I can make payments with it, so it does work.
I've set up redirecting and supplied the URLs to which I want PayPal to redirect (whether in case of cancelled or completed payments):
I realize that in the screenshot here, there's a / missing on the checkout path, but that's only because I "censored" the links after testing.
Is there anything more I need to do in order to make this redirect? All it's doing currently is spewing out the Thank You screen, which is great, but it's not what I need.
Can anyone suggest why it's not redirecting?
does your button (or rather form) have a return variable??
https://developer.paypal.com/webapps/developer/docs/classic/paypal-payments-standard/integration-guide/Appx_websitestandard_htmlvariables/
return -Optional - The URL to which PayPal redirects buyers' browser
after they complete their payments. For example, specify a URL on your
site that displays a "Thank you for your payment" page. Default –
PayPal redirects the browser to a PayPal webpage.
edit: try this
<input type="hidden" name="return" value="http://www.mysite.com/thanks.html"/>
Paypal - redirect after payment to my own page
on the checkout page, look for the 'cancel_return' hidden form element:
<input type="hidden" name="cancel_return" id="cancel_return" value="" />
set the value of the cancel_return form element to the URL you wish to return to:
<input type="hidden" name="cancel_return" id="cancel_return" value="http://royaltytech.in" />
I'm new to paypal development and am trying to create a BuyNow button in the sandbox to enable me to test my application in a non production environment. If I create a button from my normal account it directs me to the live paypal site but if I try to create a button in the sandbox, the button creation page is always on the live box and I can't find anyway of creating a button in the sandbox using sandox test accounts, that then allows me to make test payments in the sandbox. Please help.
The link in the sandbox is broken and redirects you to the live site. When this happens, sometimes you can just add sandbox into the URL to correct the issue. So if you click the button and it takes you to https://www.paypal.com/button/blah_blah, you would just need to change it to https://www.sandbox.paypal.com/button/blah_blah. Another option would be to create a non hosted clear text button from your live paypal account and then just modify the URL to point to the sandbox instead of the live site. So instewad of the following:
<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
You woudl just change it to
<form target="paypal" action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
And then you would update the business variable to reflect the email address of your test sandbox seller account.
The last option for creating a button, would be not to log into your account but use the BMCreateButtom API call. Keep in mind this could be a little bit more work then you may want to do if you are only familar with HTML.
I faced the same problem..
when i click the "create payment buttons for your website" it redirects to this link www.paypal.com/us/webapps/mpp/standard-integration which is live paypal site. your test account does not exist there so you can not do the rest with the sandbox test account..
i solved it the follwing way..
after redirect to above link... you can edit the link.
put "sandbox." in the link. The edited link will be
www.sandbox.paypal.com/us/webapps/mpp/standard-integration
now you can create your customize button.. the generated HTML will be something like this
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="5GW6UJKLK47R6">
<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>
I can't comment because my reputation isn't high enough, but I thought it was important to add this element to Sadid Khan's correct answer. When trying to change the address to the sandbox you need to add the 'www' in front of the subdomain.
sandbox.paypal.com will redirect to the frontpage/homepage for the sandbox.
www.sandbox.paypal.com will properly run the purchase emulation
You can set data-env="sandbox" to create a button which will redirect you to sandbox website.
<script type="text/javascript" charset="utf-8"
src="/assets/paypal-button.min.js?merchant={merchant-email}"
data-button="buynow"
data-name="My product"
data-amount="1.00"
data-env="sandbox"
></script>
In your sandbox account:
Click the Gear icon (Profile) on top right.
Then choose 'Business Setup',
Then 'On your website'
Then Option B to add a payment payment button.
You can choose between 'Buy Now' and 'Pay Now' in the advanced setting of the button.