'textfield', '#title' => t('Title to use COD'), '#default_value' => variable_get('cod_title', t('COD')), '#size' => 70, '#maxlength' => 780, '#weight' => -1, '#desciption' => t('Description to show shoppers for this type of payment.') ); $form['cod_url'] = array( '#type' => 'textfield', '#title' => t('Page to go to after payment'), '#default_value' => variable_get('cod_url', 'node'), '#size' => 70, '#maxlength' => 780, '#weight' => -1, '#desciption' => t('Page to go to after payment is completed.') ); $form['cod_txn_paid'] = array( '#type' => 'radios', '#title' => t('Mark transaction as paid?'), '#default_value' => variable_get('cod_txn_paid', 0), '#options' => array(t('No'), t('Yes')), '#desciption' => t('Whether to mark transactions as paid immediately, or wait till the store admin marks them as paid') ); $form['cod_txn_completed'] = array( '#type' => 'radios', '#title' => t('Mark transaction workflow as completed?'), '#default_value' => variable_get('cod_txn_completed', 0), '#options' => array(t('No'), t('Yes')), '#desciption' => t('Marks transactions that have no shippable items as completed in the workflow') ); return $form; } /** * The Controller to create a new payment interface. */ function cod_paymentapi(&$txn, $op, $arg = '') { switch ($op) { case 'display name': return variable_get('cod_title', t('COD'));; case 'payment page': return cod_goto($txn); break; } } function cod_goto($txn) { $edit = $_POST['edit']; if (variable_get('cod_txn_paid', 0)) { $edit['payment_status'] = payment_get_status_id('completed'); drupal_set_message(t('Your purchase has been completed.')); if (variable_get('cod_txn_completed', 0)) { // Check if we have shippable items $has_shippable_item = false; foreach($txn->item as $key => $value) { if (product_is_shippable($key['vid'])) { $has_shippable_item = true; } } if (!$has_shippable_item = true) { $edit['workflow'] = 6; } } $edit['txnid'] = $txn->txnid; // Update the transaction $txnid = store_transaction_save($edit); } else { drupal_set_message(t('Your purchase has been received.')); } if ($txn->txnid) { // Send an email notification store_send_invoice_email($txn->txnid); }; return strtr(variable_get('cod_url', 'product'), array('%txnid' => $txn->txnid)); }