#data-paymentintent-refund
1 messages ยท Page 1 of 1 (latest)
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
So how do I alter this: var service = new PaymentIntentService();
service.Capture("pi_3NIEDSEVoNb8mE921NTyCQEx");
To include the amount that I want to capture AND the account ID that it is associated with?
Does this look right?
var service = new PaymentIntentService();
var options = new CaptureOptions
{
AmountToCapture = 2000, // Custom amount in cents (e.g., $20.00)
TransferData = new PaymentIntentTransferDataOptions
{
Destination = "acct_1234567890", // Replace with your account ID
}
};
service.Capture("pi_3NIEDSEVoNb8mE921NTyCQEx", options);
Testing now
question when this line executes above:
service.Capture(paymentIntentID, options);
Does that return the status of what happened?
Also im getting this: "Received unknown parameter: transfer_data[destination]"}
Can you send the request id?
How do I get that
That is my code and its hitting the catch with the exception pasted above
Hi ๐
I'm stepping in as @fringe iron needs to go soon. Here's how you can find a request ID: https://support.stripe.com/questions/finding-the-id-for-an-api-request
Also only amount is valid within transfer data for the capture endpoint. See our docs: https://stripe.com/docs/api/payment_intents/capture#capture_payment_intent-transfer_data
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Hmm maybe I am doing it wrong then. I am using standard accounts - I have the account ID of which the money needs to be captured. The current status of the payment intent ID is requires_capture and I would like to capture a specific amount from the payment how should I go about doing this are there any code examples that include the capture amount as well as the account ID that it needs
Our docs show an esample of this here: https://stripe.com/docs/payments/place-a-hold-on-a-payment-method#capture-funds
But any funds that remain after your capture attempt will be automatically refunded to the customer
Great ๐ Happy to help ๐
Question
How do I do that exact thing just with refunding
Do you have a link to that as well
What do you mean? Just generate a refund instead of capturing any funds?
No after you capture funds - you can then refund if needed
Lets say you have a payment hold of $100 and you capture $50 of it
Then you want to refund $25 of the $50 that was captured
No the refund is automatic
For any funds you didn't capture
It's covered in the document I linked
Yeah I know that
But you can then refund the amount you captured
"Lets say you have a payment hold of $100 and you capture $50 of it
Then you want to refund $25 of the $50 that was captured"
Sure we have a doc on refunds here: https://stripe.com/docs/refunds
And the API document here: https://stripe.com/docs/api/refunds
You need to pass the Charge, like we show here: https://stripe.com/docs/api/refunds/create?lang=dotnet
You cant refund using a payment intent ID?
The API expects a Charge ID
data-paymentintent-refund
it's right there in our docs
https://github.com/stripe/stripe-dotnet/blob/master/src/Stripe.net/Services/Refunds/RefundCreateOptions.cs#L55 right there in stripe-dotnet
Seems to be an issue with your IDE and the way you configured stripe-dotnet locally on your machine, but it definitely works in the API and the library
Then why is it saying no definition of PaymentIntent in RefundCreateOptions
I am on an older version but I need to be on that version.
Then you need to figure out how this worked in your old version in that case
Is there documentation on that?
No we don't have documentation for old versions of the library. Which exact version are you on?
I understand but what youy need to do is try!
Download that exact version and look at the code to see what's in it. It takes a few seconds really
I just did it myself. Download the version from https://github.com/stripe/stripe-dotnet/releases/tag/v29.4.0 unzip it look at RefundCreateOptions and see "oh it's called ChargeId"
that version is multiple years old, it's normal that it doesn't support any of the new features
We made a lot of changes in our library over the years, especially renaming a lot of properties and classes to be consistent across all APIs. If you are on that old version you will have to regularly look up the source code to find the parameters/properties you need as they won't match what our docs explain.
okay gotcha thank you.
What is the best way to get the charge ID from a payment intent?
does this look right?
var service2 = new PaymentIntentService();
var paymentIntent = service2.Get(paymentIntentID);
// Access the latest Charge ID
string latestChargeId = paymentIntent.Charges.Data[0].Id;
yes
You can also use AddExtraParam which would be easier
var options = new RefundCreateOptions
{
};
options.AddExtraParam("payment_intent", "pi_123");
var service = new RefundService();
service.Create(options);```
that lets you pass parameters not yet supported in your library
yes because our API supports both options
Is it: options.AddExtraParam("payment_intent", paymentIntentID); or options.AddExtraParam("PaymentIntent", paymentIntentID);
Just asking because in the refundcreateoptions its PaymentIntent = ....
it's what I wrote exactly
aweosme thank you so much!
when you use AddExtraParam, you have to use the exact path our API would
That is so useful to know that the addextraparam works on old versions
but really you need to figure out how to upgrade as soon as possible