Recurring Transactions are processed on the Base Commerce Platform using the RecurringTransaction object to encapsulate all of the data that is needed. It is processed using the BaseCommercePayClient processRecurringTransaction() method. This section details how to process a Recurring Transaction and how to cancel a Recurring Transaction.
Process a Recurring Transaction
|Field||Method on RecurringTransaction||
|BankCard||setBankCard( BankCard vo_bank_card )||Only one BankCard or BankAccount should be set on the RecurringTransaction, not both. If it is desired to use a BankCard that is stored in the vault, the getBankCard( String vs_token ) method can be used to grab the BankCard and set on the RecurringTransaction.|
|BankAccount||setBankAccount( BankAccount vo_bank_account )||Only one BankCard or BankAccount should be set on the RecurringTransaction, not both. If it is desired to use a BankAccount that is stored in the vault, the getBankAccount( String vs_token ) method can be used to grab the BankAccount and set on the RecurringTransaction.|
|setFrequency( String vs_frequency )||Sets the frequency that the Recurring Transactions will be run. Use one of the listed frequencies below.|
|Start Date||setStartDate( Date vo_start_date )||Sets the RecurringTransactions start date. The Recurring Transactions will be run at whatever frequency interval based off of this date.|
|End Date||setEndDate( Date vo_end_date )||Sets the RecurringTransactions end date, the date that Recurring Transactions will stop running. This is optional, and if no end date is set, the number of transactions will be set to 2999, and depending on the frequency, it will auto set the end date 2999 intervals from the start date.|
|Amount||setAmount( double vd_amount )||The amount the RecurringTransaction is for.|
|Messages||getMessages()||Used on the response of processing a RecurringTransaction. If there were errors creating the RecurringTransaction, this method will show the errors. If there were no errors, this will be empty.|
|Status||getStatus()||Returns the Status of the Recurring Transaction, which can be any of the Statuses that are listed below.|
|Method||setMethod( String vs_method )||Sets the Method of the RecurringTransaction. This is only used for ACH RecurringTransactions. It can be any of the Methods that are listed in the table below.|
|Type||setType( String vs_type )||
Sets the Type of the RecurringTransaction. This is only used for ACH RecurringTransactions. It can be either XS_BAT_TYPE_CREDIT or XS_BAT_TYPE_DEBIT, and should be pulled from the BankAccountTransaction object's static variable.
|RecurringTransactionID||getRecurringTransactionID()||Returns the ID of the RecurringTransaction. This is the value thats used for canceling RecurringTransactions.|
These static Strings are on the RecurringTransaction object and should be used for when setting the frequency of a RecurringTransaction.
|XS_FREQUENCY_ANNUALLY||Annually, once a year, the transaction will be run.|
|XS_FREQUENCY_QUARTERLY||Quarterly, January 1st, April 1st, July 1st, and October 1st, the transactions will be run.|
|XS_FREQUENCY_MONTHLY||Monthly, every month, the transaction will be run.|
|XS_FREQUENCY_BIWEEKLY||Bi-Weekly, every 14 days, the transaction will be run.|
|XS_FREQUENCY_WEEKLY||Weekly, every 7 days, the transaction will be run.|
|XS_FREQUENCY_DAILY||Daily, every day, the transaction will be run.|
These are the Statuses that a RecurringTransaction can be in.
|XS_RECURRING_STATUS_ENABLED||The RecurringTransaction is enabled.|
|XS_RECURRING_STATUS_FAILED||The RecurringTransaction failed, check getMessages() function to see why it failed.|
|XS_RECURRING_STATUS_DISABLED||The RecurringTransaction is disabled.|
Example Process RecurringTransaction
To cancel a RecurringTransaction, all that is needed is the RecurringTransaction's ID, which can be obtained by the getRecurringTransactionID() method. That ID is passed into the cancelRecurringTransaction( int n_id ) method and that is all that is needed.
The user is able to Cancel/Disable only those Recurring Transaction which are in Active/Completed status. No failed transaction could be cancelled.