#mtalhaabbas-connect-disputes
1 messages · Page 1 of 1 (latest)
Taking a look now
Can you share the evt_xxx of the webhook you're referring to?
It's not immediately clear what you're trying to do. Reverse the transfer to the connected account?
So from that event you want to be able to reverse the transfer but there's no reference to it on the event payload. Correct?
So you'd need to retrieve the Charge object using the ch_xxx ID in the event payload, and expanding the transfer field on the Charge object
That will give you the tr_xxx ID you need to reverse: https://stripe.com/docs/connect/charges-transfers#reversing-transfers
ok, I will try and let you know
I guess that's code in your webhook handler that attempts to verify the signature of the webhook event: https://stripe.com/docs/webhooks/signatures
@csrf_exempt
def stripe_webhook_view(request):
stripe.api_key = settings.STRIPE_SECRET_KEY
endpoint_secret = settings.STRIPE_ENDPOINT_SECRET
payload = request.body
sig_header = request.META['HTTP_STRIPE_SIGNATURE']
event = None
try:
event = stripe.Webhook.construct_event(
payload, sig_header, endpoint_secret
)
except ValueError as e:
# Invalid payload
return HttpResponse("Invalid payload",status=400)
except stripe.error.SignatureVerificationError as e:
# Invalid signature
return HttpResponse("Invalid signature",status=400)
# Fetch all the required data from sessionif event['type'] == 'checkout.session.completed': session = event['data']['object'] elif event['type'] == 'invoice.created': invoice = event['data']['object'] elif event['type'] == 'invoice.paid': invoice = event['data']['object'] period = invoice.get('period_end') print("paid invoice",period) elif event['type'] == 'charge.dispute.created': dispute = event['data']['object'] charge=dispute.get("charge") ch=stripe.Charge.retrieve(charge) reveral=stripe.Transfer.create_reversal( ch.transfer, amount=ch.transfer_data.amount ) else: print('Unhandled event type {}'.format(event['type'])) return HttpResponse(status=200)
@hazy zealot can you check it?
Is your endpoint_secret the correct webhook secret from your Dashboard?
yes I have checked
it's working with CLI but not working with API
as you can see, it's working fine with CLI
The secret from the CLI will be different from the one from your real Dashboard webhook
Can you share an evt_xxx?
You don't need to @ me every time 😛
ok
Are you using the signing secret from here https://dashboard.stripe.com/test/webhooks/we_1LIpAOG0wc579BByqcEk3jCH ?
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
In your webhook handler (endpoint_secret)
I'm not sure then. You need to work on debugging that locally as your code is failing when trying to verify the signature
I have checked and not found any mistake
can you please check?
I have shared the code screenshot with youi
Your code looks fine. As stated, I expect your endpoint_secret is the wrong value that does not match the value used to sign the event for that specific webhook
No, that's the webhook ID. The secret is at the URL I shared above:
okay, Thanks for confirmation
I will try and let you know
I'm getting an Attribute error when I'm trying to use singing secret
can you create endpoint_secret for me?
please
@hazy zealot
Hi! I'm taking over this thread.