# Payment
A payment holds digital assets that are in transit or
expected to soon be in transit. It can be deposited in purses,
split into or combined with multiple payments, and claimed (getting
an exclusive payment and revoking access from anyone else).
A payment is linear, meaning either a payment has its full
original balance, or it is used up entirely. You cannot partially use a
payment. In other words, if a payment is 10 Quatloos, you can't
take out, say, 3 Quatloos from it, leaving the payment with 7 Quatloos.
However, you can split a payment into multiple payments, for example
into two new payments of 3 Quatloos and 7 Quatloos.
The split() operation burns (destroys) the original 10 Quatloos payment.
Payments are often received from other actors. Since they are not self-verifying,
you cannot trust payments. To get the verified balance of a payment, use the issuer
associated with the payment's brand: issuer.getAmountOf(payment).
To convert a payment into a new purse:
- Get the
payment's trustedissuer. - Use the
issuerto create an emptypursefor thatbrand. - Deposit the
paymentinto the newpurse.
purse.deposit(payment) burns the payment.
# payment.getAllegedBrand()
- Returns:
{Brand}
Get the allegedBrand, indicating the kind of digital asset this payment purports to be, and which issuer to use
with it. Because payments are not trusted, any method calls on payments
should be treated with suspicion and verified elsewhere.
const payment = quatloosMint.mintPayment(AmountMath.make(quatloosBrand, 10n));
//Should return 'quatloos'
const allegedBrand = payment.getAllegedBrand();
# Related Methods
The following methods on other ERTP components either operate
on or return a payment. While a brief description is given for each,
you should click through to a method's main documentation entry for
full details on what it does and how to use it.
issuer.burn(payment, optAmount)- Burn (destroy) all of the digital assets in the
payment.
- Burn (destroy) all of the digital assets in the
issuer.claim(payment, optAmount)- Transfer all assets from the
paymentto a returned newpaymentand burn the original.
- Transfer all assets from the
issuer.combine(paymentsArray)- Combine multiple
paymentsinto one, returned,payment.
- Combine multiple
issuer.getAmountOf(payment)- Get a description of a
paymentbalance as anamount.
- Get a description of a
issuer.isLive(payment)- Returns
trueif theissuersays thepaymentexists (i.e. it's been created and hasn't been burned).
- Returns
issuer.split(payment, paymentAmountA)- Split one
paymentinto two new ones.
- Split one
issuer.splitMany(payment, amountArray)- Split
paymentinto multiplepayments, returned as an array.
- Split
mint.mintPayment(newAmount)- Returns a new
paymentcontaining the newly minted assets corresponding to thenewAmountargument.
- Returns a new
purse.deposit(payment, optAmount)`- Deposit all of
paymentinto thispurse.
- Deposit all of
purse.getDepositFacet()- Creates a deposit-only facet on the
pursethat can be given to other parties to depositpaymentsin.
- Creates a deposit-only facet on the
purse.withdraw(amount)- Returns a new
paymentwhose balance is described by theamountargument.
- Returns a new
← Purse AmountMath →