How does one integrate PayPal with a MERN stack - paypal

Hey I would love to learn an know how payment gateways are implemented I have been google searching for code examples to implementing PayPal to a MERN Ecom project but I really could not find any examples on this
Can you please refer me to link where I check that up and if possible please you can make just a basic snippet on how this can be implemented I would really appreciate it
This is the kind of implementation I would love to have
Take in the customers Personal info i.e Name, Email and all necessary info etc
I would love to collect a shipping address

I am not sure what about approaches to implementing a server and client side confuses, but below is some documentation to review. The samples are in standard node.js and JavaScript, so no express or react details are considered. Make your own adjustments to use with express and react.
On the server, two new routes, one for "Set Up Transaction" and one for "Capture Transaction", documented here: https://developer.paypal.com/docs/checkout/reference/server-integration/
A client-side approval flow to connect to the above, documented here: https://developer.paypal.com/demo/checkout/#/pattern/server
By default PayPal collects and returns a shipping address, so it will be available to you inside onApprove on the client side, or via an additional API call you could implement to get the details before going ahead with a capture, or simply in the final response of your order capture API call
When you capture an order, there will be a payment object with an ID. That is the PayPal transaction, and what you should persist in a database, and also what would be referenced for any refund. (The order ID used during approval and any debug_id of the response can be kept around for logging purposes, but have no accounting or reporting value)

Related

PayPal Checkout Integration

I am hoping someone here can help me as I have been on to PayPal technical support who haven't been very helpful.
I am integrating PayPal checkout, following the instructions here: https://developer.paypal.com/docs/checkout/standard/integrate/
I wish to collect the paypal transaction ID in my database, send order confirmation emails etc... so as such I need to implement the optional step 5 described in this integration guide, which essentially means creating two routes on my server, one to call "create order" and one to call "capture order" - as per the sample code here: https://developer.paypal.com/demo/checkout/#/pattern/server
I have got this working successfully however I wish to know 2 things:
How can I see the 3D Secure flow - PayPal tell me know to worry about it as they handle it within the popup window but I would like to see the flow. I have tried test cards that should invoke the 3DS flow but they dont show any 3DS flow, just complete the payment.
The response to the capture order end point can return multiple statuses (COMPLETED, APPROVED, VOIDED, PAYER_ACTION_REQUIRED etc). Is it only the "COMPLETED" status that means a fully completed payment (and therefore I should complete the order)? What happens if it returns "PAYER_ACTION_REQUIRED" - which means 3DS check needed - will PayPal handle this and then re-execute my route?
Any help or advice would be greatly appreciated.
For the normal, 'Standard' integration, you don't have to test 3DS. The PayPal page/iframe already takes care of everything about it.
[Only for the 'Advanced' integration -- where you are implementing individual hosted card fields with your own styling -- do you need to implement and test 3DS yourself]
PAYER_ACTION_REQUIRED only happens with Advanced. All you need to do on the server end after the capture is check for COMPLETED and the existence of the Capture Id you're going to store for accounting purposes.

Is it somehow possible to get transaction details from any paypal user using my service?

Assume the following situation:
I have a 3rd party service offering some kind of analytics/report/whatever... on a paypal user's transaction history.
Is it possible to fetch payments (only amount - in case that matters) of private paypal accounts (ofc assuming they somehow granted access by registering to my service), even though they didn't buy anything of me directly?
I hope the situation is somewhat clear, unfortunately I coulnd't find any matching questions on the web.
Thanks in advande!
It's easier to download activity and import a CSV than to query transactions via API, but there is a Transaction Search API that can be used.

API for completing PayPal one-time payments

I'm looking for ways to make a PayPal payment using PHP. I understand there are deprecated APIs and current one. so I've found several ways to do so. but lots documents lead me into labyrinth. I'm quite confuse de.g. client button rendering, how to call our PHP script/ what is a PayPal-Request-Id and to get it/ what can we do with a token from webscr ==> cmd=_express-checkout&token=EC-7BA65327KY8480517 and etc.
I tried to use a button on my page to submit some few paypal-required parameters using html form. The receiving php file formed payment record as need, then create order. I got the order-id, but what is it for? so I set up a new parameters, conformed the PayPal needs to create a payment. This give me 4 links, one I choose to get redirected for client logging in and continuing. with this one I got to landing page then I executed a payment but each payment on sandbox dashboard says pending.
I am then confused how to get completed payment. Right here there is my data with THB currency
{"id":"PAYID-MAKU2OI7RR56034B9692111L","intent":"sale","state":"created","payer":{"payment_method":"paypal"},"transactions":[{"amount":{"total":"1126.15","currency":"THB","details":{"subtotal":"979.26","tax":"146.89","shipping":"0.00","insurance":"0.00","handling_fee":"0.00","shipping_discount":"0.00"}},"description":"aonang to","custom":"0","invoice_number":"kbv.starlight_12","soft_descriptor":"MFWD","payment_options":{"allowed_payment_method":"INSTANT_FUNDING_SOURCE","recurring_flag":false,"skip_fmf":false},"item_list":{"items":[{"name":"MFWD","sku":"kbv.starlight_12","description":"aonang to ","price":"979.26","currency":"THB","tax":"146.89","quantity":1}]},"related_resources":[]}],"note_to_payer":"Contact us for any questions on your order.","create_time":"2021-01-30T12:12:40Z","links":[{"href":"https://api.sandbox.paypal.com/v1/payments/payment/PAYID-MAKU2OI7RR56034B9692111L","rel":"self","method":"GET"},{"href":"https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-1G552540DR9655320","rel":"approval_url","method":"REDIRECT"},{"href":"https://api.sandbox.paypal.com/v1/payments/payment/PAYID-MAKU2OI7RR56034B9692111L/execute","rel":"execute","method":"POST"}]}
Sandbox account interface screenshot
You mention the classic Express Checkout API and the deprecated v1/payments API, but the right solution is to use the current API, v2/checkout/orders
Create two routes on your server, one for 'Create Order' and one for 'Capture Order', documented here. These routes should return JSON data (and only JSON data) when called by an XHR/fetch.
Pair your two routes with the following approval flow: https://developer.paypal.com/demo/checkout/#/pattern/server

Roadblocks with using PayPal Recurring Payment Subscription with ASP.Net Membership?

I'm using ASP.Net Membership Provider for logging into the premium content of this web site. The content isn't downloads, it's web pages of information and discounts, etc. That part is done. We want them to also have a PayPal Subscription annual payment to see the premium content. I would like ASP Membership and PayPal Subscription to work together as much as possible, but for the minimum I am thinking they will have to create a MemberId before they pay. Then I will send that MemberId to PayPal to associate the two.
I think I can do that like this:
Set "Auto Return" on in the interface so that it will redirect to return URL when payment is made.
Set "return URL" query string to MemberId. This requires not using the precompiled "Saved" buttons. I'll have to set it in Code Behind with Name Value Pairs, "NVP" to PayPal. I was hoping to just paste the stupid button.
But then, there were those "Advanced Variables" in the Button maker. Problem was they are compiled into the Saved button, so I can't change them for each person. But maybe that one parameter could be separate from the compiled parameters? Is this better than hacking the return URL? Are "Advanced Variables" good for anything?
All the details about the transaction will be POSTed to the return URL if I put in the right code, which might be rm=2. (Right?) Then I can record it.
This process is said to be unreliable, though, and PayPal recommends using a secondary system that they have, "IPN". PayPal sends the transaction details to me. I send them back http 200 code. Then I send it back to them in the same order I got it. Then they send me http 200. Then we all know it's good. This sounds like a few hours research to me, but if you've already done it once, it sounds like copy and paste. I hate reinventing the wheel. Is there a .Net sample of this IPN handshake/dance?
Also, if I do the IPN thing, maybe I don't need Auto Return. Maybe I add MemberId to "notify" URL instead of "return" URL. Then PayPal can handle the confirmation page, email, etc. Is that better?
Assuming we get the Subscription paid for and recorded with the MemberId, at least once per user session, after they log in, I have to check if they have paid their PayPal subscription and if it's up to date. "GetRecurringPaymentsProfileDetails" does this, but it is an API operation. That makes sense, but I was hoping to avoid learning their REST API. (Is there a "NVP" version?)
REST API OAUTH tokens expire every few minutes, but the only way it tells to get one is by using "Bash" to "cURL" some Linux commands. Again, this seems like the kind of thing that would only ever have to be written once. Does this already exist as a sample code somewhere?
(I don't want to use the API to do the Subscribe, because I don't want the Credit Card numbers to ever go to our site. Too much liability. That's why I wanted PayPal.)
Will this even work? I know PayPal has 18 ways to do everything and they all exclude each other, and I'm just getting the feeling that I'm creating a patchwork of unrelated ideas to fool myself into believing there's a light at the end of the tunnel. I've already been researching and experimenting for 10 hours or so. I really thought, going in, I'd just be pasting a stupid button.
If you want to just "copy the stupid button" then you'll have to stick to Payments Standard, and then you'll be limited with what you can do. For example, you won't be able to use GetRecurringPaymentsProfileDetails for a standard subscription.
Instead, you'll need to use Express Checkout and / or Payments Pro. There is indeed an NVP API available for these, and there is also a SOAP/XML version. Details on those can be found here: https://developer.paypal.com/docs/classic/api/
Specifically, for Express Checkout, you'll want SetExpressCheckout, GetExpressCheckoutDetails, DoExpressCheckoutPayment, and CreateRecurringPaymentsProfile. Some of those calls are optional depending on how exactly you're configuring things with the checkout flow.
For Payments Pro you'll use either DoDirectPayment / CreateRecurringPaymentsProfile or PayFlow depending on what version they put you on.
In any case, IPN is definitely the way to go for post-transaction processing.
.NET IPN Sample - https://github.com/paypal/ipn-code-samples/blob/master/paypal_ipn.asp

facebook chargeback refund details

we are dealing with heavy chargebacks and refunds. But I am unable to identify how can I get the details of chargebacks and refunds. We have published our game through third party so they own the Company Account for transactions. We have asked them, but apparently they don't have anything to help us out. I have used Graph API to log the transaction details and I have also used the debug tool to find out the reason or details of chargebacks and refunds. but even our refunds does not have any reason attached with it. Please help me out of this. I have done alot of Google on this but i am unable to find out what I need to know
Regards.
All you will actually get is a “Refund Reason Code” – which of these there are, and how to access them, is described here:
https://developers.facebook.com/docs/payments/disputes/#refundcb_tracking
Edit:
It does not look like you can look up the refund reason code via the API – but Facebook will send it to you, via a ping to your callback URL:
“If the order has been refunded by Facebook, we will ping your callback with a payments_status_update for the order in questions with a status of refunded. In addition, there will be an additional field returned called refund_reason_code with one of the following values: […]”
So you will have to react to that and evaluate the refund reason code (save it to your database, …) in this callback.