-
Notifications
You must be signed in to change notification settings - Fork 88
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
Example of using CheckoutSession flow? #85
Comments
Yes, on further reading, stripe is suppose to return this |
I've fidgeted with it a bit, and slightly more convinced it's just not possible with the current API. I am willing to work on a PR for this |
Hi @milesgranger. It looks like the code generation didn't automatically generate corresponding methods for this because it's path is a bit unusual compared to other Stripe api resources. The request path is two segments long (e.g.
let post_request = &request["post"];
// ...
if segments.len() == 1 {
if !doc_comment.contains("Create") && !doc_comment.contains("create") {
continue; // skip requests which don't appear to be `create` for now
}
// ...
} I'd recommend one of two paths towards getting this implemented: Easy PathIn the easy path, we'd hand code the methods that don't get automatically generated. We do this by adding a A good reference for this is The general structure might be: /// The parameters for `CheckoutSession::create`.
///
/// For more details see [DOCS_URL](DOCS_URL).
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct CreateCheckoutSession<'a> {
// ... Whatever the parameters are ...
}
impl CheckoutSession {
/// <DESCRIPTION OF WHAT THIS FUNCTION DOES>
///
/// For more details see [DOCS_URL](DOCS_URL).
pub fn create(
client: &Client,
params: CreateCheckoutSession<'_
) -> Response<CheckoutSession> {
client.post_form("/checkout/session", ¶ms)
}
} You may need to end up needing to implement methods for most of the "Checkout" api that you want to use, because most of it doesn't look auto-generated. Longer PathThe more-effort path would be to explore the The benefit of that is it might implement other methods you'll need to use Stripe's "Checkout" apis and is generally less prone to human error. |
Closing now that async-stripe in the de-facto successor. There is an example in there. https://github.com/arlyon/async-stripe/blob/master/examples/checkout.rs |
Hello there, and thanks for this lib! 💯
I've been trying for a while now to use the
CheckoutSession
client-server checkout flow.I've got a
/create-session
route, creates thestripe::CheckoutSession
and posts this tohttps://api.stripe.com/v1/checkout/sessions
before returning thesessionID
to the client.However this seems wrong, as in their examples it seems I'm not the one suppose to be creating the
id
(here thestripe::CheckoutSessionId
) but stripe will and this is what I send in thestripe.redirectToCheckout(sessionId...)
in the client.Pretty certain I'm simply going down the wrong path, so in short, any example would be highly appreciated. 👍
The text was updated successfully, but these errors were encountered: