Skip to content

Commit

Permalink
Merge pull request #4 from encryptedge/dev
Browse files Browse the repository at this point in the history
fix: bug fix regarding api request razorpay
  • Loading branch information
BRAVO68WEB authored Jan 10, 2024
2 parents c71e49a + 125600a commit d440db4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/services.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ pub async fn check_payments(

let response = request.send().await.unwrap();
if response.status() != StatusCode::OK {
return format!("FAIL!");
return format!("FAIL for Razorpay Fetch!");
// return response.text().await.unwrap();
}

let body = response.text().await.unwrap();
Expand Down Expand Up @@ -143,19 +144,24 @@ pub async fn check_payments(
notes_key_4: Some(ticket_id.clone()),
};

let request = client.request(reqwest::Method::PATCH, format!("https://api.razorpay.com/v1/orders/{}", order_id))
let updated_notes = RazorpayPaymentNotesUpdate {
notes: updated_notes,
};

let request = client.request(reqwest::Method::PATCH, format!("https://api.razorpay.com/v1/orders/{}", order.id))
.headers(headers)
.json(&updated_notes);

let response = request.send().await.unwrap();
if response.status() != StatusCode::OK {
return format!("FAIL!");
// return format!("FAIL for Update Razorpay!");
return response.text().await.unwrap();
}

let mailer = send_ticket(ticket, mailer_auth).await;
return mailer
} else {
return format!("FAIL!")
return format!("FAIL, order not paid!!")
}
}

Expand Down
5 changes: 5 additions & 0 deletions src/structs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ pub struct CreateOrderNotes {
pub notes_key_4: Option<String>,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct RazorpayPaymentNotesUpdate {
pub notes: CreateOrderNotes,
}

#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct EnvStore {
pub rpay_id: String,
Expand Down

0 comments on commit d440db4

Please sign in to comment.