Files
imphnen-backend-service/imphnen-entities/src/seaorm/common/payments.rs
T
asepharyana 390f46b0e7 feat(dimentorin): payment status refresh via Midtrans + auto-paid auto-confirm
- store provider_order_id (Midtrans order id) on payment create
- POST /payments/{id}/refresh: query Midtrans v2/{order}/status (settlement/capture → paid + confirm session)
- fix: status URL must end with /status; force Accept-Encoding: identity (istio gzip mangling)
- e2e verified: simulated VA payment in sandbox → refresh → paid + session confirmed
2026-08-05 15:15:43 +07:00

67 lines
1.7 KiB
Rust

use chrono::{DateTime, Utc};
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
use uuid::Uuid;
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, DeriveEntityModel)]
#[sea_orm(table_name = "app_payments")]
pub struct Model {
#[sea_orm(primary_key, default = "gen_random_uuid()", auto_increment = false)]
pub id: Uuid,
#[sea_orm(column_type = "Uuid")]
pub session_id: Uuid,
#[sea_orm(column_type = "Uuid")]
pub mentee_id: Uuid,
#[sea_orm(column_type = "Uuid")]
pub mentor_id: Uuid,
#[sea_orm(column_type = "BigInteger", default = 0)]
pub amount: i64,
#[sea_orm(column_type = "BigInteger", default = 0)]
pub service_fee: i64,
#[sea_orm(column_type = "BigInteger", default = 0)]
pub total: i64,
// payment method: "va" | "qris" | "manual"
#[sea_orm(default = "manual")]
pub method: String,
// payment provider: "manual" | "midtrans" | "xendit" (swap later)
#[sea_orm(default = "manual")]
pub provider: String,
// status: "pending" | "paid" | "expired" | "cancelled"
#[sea_orm(default = "pending")]
pub status: String,
// provider reference: VA number / QR string / external transaction id
#[sea_orm(nullable)]
pub external_ref: Option<String>,
// provider order id (Midtrans order_id, e.g. "DM-<uuid>") used to query status
#[sea_orm(nullable)]
pub provider_order_id: Option<String>,
#[sea_orm(nullable)]
pub paid_at: Option<DateTime<Utc>>,
#[sea_orm(not_null)]
pub expires_at: DateTime<Utc>,
#[sea_orm(not_null, default = "now()")]
pub created_at: DateTime<Utc>,
#[sea_orm(not_null, default = "now()")]
pub updated_at: DateTime<Utc>,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {}
impl ActiveModelBehavior for ActiveModel {}