From 3444bd3480b8af586c95119f8349c114b810c4b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frank=20Pr=C3=B6=C3=9Fdorf?= Date: Fri, 29 Apr 2022 08:35:06 +0300 Subject: [PATCH] Add idempotency key to headers --- src/client/async.rs | 6 ++++++ src/params.rs | 1 + 2 files changed, 7 insertions(+) diff --git a/src/client/async.rs b/src/client/async.rs index 8f59c5a2..03dca9ed 100644 --- a/src/client/async.rs +++ b/src/client/async.rs @@ -205,6 +205,12 @@ impl Client { HeaderValue::from_str(account).unwrap(), ); } + if let Some(key) = &self.headers.idempotency_key { + headers.insert( + HeaderName::from_static("idempotency-key"), + HeaderValue::from_str(key).unwrap(), + ); + } if let Some(client_id) = &self.headers.client_id { headers.insert( HeaderName::from_static("client-id"), diff --git a/src/params.rs b/src/params.rs index c4cac3e1..2b9ec32f 100644 --- a/src/params.rs +++ b/src/params.rs @@ -21,6 +21,7 @@ pub struct Headers { pub stripe_version: Option, pub stripe_account: Option, pub user_agent: Option, + pub idempotency_key: Option, } /// Implemented by types which represent stripe objects.