Invoice and receipt statements API for 'My account' - paypal

I want to add Payment History to a user's account.
On this page, a user should see payments received (via PayPal) and payments made (via Stripe or PayPal). I want them to be able to download the receipts in PDF form as shown here in a mockup: Mock Image of Payment History
The details on the PDF should simply include: Date, Reference Number, Amount Paid or Amount Received.
What would be the best way to generate these statements?

For PayPal there is a transaction search API: https://developer.paypal.com/docs/api/transaction-search/v1
If the user creates a new live Rest API APP and checks the box for the permission needed and copy-pastes the clientid/secret into the config of your system, you'd be able to run this call on their behalf and assemble some history with repeat API calls.
It'd be simpler for them to log into their account and generate an activity download as a CSV file, though.

Related

Check if user have valid subscription on PayPal

In our app user is paying for one year of use during checkout and then after a year we are staring to charge subscription.
Let's say that users are identified by email. So, how can I verify that user have now an active subscription ?
I have seen a few posts that suggest to build webhook and listen to PayPal events.
In our flow the initial purchase will be on WordPress website with one of the subscriptions Plugins and then I need to "activate" subscription in the App.
Is the "webhook" the only possible option with PayPal?
I have seen something in Braintree SDK related to subscription, can this work?
Seems to me too complicated to build the whole system only to verify subscription. In Stripe, for example, you can proactively ask if the user has subscription.
The webhook PAYMENT.SALE.COMPLETED informs of every completed subscription payment. Use this information to continuously update your records of whether a user has a paid-for subscription.
If you need metadata for reconciliation of which subscription corresponds to which user (since however they are identified at PayPal may not correspond to however you identify them), you can set the parameter custom_id when creating the subscription, to any value of up to 127 characters.
If you need to download a transaction history of previous payments, you can get a report in CSV format from the https://www.paypal.com account interface, typically under Activity -> All Reports -> Activity Download. This can then be imported to a database to backfill any gap in your records that you don't have webhook events for.

Upgrading PayPal payment to Orders API, the testing account didn't receive any money after finish the payment

I'm trying to implement the new PayPal Orders API, here is what I did:
Create a developer account, add an app name and then I have Client Id and Secret.
Use OrderCreateRequest to create an Order
Get approvel_url from the resposne->result->links
Redirect to this approvel_url and finish the payment
Paypal will redirect back to my website.
But I never got any thing from the PayPal testing account,Please, what did I miss?
Edit:
On No.4, when redirects to the PayPal page, somehow it only shows 'Continue' button on the page, not the 'make payment' button.
You are missing:
Display an order review page to the payer.
Capture the order with an API call, which (if successful) will return the transaction ID in the purchase_units[0].payments.captures[0] object.
On success, display a thank you/confirmation page.
Without the final capture API call, there is no PayPal transaction.
You are also still using an old integration method based on redirects, which is for old websites. Current PayPal Checkout integrations use no redirects. At all.
Instead of redirecting, 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). When a capture response is successful, store its resulting payment details in your database (particularly purchase_units[0].payments.captures[0].id, the PayPal transaction ID) and perform any necessary business logic (such as sending confirmation emails or reserving product) right before sending your return JSON.
Pair those two routes with the following approval flow: https://developer.paypal.com/demo/checkout/#/pattern/server

I can't find out transaction history in sandbox use paypal checkout-sdk

I use java checkout-sdk-1.0.4 to develop PayPal payment. I successfully submit an order to PayPal, get the payment url.
I log in with personal account and click the continue button.
And then paypal just redirect to the url i set.
http://localhost:38001/checkout/submit/result?token=60X99286YV4394812&PayerID=9WXE2YPSNEJSN
I can see the api call history in developer dashboard.
But i can't see any transaction history in my business account and personal account.
How do I determine if my payment is successful。
I try this tutorial from here
https://developer.paypal.com/docs/business/checkout/server-side-api-calls/create-order/
https://developer.paypal.com/docs/business/checkout/server-side-api-calls/capture-order/
At the end, paypal return capture success.
Status Code: 201
Status: COMPLETED
Order ID: 1AL061567P026410J
Links:
self: https://api.sandbox.paypal.com/v2/checkout/orders/1AL061567P026410J
Capture ids:
6NY33838LX3268618
But i still can't see transaction history in my personal test account.
But I can't see any transaction history in my business account and personal account. enter image description here
You can't see any transaction because there is no transaction. There won't be any, unless you show the required order review page and perform the required capture API call when the customer returns to your site. (if you want to skip showing a review page and proceed directly with making the API call, then you should set the application_context object's user_action to 'PAY_NOW', so the last button's text is changed from 'Continue' to 'Pay Now' and the user knows to expect no review page. You still need to perform the API call to capture regardless).
The flow you are using of redirecting over to PayPal and then showing a review page or doing a capture call after being redirected back, is an old checkout flow and does not provide the best user experience. It is better to not use any redirects. At all.
Instead, 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

paypal express checkout on REST api (C# lib)

I dont get the idea. If Classic api have DoExpressCheckout methods... what Rest API have for it?
On that image we have the way how it should work for classic way
So for my case Express Checkout steps are:
1) Customer put items in cart and click on PayPal checkout button
I run
var payment = new PayPal.Api.Payment();
var createdPayment = payment.Create(apiContext);
so make the payment and redirect customer to paypal site
2) Customer go thu the paypal process and return back to my site. From his pay pal transaction I should get Shipment address and his email (without submit that payment!) and based on his shipment address calculate shipment cost
3) After customer select shipment method I need update his transaction (add shipment cost) and only then sumbit it.
So the questions here
1) how to get payment (transaction) info with C# lib based on paymentId (like PAY-21A17783AU475540MKYGAM5Q) because PayPal.Api.Payment() have methods only Creare, Execute and Update?
2) How to Update current transaction (add some new data like shipment cost) and then submit it?
PS. In the documents a lot of mess and a lot of people dont understand how they should use that api properly.
Duke
Based on your post, you'd create an Order - strongly suggest you use their library in this link (it includes samples, should get you going quickly, is very well maintained, and the maintainers are great/responsive)
Create it - this would map to classic SetExpressCheckout
Redirect to Paypal to obtain user approval. The redirect URL is part of the response (no longer just a token)
if the user "approves", Paypal redirects back just like in classic
you'll see this handled in the sample in the else block
just like in classic PayerID is in the querystring
Execute the payment
the response will contain the data you need as you will see in the lines below the execute statement, so this maps to GetExpressCheckoutDetails
you will also see your options on what to do next (Auth, Capture, etc.) in the commented lines. These would map to "finalizing" the payment
you can "adjust" for shipping/tax in the above after obtaining the details and will have same rules as classic IINM as far as the maximum additional amount you can add - 115% not to exceed $75)
If you have a sandbox account, I have a debug page here that shows the data io that maybe helpful.
Note that I'm only partially capturing ("is_final_capture": false) so if you check your sandbox (buyer) account, the total charged wouldn't be the full amount
Hth..

Store credit card details in Paypal payment

I wanna store card details while using Paypal payment, there is any why in Paypal SDKs which store details of card.
PayPal's REST API calls this a "Vault" and allows you to save the credit card details on PayPal's server so you don't have to save it on your own server. This way you can still process saved cards without any risk of saving it on your own server.
The Classic API (which is what I still prefer) has the same thing except that it's called Reference Transactions. You can run a card verification / $0 authorization, and then in the future you make a call to DoReferenceTransaction to process any amount you need using the card details PayPal has saved on their server.
Either way it's just a matter of building the API requests per the documentation. There are SDKs available to help you with this.
Paypal does not share its users' account details, especially card details to anyone. You have to use the unique account email address to define a user.
It is highly recommended to not save any payment information of users. Only transaction IDs, and perhaps a unique user ID or hash.