# Payment Object

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, or claimed (i.e., getting an exclusive Payment and revoking access from anyone else).

Digital assets in Payments can be any of:

  • Currency-like, such as our imaginary Quatloos currency.
  • Goods-like digital assets, such as theater tickets or magic weapons used in a game.
  • Other kinds of rights, such as the right to participate in a particular contract.

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, only 3 Quatloos from it.

However, you can split a Payment into multiple Payments. For example, you could split a 10 Quatloos Payment into two new Payments of 3 Quatloos and 7 Quatloos by calling the anIssuer.split() method which consumes the original 10 Quatloos Payment and creates two new smaller Payments.

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, call the anIssuer.getAmountOf() method.

To convert a Payment into a new Purse:

  1. Get the Payment's trusted Issuer.
  2. Use the Issuer to create an empty Purse.
  3. Deposit the Payment into the new Purse.

aPurse.deposit() consumes the Payment, making it unavailable for later use.

# aPayment.getAllegedBrand()

Returns the Brand indicating the kind of digital asset this Payment purports to be. Because Payments are not trusted, any method calls on them should be treated with suspicion and verified elsewhere. Any successful operation by an Issuer on a Payment verifies it.

const payment = quatloosMint.mintPayment(AmountMath.make(quatloosBrand, 10n));
// Should return 'quatloos'
const allegedBrand = payment.getAllegedBrand();

The following methods on other ERTP components either operate on or return a Payment.