# 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
issuer
to create an emptypurse
for thatbrand
. - Deposit the
payment
into 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
payment
to a returned newpayment
and burn the original.
- Transfer all assets from the
issuer.combine(paymentsArray)
- Combine multiple
payments
into one, returned,payment
.
- Combine multiple
issuer.getAmountOf(payment)
- Get a description of a
payment
balance as anamount
.
- Get a description of a
issuer.isLive(payment)
- Returns
true
if theissuer
says thepayment
exists (i.e. it's been created and hasn't been burned).
- Returns
issuer.split(payment, paymentAmountA)
- Split one
payment
into two new ones.
- Split one
issuer.splitMany(payment, amountArray)
- Split
payment
into multiplepayments
, returned as an array.
- Split
mint.mintPayment(newAmount)
- Returns a new
payment
containing the newly minted assets corresponding to thenewAmount
argument.
- Returns a new
purse.deposit(payment, optAmount
)`- Deposit all of
payment
into thispurse
.
- Deposit all of
purse.getDepositFacet()
- Creates a deposit-only facet on the
purse
that can be given to other parties to depositpayments
in.
- Creates a deposit-only facet on the
purse.withdraw(amount)
- Returns a new
payment
whose balance is described by theamount
argument.
- Returns a new
← Purse AmountMath →