Skip to content

Commit 97e4eeb

Browse files
committed
feat(customer) added support for deactivating customer authorization
1 parent 1ef6ecc commit 97e4eeb

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

src/endpoints/customers.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,4 +201,31 @@ impl<T: HttpClient + Default> CustomersEndpoints<T> {
201201
Err(e) => Err(PaystackAPIError::Customer(e.to_string())),
202202
}
203203
}
204+
205+
/// Deactivate an authorization when the card needs to be forgotten
206+
///
207+
/// It takes the following parameters:
208+
/// - `authorization_code`: Authorization code to be deactivated.
209+
pub async fn deactivate_authorization(
210+
&self,
211+
authorization_code: String,
212+
) -> PaystackResult<PhantomData<String>> {
213+
let url = format!("{}/authorization/deactivate", self.base_url);
214+
let body = json!({
215+
"authorization_code": authorization_code
216+
});
217+
218+
let response = self.http.post(&url, &self.key, &body).await;
219+
220+
match response {
221+
Ok(response) => {
222+
let parsed_response: Response<PhantomData<String>> =
223+
serde_json::from_str(&response)
224+
.map_err(|e| PaystackAPIError::Customer(e.to_string()))?;
225+
226+
Ok(parsed_response)
227+
}
228+
Err(e) => Err(PaystackAPIError::Customer(e.to_string())),
229+
}
230+
}
204231
}

tests/api/customer.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,3 +282,5 @@ async fn can_blacklist_and_whitelist_a_customer() {
282282
assert!(res.message.contains("Customer updated"));
283283
assert_eq!(res.data.unwrap().risk_action, Some(RiskAction::Default));
284284
}
285+
286+
// TODO: make test for dea

0 commit comments

Comments
 (0)