feat(dimentorin): payment module - gateway-agnostic VA/QRIS with admin confirm
- app_payments table + PaymentEntity (amount from mentor mentoring_rate + service fee 2000)
- PaymentRepository (postgres) + PaymentServiceImpl (create/get/confirm/list)
- Routes: POST /payments/sessions/{id}/create, GET /payments/me, GET /payments/{id}, POST /payments/{id}/confirm
- confirm guarded by Admin/Admin Pembayaran role; ownership guard mentee-only view
- provider=manual default (swap midtrans/xendit later), e2e verified: VA+QRIS create, confirm 200, re-confirm 409, non-admin 403, foreign payment 403
This commit is contained in:
@@ -4,6 +4,7 @@ pub mod enum_impls;
|
||||
pub mod enums;
|
||||
pub mod events;
|
||||
pub mod otp_cache;
|
||||
pub mod payments;
|
||||
pub mod rate_limit;
|
||||
pub mod roadmap_items;
|
||||
pub mod testimonials;
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
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>,
|
||||
|
||||
#[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 {}
|
||||
Reference in New Issue
Block a user