This billing method will charge a fixed currency amount per billing period. The customer is charged in currency at the start of the billing period. Refunds, in the event that a customer closes their account or downgrades their package partway through a billing period, are supported by this billing method.
-- ************************************ SUBSCRIPTION BILLING ******************************************** function getChargeAmount(p) local chargeAmount = p.billingComp:getBillingValue("charge_amount") if(chargeAmount ~= nil) then local chargeValue = chargeAmount:getValue() if(chargeValue ~= nil) then return tonumber(chargeValue) end end return nil end function advanceSubscriptionBilling(p) if (p == nil) then return { ref="_advance_subscription_billing", name = "Advance Subscription Billing", description = "Subscription billing which will charge a set amount at the start of each billing period. If the subscription is cancelled you will be refunded the outstanding amount.", permittedPCT = {"PCT_CUST_CREDIT"}, configuredValues = { { key = "charge_amount", name = "Charge amount", description = "The amount that will be charged at the start of each billing period", validator = {validatorType = "NUMERIC_DOUBLE"}, measureType = "NUMERIC" }, }, api = "BILLING", version = 1 } end if(p.lastBillingRun) then local amount = getChargeAmount(p) local refundAmount = amount - (amount * p.billingFactor) if(refundAmount >= 0.01) then return {{charge = refundAmount * -1 , description = "Subscription Refund" }} end else local amount = getChargeAmount(p) if (amount >= 0.01) then return {{charge = amount , description = "Subscription Charge" }} end end return nil end -- ************************************ END OF SUBSCRIPTION BILLING ******************************************** function register () return { "advanceSubscriptionBilling" } end