wyyerd / stripe-rs

Rust API bindings for the Stripe HTTP API.
Apache License 2.0
219 stars 88 forks source link

FeatureRequest: self_service_portal #132

Open ruseinov opened 4 years ago

ruseinov commented 4 years ago

Add support for https://stripe.com/docs/api/self_service_portal.

Similar to https://stripe.com/docs/billing/subscriptions/integrating-self-serve-portal#redirect

ruseinov commented 4 years ago

I have implemented this directly in my application in a very minimal fashion, looks similar to this:

#[derive(Serialize)]
struct BillingPortalParams {
    pub customer: String,
    pub return_url: String,
}

#[derive(Deserialize)]
struct BillingPortalResponse {
    pub url: String,
}

    let resp: BillingPortalResponse = stripe_client
        .post_form(
            "/billing_portal/sessions",
            &BillingPortalParams {
                customer: ...,
                return_url: ...,
            },
        )
        .await?;

    Ok(HttpResponse::Found()
        .header(LOCATION, resp.url)
        .finish()
        .into_body())
manonthemat commented 4 years ago

Thank you for opening the issue and posting your solution. I am also looking to offer my customers to use the self service portal.