#BruceWayne
1 messages · Page 1 of 1 (latest)
Hi there, how can I help?
Here is my complete code please help me to check
Like I mentioned just now, you can give me an example of monitoring the refund, and I will follow your example
I'm not sure if the code is collapsed or incomplete, because I saw nothing for `refundEvent.status== 'suceeded')
So this is used to monitor the success of the refund, right?
I still don't have the details of your implementation so I can't really comment more.
I want to use the above code to listen for refund success, and then handle some logic. I'm wondering if my code can successfully listen for refund success?
I can see that you only listen to charge.refund.update, and you didn't listen to charge.refunded.
charge.refund.updated will be fired if there's an update. If there's no update (i.e., a refund is succeeded immediately upon creation), then this event won't be fired.
I see. Do you have a complete code to monitor the successful refund for our reference?
No I don't have.
When I listen to charge.refunded, the refund will be sent as soon as it is created, and the refund object cannot be converted. This means I can't convert the refund object
When charge.refunded happens. You can get the refund list from the charge object (https://stripe.com/docs/api/charges/object#charge_object-refunds) and check the refund status.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
I just asked the developer, and he said that he has monitored the success of the refund. Is this wrong?
I don't think your developer took my advice in.
Let me write a pseudocode, perhpas tha'ts easier for your developer to understand.
Ok
if (event.type == 'charge.refunded') {
// need to expand the refunds field because it's not included. by default
const charge = stripe.charges.retrieve(event.data.charge.id, expand=['refunds']
// get refunds from charge object
const refund = charge.refunds[0]
if (refund.status == 'succeeded') {
// refund is succeeded
}
} else if (event.type == 'charge.refund.updated') {
const refund = event.data.refund
if (refund.status == 'succeeded') {
// refund is succeeded
}
}```
The complete refund logic is like this. First, the refund will be successful immediately, that is refunded.
After the refund is successful, the customer's bank card cannot receive the refund amount, or the bank card is frozen. Then updated will be updated.
If the refund is successful and the refund amount has reached the customer's bank card, it will not trigger updated
Right?
No
A successful refund creation means that the refund request has been created successfully. (i.e., when you get a charge.refunded event), but the refund may not may not completed immediately.
If the refund is completed immediately, you'll expect charge.refunds[0].status == succeeded.
If the refund is not completed immediately, the refund status will be pending. And you'll receive its update through charge.refund.updated events
Wait me a moment
refund The refund object cannot be converted here, and processing cannot continue
May I ask which object should be converted here to obtain object information?
obj is null, and the refund object cannot be converted. The latter said that the refund type should not be converted here. If you are happy, then you need to tell me to convert to that type of object, and I will continue to process
However, if you listen to Updated, the conversion can be successful here.
@barren pebble
{<Stripe.Charge@42799128 id=py_3NN9URILBklWVE7i17Nskfst> JSON: { "id": "py_3NN9URILBklWVE7i17Nskfst", "object": "charge", "amount": 1500, "amount_captured": 1500, "amount_refunded": 500, "application": null, "application_fee": null, "application_fee_amount": null, "authorization_code": null, "balance_transaction": "txn_3NN9URILBklWVE7i1BBsCl3S", "billing_details": { "address": { "city": null, "country": "JP", "line1": "1", "line2": "213", "postal_code": "23", "state": "福井県" }, "email": "panjonsen@foxmail.com", "name": "pan js", "phone": null }, "calculated_statement_descriptor": null, "captured": true, "created": 1687763141, "currency": "usd", "customer": null, "description": null, "destination": null, "dispute": null, "disputed": false, "failure_balance_transaction": null, "failure_code": null, "failure_message": null, "fraud_details": { "stripe_report": null, "user_report": null }, "invoice": null, "level3": null, "livemode": false, "metadata": {}, "on_behalf_of": null, "outcome": { "network_status": "approved_by_network", "reason": null, "risk_level": "not_assessed", "risk_score": 0, "rule": null, "seller_message": "Payment complete.", "type": "authorized" }, "paid": true, "payment_intent": "pi_3NN9URILBklWVE7i1ONWZCwv", "payment_method": "pm_1NN9URILBklWVE7iS6ULYhsa", "payment_method_details": { "ach_credit_transfer": null, "ach_debit": null, "acss_debit": null, "affirm": null, "afterpay_clearpay": null, "alipay": { "buyer_id": null, "fingerprint": null, "transaction_id": null }, "au_becs_debit": null, "bacs_debit": null, "bancontact": null, "blik": null, "boleto": null, "card": null, "card_present": null, "cashapp": null, "customer_balance": null, "eps": null, "fpx": null, "giropay": null, "grabpay": null, "ideal": null, "interac_present": null, "klarna": null, "konbini": null, "link": null, "multibanco": null, "oxxo": null, "p24": null, "paynow": null, "paypal": null, "pix": null, "promptpay": null, "sepa_debit": null, "sofort": null, "stripe_account": null, "type": "alipay", "us_bank_account": null, "wechat": null, "wechat_pay": null, "zip": null }, "radar_options": null, "receipt_email": null, "receipt_number": null, "receipt_url": "https://pay.stripe.com/receipts/payment/CAcaFwoVYWNjdF8xTjZSWExJTEJrbFdWRTdpKNPx5KQGMgba4gA3RY46LBbqgtgGMkzP_1-3rZiZjNcbYAaKewOwvQuPMRcd7ykWySzu_LsYD4M-nSFc", "refunded": false, "refunds": null, "review": null, "shipping": null, "source": null, "source_transfer": null, "statement_descriptor": null, "statement_descriptor_suffix": null, "status": "succeeded", "transfer": null, "transfer_data": null, "transfer_group": null}}
Hmm. I thought I've told you in the very begining that charge.refunded event data type is charge, not refund ?
The key is here, the object cannot be converted, and in the C# SDK, the conversion cannot be successful
You can't cover the data to an incorrect type.
I can get the object through this monitoring, but what type of object does the object in it correspond to the type of object in the SDK?
I don't know this, so I said, I can't convert
Does your engineer understand the psydocode that I sent earlier?
btw if you prefer to communicate in other language than English, you can reach out to our support at https://support.stripe.com/contact/email You can ask your engineer to write in the language that they prefer and our Support will rely in the same language.
btw if you prefer to communicate in other language than English, you can reach out to our support at https://support.stripe.com/contact/email You can ask your engineer to write in the language that they prefer and our Support will rely in the same language.
Find help and support for Stripe. Our support center provides answers on all types of situations, including account information, charges and refunds, and subscriptions information. Get your questions answered and find international support for Stripe.
if (event.type == 'charge.refunded') {
// need to expand the refunds field because it's not included. by default
const charge = stripe.charges.retrieve(event.data.charge.id, expand=['refunds']
// get refunds from charge object
const refund = charge.refunds[0]
if (refund.status == 'succeeded') {
// refund is succeeded It is also marked as a successful refund
}
} else if (event.type == 'charge.refund.updated') {
const refund = event.data.refund
if (refund.status == 'succeeded') {
// refund is succeeded It is also marked as a successful refund
}
}```
I will receive these two now, so which one shall prevail? If the first one is used, which one shall be used for the conversion object?
The code currently written is that both states are marking success, but I tested that both of them will be received
These are two different events so I don't see they prevail one another.
If my explanation isn't clear, you can ask your engineer to read through this doc again https://stripe.com/docs/refunds
I went to online support and he can only support me in English. . . .
https://support.stripe.com/contact/email you can email to support through this link
Find help and support for Stripe. Our support center provides answers on all types of situations, including account information, charges and refunds, and subscriptions information. Get your questions answered and find international support for Stripe.
We read the documentation, but the developers still don't know which one will determine whether the refund is successful or not
We talked about this many times. You shouldn't just rely one event to determined if the refund is succeeded, you should listen to both events as I explained before.
The developer explained that the object cannot be converted when he listens to refunded, so I should tell him that there is no need to convert the object here? When we initiate a refund, we should follow: When a recharge refund occurs. You can get a list of refunds and check the refund status from Charge Objects (https://stripe.com/docs/api/charges/object#charge_object-refunds).
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
We should get the list of refunds to check the refund status, instead of talking about what objects are converted to check whether the refund is successful, am I right?
Yes you are right, and that's exactly what I wrote in the pseudocode.
If you don’t convert it, can you take the information in it by yourself? Then there is a problem with this sdk
There is a session object for creating an order, and there is a refund object for update. When this is reached, it will be gone. Not quite right
When it comes to refunded, there is no object? Need to get the information from the refund list to judge the status of the refund?
I still don't understand when you want to convert a charge to refund, you should get the refunds from the charge object, not covert a charge object to a refund object.
The developer thinks that everything will use webhooks to tell him the result, but when it comes time to refund, there is no webhook to tell him the status of the refund, but he needs to go to the refund list to get the information, which is very strange
I see. I hope that the refund webhook can be more straightforward, I'll take your feedback in and pass along to the relevant team.
what charge? Charges for refunding customers?
The Charge object represents a single attempt to move money into your Stripe account. So it's the amont the customer paid to you.
And it contains two properties called refunded and amount_refunded, which tells you if the charge was refunded or not and by how much
You can learn more about the charge object here: https://stripe.com/docs/api/charges
Does it mean the refund is successful when there is a fee? Then it is not easy to judge whether the refund is successful in the end? Assume that I got charge.refunded, and then I treated it as a customer as a successful refund, but after a long time, an updated message was sent, telling me that the refund failed? At this time, it is revised to refund failure again? Success and failure? seems unreasonable
Fees have nothing to do with a refund. To keep track of refunds status, here's what we recommend:
- Listen to
charge.refundedand mark the refund as successful - Also listen to
charge.refund.updatedand update the refund status accordingly (in case the status change from successful to failed, which may happen sometimes)
Developers have been baffled by this, how to listen to charge.refunded and mark the refund as successful? He listened, but he doesn't know what parameters are the refund success?
we are back to square one
What do you mean by
but he doesn't know what parameters are the refund success?
There's no parameters to check, if you get a charge.refunded event, then the refund was successful.
The developer listens to refunded, and once the charge.refunded event is received, the refund is successful. Is it right?
If the customer's bank card is frozen after the refund is successful, and the refund funds are returned to my stripe, then the refund will fail, and updated will notify me through webhook, right?
The developer listens to refunded, and once the charge.refunded event is received, the refund is successful. Is it right?
Yes
If the customer's bank card is frozen after the refund is successful, and the refund funds are returned to my stripe, then the refund will fail, and updated will notify me through webhook, right?
Yes, withcharge.refund.updated
What should I do if I receive updated? Or rather, I need to privately issue refunds to customers, right? Instead of giving refunds through API to continue refunding
At this point my developers don't need to do anything. I need to refund the customer by other means
That's completely up to you. But yes it would make sense to try to contact the user to explain the refund failed and see what can be done to solve this.
Got it, thanks for your help