1use reqwest::Method;
2
3use crate::client::Client;
4use crate::error::Error;
5use crate::types::{
6 BillingChargeCreateRequest, BillingChargeDetailResponse, BillingChargeOneStepRequest,
7 BillingChargePayRequest, BillingChargeResponse, BillingNotificationResponse,
8};
9
10impl Client {
11 pub async fn billing_charge_create(
12 &self,
13 payload: &BillingChargeCreateRequest,
14 ) -> Result<BillingChargeResponse, Error> {
15 self.send_authenticated_billing(Method::POST, "/v1/charge", Some(payload))
16 .await
17 }
18
19 pub async fn billing_charge_one_step(
20 &self,
21 payload: &BillingChargeOneStepRequest,
22 ) -> Result<BillingChargeResponse, Error> {
23 self.send_authenticated_billing(Method::POST, "/v1/charge/one-step", Some(payload))
24 .await
25 }
26
27 pub async fn billing_charge_pay(
28 &self,
29 charge_id: i64,
30 payload: &BillingChargePayRequest,
31 ) -> Result<BillingChargeResponse, Error> {
32 let path = format!("/v1/charge/{charge_id}/pay");
33 self.send_authenticated_billing(Method::POST, &path, Some(payload))
34 .await
35 }
36
37 pub async fn billing_charge_get(
38 &self,
39 charge_id: i64,
40 ) -> Result<BillingChargeDetailResponse, Error> {
41 let path = format!("/v1/charge/{charge_id}");
42 self.send_authenticated_billing::<serde_json::Value, BillingChargeDetailResponse>(
43 Method::GET,
44 &path,
45 None,
46 )
47 .await
48 }
49
50 pub async fn billing_notification_get(
51 &self,
52 token: &str,
53 ) -> Result<BillingNotificationResponse, Error> {
54 let path = format!("/v1/notification/{token}");
55 self.send_authenticated_billing::<serde_json::Value, BillingNotificationResponse>(
56 Method::GET,
57 &path,
58 None,
59 )
60 .await
61 }
62}