Integrating application shopping cart with PayPal through PayPal API - angularjs

I need to integrate PayPal with my client AngularJS app, where the app visitors can donate specific amounts of money based on various causes, but not sure where to start? My client requested that visitors can select cause, amount to be donated, then get routed to Paypal to enter their details, process payment then finally routed back to the app for (thank you page) which should receive payment confirmation as parameter.
I've skimmed through the PayPal developers API and can see that there are a lot of options / features offered but not sure really where to start and which is the best approach to accomplish my client needs? Shall I use REST API? or will simple button integration do the job? What if I need to add causes selected to Paypal checkout page? Can I do this using the API? Thanks

If you don't have some specific reason to use REST I would recommend just going with the Classic API, specifically Express Checkout. It's much more mature and provides a lot more freedom to integrate with different options and customization.
With Express Checkout you'll be using the following calls.
SetExpressCheckout
GetExpressCheckoutDetails
DoExpressCheckoutPayment
You'll call SEC and that will return a token. Then you'll redirect the user to PayPal with that token appended to the URL. The user signs in and approves the payment, and they're returned to a URL that you supply in the SEC request.
At that URL you can call GECD to obtain all the details about the buyer. This allows you to tae their address and apply any shipping or tax rules you need to so that you can present a final review before the user would approve the payment, which is when you trigger DECP to finalize the transaction.
There are various options with that flow. For example, GECD is optional, and depending on your flow you may or may not need a final review, so you could skip straight to DECP and display nothing but a final receipt page when the user gets back to your site if you want to.
If you happen to be using PHP my class library for PayPal will make all of this very simple for you.

Related

Is OAuth 2.0 required for accounts.locations.reviews.list "My Business API"?

I have a React Application which is going to leverage Google My Business API to get review data of a business.
I was expecting to use the API-KEY via REST approach however Authorization Scope mentions that OAuth 2.0 is required to use this API.
After I read more about OAuth's purpose, it seemed like it is more for application's which require access to a user's data and therefore would required a consent screen verified by google.
For my use-case however, all I need is access to all google reviews for a business and nothing related to the visiting users.
Can someone recommend an approach for this? (I don't want a pop-up/consent request when a user visits as I don't need user data.)
After much research, it seems that if you want to retrieve ALL REVIEWS for your business you will have to use Google's My Business API. This API requires you to use OAUTH2 for authentication which means (although you will not be querying a visiting user's data) visiting users will be required to provide consent pop up screen.
This leaves you with the places API as the next best option:
REST GET endpoint maps.googleapis.com/maps/api/place/details/json?placeid={your place ID}&fields=review&key={YOUR API KEY}
Although this only returns google's top 5 "most helpful" reviews, its pretty much the only way to get reviews without a consent screen unless you want to scrape data which is not ideal for many reasons...

React Form send email

I am building a form in react and I wanted to send it to my email when the user clicked the submit button.
I was looking at Microsoft Graph API for sending the email (https://learn.microsoft.com/en-us/graph/api/user-sendmail?view=graph-rest-1.0&tabs=javascript), but checking it, seems that it needs a temporary token, so I can't use it as I would need to be changing the token every hour or so.
So, I'm basicaly trying to find an API like the Gmail but for office 365 accounts (https://developers.google.com/gmail/api/guides/sending), as we can create a gcp project and use the keys that it generates for us, instead of using a token like the MS Graph API
Generaly I would use a route in my API, but this site is static, so I do not have any API (neither serverlets, cloud functions or other stuff like it).
Is there any away to send an email through a Microsoft API from my web client in react, using only a token specific to the domain? Or is there a better away to acomplish this same result?
I highly recommend using https://formsubmit.co/. It's free and I personally use it in many projects. Works flawlessly with many features like email templating, captcha, reply_to, etc.
No backend knowledge is required. Can set it up in like 1 minute.
One option would be to authenticate on behalf of the user.
You can also have a small proxy API, dedicated for the purpose of allowing the users to send an email.

How to authorise a transaction between two PayPal accounts?

I am using AngularJS and have built a basic single page application. My users will enter in their PayPal email address and currency upon signing up and it will be saved within the database.
Any user can post something basic for sale for another user to purchase.
How can I authorise a transaction between two users PayPal accounts while keeping them within my site without a redirect to PayPal? All solutions online require the user to be redirected to PayPal.
You would need to use either Reference Transactions or Preapproved Payments.
You can't avoid a redirect entirely if the users are going to be paying with the PayPal Wallet. When they first sign up for your app/service they would need to authorize your system to make payments on their behalf.
So if you're using Express Checkout, for example, the user would be redirected to PayPal to authorize their account. After that is done your app could then process payments using the DoReferenceTransaction API without the need for any redirection through PayPal.
The Preapproval API sets up the preapproval profile, so yes, at that point they would be redirected. After that, though, you would have a preapproval ID that you would then pass into the Pay API in order to process payments for that person without any further approval (so no redirect) required.
If you're going to set this up with credit cards directly then you would need Payments Pro. With that you could authorize a credit card directly within your app so you wouldn't need any redirect at that point, and then once again you would use a reference transaction to process payments for that card in the future.

Integrate SurveyMonkey in an existing community

I have a cakePHP community. User are able to signup and login. I like to create a survey using SurveyMonkey.
Therefor I create the survey and make it available to my members using the direct URL. In my member database I have to save the information "did completed the survey = yes/no".
Is there any way to identify the user filling in the survey and write this information into the database?
SurveyMonkey has an API https://developer.surveymonkey.com/ , that let you collect info from your survey (completedf or not).
This is the only way i think, (if it s not include in your website).
I know that you can simply do this with Examinare Survey Tool. What you do first is that you use the API inside Examinare to add a recipient for all the users in the survey base.
Use the PHP Wrapper library in their developer site.
Loop it through and use the https://developer.examinare.com/php-wrapper-library/ and use the example code.
If you let people register with same email more than 1 time then save the ContactID into your database on the recipient.
Then to not create an email invite you use this : markrecipientstosurvey
The surveyID is available inside the Examinare account.
When you done this script part then make it as a cronjob for instance inside the crontab -e
I would run it every 30 minutes or 1 per hour.
Next part you create a page for the survey redirect where you use the function: listsurveysbyuser
to get the survey version and url
(there is a special link for the mobile user that even works for the normal mobile phone NOT only smartphones)
Now you just redirect them to the survey. If you want them to return to your site after then you use the redirect_url parameter that is added to the url or use the redirect inside your account. Ask support about that if you need :) They are fast... Never had to wait more than a couple of minutes.
When the person return then just check if they are marked as complete with the same api call: listsurveysbyuser
Looks much but it is very easy to implement and if you have any problems then just ask the support at support#examinare.com I have asked alot and never had them to say that it can not be done. Really nice!
EDIT:
I see that they just released a tutorial much better than my example:
https://developer.examinare.com/how-to-use-surveys-in-cakephp-with-very-little-development/
One option:
Use unique Custom Variables in the URL that is visited by each member of the community
For example, https://www.surveymonkey.com/s/your_survey?userid=$my_user_id
Note that you can create weblink or email collectors with the API (endpoints: create_flow or create_collector).
Then track the responses using the get_respondent_list or get_responses endpoints of the API.
Note: Please confirm with the Survey Monkey API team that the custom variables can be read via the API.
Another option:
Use the email collector (create_flow) API endpoint and send it to your members' email addresses.

Paypal Integration in Web application

The scenario is that users of web application can purchase digital items. The web application will use Paypal Instant Payment Notification.
The IPN protocol consists of three steps:
PayPal sends your IPN listener a message that notifies you of the event
Your listener sends the complete unaltered message back to PayPal; the message must contain the same fields in the same order and be encoded in the same way as the original message
PayPal sends a single word back, which is either VERIFIED if the message originated with PayPal or INVALID if there is any discrepancy with what was originally sent.
Let's say it's VERIFIED, how could I know who have completed the transaction or purchased the item (user of the web application) if the user used other email address in his/her paypal? I have stored the email address of the user in session but what if he/she have different paypal email? Paypal email is included in IPN message.
For other details, maybe not useful, the application is written in Struts2 in Google-App-Engine.
You'll need a way to correlate the IPN data coming back with the user. Either by asking them to provide their paypal email or using the username/password generation facility in the IPN service. Here is a somewhat inelegant but functional approach:
When the IPN comes in off the wire, persist the paypal generated username/password and payer_id (in perhaps the datastore).
If you can't correlate by email, then when the user comes back to your site request that they enter the username/password generated from paypal's site once (just to correlate).
Lookup the username/password and then correlate their userid from the UserService back to the payerid.
The reason to use IPN is for subscription services as you can get IPN messages when the subscription is terminated, cancelled, or when payments come in (for an account that stopped paying).
The most important thing to think about is how to correlate a user of your site back to the payer_id (or even payer_ids in some cases) that are used to pay for the services they are using.
On another note, I wouldn't use the session to store information for IPN callbacks, those actually can take a LONG time sometimes (say when the x.com conference is on and everyone is hammering paypal).
If you have a running application or a better description of the look & feel, I might be able to come up with a more elegant suggestion. Let me know if this helps at all.
Why don't you use PayPal's express checkout? This way you negotiate server2server a token and then you can check with PayPal the result of that token on user's return.
If users are buying directly from your application it's easier to implement.
And I think it'is more robust than the method you're using (I never heard of it before :D )

Resources