paymentlib/remote/
payment_remote.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
use common::remote::{post, services};
use hyper::HeaderMap;
use uuid::Uuid;

use crate::dto::payment_request::PaymentRequest;
use crate::dto::payment_response::PaymentResponse;

pub fn create_payment(headers: HeaderMap, dto: PaymentRequest) -> Result<PaymentResponse, String> {
    post::<_, PaymentResponse>(
        services::PAYMENT_API,
        String::from("/payment"),
        headers,
        dto,
    )
}

pub fn refund(headers: HeaderMap, id: Uuid) -> Result<PaymentResponse, String> {
    post(
        services::PAYMENT_API,
        format!("/payment/refund/{}", id),
        headers,
        "",
    )
}

pub fn refund_credit(headers: HeaderMap, id: Uuid) -> Result<PaymentResponse, String> {
    post(
        services::PAYMENT_API,
        format!("/payment/refundCredit/{}", id),
        headers,
        "",
    )
}