pub struct PayOrder {
pub out_trade_no: String,
pub total_amount: i64,
pub subject: String,
pub body: Option<String>,
pub notify_url: Option<String>,
pub return_url: Option<String>,
pub timeout_express: Option<i64>,
pub passback_params: Option<String>,
pub extra: Value,
}Expand description
支付订单 — 对齐 PHP Yansongda\Pay\Pay::alipay()->app() 的订单参数
使用 Builder 模式构建订单内容,通过 PayProvider::pay 发起支付。
§PHP 对齐
// PHP yansongda/pay
$order = [
'out_trade_no' => '202401010001',
'total_amount' => '88.00',
'subject' => '鲜视达商品',
];
Pay::alipay()->app($order);§Rust 用法
ⓘ
use sz_rust_core::pay::{PayOrder, MemoryPayProvider, PayProvider};
let order = PayOrder::new()
.out_trade_no("202401010001")
.total_amount(8800)
.subject("鲜视达商品");
let provider = MemoryPayProvider::new();
let result = provider.pay(order).unwrap();Fields§
§out_trade_no: String商户订单号(必填)
total_amount: i64订单总金额(必填,单位:分)
subject: String订单标题(必填)
body: Option<String>订单描述
notify_url: Option<String>异步通知 URL
return_url: Option<String>同步跳转 URL
timeout_express: Option<i64>过期时间(秒)
passback_params: Option<String>附加数据
extra: Value业务扩展参数
Implementations§
Source§impl PayOrder
impl PayOrder
Sourcepub fn out_trade_no(self, out_trade_no: impl Into<String>) -> PayOrder
pub fn out_trade_no(self, out_trade_no: impl Into<String>) -> PayOrder
设置商户订单号
Sourcepub fn total_amount(self, total_amount: i64) -> PayOrder
pub fn total_amount(self, total_amount: i64) -> PayOrder
设置订单总金额(单位:分)
Sourcepub fn notify_url(self, notify_url: impl Into<String>) -> PayOrder
pub fn notify_url(self, notify_url: impl Into<String>) -> PayOrder
设置异步通知 URL
Sourcepub fn return_url(self, return_url: impl Into<String>) -> PayOrder
pub fn return_url(self, return_url: impl Into<String>) -> PayOrder
设置同步跳转 URL
Sourcepub fn timeout_express(self, timeout_express: i64) -> PayOrder
pub fn timeout_express(self, timeout_express: i64) -> PayOrder
设置过期时间(秒)
Sourcepub fn passback_params(self, passback_params: impl Into<String>) -> PayOrder
pub fn passback_params(self, passback_params: impl Into<String>) -> PayOrder
设置附加数据
Sourcepub fn validate(&self) -> Result<(), PayError>
pub fn validate(&self) -> Result<(), PayError>
校验必填字段
§返回
- 商户订单号为空 →
PayError::MissingField - 订单金额 ≤ 0 →
PayError::MissingField - 订单标题为空 →
PayError::MissingField
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PayOrder
impl RefUnwindSafe for PayOrder
impl Send for PayOrder
impl Sync for PayOrder
impl Unpin for PayOrder
impl UnsafeUnpin for PayOrder
impl UnwindSafe for PayOrder
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.