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

Fix intermittent PDT issues #245

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Fix intermittent PDT issues #245

wants to merge 2 commits into from

Conversation

djw
Copy link
Contributor

@djw djw commented Nov 13, 2021

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, and notify_version is a string. With this PR both these parameters will be ignored.

Copy link
Owner

@spookylukey spookylukey left a 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']
Copy link
Owner

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.

Copy link
Contributor Author

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:

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.

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

Successfully merging this pull request may close these issues.

None yet

2 participants