wyyerd / stripe-rs

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

PaymentIntent::create `payment_method_types` does not send data in a correct format to stripe api. #207

Closed kushwahashiv closed 2 years ago

kushwahashiv commented 2 years ago

PaymentIntent::create payment_method_types does not send data in a correct format to stripe api.

when i send


async fn create_payment_intent(&self, input: NewPaymentIntent) -> Result<PaymentIntent, Error> {
    let mut params = CreatePaymentIntent::new(input.amount, input.currency);
    params.payment_method_types =  vec![PaymentIntentMethodType::Card];
    params.capture_method = input.capture_method
    params.customer = input.customer_id;
    params.source = input.source;
    params.description = input.description;
    params.shipping = input.shipping;

    PaymentIntent::create(&self.client, params).await.map_err(From::from)
  }

in above code params.payment_method_types is of Vec<PaymentIntentMethodType> type and when I assign vec![PaymentIntentMethodType::Card] it sends on stripe side below

| POST /v1/payment_intents

{
  "payment_method_types": {
    "0": "card"
  },
 ...
}

instead of

{
  "payment_method_types": [
    "card"
  ],
 ....
}

what I'm missing here?

/Shiv

kushwahashiv commented 2 years ago

I was missing confirm attribute in the param.