I'm calling this API: https://api.paypal.com/v1/reporting/transactions?start_date=2019-10-01T00:00:00-0700&end_date=2019-10-30T23:59:59-0700&fields=all, and it is returning all transactions but I want to retrieve cart details options although in the fields I have set it to all.
I have read https://developer.paypal.com/docs/integration/direct/sync/#list-transactions.
What I want is the following (but via API):
As a general rule, using PayPal APIs for reporting is a bad idea, for various reasons -- including slowness. But even if they were good for this use case, I know of no way to get the shopping cart data you mention in a list via an API. The only possible solution might be to first get the list without shopping cart data and then query each transaction individually (one API cal per transaction) to get its shopping cart details, but this is incredibly inefficient.
So basically, you should:
Record and save all shopping cart details at transaction time, in your own database, using IPN/webhooks as a listener if necessary
Manually use the activity download of your screenshot to download a CSV, if it's ever necessary to backfill information from the past.
Not use reporting APIs.
Related
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.
I apologize in advance for this question, as its probably rather silly, but I really can not find any answers elsewhere.
My current goal is to integrate a subscription to my website, that allows for a user to have access to certain parts of the site.
I've watched a few videos on it, but it leaves me open ended with some questions.
PayPal allows you to manually create a subscription plan at https://www.paypal.com/billing/plans. When you create a plan here, it gives you the code you need to get the pay pal sub buttons to display on the page. Users can then use them to create the subscription. This is great. However, I have found now way to validate the results of the transaction. My goal would be that if the user was successful, I would be able to retrieve data via the API, that says it was successful, and I could then store than information in my database, and grant them access. Does anyone know how to get the data from the manually created facebook plans?
I did watch a video that had you do everything from your website (you create it all within your own code), the end result however sent everything through $_GET variables in the url. I feel like having this data exposed could result in the manipulation of the subscription, and grant it to users who were unsuccessful in creating a subscription.
I have no problem doing all of the coding to make this work, but I really want to make sure I do it the best possible way.
There is a few way to do it. By setting up a webhook and listen to paypal success notification and react to it. By using the Paypal Subscription API. Or a combination of both.
As you are using the paypal button you will have the onApprove function which will trigger upon user confirming the subscription. You can query the subscription data with:
onApprove={async (data: any, actions: any) => {
const detailedSubscriptionData = await actions.subscription.get()
// activate subscription on your side by sending it to your backend
...
// etc.
}}
Inside the data you have queried above, there will be a paypal transaction id (I-....) that is unique for each transaction, as well as your product id (plan_id). You can now do the following for verification on your backend:
Check if there is already a subscription (from another customer) on your side with that paypal transaction id
Check for the plan_id
Queried the API Subscription Details with the paypal transaction id and check for status, etc. as well as matching of plan_id
Keep in mind that for using the API you will have to queried for an access-token which in turn required you to have Developer App Setup following these steps.
I'm trying to make an app that sells a service, for which users pay based on the amount of time they've used it for, so I don't have a physical shipping address involved.
I want to be able to allow my users to save and then reference saved cards in future transactions. I know the way Stripe tracks a specific customer is through a customer_id, but I'm not sure how to attach a card to a specific customer_id and then reference it in future.
Also, I'm a little confused on the use of ephemeral_keys. Some Stripe tutorials talk about needing these on the server side, and some don't mention them at all, and that leaves me very confused.
This one talks about ephemeral_keys while creating a paymentIntent: https://stripe.com/docs/mobile/ios/basic#
And this one doesn't: https://stripe.com/docs/payments/integration-builder
Any help would be greatly appreciated! Please let me know if you need any more information from me.
PS: If you could also point me to some of the relevant View Controllers Stripe uses to save new cards and display saved cards, I'd be more than grateful!
The flow on https://stripe.com/docs/mobile/ios/basic includes the Customer for your payment context, which will cause the created PaymentMethod to be attached to that Customer. You can verify this after the initial payment by retrieving the PaymentMethod on your backend with your secret key and checking its customer field [0].
If you have a PaymentMethod and want to attach it to a Customer, you'd use the API on the backend [1].
You can retrieve a list of the Customer's existing PaymentMethods via the API [2] on the backed as well (again, with your secret key). Then you can pass a list of their id's and some identifying feature (last 4 digits, as an example) to your app in order to display and let the customer select the one they want to use. Then you take that PaymentMethod's 'id' and use it to create the new payment.
Ephemeral keys are usually only used with the iOS (or Android) SDK's, so when you're using the backend of your integration (i.e. the part that is running on a server somewhere and not distributed with your app) you generally don't need to worry about them.
[0] https://stripe.com/docs/api/payment_methods/retrieve
[1] https://stripe.com/docs/api/payment_methods/attach
[2] https://stripe.com/docs/api/payment_methods/list
The "country" field in the PayPal transaction history CSV exports is almost always empty. However, PayPal must know the country where a transaction originates, and in fact tools such as Putler can display the country for nearly all transactions.
I wish to obtain this data myself, but since the export doesn't appear to have it, should I obtain it by using the API? And which of the APIs wold be appropriate to use for this purpose?
Thanks in advance.
Yes you can probably do this using the API. First you'll need to search your account's transaction history. After that you'll get a list of transaction ID's, you can then retrieve information about a specific ID which includes the country code of the buyer.
You can see more details here: https://developer.paypal.com/docs/classic/express-checkout/ht_searchRetrieveTransactionData-curl-etc/
From PayPal's documentation:
"PayPal returns related variables for each kind of IPN message. Not all variables are returned for each type of transaction."
I was initially planning to create a table in the database with the message fields but now after I read this it doesn't seem like a good a idea anymore (esp. that I see a lot of fields in their IPN documentation).
I have a few ideas (e.g. using tabs and new lines character separate fields and values. Or, saving the the whole thing in XML in the database) but just wondering how you handle logging IPN messages?
What I do is save it to a database table with columns for information that is important to me along with a "raw" column. I take the form parameters collection and serialize it like a query string and push it in. That way all of the original information is available if I should need it but my database schema remains simple and reflects the information that is important to me.
I'd agree with the previous comment. IPN messages can be quite variable, and can be about 40-50 fields per submission. Just pull the few fields you need for your application (amount, customer info, etc) and drop the rest into an XML or TEXT field just in case you need it later.
I faced the same challenges when I integrate PayPal adaptive Payment. The fastest way I did is to store the IPN details (when PayPal calls the IPN handler that I did) to static variable so that the values can be shown regardless of browsers I used.