dj-stripe: PaymentMethod event incorrect behavior
Describe the bug
I encountered a new bug related to new models (#914 ) in current master.
At least payment_method.*
-events are not working correctly with the general crud-style handling.
The payload can contain ie. card id instead of real PaymentMethod IDs and that means you can’t currently retrieve them through stripe /v1/payment_methods/:id
-api.
I also reported that to stripe (related IRC conversation: https://freenode.logbot.info/stripe/20190903#c2618918) because I think it’s bug in implementation of either the events or then the API
Anyway the current implementation indicates that we should check out all the events related to those new models if they really are doing what they supposed to. Preferably with real production environment, the data is not like in the documentation apparently.
Example event causing problems
{
"id": "evt_1FEiXXXXXXXX",
"object": "event",
"api_version": "2018-11-08",
"created": 1567541994,
"data": {
"object": {
"id": "card_1DXXXXXXXXXXX",
"object": "payment_method",
"billing_details": {
"address": {
"city": null,
"country": null,
"line1": null,
"line2": null,
"postal_code": null,
"state": null
},
"email": null,
"name": "Charles Customer",
"phone": null
},
"card": {
"brand": "visa",
"checks": {
"address_line1_check": null,
"address_postal_code_check": null,
"cvc_check": null
},
"country": "FR",
"exp_month": 8,
"exp_year": 2022,
"fingerprint": "xxxxx",
"funding": "debit",
"generated_from": null,
"last4": "2222",
"three_d_secure_usage": {
"supported": true
},
"wallet": null
},
"created": 1545493504,
"customer": "cus_ECbxxxxxxxxxx",
"livemode": true,
"metadata": {
},
"type": "card"
}
},
"livemode": true,
"pending_webhooks": 1,
"request": {
"id": "req_j9PAxxxxxxxxx",
"idempotency_key": null
},
"type": "payment_method.detached"
}
Expected behavior Events should be handled with more specific handlers.
Environment
- dj-stripe version: [e.g. master at 0298f21e456b25232a6e47199db14cee18c9cfc1]
Can you reproduce the issue with the latest version of master?
Yes
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 15 (14 by maintainers)
Commits related to this issue
- Handle special case of paymentmethod.detached with card_xxx Special case to handle a quirk in stripe's wrapping of legacy "card" objects with payment_methods - card objects are deleted on detach, so ... — committed to prismaticd/dj-stripe by therefromhere 5 years ago
- Handle special case of paymentmethod.detached with card_xxx Special case to handle a quirk in stripe's wrapping of legacy "card" objects with payment_methods - card objects are deleted on detach, so ... — committed to prismaticd/dj-stripe by therefromhere 5 years ago
- Handle special case of paymentmethod.detached with card_xxx Special case to handle a quirk in stripe's wrapping of legacy "card" objects with payment_methods - card objects are deleted on detach, so ... — committed to prismaticd/dj-stripe by therefromhere 5 years ago
- Handle special case of paymentmethod.detached with card_xxx Special case to handle a quirk in stripe's wrapping of legacy "card" objects with payment_methods - card objects are deleted on detach, so ... — committed to prismaticd/dj-stripe by therefromhere 5 years ago
- Handle special case of paymentmethod.detached with card_xxx (#1013) Special case to handle a quirk in stripe's wrapping of legacy "card" objects with payment_methods - card objects are deleted on det... — committed to dj-stripe/dj-stripe by therefromhere 5 years ago
- Implement PaymentMethod.detach() (#981) Closely modelled on Source.detach(), the difference being a) This handles the special case of legacy "card"-type PaymentMethods as per #967 b) This does a ... — committed to dj-stripe/dj-stripe by therefromhere 5 years ago
Hi @therefromhere, thanks for flagging this. As you rightly pointed out, the root cause is the card being deleted when detached… but we should be consistent or at least provide a way to identify these payment-method-compatible cards. Looking at the prefix should never be required. I’ll get back to you as soon as we ship a fix.
It would be useful to have a reference to this issue that we can refer to (deleted “card_xxx” disappears, leaving a payment method that can’t be retrieved), since it’s popping up in various other issues.
@theikkila did you get any more feedback from stripe on this, eg a ticket number or something?
@lx-stripe just pinging you as a Stripe dev that touched the SCA stuff - any idea if there’s an artifact we can link to other than the above IRC log?