Make a payment
Permissions Required
This feature requires the
Pay
permission.
Make a payment
Once you've authorized a user, you may use their credentials to push transactions on their behalf. This can be done by passing payment parameters through the wallet.pay
function:
const {HandCashConnect} = require('@handcash/handcash-connect');
const handCashConnect = new HandCashConnect({
appId: '<app-id>',
appSecret: '<secret>',
});
const account = handCashConnect.getAccountFromAuthToken(token);
const paymentParameters = {
note: "Hold my beer!๐บ",
payments: [
{ destination: 'nosetwo', currencyCode: 'BSV', sendAmount: 0.001 },
]
};
const paymentResult = await account.wallet.pay(paymentParameters);
console.log(paymentResult);
note
must be 25 characters or less.
// paymentResult
{
transactionId: '4c7b7cdc18702bb1a09c75a47bc2fa9630545761fbbd53b8c38735c73173e043',
note: 'Hold my beer!๐บ',
type: 'send',
time: 1604958667,
satoshiFees: 113,
satoshiAmount: 12500,
fiatExchangeRate: 160.74284545024352,
fiatCurrencyCode: 'USD',
participants: [
{
type: 'user',
alias: 'nosetwo',
displayName: 'Nose two',
profilePictureUrl: 'https://res.cloudinary.com/hk7jbd3jh/image/upload/v1574787300/gntqxv6ed7sacwpfwumj.jpg',
responseNote: ''
}
],
attachments: [],
}
Pay-to-many
The Connect SDK allows up to 1000
recipients per payment. To send to multiple people, add more recipients to the payments
array while assigning your payment parameters:
const paymentParameters = {
description: "Hold my beer!๐บ",
payments: [
{ to: 'eyeone', currencyCode: 'BSV', amount: 0.004 },
{ to: 'BrandonC', currencyCode: 'BSV', amount: 0.0005 },
{ to: '[email protected]', currencyCode: 'EUR', amount: 0.25 },
{ to: '131xrWSKXHbhucFPTfZqnxF8ZhjpMxJH7K', currencyCode: 'USD', amount: 0.25 },
]
};
Recipient Types
HandCash Connect supports three different recipient types:
Handles
Recommended in most cases
Example:eyeone
Paymails
Allow sending to external wallets
Example:[email protected]
,[email protected]
,etc...
P2PKH Addresses
May be used to support advanced use-cases.
Example:1BvBMSEYstWetqTFn5Au4m4GFg7xJaNVN2
Updated 10 months ago