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

PDT payments intermittently broken? #239

Open
djw opened this issue May 15, 2021 · 4 comments
Open

PDT payments intermittently broken? #239

djw opened this issue May 15, 2021 · 4 comments

Comments

@djw
Copy link
Contributor

djw commented May 15, 2021

In some recent requests on my site the query parameters passed to the return_url have changed, in a way that's incompatible with the current implementation of PayPalPDTForm.

Specifically, I'm now receiving:

  1. notify_version=UNVERSIONED which is incompatible with the decimal type of the underlying model field
  2. payment_date=2021-05-11T12:00:00Z which is incompatible with PayPalDateTimeField

Tweaking the form like this works fine locally with Django 3.1 — when I get a moment I'll create a proper patch with a test case.

class PayPalPDTForm(PayPalStandardBaseForm):
    payment_date = DateTimeField(required=False)

    class Meta:
        model = PayPalPDT
        exclude = [
            "ipaddress",
            "flag",
            "flag_code",
            "flag_info",
            "query",
            "response",
            "created_at",
            "updated",
            "form_view",
            "notify_version",
        ]

Edit: I originally thought this was related to v1.1 due to the timing of the issue, but even after I reverted I'm still seeing some requests arrive with the new parameters. Looking at the code I can't see how changing the postback endpoint would cause this issue anyway!

@djw djw changed the title PDT payments broken in v1.1 PDT payments intermittently broken? May 15, 2021
@spookylukey
Copy link
Owner

Based on what you've said, it looks like we're going to have to be compatible with all the different things they might be sending. If you can post examples of different things you are seeing that would really help. A patch that fixes the issues would also be a huge help. Thanks so much!

@djw
Copy link
Contributor Author

djw commented May 28, 2021

I've been running this branch for the last week or so without any issues, but it's a bit hacky to push upstream:

master...djw:return-query-changes

Given that payment_date is now arriving in ISO format in the query parameters, but still in PayPalDateTimeField format in the postback response, I think the options are:

  1. Extend PayPalDateTimeField to support ISO format (perhaps requiring a dependency on python-dateutil)
  2. Use separate form classes to handle query parameters and the postback response, and probably ignore all the new parameters, including the ISO format date.

I lean towards the second option, but would like your opinion before working on a patch. :)

@spookylukey
Copy link
Owner

Your second option sounds fine if you feel like working on a patch. Thanks!

@djw
Copy link
Contributor Author

djw commented Nov 6, 2021

Apologies for the delay, I've created a new branch which implements the fix following Option 2 above:

master...djw:issue-329

I'll test this out for a few days and then submit a PR.

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