There doesn't seem to be much documentation (or any!) about the cancel callback function. Testing it by simply returning TRUE shows us that the record in the uc_recurring_users table isn't being removed. If I'm not missing something, I assume we have to do it ourselves in the function. The API has the uc_recurring_fee_delete function for performing this task:
<?php
function uc_recurring_fee_delete($feature, $type = 'product') {
switch ($type) {
case 'product':
db_query("DELETE FROM {uc_recurring_products} WHERE pfid = %d", $feature['fid']);
break;
case 'user':
module_invoke_all('recurring_api', 'delete', $feature['fid']);
db_query("DELETE FROM {uc_recurring_users} WHERE rfid = %d", $feature['fid']);
break;
}
}
?>
My questions is,how do we get the $feature array into our cancel callback function so we can access the fid (or rfid in the db) and use the uc_recurring_fee_delete?
Our cancel callback function:
function uc_recurring_psigate_cancel($order, &$fee) {
...
}
Thanks.
Comments
Comment #1
BigTuna commentedLooked closer at the uc_recurring API and I see that the functions changed. Will try using uc_recurring_get_fees($order) and uc_recurring_fee_cancel($rfid, 'user'). Assuming that will work.
Comment #2
univate commentedCancelling is not supposed to remove records from the database.
Cancelling means do not renew, ie: it will just set the number of remaining intervals to 0, so that when the expiry date is reached it will then expire.
The callback function just allows your gateway module to do something at this point - you shouldn't be deleting stuff though.
This all assumes you are using the default uc_recurring cancel menu item in your gateway, as this functionality will be completely overridden if you provide your own 'cancel' menu item and then you will want to look at uc_recurring cancel function to copy over the cancel stuff, which is only one function -> uc_recurring_fee_cancel($rfid)
If you want you could create a delete 'menu' operation that deleted all this stuff, personally I think that the current functionality of leaving the information in the database and only deleting the recurring records if you delete the order from the database is a better approach.
Comment #3
BigTuna commentedMakes sense now.
Thanks!