I am trying to integrate PayPal adaptive payment flow in my site. I am using following code in my angular application.
Now when I click on "Pay" button, mini browser window opens but it is blank, I am expecting to see PayPal login screen. Any clue for a possible issue?
<form action="https://www.sandbox.paypal.com/webapps/adaptivepayment/flow/pay" target="PPDGFrame">
<input id="type" type="hidden" name="expType" value="mini">
<input id="paykey" type="hidden" name="paykey" value="AP-XXXXXXXXXXX">
<input type="submit" id="PPsubmitBtn" value="Pay">
</form>
<script src="https://www.paypalobjects.com/js/external/apdg.js"></script>
<script>
var dgFlowMini = new PAYPAL.apps.DGFlowMini({trigger: 'PPsubmitBtn', callbackFunction: 'updateOrder'});
function updateOrder() {
//My order stuff update code goes here
}
</script>
Related
The 'Local development testing' section of PayPal's IPN Testing page implies that it is possible to test your IPN listener code via localhost, using a test page to simulate a message from PayPal.
My TestIPN.aspx page contains the following markup, which appears to follow the example provided by PayPal, but when I open it in Firefox under localhost (via Visual Studio 2019) and click the Submit Query button I get a 'File not found' error for https://localhost:44390/PayPal/IPNHandler.aspx.vb.
Needless to say, IPNHandler.aspx.vb does exist in my PayPal folder (using "PayPal/IPNHandler.aspx" in the form tag on my test page makes no difference). I also get the same error when I run it on my live site.
Any guidance on how to debug this problem would be much appreciated.
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Test IPN message</title>
</head>
<body>
<!--
<form target="_new" method="post" action="https://www.YourDomain.com/Path/YourIPNHandler.php">
-->
<form target="_new" method="post" action="PayPal/IPNHandler.aspx.vb">
<input type="hidden" name="receiver_email" value="admin%40mysite.co.uk"/>
<input type="hidden" name="business" value="admin%40mysite.co.uk"/>
<input type="hidden" name="first_name" value="Fred"/>
<input type="hidden" name="last_name" value="Bloggs"/>
<input type="hidden" name="payer_email" value="fred.bloggs%40gmail.com"/>
<input type="hidden" name="address_city" value="Southampton"/>
<input type="hidden" name="payment_type" value="instant"/>
<input type="hidden" name="payment_date" value="19:54:19 Apr 12, 2021 GMT"/>
<input type="hidden" name="payment_status" value="Completed"/>
<input type="hidden" name="mc_currency" value="GBP"/>
<input type="hidden" name="mc_gross" value="5.00"/>
<input type="hidden" name="custom" value="25"/>
<input type="submit"/>
</form>
</body>
</html>
I get a 'File not found' error for https://localhost:44390/PayPal/IPNHandler.aspx.vb
Is that the correct port? What happens if you put https://localhost:44390/PayPal/IPNHandler.aspx.vb in the URL bar? Use a URL that works to the handler on your localhost, which does not return a 404. Set the action accordingly.
Consider something like https://ngrok.com for testing as well.
Why are you integrating IPN anyway? It's 20 or so years old, and not required for current PayPal Checkout integrations you should be using instead...
Follow the Set up standard payments guide and make 2 routes on your server, one for 'Create Order' and one for 'Capture Order', documented here. Both routes should return only JSON data (no HTML or text). Inside the 2nd route, when the capture API is successful you should store its resulting payment details in your database (particularly purchase_units[0].payments.captures[0].id, which is the PayPal transaction ID) and perform any necessary business logic (such as sending confirmation emails or reserving product) immediately before forwarding your return JSON to the frontend caller.
Pair those 2 routes with the frontend approval flow: https://developer.paypal.com/demo/checkout/#/pattern/server
I have created a hosted PayPal button for monthly subscription and included its code on my website.
The subscription offers a free trial period of 1 week.
I would like to check if the user has already used their trial and is trying to subscribe again. And if so, how do I let PayPal know that it should not allow a trial period for that user?
The button's code looks 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="ABCDEFGHIJKLM">
<input type="hidden" name="on0" value="Your email">
<label for="plan-email">Your email</label>
<input id="plan-email" type="email" name="os0" placeholder="joanne.doe#gmail.com" required maxlength="200">
<button type="submit">Subscribe</button>
</form>
It would be even better, if you know a way to use Subscription Plan (created in https://www.paypal.com/billing/plans) as an HTML form similar to the one above (pure HTML form, without using PayPal JavaScript SDK) instead of a Button (created in https://www.paypal.com/buttons/). I need to pass an extra option (user's email) to PayPal as well as whether to allow a trial period or not.
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
I need to override the given default Auto return URL from the paypal button HTML code. I followed these steps:
Check the Auto return Url section and gave a default URL
Generate a Buy Now button and left the Return and Cancel URL options as it is.
Paste the button code
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="return" value="http://www.someURL.com"/>
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="G3WQ*******">
<input type="image" src="https://www.sandbox.paypal.com/en_GB/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_GB/i/scr/pixel.gif" width="1" height="1">
</form>
After successful payment on Sandbox PayPal is always redirecting me to the default URL.
Why isn't overriding it? Any help would be appreciable.
I saw a couple of similar unanswered question on PayPal community and StackOverflow as well:
https://www.paypal-community.com/t5/About-Payments-Archive/Auto-Return-Custom-URL-Not-Overriding-Auto-Return-Setting-URL/td-p/1038334
Paypal button auto-return url not overriding the default url
Setting PayPal return URL and making it auto return?
You won't be able to use the return field directly in the button when you're using a hosted button. That has to be set in the hosted button settings when creating the button (or editing it through the PayPal account.)
If you want to be able to set your own return URL on the fly then you'll have to use a non-hosted button.
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.