diff --git a/crates/payment_adapter_pay_u/src/lib.rs b/crates/payment_adapter_pay_u/src/lib.rs index 8b52aee..47dcf54 100644 --- a/crates/payment_adapter_pay_u/src/lib.rs +++ b/crates/payment_adapter_pay_u/src/lib.rs @@ -117,6 +117,10 @@ impl PayU { } fn create_payment(c: CreatePayment) -> Result { + eprintln!("Authorizing..."); + authorize()?; + eprintln!("Authorized!"); + let config = client(); let pay_u = config.lock().unwrap(); @@ -158,6 +162,7 @@ fn create_payment(c: CreatePayment) -> Result { description, ) .map_err(|e| { + eprintln!("{}", e); tracing::error!("{}", e); Error::MalformedCreatePayment })? @@ -172,7 +177,7 @@ fn create_payment(c: CreatePayment) -> Result { .with_notify_url(notify_uri) .with_continue_url(continue_uri); - authorize()?; + eprintln!("calling host http 'create order'!"); let res = wapc::host_call( "binding", "http:req", @@ -187,11 +192,13 @@ fn create_payment(c: CreatePayment) -> Result { .unwrap(), ) .map_err(|e| { + eprintln!("{}", e); tracing::error!("{}", e); Error::PaymentFailed }) .and_then(|v| { deserialize(&v).map_err(|e| { + eprintln!("{}", e); tracing::error!("{}", e); Error::PaymentFailed }) @@ -219,6 +226,7 @@ fn authorize() -> Result { expires_in: i64, } + eprintln!("calling host http 'authorize'!"); let res = wapc::host_call("binding", "http:req", "http_req", &serialize(HttpRequest { method: HttpMethod::Post, url: format!( @@ -230,16 +238,20 @@ fn authorize() -> Result { bearer_auth: None, body: None, }).map_err(|e| { + eprintln!("{}", e); tracing::error!("{}", e); Error::PaymentFailed })?).map_err(|e| { + eprintln!("{}", e); tracing::error!("{}", e); Error::PaymentFailed })?; let res: BearerResult = deserialize(&res).map_err(|e| { + eprintln!("{}", e); tracing::error!("{}", e); Error::PaymentFailed })?; + eprintln!("Authorized with calling host"); tracing::trace!("Bearer is {}", res.access_token); pay_u.bearer_expires_at = Utc::now() + Duration::seconds(res.expires_in); pay_u.bearer = Some(res.access_token); diff --git a/crates/payment_manager/src/main.rs b/crates/payment_manager/src/main.rs index 9b0e79b..93b489c 100644 --- a/crates/payment_manager/src/main.rs +++ b/crates/payment_manager/src/main.rs @@ -33,6 +33,7 @@ impl UpdateConfig for Opts { #[tokio::main] async fn main() { + tracing_subscriber::fmt::init(); let opts: Opts = gumdrop::parse_args_default_or_exit(); let config = config::default_load(&opts); @@ -180,11 +181,13 @@ fn http_request(req: HttpRequest) -> Result, payment_adapter::Error> { .bearer_auth(bearer) .send() .map_err(|e| { + eprintln!("{}", e); tracing::error!("{}", e); payment_adapter::Error::HttpFailed })? .text() .map_err(|e| { + eprintln!("{}", e); tracing::error!("{}", e); payment_adapter::Error::HttpFailed })?; @@ -196,11 +199,13 @@ fn http_request(req: HttpRequest) -> Result, payment_adapter::Error> { .headers(headers) .send() .map_err(|e| { + eprintln!("{}", e); tracing::error!("{}", e); payment_adapter::Error::HttpFailed })? .text() .map_err(|e| { + eprintln!("{}", e); tracing::error!("{}", e); payment_adapter::Error::HttpFailed })?; @@ -208,9 +213,7 @@ fn http_request(req: HttpRequest) -> Result, payment_adapter::Error> { } (HttpMethod::Post, Some(bearer)) => { let body = body.unwrap_or_default(); - let len = body.len(); - let body = std::io::Cursor::new(body); - let body = reqwest::blocking::Body::sized(body, len as u64); + let body = reqwest::blocking::Body::from(body); let text = client .post(url) .headers(headers) @@ -218,11 +221,13 @@ fn http_request(req: HttpRequest) -> Result, payment_adapter::Error> { .body(body) .send() .map_err(|e| { + eprintln!("{}", e); tracing::error!("{}", e); payment_adapter::Error::HttpFailed })? .text() .map_err(|e| { + eprintln!("{}", e); tracing::error!("{}", e); payment_adapter::Error::HttpFailed })?; @@ -235,11 +240,13 @@ fn http_request(req: HttpRequest) -> Result, payment_adapter::Error> { .body(body.unwrap_or_default()) .send() .map_err(|e| { + eprintln!("{}", e); tracing::error!("{}", e); payment_adapter::Error::HttpFailed })? .text() .map_err(|e| { + eprintln!("{}", e); tracing::error!("{}", e); payment_adapter::Error::HttpFailed })?;