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&...
Related
PayPal is ignoring my return variable on PayPal Subscribe Button, even though "Auto return" option is enabled.
At first, I did not have the "Auto return" option enabled, and PayPal just showed a receipt page after the user subscribed, with no link back to our site, despite passing the return variable with our receipt page.
Then we enabled the "Auto return" option and was forced to enter some URL, so we created a generic page for PayPal to hit to verify the page exists, which I understand is required to enable the feature.
However, now users are able to subscribe and they see that awesome "If you are not redirected... in 10 seconds... click here" message, which takes the user to the static return page we setup in the "Auto return" settings, not the dynamic URL we passed to PayPal using the return variable.
Here's what our button code looks like:
<form action="https://www.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="MYHOSTEDBUTTONID">
<input type="hidden" name="custom" value="MyCustomData">
<input type="hidden" name="return" value="https://www.example.com/secure/page/receipt?specialId=1234">
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_subscribeCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
Did PayPal break this feature or am I doing something wrong?
For hosted buttons, the return doesn't belong there, it should be in the Advanced Variables section of step 3 of creating the button.
These HTML buttons are deprecated, they are from ~18 years ago and some new PayPal accounts can no longer create them (my understanding is all will not be able to create them soon enough.) The recommended integration method is a "Smart Subscribe" button, which uses JS and a client ID to identify the receiver account. To be notified of completed payments with a smart subscribe button, create a listener URL on your server for the webhook event PAYMENT.SALE.COMPLETED (that is the only subscription webhook event that is truly useful, all others are of limited utility). As for redirecting a Smart payer, if you need to do that you can add a window.location.href redirect from the onApprove function. Modern websites don't redirect unless they absolutely need to, consider using this function to display whatever message in the DOM w/o a redirect. But don't depend on sending data to a server from the client onApprove, as for whatever reason the client may never notify the server. The PAYMENT.SALE.COMPLETED webhook is the only reliable way to get notifications. For reconciliation, there is a similar custom_id variable available alongside the plan_id when creating the subscription in the createSubscription function.
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/
It works fine for me using chrome, and a buddy using FF says it works as well. Doesn't work on IE at all. All I did was copy / paste the button code from paypal and put it into my footer. Page I'm getting says: Error Detected; Some required information is missing or incomplete. Please correct your entries and try again. Help?
<div style="
width: 145px;
margin: 0 auto;
"><form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="encrypted" value="-----BEGIN PKCS7-----MIIHNwYJKoZIhvcNAQcEoIIHKDCCByQCAQExggEwMIIBLAIBADCBlDCBjjELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtQYXlQYWwgSW5jLjETMBEGA1UECxQKbGl2ZV9jZXJ0czERMA8GA1UEAxQIbGl2ZV9hcGkxHDAaBgkqhkiG9w0BCQEWDXJlQHBheXBhbC5jb20CAQAwDQYJKoZIhvcNAQEBBQAEgYAG9sQZQh2AAgcLjbZ70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6OoXPWeNq70/XBi133jAq+q0kkRzw4EM-----END PKCS7-----
">
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!" style="
padding-top:30px;
padding-left:30px;
">
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
</div>
Looks like this is related to PayPal button code protection.
By default PayPal button code has a hidden field named encrypted that contains all information about payment in encrypted form.
When Remove code protection link (located above textarea with button code in PayPal button generation page) is clicked different code, containing many fields in plain-text form is displayed.
I have faced situation where protected (encrypted) code had this issue, but unprotected code worked without any issues. NB Using unprotected code may result in decreased security - by modifying unprotected button code users can make payments with changed currency, purpose or reference ID. Besides spambots can easily pick up e-mail from unprotected button code if email address is used instead of secure merchant ID. Also it is recommended to ask PayPal support for other possible issues that may arise from using unprotected code.
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.
I have a form on my website. When this form is submitted ( to the same page ) , a file is uploaded and all the details in the form are entered into a database. Next thing is we need to redirect to paypal for payment. Whats the best way to design this?
My form has the following fields:
name, email, password, attached file
PayPal Submission form is like this
<form id="frm_paypal" 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="JDEC8Q72KAYRN">
<input type="submit" src="https://www.paypalobjects.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.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
Note:
I am not being able to redirect to paypal with post data using header('paypalurl')
Ya you cant redirect using header() because you've already sent headers to the page.
So basically, what you can do is gather all the data you need to save in the DB and when they click 'Sign Up' send them to a 'Confirmation Page' that says "Please confirm what you entered, press Pay Now when ready". So it adds an additional click, but its a familiar flow for most checkout processes, so it shouldnt be inconvenient really.
i know this question is old, but maybe it helps someone who comes across this like myself...
alternatively, you do not output any form fields but do a header redirect like so
header('location: https://www.paypal.com/cgi-bin/webscr?'.http_build_query($varsToSendtoPaypal).'');
i know in the paypal documntation it is supposed to be a post request, but I have - as yet anyway - not have had any problems doing it this way (and it saves that additional click)
just a suggestion though