virto-network / open-runtime-module-library

Substrate Open Runtime Module Library
Apache License 2.0
0 stars 1 forks source link

Payment validation #6

Open olanod opened 2 years ago

olanod commented 2 years ago

I propose creating another interface that acts like a pre-payment hook which does an early validation of the payment information and rejects it if it doesn't fulfill some requirements. We pass it the payment info preferably wrapped in a struct to avoid breaking changes in the trait definition,

struct PaymentIntent<T: Config> {
    from: T::AccountId,
    recipient: T::AccountId,
    asset: AssetIdOf<T>,
    amount: BalanceOf<T>,
    remark: Option<&[u8]>,
}

Early payment validation has several uses like being able to reject payments based on the amount, check if the remark has the right structure, check if recipients are allowed to receive a payment with a given remark(i.e. is a merchant registered in the marketplace?), check if a kind of product is allowed, etc.