pub struct PayConfig {
pub platform: PayPlatform,
pub app_id: String,
pub merchant_private_key: String,
pub platform_public_key: String,
pub notify_url: String,
pub return_url: Option<String>,
pub sandbox: bool,
pub mode: String,
}Expand description
支付配置 — 对齐 PHP Pay::config(config) 的配置结构
使用 Builder 模式构建配置,各支付提供商共享此配置结构。
Fields§
§platform: PayPlatform支付平台
app_id: String应用 ID
merchant_private_key: String商户私钥(PEM 格式或 PKCS8 字符串)
安全注意:此字段在 Debug 输出中始终脱敏为 "<redacted>",
防止日志泄漏。序列化/反序列化不受影响(未派生 Serialize)。
platform_public_key: String平台公钥
notify_url: String回调 URL
return_url: Option<String>返回 URL
sandbox: bool沙箱模式
mode: String模式(如 web/app/mini/scan)
Implementations§
Source§impl PayConfig
impl PayConfig
Sourcepub fn with_merchant_private_key(self, key: impl Into<String>) -> PayConfig
pub fn with_merchant_private_key(self, key: impl Into<String>) -> PayConfig
设置商户私钥
Sourcepub fn with_platform_public_key(self, key: impl Into<String>) -> PayConfig
pub fn with_platform_public_key(self, key: impl Into<String>) -> PayConfig
设置平台公钥
Sourcepub fn with_notify_url(self, notify_url: impl Into<String>) -> PayConfig
pub fn with_notify_url(self, notify_url: impl Into<String>) -> PayConfig
设置回调 URL
Sourcepub fn with_return_url(self, return_url: impl Into<String>) -> PayConfig
pub fn with_return_url(self, return_url: impl Into<String>) -> PayConfig
设置返回 URL
Sourcepub fn with_sandbox(self, sandbox: bool) -> PayConfig
pub fn with_sandbox(self, sandbox: bool) -> PayConfig
设置沙箱模式
Sourcepub fn validate(&self) -> Result<(), PayError>
pub fn validate(&self) -> Result<(), PayError>
校验配置必填字段
§返回
- 应用 ID 为空 →
PayError::Config - 商户私钥为空 →
PayError::Config - 平台公钥为空 →
PayError::Config - 回调 URL 为空 →
PayError::Config
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PayConfig
impl RefUnwindSafe for PayConfig
impl Send for PayConfig
impl Sync for PayConfig
impl Unpin for PayConfig
impl UnsafeUnpin for PayConfig
impl UnwindSafe for PayConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.