Sending customers to a PayPal payment page with a webhook? C# - c#

I'm a bit confused with the PayPal (REST) integration.
What I want is the following:
My customers on my website see a order-summary, they then click on
'go to payment page'. I only need to set the Currency, Amount and Description.
They arrive on a PayPal page where they choose to signin/as guest, and choose creditcard/paypal account to pay, fill in all the data etc.
I get notified by using a webhook that they actually paid, and process the payment internally.(Receiving an email about the status won't let me automate.)
Somehow all the examples I see are about sending complete payments through paypal, and not just 'setting up a payment page'. Is this even possible?
Thanks!

I hope this helps clarify:
There are 2 types of payments/funding :
credit_card
paypal
If by "payment page" you mean collecting payment info (credit card) on your website and sending it to a "gateway" for processing, then that's the credit_card flow option. There are account requirements for that (and PCI compliance).
The flow you describe above is the paypal flow. Your customers go to Paypal, select whatever payment instrument they have/choose (credit card, bank account, etc.) and then "approve" your request for a transaction.
When they "approve" - don't confuse this with payment, they are merely saying "yes, I want to pay this merchant using my Paypal account/funds", they are redirected back to your web site/application (to complete/finish things). At which point you will perform the necessary steps to "complete" the transaction request (e.g. send an execute, authorizeand capture request - depending on what you want).
So excute and capture (of an authorization) are the actual acts of "obtaining the actual payment so you get paid". You will get some result in the response to these requests at this stage for you to determine things.
If you've used the Classic API, this maps to Express Checkout. I'd map webhook to IPN (optional messaging/event tracking, and really isn't part of your payment/checkout flow).
Hth...
Update:
I'd really suggest that you take a look at the SDK (.Net). It's very well maintained and Paypal dev support is awesome. The samples will really get you going quickly.

Recently I've taken a project which involves PayPal integration. It was a complete disaster for me. The struggle was tough on me for few days until I found the answer above AND after looking into the "Update" link, noticed they suggest to actually use a different NuGet.
So, this repository and quick start guideline was the cure to my pain with Paypal: https://github.com/paypal/Checkout-NET-SDK

Related

Is it a good way to only rely on PayPal Checkout when it comes to Securing a website from unintended use?

I am planning a website based on C# and ASP.NET MVC on which I want to offer a small function for a small amount of money. I dont want to use User Profiles because I dont want to do the managing part (like user/pwd) of it and save time. (I know there is a built in User-Handling in ASP.NET but I dont want a User-Login here because no one would register an account for this little function)
So a Idea comes to my mind that I could simply offer a PayPal-Button to let the User pay the money and let PayPal handle the redirect with an response key/hash (I think this is how it works) and on the redirected page on my site validate the payment through the key/hash from paypal to call the function the user paid for. Something like a paywall I think.
Is this a safe approach to secure my function and only show it to users who have paid or is this vulnerable to brute-forcing my application with a massive amount of keys to get away with not paying at all?
There are two reliable ways to confirm that a PayPal payment has been successful:
Synchronously: A server-side, API-based integration
Asynchronously: Any integration, and wait for a Webhook or IPN notification from PayPal for confirmation.
I'll cover the first way.
Integrate PayPal Checkout, documented here: https://developer.paypal.com/docs/checkout/
Here is a demo pattern of the client-side UI
The server side portion of this type of integration (particularly for the transaction set up and capture API calls) is discussed here: https://developer.paypal.com/docs/checkout/reference/server-integration/
Set up the payment
Capture the payment
If you do choose to implement a server-side integration, then -- once everything is working for the happy path -- don't neglect to implement funding failure error handling: https://developer.paypal.com/docs/checkout/integration-features/funding-failure/ ; This will allow buyers to choose a different funding instrument if e.g. their first card is declined by the capture attempt

Working with PayPal HERE and PayPal API

I am trying to use the PayPal Here Sideloader (C# web application). I am getting unexpected results where the Application doesn't always return to my web application in Safari (iPad). Also, it opens a new tab every time. So I decided to use IPN to handle processing after the purchase.
But while using PayPal HERE, I noticed that check and cash transactions are not calling my IPN Url. I tried to search transactions using the REST API and I don't even see them. Credit card and Apple pay transactions work fine. So my question is two fold.
After speaking to someone at PayPal who might or might not know what they are talking about said something to the effect of, 'those transactions aren't supported'. I don't necessarily believe that because if I have the Invoice Id (INV2-XXXX-XXXX-XXXX-XXXX) I can use the REST API to get what I need. Was the person correct, or has anyone else done this before?
What if I have my custom Order Id (see image), how can I get the Invoice Id?
(I've looked at the Invoicing API (REST) and TransactionSearch (NVP) and neither of these return information about the transaction.
After feeling like I have searched the ENTIRE internet, I saw that the documentation for the iOS and Andriod SDK mentioned the URL for the PayPal Here API.
That url (for production) is https://www.paypal.com/webapps/hereapi/merchant/v1
I just happen to add '/invoices/' to it and got an authentication error. Once I was able to authenticate, I see that this returns a list of all 'invoices' processed in PayPal Here. You'll need to connect using OAuth2, but the list is what I needed to filter based on order ID.

How do I set up a recurring charge where the amount fluctuates

I need to use our Paypal account to handle recurring charges (we presently just do one-time charges for our online store). What I think I want (feel free to let me know if this is not optimum) is:
We pass a customer from our website to Paypal's website, with the expected monthly charge and the maximum monthly charge. At this point they are registering for a 1 month free trial.
Paypal validates the credit card and returns a token to us for upcoming charges.
After 1 month, and every month after that, we use the token to charge their card. We pass the token and the charge amount.
We get back success or an error code, with the error code giving us the specific problem.
First off, is this the best way to do this? I think it's very safe because that token is only good for our company charging the card and we hold no card info. So even if a hacker gets the token - all they can do is have that person send us money, which will then be reversed.
Second, how do I do this? We're programming in C# using ASP.NET Web API2 for the REST server component and Sencha/javascript for the web pages. Is there any example code for this? Both for the handoff to/return from the paypal page for entering the credit card info and for the code in our server to make the monthly charges.
thanks - dave
I got an answer to this direct from paypal and am reposting it here as it fully answers the question:
"First off, is this the best way to do this?"
What you're looking to do is a product called "Reference
Transactions". With your business model I believe this would be the
best fit for your needs. I do want to mention there is an approval
process, so you'll want to contact our Business Support team sooner
rather than later to ensure when you're done testing you're ready to
go live.
"Second, how do I do this?"
Here's where the documentation comes in:
https://developer.paypal.com/docs/classic/express-checkout/ht_ec-refTrans-SetEC-DoRefTrans-curl-etc/
This page provides instructions on the redirect to PayPal to set up
the Billing Agreement, then walks through running Reference
Transactions for future purchases.
You can find our SDK's here (I've linked the Merchant SDK directly for
you):
http://paypal.github.io/sdk/#merchant
Here is our API explorer to see working examples of our API's:
https://devtools-paypal.com/apiexplorer/PayPalAPIs

Require Paypal Subscription to Create an Account - ASP.Net / MVC4 / C# / Razor

I am new to Entity Framework, MVC and Razor but am almost finished with my first project using it.
The final piece of the puzzle is to tweak the "canned" Log-in / Registration piece that comes by default when setting up an MVC project. I need to integrate with Paypal in order to create a monthly subscription. If payment is up-to-date then their account will then allow them to access all the benefits my site has to (hopefully) offer.
I signed up with developer.paypal.com and think I have a good start as far as creating test accounts. I just need to get the code in place.
Is there any sample code that already tackles this? I read through the API doc but
Is there any best practices that relate to what I want to accomplish? For example, should someone pay first, then create an account or vice versa? Should I have to implement managing their subscription cancellation or do they have to do it within their account? etc...
How can I tell if a user is current with their subscription and they didn't cancel.
How can I tie a user to their Paypal transaction?
Any help would be much appreciated. Thanks in advance!
PayPal has Standard Subscriptions and then they have the Recurring Payments API, or what can sometimes be seen as Recurring Billing. I would definitely recommend going with the API's as it will give you much more freedom to do everything you're wanting.
If you're talking about PayPal payments (where people sign in to pay) I'd go with Express Checkout, which consists if SetExpressCheckout, GetExpressCheckoutDetails, and then DoExpressCheckoutPayment and/or CreateRecurringPaymentsProfile depending on what you're doing. In your case it sounds like you'll be doing CRPP because you're working with subscriptions.
That will return a profile ID which you can save locally in your user table(s). Then, when people login you can make a call to GetRecurringPaymentsProfileDetails to lookup the current status of the profile, and then redirect the user to different places depending on the status.
PayPal's .NET SDK should make all of those calls easy on you, but it's really just a matter of building NVP requests and sending them to PayPal via HTTP POST.
If you want to do all of that with credit cards directly then the process is the same, but there are different API calls involved, and depending on the version of PayPal account you have the calls would be different.
If you're using Website Payments Pro 3.0 then you would use the DoDirectPayment platform, which in the case of recurring payments you would just make a single call to CreateRecurringPaymentsProfile and include the credit card details in that request.
If you're on Payments Pro 2.0 that would use the PayFlow API, and that's where it's called Recurring Billing, so you'd just have to setup a PayFlow request accordingly.

PayPal Recurring Payments Billing frequency

I am implementing paypal in my website first time so can anybody tell me that how can i test recurring payments as the Minuimum billing cycle is day and frequency is 1 so should i have to wait for one day to check the IpN handler hits?
or is there any other way to test recurring payment without waiting?
Thanks in advance
If you need to test subscriptions or recurring payment IPN's you can easily do so by creating your own HTML form and setting the action to your IPN listener URL.
Add hidden fields to the form that match the fields you would expect to get from PayPal, which you can see by doing an actual transaction on the sandbox to get that first IPN, and then duplicate it in your test form.
This way, you can submit the form directly to your IPN listener and actually see the result on the screen. This is also useful for troubleshooting.
The only thing you need to consider is that when testing this way the IPN will not verify because the original data did not come from PayPal. You could easily handle this in your code for testing purposes.
Once you have everything working the way you want like this you can rest assured it will work the same way for actual IPN's received from PayPal.
To the best of my knowledge, there is no way other than waiting to test PayPal subscriptions. You cannot run the sandbox under an artificial clock:
Similar question:
Testing Paypal subscription IPN
PayPal Documentation:
PayPal Payments Standard Integration Guide
you can test it on paypal sandbox as many time as you want

Categories

Resources