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
functionmakePayment(stringmemory_id,// payment ID, must not be a duplicateuint256_amount,// amount due in weiaddress_vendor,// vendor addressbool_isInstallments,// true if payment is a downpayment with installmentsuint256_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) externalpayable;
1
Define OmniPay variable
IPayments99 public omnipay =IPayments99(0xEe47e2484342eA7Bcf13B9e6d4F9d53B28F1b724); // address on Avalanche C-Chain
uint256public _amount =1*10**15;omnipay.makePayment{value: feePerPayment + _amount}('ID1',// payment ID, must not be a duplicate_amount,// amount due in weiaddress(0x6BF6D002b5140b7CE0A0a4993621ecE52271e5f0),// vendor addressfalse,// 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.
structPayment {string id; // payment IDuint256 amount; // amount due in Weiaddress customer; // customer addressaddress vendor; // vendor addressbool isPaid; // true if the payment exists and has been paidbool isRefunded; // true if the payment was refundedbool isInstallments; // true if the payment contains installmentsuint256 fullAmount; // the full amount of the paymentuint256 amountPerInstallment; // amount due per month uint8 installmentPeriod; // the installment period in monthsuint8 paidInstallments; // how many installments have been paid uint8 remainingInstallments; // how many installments remainuint256 datePaid; // date the payment was madeuint256 dateLastInstallmentPaid; // date the last installment was paid}
IPayments99 public omnipay =IPayments99(0xEe47e2484342eA7Bcf13B9e6d4F9d53B28F1b724);IPayments99.Payment public payment = omnipay.lookupPayment('ID1'); boolpublic isPaid = payment.isPaid ==true; // check if paidboolpublic 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');uint256public feePerInstallment = omnipay.feePerInstallment();uint256public 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 .
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.♾️