Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom data got truncated #257

Open
PetrDlouhy opened this issue May 3, 2022 · 4 comments
Open

Custom data got truncated #257

PetrDlouhy opened this issue May 3, 2022 · 4 comments

Comments

@PetrDlouhy
Copy link

Recently I have got 4 payments where the IPN returned with truncated custom field.
I did create the (unencrypted) form with data like:

 'custom': '{"user_plan_id": 310606, "plan_id": 1, "pricing_id": 1, "first_order_id": 43102, "user_email": "xxxxx@gmail.com"}

But i am receiving IPN with only ...&custom={&... in URL, so I can't pair the payment with the data in DB.

This would probably be error on side of PayPal, but also can be caused by some interaction with the form in browser on user's side (but it happened for 4 different users).
I am creating this issue mainly because I want to ask if somebody has similar experience.

@spookylukey
Copy link
Owner

spookylukey commented May 3, 2022

I would not be at all surprised if PayPal mangled data like that. I would recommend doing base64 encoding to reduce the chances of your data getting mangled. You will still need to be careful of data length - don't expect PayPal to allow you to store much, or to be correct in what it advertises as the maximum length.

In general, see if you can reduce the amount of data in your custom field, which can be done using, for example, a single user ID or creating an "Orders" table, putting the data in there and sending only the order id in the custom field.

@PetrDlouhy
Copy link
Author

@spookylukey Thank you very much for your reply. I will consider what you are writing.

But length or something in the custom string is not the problem here. Tens or hundreds of payments did pass just OK in few recent months I have been using this type of payment. There have been longer custon data strings than those that didn't pass and also there is nothing special in them (special characters etc.).

This problem did occur just in the last month only for few payments out of many.

@spookylukey
Copy link
Owner

This problem did occur just in the last month only for few payments out of many.

That sounds about normal. There have been many such instances of PayPal's stuff mostly working, but just not working sometimes.

@PetrDlouhy
Copy link
Author

When I originally implemented the custom field logic, I taught, it would be better to store more values for cases when I will need to identify some payment.
I didn't think much about the length of that field, but according to documentation it is 255 characters, which I am far from reaching. Even my tests on sandbox don't show any problems with longer with long custom values, and if the 255 limit is reached, the payment would fail sooner, before it's creation.

In fact I only really need the Order ID, but PayPal leaves me only one character in the faulty cases, so I can't work with that.

Now I will try to use item_number field as fallback to store Order ID: PetrDlouhy/django-plans-paypal@ca29ab3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants