To execute a payment you must inform Rise of the payment parameters, and then sign the data Rise api gives you, and finally send the signature to execute the payment. Make sure the wallet used to execute the RiseID payment is either the owner or delegate of the RiseID

Request Payment Intent

First, request payment intent that will be used for signing in the next step. The Salt can be any numeric unique value that you should store in your records.


const salt = '1234567890'
const paymentIntent = {
  wallet: ethersWallet.address,
  rise_id: RISE_ID, // Your RiseID address
  payee: PAYEE_RISE_ID, // Payee RiseID address
  amount: '50000000', // in 1e6 units. $50 = 50 * 1e6 
  salt: new Date().getTime() // can be any number you like to use for salt
}
const { data } = await api.put('/payments/pay', paymentIntent)

Create a Signature

Next, sign the payment intent message that is returned from Rise API

const types = { ...data.data.typedData }
delete types.EIP712Domain // Remove EIP712 because it is added as separate arguments
// Sign
const signature = await ethersWallet.signTypedData(
  typedData.domain,
  types,
  typedData.message
)
	

Submit Payment

Now you can submit the payment along with your newly created signature.

// Send the payment parameters, the signature and the message to execute the payment
const { data } = await api.post('/payments/pay', {
  ...paymentIntent,
  signature,
  request: typedData.message
})
// The response will be a transaction on the blockchain
console.log('Result', data.data)