paypal buy it now button process flow - asp.net

Im adding paypal payments to my site via a buy it now button, which as i understand it posts a form to paypal then the user completes payment on paypal's site.
To process the order after payment is confirmed im using an IPN listener, but id like to do some processing on our server at the time of ordering too. Is it possible to have the buy it now button submit to our own server first so i can record the order, before redirecting to paypal for payment details?

You have two options here.
First option that is more simple but can fail if the user did not have javascript, is to make a post to your server with what data you like, with ajax, and only after the return you let the user continue the submit.
Second option is to post your data to your server on code behind, there you prepare a simple page with auto submit to paypal - actually you make a redirect with post. Here you can find source code and one example on how to make it:
http://www.codeproject.com/Articles/37539/Redirect-and-POST-in-ASP-NET

Actually, you have many options.
As you said, the buy now button is nothing more than a form post to PayPal. You can build your own form using any of their standard variables rather than be limited to these buttons. They call this the cart upload method.
With this method you can do whatever you need to do whatever local processing you need to do prior to ever sending the user over to PayPal. It's a good practice to create an order record of some kind in your own system which you can then include with your PayPal payment info. That same value will come back in IPN so you can process it post-payment as well.
Another option that would you open you up even more is to use the Express Checkout APIs. This gives you complete control of your checkout system and has more features than standard payments. I recommend this if you're familiar with web service APIs.
Of course, IPN works with Express Checkout, too, so you can still use that for whatever you want/need as well.

Related

Recurring and non-recurring items in single PayPal checkout flow

I'm currently migrating a website from WooCommerce to Shopware 6, which needs to support recurring payments for a membership subscription.
WooCommerce is still using PayPal Standard, which allows you to mix non-recurring line items with a recurring subscription, in a single checkout flow.
Shopware 6 uses the REST API, which doesn't appear to support this ability and the only solution appears to be using the Javascript SDK:
User clicks Pay with PayPal.
Subscription is created via actions.subscription.create
Dialog is displayed requesting approval.
Customer approves.
Submit original checkout.
Redirect to PayPal.
Complete payment.
Redirect back to website with confirmation.
A potential solution I'm looking into now is changing the return URL of the initial order creation to redirect to a billing agreement approval URL and have the return URL's of that redirect back to the original return url.
Overly complicated and the worse UX I've ever seen.
Before I tear what's left of my hair out, does anyone have any suggestions?
UPDATE
Although it isn't the solution I was hoping for, I ended up removing the Shopware 6 PayPal plugin and implementing my own payment method using the NVP API.
From the user perspective, there is only one approval process. In the backend, once the user has approved the transaction (that has been marked as needing a billing agreement) the transaction is verified and then a recurring profile is created.
There's no way to combine Subscriptions and one-time payments in a single checkout. Such items even require different parameters on the PayPal SDK line, if using the PayPal buttons to show an in-context experience.
The in-context experience is best, since it involves no redirects away from your site to PayPal and back. Here is the flow for one-time payments:
Make two routes on your server, one for 'Create Order' and one for 'Capture Order', documented here. These routes should return only JSON data (no HTML or text). The latter one should (on success) store the payment details in your database before it does the return (particularly purchase_units[0].payments.captures[0].id, the PayPal transaction ID)
Pair those two routes with the following approval flow: https://developer.paypal.com/demo/checkout/#/pattern/server
A similar (separate) flow can be used for PayPal Subscriptions. Only one subscription can be approved at a time.

Google Forms PayPal Express Integration

I am doing work for a non profit with 0 budget for IT. They need to allow users to enter information on a Google Form and then collect payment. I have done a lot of research on the topic and currently appears you can only add a hyperlink on the Google Forms to link to PayPal. However, I was wondering if there was some way to link the PayPal Express Checkout javascript(https://developer.paypal.com/docs/integration/direct/express-checkout/integration-jsv4/add-paypal-button/) into the Google Form so it calls back with a transaction id and status. Then I would be able to somehow insert those values into the Google Form. Any thoughts on how to integrate would be helpful. I am a developer but not familiar with Google Forms.
I recently wrestled with this exact question and ended up building a G Suite addon to make this easier for others. Coincidentally I also do volunteer IT for a small nonprofit and we wanted to use PayPal with our signup form (there's pricing for the addon but just ping me if you're a small nonprofit).
Here's what I learned while building it:
There's no way for Apps Script to modify the form once it's shown to the user, or to use Apps Script to respond to user input
There's no way to redirect the user automatically to PayPal after a form is submitted
That means if you want to send someone to PayPal, you've got to use an ordinary link. You can do this within the form by adding the URL to a question description, or you can add the URL to the text shown once someone has submitted the form. For PayPal, you've got two options for this kind of link:
PayPal buttons
Express checkout
PayPal buttons are a static link managed by PayPal. They don't require any coding - just go here and create a button. Then you need to get the raw text link for the button, which PayPal calls the "email" version. You can insert that into your form directly and tell users to access it. The one problem is there's no real way to get the transaction ID. You could try correlating the form submit time with the payment time, or the payer email with the form submit email. It's possible that neither of them will match up and you'll have to do it manually.
Express checkout requires you to dynamically create a new link for each payment by calling the PayPal API. That means your link needs to open a page that then generates an express checkout URL and redirects the user to it. You can do this using a web app in Google Apps Script using a doGet() trigger, or you can create your backend on your server in any language.
If you can run your own server somewhere, I recommend that (plenty of PaaS services have a free tier). It's much easier to test and debug things when you aren't using Apps Script. I used the PayPal Node SDK which works great despite being unmaintained. (Express checkout is "deprecated" by PayPal, but I'll bet it's not going away anytime soon). Their example will get you most of the way there. When the user arrives, generate a payment link and redirect them. When they finish they'll return to your server, and you can display whatever you want. For example, you can ask them to copy the transaction ID and paste it into your form.
Finally, when your form is submitted an onSubmit() trigger can be set up. There are actually two kinds of onSubmit() triggers for forms - one for the form itself, and a second for the spreadsheet linked to the form. You can register a trigger to do extra processing (e.g. look up the transaction ID), but you can't modify the response in the trigger. You can however modify the spreadsheet where the trigger gets sent, which for most cases is equivalent. For example, you could add a column to the spreadsheet with a link to the PayPal transaction based on the transaction code.

Paypal website payment standard not returning to return url from Sandbox test account

I am using Paypal Website Standard integration with Asp.Net and my problem is even after payment is successful, paypal is not returning me to my thank-you.aspx page. I have already set return-url in code as
sbForm.Append("<input type=\"hidden\" name=\"return\" value=\"" + successUrl + "\">");
means, I have created form mark-up using Code-Behind. Success url is absolute reachable (I can copy url and paste in browser, it works). I have my sand-box settings as below:
Profile -> Selling Tools
Under Selling Online -> Website Payment Preferences
Auto Return: On
Return URL: http://mywebsite/thank-you.aspx
Payment Data Transfer: Off
PayPal Account Optional:On
Contact Telephone:Off (PayPal recommends this option)
Support giropay and bank transfer payments:No
However it return to cancel page without fail if I cancel payment.
Edit
Taking reference if this, I set PayPal Account Optional:Off but no luck.
Edit
When I click the link after payment success message on Paypal's success page, I can go back and debug but it not returning any QueryString with the key name tx which results always Fail\n response.
With Payments Standard, enabling auto-return with a return URL should redirect, but it can sometimes take up to 10 seconds or so for the redirection to happen. That's why there is no guarantee users will make it to your thank you page even when it's all configured and working well.
If you need to ensure users end up at your site and there's no chance they wouldn't reach your thank you page then you'll want to use the Express Checkout API instead of Payments Standard.
The Express Checkout flow doesn't get completed until the user is back at your site (where you make the final API call) so you can rest assured you'll always end up on your thank you page.
Even still, if you're trying to automate procedures like updating your database, sending email notifications, etc. you'll want to use Instant Payment Notification (IPN).
IPN's are triggered instantly, so you can automate procedures in real-time. It also allows you to handle things like pending payments that have cleared (which you wouldn't want to deliver or ship right away), disputes, refunds, etc.
Turned Payment Data Transfer On and get it worked

If I turn on IPN can I still redirect my button users to my custom response pages?

I am currently using email2db to read the emails PayPal sends regarding new subscriptions, payments, cancellations, etc.
Now that I have 6 different fork, including 1 from intl.paypal.com and one from paypal.co.uk it has become difficult to manage my db with email2db.
This is a production system. I want to know if the existing system will remain intact if I turn on IPN for testing and development. I need it continue to redirect the subscriber to my currently chosen thankyou page as included in my button code.
Is it safe for me to activate IPN?
Thank you,
Gordon L
IPN is an entirely separate process from anything else you do. It's simply a notice you can have PayPal send when you get a payment or the status of one changes (i.e. chargeback etc). So it's safe to use with any payment process.

How do I fetch the Transaction ID from PayPal website to my web site?

I am using Paypal sandbox testing module in my Shopping cart site. I have test account in paypal sandbox. i am sending amount to paypal. After payment success when retun back to my web page I want to get transaction id and amount.Kindly help me.
You probably want to use Paypal IPN. You can get the Paypal transaction id, amount, and a slew of other information, using Paypal IPN. Basically, this is where Paypal will do an https post back to your site after a transaction, and send all of the info for the transaction. See https://developer.paypal.com/webapps/developer/docs/classic/ipn/integration-guide/IPNIntro/ for info.
You need to specify redirect url.You can have two urls one for success and other for failure.Thats how i implemented it in one of my project (Dont have it now with me for reference).
Take a look here or here.This link has an sample project.It may help.

Resources