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

application/json vs application/x-www-form-urlencoded #282

Open
basictheprogram opened this issue Aug 22, 2023 · 0 comments
Open

application/json vs application/x-www-form-urlencoded #282

basictheprogram opened this issue Aug 22, 2023 · 0 comments

Comments

@basictheprogram
Copy link

Using the Webhooks simulator in 2023-Aug it looks like a events Content-type are application/json. This code will not work

    # Avoid the RawPostDataException. See original issue for details:
    # https://github.com/spookylukey/django-paypal/issues/79
    if not request.META.get("CONTENT_TYPE", "").startswith("application/x-www-form-urlencoded"):
        raise AssertionError(CONTENT_TYPE_ERROR)

Example from the Webhook simulator

{
  "id": "WH-4YP718828D2768154-96229356YL4818534",
  "create_time": "2015-10-07T16:45:17Z",
  "resource_type": "sale",
  "event_type": "PAYMENT.SALE.DENIED",
  "summary": "A EUR 17.47 EUR sale payment was denied",
  "resource": {
    "parent_payment": "PAY-9SM48294F4717633YKYKUXNQ",
    "update_time": "2015-10-07T16:43:35Z",
    "amount": {
      "total": "17.47",
      "currency": "EUR"
    },
    "payment_mode": "INSTANT_TRANSFER",
    "create_time": "2015-10-07T16:43:35Z",
    "protection_eligibility": "INELIGIBLE",
    "links": [
      {
        "href": "https://api.paypal.com/v1/payments/sale/0UV619993K905211J",
        "rel": "self",
        "method": "GET"
      },
      {
        "href": "https://api.paypal.com/v1/payments/sale/0UV619993K905211J/refund",
        "rel": "refund",
        "method": "POST"
      },
      {
        "href": "https://api.paypal.com/v1/payments/payment/PAY-9SM48294F4717633YKYKUXNQ",
        "rel": "parent_payment",
        "method": "GET"
      }
    ],
    "id": "0UV619993K905211J",
    "state": "denied"
  },
  "links": [
    {
      "href": "https://api.paypal.com/v1/notifications/webhooks-events/WH-4YP718828D2768154-96229356YL4818534",
      "rel": "self",
      "method": "GET",
      "encType": "application/json"
    },
    {
      "href": "https://api.paypal.com/v1/notifications/webhooks-events/WH-4YP718828D2768154-96229356YL4818534/resend",
      "rel": "resend",
      "method": "POST",
      "encType": "application/json"
    }
  ],
  "event_version": "1.0"
}```
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

1 participant