App-to-User Payments
App-to-User payments will allow you to transact Pi from your application to your users. This type of transaction may often be used following a User-to-App transaction.
For example, a marketplace app may receive Pi from a buyer in a user-to-app transaction and then will create an app-to-user transaction to award the seller their Pi, allowing the marketplace app to easily keep their cut of the transaction.
Usage with NPM Package
// Create payment
const paymentData = {
amount: NUMBER; // Will be deducted from your wallet, plus blockchain fee (0.01 Pi)
recipient: STRING; // Either Pi username OR wallet address
wallet_public_key: STRING; // Your Mainnet wallet address
wallet_secret_key: STRING; // We will never see or store this
};
piecard.makePaymentToUser(paymentData)
.then((response) => {
console.log("Create payment : ", response);
})
.catch((err) => {
console.log("Create payment error : ", err);
});
Do not hard code your wallet secret key! Always store as an environment variable.
Last updated
Was this helpful?