Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
zrll12 committed Mar 20, 2024
1 parent f0d0835 commit d61fa3e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/service/trade/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ lazy_static! {
&WECHAT_PRIVATE,
&CONFIG.wechat.serial,
&CONFIG.wechat.key,
&"https://api.ituyou.cc/par/wechat".to_string()
&CONFIG.wechat.call_back_url,
);
}

Expand Down
7 changes: 3 additions & 4 deletions src/service/trade/wechat/recall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,15 @@ use crate::service::trade::{TradeStatus, WECHAT_PAY_CLIENT, WECHAT_PUBLIC};

pub async fn wechat_pay_recall(header_map: HeaderMap, body: String) -> Json<WechatNoticeResponse> {
let request: WechatPayNotify = serde_json::from_str(&body).unwrap();

//verify trade status
let nonce = request.resource.nonce;
let chiphertext = request.resource.ciphertext;
let associated_data = request.resource.associated_data.unwrap_or_default();
let result = WECHAT_PAY_CLIENT.decrypt_paydata(&chiphertext, &nonce, &associated_data).unwrap();
let id = result.out_trade_no.clone();
info!("Wechat pay recall: {result:?}");
let mut trade = Trade::find_by_id(id).one(&*crate::DATABASE).await.unwrap().unwrap().into_active_model();

let cert = WECHAT_PAY_CLIENT.certificates().await.unwrap();
//verify signature
if WECHAT_PAY_CLIENT.verify_signatrue(
&WECHAT_PUBLIC,
Expand All @@ -35,7 +33,8 @@ pub async fn wechat_pay_recall(header_map: HeaderMap, body: String) -> Json<Wech
message: "签名错误".to_string(),
});
}


let mut trade = Trade::find_by_id(id).one(&*crate::DATABASE).await.unwrap().unwrap().into_active_model();
trade.status = Set(TradeStatus::Paid as i16);
trade.pay_time = Set(Some(chrono::Local::now().naive_local()));
trade.save(&*crate::DATABASE).await.unwrap();
Expand Down

0 comments on commit d61fa3e

Please sign in to comment.