Omnify's payment suite and infrastructure is all hosted in OmniPay. It paves the way for full payments, receipts, refunds, installments, and instant revenue withdrawals. Accessible from pay.omnify.finance and app.omnify.finance/payments.
In this section we will cover making payments, paying installments, withdrawing revenues, and checking if a payment was made and if a payment was refunded. Payments are made in the native token of the network you are on. You can find a list of all Omnify services' tiers and fees at omnify.finance/fees.
Start by downloading the OmniPay interface found in our github repo.
Making a payment
function makePayment(
string memory _id, // payment ID, must not be a duplicate
uint256 _amount, // amount due in wei
address _vendor, // vendor address
bool _isInstallments, // true if payment is a downpayment with installments
uint256 _fullAmount, // if is installments place the full amount due here, use _amount if full payment (in wei)
uint8 _installmentPeriod // how many months the installment period is max is 120
) external payable;
1
Define OmniPay variable
IPayments99 public omnipay = IPayments99(0xEe47e2484342eA7Bcf13B9e6d4F9d53B28F1b724); // address on Avalanche C-Chain
2
Get Omnify's fee / payment
uint256 public feePerPayment = omnipay.feePerPayment();
3
Call makePayment
uint256 public _amount = 1 * 10 ** 15;
omnipay.makePayment{value: feePerPayment + _amount}(
'ID1', // payment ID, must not be a duplicate
_amount, // amount due in wei
address(0x6BF6D002b5140b7CE0A0a4993621ecE52271e5f0), // vendor address
false, // true if payment is a downpayment with installments
_amount, // if is installments place the full amount due here, if not use _amount (in wei)
0 // how many months the installment period is max is 120
);
Checking if a payment was made or refunded via ID
We lookup a payment by its ID from the OmniPay contract by calling lookupPayment. The return value is a Payment struct containing all details about the payment.
struct Payment {
string id; // payment ID
uint256 amount; // amount due in Wei
address customer; // customer address
address vendor; // vendor address
bool isPaid; // true if the payment exists and has been paid
bool isRefunded; // true if the payment was refunded
bool isInstallments; // true if the payment contains installments
uint256 fullAmount; // the full amount of the payment
uint256 amountPerInstallment; // amount due per month
uint8 installmentPeriod; // the installment period in months
uint8 paidInstallments; // how many installments have been paid
uint8 remainingInstallments; // how many installments remain
uint256 datePaid; // date the payment was made
uint256 dateLastInstallmentPaid; // date the last installment was paid
}
IPayments99 public omnipay = IPayments99(0xEe47e2484342eA7Bcf13B9e6d4F9d53B28F1b724);
IPayments99.Payment public payment = omnipay.lookupPayment('ID1');
bool public isPaid = payment.isPaid == true; // check if paid
bool public isRefunded = payment.isRefunded == true; // check if refunded
Paying installments
When paying an installment be sure to get the amount per installment of that payment, and the fee Omnify charges per installment.
IPayments99 public omnipay = IPayments99(0xEe47e2484342eA7Bcf13B9e6d4F9d53B28F1b724);
IPayments99.Payment public payment = omnipay.lookupPayment('ID1');
uint256 public feePerInstallment = omnipay.feePerInstallment();
uint256 public amountPerInstallment = payment.amountPerInstallment;
omnipay.payInstallment{value: amountPerInstallment + feePerInstallment}('ID1');
Additionally, if its the last installment it is required to calculate the final installment by subtracting the paid amount so far from the full amount. Replace amountPerInstallment with paidSoFar and installmentAmount .
IPayments99 public omnipay = IPayments99(0xEe47e2484342eA7Bcf13B9e6d4F9d53B28F1b724);
IPayments99.Payment public payment = omnipay.lookupPayment('ID1');
uint256 public feePerInstallment = omnipay.feePerInstallment();
uint256 public paidSoFar = payment.paidInstallments * payment.amountPerInstallment;
uint256 public installmentAmount = payment.fullAmount - paidSoFar;
omnipay.payInstallment{value: installmentAmount + feePerInstallment}('ID1');
Withdrawing Revenues
Any vendor can withdraw any amount of their revenues whenever they wish by simply calling withdrawBalance , granted they've received payments equal or more than the amount they are trying to withdraw.
IPayments99 public omnipay = IPayments99(0xEe47e2484342eA7Bcf13B9e6d4F9d53B28F1b724);
omnipay.withdrawBalance(1 * 10 ** 15);
All our crypto payment needs are covered with OmniPay.♾️