Paypal multiple payments - php

I'm trying to write a PHP class for paypal express mutliple payments. All is well so far except one thing I haven't figured out.
In PayPal's docs it says that PAYMENTREQUEST_n_PAYMENTREQUESTID is a required field for multiple payments, however I have no idea where to obtain a value for it. Is it a user set value? I tried putting random values and PP returns a SUCCESS however I'm not sure if that's good or bad.

PAYMENTREQUESTID is a user set value. The purpose of this field is to allow you co-relate response data for each of your parallel payments with your request data - Therefore it is good enough that this field is unique amongst multiple payment data for a given API call but random numbers should work too. See the docs for more.

Related

How to prevent duplicate invoice in Quickbooks Online API?

I have been trying to integrate Quickbooks Online API with PHP in to my website and I have found an issue where I could keep on creating the same invoice.
Although there have been accepted answer in this forum however it is really being vague not exact.
"If you don't have the TxnID, there really isn't a way to detect a "duplicate" invoice in QuickBooks.Does this mean that upon creation of invoce there is no way to check if an invoice was already create via API?
https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/invoice#create-an-invoice
When creating an invoice the values returned under "LinkedTxn" field is always empty
"The closest you can get is querying by RefNumber ...there's no guarantee that the invoice that you get back from that query is the invoice that you created."
Still same as first but I have been searching RefNumber under the documentation but I can't seem to find it.
If "RefNumber's" cannot be gauranteed then what are the other
alternatives?
Do I have to handle this on my local or at least add a column on my
local table for indicating if item is already sync?
PS: I also tried to insert txnid on the create invoice field however I wasn't successful.
While testing on sandbox I realized there is this number, what is this called? Can I use this for checking the existing invoice?
The NO. column you're showing in your screenshot is the DocNumber field. It's in the documentation here:
https://developer.intuit.com/app/developer/qbo/docs/api/accounting/most-commonly-used/invoice#the-invoice-object
In most cases, the DocNumber is a unique field. But not in all cases (you'll see some exceptions noted in the docs related to France and also to custom document numbers).
The best way to avoid duplicates is to keep track of what you send to QuickBooks on your end. On your end, maintain a list of what you sent to QuickBooks. Don't send it again if you've already sent it.

subscr_payment using paypal ipn simulator

The paypal IPN simulator "currently" (As in I'm assuming never will) does not have functionality to test the subscr_payment payment option, this is really putting a dead hault in my project. I've read that I can just create a button that simulates this, but I don't have a clue how and after looking I can't find any information on it.
I'm creating a subscription based system for hosting a special type of website, I have everything done besides for the subscription model now and it seems like it's going to be the hardest part.
It is completely possible to test recurring billing with Paypal.
There are multiple ways possible for this.
One is the paypal subscribe button and another way (which i have used) is via a subscription form.
For the subscribe button you can refer this documentation, it contains all the information you need to setup this.
For second method, you need to create a form and place all the required variable in that form.
All the required variables are listed here.
I hope this helps.
Hopefully this workaround will help you. From within the PayPal developer site, you can go to the IPN simulator, select Transaction Type as Web Accept, click Show All Fields. You can then edit txn_type to be subscr_payment, subscr_signup, etc.
It's not perfect, as it doesn't give you all of the variables, but you can put info in other entries, and use a logical to determine whether or not the correct entry exists.
Do one test subscription, so that you have the values, and then work from there.

Unique PayPal IPN variable for buyer and seller

I've been working on a website where people can submit questions to me online and I'll answer them for a small fee. I'm using PayPal to collect this small fee, and I've recently successfully implemented the PayPal IPN in order to collect transaction IDs. What I planned on doing was storing the transaction ID and asking the individual for the transaction ID when they ask a question. Once a transaction ID had a question associated with it, it would be marked as used and could not be used twice. I chose this method over having people create an account and storing variables within each account because I figure people will be deterred from using my service (it's related to academia) so this is kind of perfect.
So.. what's the issue?
I had a friend try it out, and we unfortunately found out that the transaction ID that I got and stored is different from the transaction ID that he got, hence completely breaking the system I had envisioned.
My Question
What is a unique variable passed on through the PayPal IPN that I can use to ask the buyer about and ensure that it doesn't get used twice?
I want the process to be automated, which eliminates the possibility of invoices since you have to do those by hand each time.
Thanks for your thoughts and efforts.
You can pass custom in your PayPal integration, which is subsequently returned in the IPN message.
I.e., for Express Checkout:
METHOD=SetExpressCheckout
PAYMENTREQUEST_0_AMT=1.00
RETURNURL=http://...
CUSTOM=yourUniqueDataHere
Or for Payments Standard:
<input type="hidden" name="custom" value="yourUniqueDataHere">
Once the transaction completes, you can find custom in your IPN message's POST data.

Where to store dynamic data for paypal express checkout (digital goods)

Imagine a site like istockphoto or envato where the user can only purchase digital credits...
How would one implement this in the cleanest, easiest way using paypal's API's? The docs there are a bit confusing to navigate...
Aside from that general "best-practices" question, my guess was to start with the Integration Wizard at https://devtools-paypal.com/integrationwizard/ and select "Express Checkout - Digital goods"
After setting up some test accounts on the sandbox, I've kinda sorta got it working- but I'm confused how I track dynamic data across the session.
I.e. where would I securely store the "number of credits" and "userid" values so that it gets added to this user (who may not have an email address, nevermind one matching their paypal account) upon successful payment. Is a database/callback system necessary?
Assuming so for the time being, my guess is to maybe store the data in a database where the primary key is the TOKEN received at SetExpressCheckoutDG(), and prepopulated fields are the data I want to keep... and then the final confirm.php page will check the database at that token and implement that data... but something just seems strange about that, i.e. relying on a callback (could be timeouts, etc.) and I'm not sure if it's really the most secure way of doing it.
If using examples, please stick with PHP (not curl or other langs). Thanks!
You could just bounce this along with your calls. I'll use NVP for my examples
You set your digital goods in SetExpressCheckout. Inside, you pass how many credits the user is buying and set the PAYMENTREQUEST_0_CUSTOM with their user ID.
In GetExpressCheckoutDetails that data would be passed back to you so you could store it in some fashion (you would get their items and quantity, plus the user ID). Then, you finish with DoExpressCheckoutPayment.
If that still doesn't help let me know.

Paypal NVP API - Narrowing Transaction Search Results

I'm currently building a simple ecommerce site for a client that will use solely Paypal to take payments. I want to display orders in the CMS I'm building for them, but only transactions that are made on the site I'm building.
I have achieved this so far by using the Paypal IPN to add transactions from the site into a database table (just the transaction id) and then borrowing heavily from the TransactionSearch.php file that Paypal supply with the API.
My concern is that at the moment, I'm fetching every transaction from the account (even ones not attributed to this site) and then filtering them by matching them against an array and only displaying the ones that are stored in the DB. It would be better if I could send the array I have through to Paypal and just receive those transactions - does any body know if that is possible?
The system works as is but I would prefer to make it more efficient if possible.
Thanks
I'd say a foreach with the GetTransactionDetails API should do the trick?
https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_nvp_r_GetTransactionDetails

Categories