-
Notifications
You must be signed in to change notification settings - Fork 206
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
Fix intermittent PDT issues #245
base: master
Are you sure you want to change the base?
Conversation
The rest of the data will come from the postback
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry it has taken me so long to look at this, see my question below.
class PayPalPDTCallbackForm(forms.ModelForm): | ||
class Meta: | ||
model = PayPalPDT | ||
fields = ['amt', 'cm', 'tx', 'st'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I've read it correctly, the only piece of information that we use is tx
(looking at PayPalPDT._postback()
. Do you agree, if so, should we make that the only field? Are all the other fields set from the postback call? My reading of the PayPal docs suggests that it is actually just the transaction ID we are looking for at this point.
(Please forgive my ignorance, I've only ever personally used IPN)
It would be great, either way, if we could have a reason for the specific set of fields included here, and a comment on PayPalPDTCallbackForm
that explained its purpose.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't remember my logic, but I assume I chose these four to match the PDT-specific fields here:
django-paypal/paypal/standard/pdt/models.py
Lines 33 to 37 in 9c75afe
amt = models.DecimalField(max_digits=64, decimal_places=2, default=0, blank=True, null=True) | |
cm = models.CharField(max_length=255, blank=True) | |
sig = models.CharField(max_length=255, blank=True) | |
tx = models.CharField(max_length=255, blank=True) | |
st = models.CharField(max_length=32, blank=True) |
I suspect I omitted sig
because it doesn't appear in either the old-style or new-style query parameters.
As you say, tx
is the only field used explicitly, but the others are saved to the instance, and I wanted to avoid introducing any changes in behaviour in this PR.
Having said all that, I'm not convinced that PayPalPDT
needs these custom fields at all — all the interesting information comes from the postback and is saved to fields defined in PayPalStandardBase
.
Fixes issue #239.
Rather than use the same form for both the PDT callback and the postback, split these apart. We'll take a minimal set of parameters from the callback, and fill in rest using the postback endpoint.
I've included a test which includes the full set of query parameters I'm seeing on most (but not all) PDT callback requests. Note
payment_date
is in ISO format in these requests, andnotify_version
is a string. With this PR both these parameters will be ignored.