Definition and Validation
Moyasar employees the metadata
section of the payment in order to define splits. The splits information includes the following:
- 2 or more split targets + amounts
- Fee source
Split Targets
The split traget is identified by their ID, which is a UUID assigned by Moyasar API to all models. Example: fa42e33e-aa82-46b1-81c8-1d7db0cf0353
.
Let's take an example where we have a payment with the amount 5000.00
SAR. We want to send 500.00
to the the benediciary 506cced8-5374-4842-8e6d-bcd3391c0fbc
and keep the remaining amount to the entity 0dafd52e-e8cd-4566-8847-08859c82143b
.
The splits will be as follows:
{
"#split_1": "450000",
"#target_1": "0dafd52e-e8cd-4566-8847-08859c82143b",
"#split_2": "50000",
"#target_2": "506cced8-5374-4842-8e6d-bcd3391c0fbc"
}
Fee Source
Fee Source is the split from where Moyasar will deduct the payment fees. The default fee source is the current entity's split.
In the previous example, fee source will default to the Entity
model performing the payment which is 0dafd52e-e8cd-4566-8847-08859c82143b
.
The fee source can be selected by setting the #fee_source
key to the UUID of the split target.
Validation & Rules
Taking the previous example into account, here are rules Moyasar will apply when validating the split structure:
- Splits must be numbered in order from
1
to the maximum number of splits with no missing numbers in the middle. - Each
split_x
must have an associated targettarget_x
. - Each target must be an Entity, Platform or Beneficairy.
- The Entity used must be the same Entity (Merchant) performing the payment
- The Platform used must be the current platform sponsoring the entity.
- A target must be only used once.
- The fee source must be one of the specified targets if manually set.
- The total split amounts must exactly be equal to the payment amount, e.g.
450000
+50000
=500000
which is5000.00
SAR.