PayPal Smart Button: Get Transaction Details & Update into Database - paypal-sandbox

Hi I am currently doing project that is creating a payment gateway for my webpage and currently I am using PayPal Smart Button for the payment gateway
For now, I have successfully doing the payment but I am unable to get the data that I decided to use for updating the database. I used the PayPal developer website as reference(code, methods etc.), but it doesn't work. Get Transaction <-- I am not sure where should I put the provided code in a Controller/Model
I am using ASP.NET MVC for my project.
Please help me.
Thank you.

Create two routes that return JSON, one for "Create an order" and one for "Capture an order", documented here: https://developer.paypal.com/docs/business/checkout/server-side-api-calls/#server-side-api-calls
Pair your two routes with Smart Button JS for approval. Here is a demo: https://developer.paypal.com/demo/checkout/#/pattern/server
This way when an order is captured, you'll have an immediate API response on your server with all the transaction details. Update your database then.

Related

While subscribe a user I got eror code 91927 in braintree using node js

I'm new to braintree. And when I run the subscribe user code from node sdk I got this Error.
gateway.subscription.create({
paymentMethodNonce: req.body.nonce,
planId: req.body.planId
}...
Need
I want to subscribe a user on specific plan in my app.
Full disclosure: I work at Braintree. If you have any further questions, feel free to contact support.
The payment method must be vaulted before you can associate it with a subscription, so you should refer to the payment method using its paymentMethodToken instead of a paymentMethodNonce.

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 buy it now button process flow

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.

How to process a google-checkout "buy-now button" transaction?

Google-checkout has a wizard that creates the html code for the button, but how do I have my website get confirmation that the transaction has been completed (or that it wasn't)?
EDIT: I have already seen pages such as https://developers.google.com/checkout/developer/Google_Checkout_HTML_API_Notification_API#Receiving_and_Processing_Notifications and the like. But I don't know how to implement them. For example: what is "HTTP Basic Authentication" , "HTTP request headers" , "HTTP 200 response code" , "POST" , etc.
So what I need is a simple (!) example with minimum code.
You would have to implement Google's Notification API. You can read about it here: Implementing the Notification HTML API.
Edit
In Response to:
Thanks. But unfortunately I don't know enough web developing to know
how to apply what is written there.
I'll be honest with you. Simple is relative and if you aren't familiar with some of the fundamental concepts as POST and request headers, it's likely you will never get a simple response.
Having said that, I believe the simplest solution for you is to manually confirm the transaction upon receipt of the confirmation email.
I envision that you would have some sort of management screen that displays a list of all 'pending' transactions. When you receive your confirmation email from Google, you would simply mark the corresponding transaction as having been completed. This is not entirely uncommon. In fact, since you are using single-item purchases using the Google button, this is probably the best option for you.
A more complex scenario (again not a simple solution), would be to create a service that will parse your emails and using some voodoo to map those emails to the corresponding transaction in your web app. This, though, is probably as advanced as implementing the Notification API.

Asp.net, paypal and IPN.. how to automate payment?

i'm trying to integrate Paypal in an asp.net app.
It works fine, the last thing i would like to do is to automize payment notify.
In particular, how does it works IPN ? I would like to set a field to 1 when a user buy a service... How can i do with ipn ?
I'm asking here to avoid to read all 120 pages of paypal IPN documentation... ;)
Thanks in advance...
Theres lots of examples out there on how to build a basic IPN listener. Once you build one and point your PayPal account at it, all transactions will have their details sent to this listener as a request. You will need to parse out the relevant data from this request to determine the success of the transaction and process the order.
Similar SO Question
PayPal Code Sample
Other good sample C#

Resources