Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 

README.md

ILP Protocol SPSP

Description

Implements version 4 of the Simple Payment Setup Protocol.

Example

Simple Usage

Sends a single-chunk PSK payment or a STREAM payment, if the server supports it. Great for micro-payments or micro-donations inside of a script.

try {
  const resp = await SPSP.pay(plugin, {
    pointer: '$bob.example.com',
    sourceAmount: '1000'
  })
  console.log(`sent "${resp.totalSent}"`)
} catch (e) {
  console.log(`sent "${e instanceof SPSP.PaymentError ? e.totalSent : 0}"`)
}

Make a pull payment from a designated pull payment pointer.

try {
  const resp = await SPSP.pull(plugin, {
    pointer: '$bob.example.com/4139fb24-3ab6-4ea1-a6de-e8d761ff7569',
    amount: '1000'
  })
  console.log(`pulled "${resp.totalReceived}"`)
} catch (e) {
  console.log(`pulled "${e instanceof SPSP.PaymentError ? e.totalReceived : 0}"`)
}

Advanced Usage

Query the endpoint manually to construct a STREAM or PSK2 payment.

const query = await SPSP.query('$bob.example.com')
console.log(query)
// {
//   destination_account: "test.example.bob.LwNAw4ZEjlOwkc8xmaQRaRd37YRl8sixSCBPgEEqo8I",
//   shared_secret: "RvqL/HJO3GinYIeujez/OEsBtX6+NtxJwabh7KthfOI=",
//   content_type: "application/spsp4+json"
// }

The query may contain additional information.

About

SPSP client for ILPv4

Resources

Packages

No packages published
You can’t perform that action at this time.