Embedded payments and 'This function is temporarily unavailable' error - paypal

I am trying to implement Embedded chained payments.
I have downloaded PHP PayPal SDK and it works fine without embedded option. The problem comes when I try to do it embedded:
I get my payKey with sdk. It returns something like:
Pay - Response
responseEnvelope.timestamp: 2012-09-30T16:30:09.512-07:00
responseEnvelope.ack: Success
responseEnvelope.correlationId: 297f1e4a38b63
responseEnvelope.build: 3779320
payKey: AP-9EB01133M3012281Y
paymentExecStatus: CREATED
* Redirect URL to Complete Payment
(href of the link: https://www.sandbox.paypal.com/webscr&cmd=_ap-payment&paykey=AP-9EB01133M3012281Y)
Then, I copy the paykey (AP-9EB01133M3012281Y) and I paste on this html code:
<script type="text/javascript" src="https://www.paypalobjects.com/js/external/dg.js"></script>
<form action= "https://www.sandbox.paypal.com/webapps/adaptivepayment/flow/pay" target="PPDGFrame">
<input id="type" type="hidden" name="expType" value="light"></input>
<input id="paykey" type="hidden" name="paykey" value="AP-3GH99339RW1696440"> </input>
<button id="submitBtn" value="Pay with PayPal"><p style="font-size:20px">Pay</button>
</form>
<script>var dgFlow = new PAYPAL.apps.DGFlow({ trigger: 'submitBtn' });</script>
When I click the button, the iframe is shown right, but an error appears: "Transaction Cancelled. This function is temporarily unavailable".
If I click the cancel button, I am redirect correctly to my sdk page (the same if I wouldn't have do it embedded)
I am using sandbox.

Not setting the senderEmail when you create the PayRequest message should resolve the issue. It seems the PayPal embedded flow requires the buyer/sender to insert his/her email manually on PayPal.

Related

Finding PayPal Buy Now Button redirection link

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&...

Why Am I Getting Paypal generic error page in production but not in sandbox

Have been successfully using PayPal Cart buttons in PayPal Express for 2 years. Suddenly, when I click any "Cart button on my Store page, I get the dreaded ""Things don't appear to be working at the moment. Please try again later."
I tried the exact same transaction in the PayPal Sandbox and it processed fine. Now, however, that transaction draws the generic error page in "Live PayPal"
The only differences in the are in the action url, the business email, and the return url and store url:
Sandbox version of action attrbute:
<form id="form107" onsubmit="return CheckForm(this);"
action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" target="_self">`
Live Version of action attribute:
<form id="form107" onsubmit="return CheckForm(this);"
action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_self">
(the javascript "CheckForm" function just checks data on the page to determine whether to show or hide a size dropdown)
The Sandbox integration URLs:
<input name="return" type="hidden" value="http://localhost:52980/Open/Congratulations/107/store">
<input name="shopping_url" type="hidden" value="http://localhost:52980/Store">
The "Live" integration URLS:
<input name="return" type="hidden" value="http://www.(mydomain).org/Open/Congratulations/107/store">
<input name="shopping_url" type="hidden" value="http://www.(mydomain).org/Store">
The code has worked up through 16 April 2018. No changes were made. As of 18 April 2018, we are now getting the PayPal generic error page upon clicking the Cart button

Paypal sandbox: this transaction is invalid

I am trying to integrate paypal express checkout(test) with no luck. Not sure what i am doing wrong. I have followed the documentation but i get "This transaction is invalid. Please return to the recipient's website to complete your transaction using their regular checkout flow." when i try to redirect to the browser to the sandbox login page.
<form method=post action=https://api-3t.sandbox.paypal.com/nvp>
<input type=hidden name=USER value=j***-1_api1.g*******s.com.au>
<input type=hidden name=PWD value=Q8P*******U6>
<input type=hidden name=SIGNATURE value=AFc************fH>
<input type=hidden name=VERSION value=124.0>
<input type=hidden name=PAYMENTREQUEST_0_PAYMENTACTION
value=Sale>
<input name=PAYMENTREQUEST_0_AMT value=19.95>
<input type=hidden name=RETURNURL
value=http://localhost/moes/paypal_complete.php>
<input type=hidden name=CANCELURL
value=http://localhost/moes/paypal_complete.php>
<input type=submit name=METHOD id="submit_paypal" value=SetExpressCheckout>
</form>
have also tried this on my site live in case localhost is causing the troubles, but still the same.
The ACK response i get back is success:
TOKEN=EC-83V63085L7957480A
TIMESTAMP=20150901T14:14:08Z
CORRELATIONID=ffb632c840981
ACK=Success
VERSION=124.0
BUILD=000000
But when i use the redirectURL in the documentation with the token i get the invalid transcation error.
https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&TOKEN=EC-83V63085L7957480A
I am logged into developer.paypal.com when i try it, still every time is an invalid transaction.
the URL of the invalid transaction:
//http://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_flow&SESSION=xa6gvld5X3qDZhYbt7pnz6rWMCzBdIFvAREoxohX4E5zH_3ydrzEQBnpQFW&dispatch=50a222a57771920b6a3d7b606239e4d529b525e0b7e69bf0224adecfb0124e9b61f737ba21b0819803370655d2811b9456e01fe893c80ec2
ideas?
You can get sample Express Checkout Code from the PayPal Wizard:
PayPal Express Checkout Code Wizard
<form action='expresscheckout.php' METHOD='POST'>
<input type='image' name='submit' src='https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif' border='0' align='top' alt='Check out with PayPal'/>
</form>
You will need to download the expresscheckout.php and the paypalfunctions.php files from the PayPal Code Wizard. Typically your PayPal API Signature goes in a separate php file. The paypalfunctions.php on the code wizard has the API credentials stored.
The below snippet is from the paypal.php file and it is the portion of the code for the sandbox endpoints.
if ($SandboxFlag == true)
{
$API_Endpoint = "https://api-3t.sandbox.paypal.com/nvp";
$PAYPAL_URL = "https://www.sandbox.paypal.com/webscr&cmd=_express-checkout&token=";
}
Also with Express Checkout you need to call Mark Express Checkout which is normally done in one of your PHP files.
You can get the complete php code from the code wizard.
Here is more documentation on Express Checkout from the PayPal Developer Site.
For anyone else reading this, i found that if i changed the redirectURL from:
https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&TOKEN=
to:
https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&useraction=commit&token=
It redirects to the paypal(sandbox) log-in page as intended without error.
Hope this helps

Redirect back to specific URL once payment is made

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" />

create buynow button for sandbox account

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.