Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function payment_method_paypal_conf(){
- if(arg(2) && is_numeric(arg(2))){
- $uid = arg(2);
- }
- else if(arg(3) && is_numeric(arg(3))){
- $uid = arg(3);
- }
- else{
- global $user;
- $uid = $user->uid;
- }
- $check = db_select('afl_usr_payment_methods' , 'method')
- ->fields('method', array('method'))
- ->condition('method', 'method_paypal', '=')
- ->condition('uid', $uid, '=')
- ->condition('status', 1, '=')
- ->execute()->rowCount();
- if(! $check){
- drupal_set_message(t('The payment method: Paypal is not enabled'), 'info');
- drupal_goto('afl/payment-methods');
- }
- $data = db_select('afl_usr_payment_methods' , 'method')
- ->fields('method', array('data'))
- ->condition('method', 'method_paypal', '=')
- ->condition('uid', $uid, '=')
- ->condition('status', 1, '=')
- ->execute()->fetchField();
- $afl_available_payment_methods = afl_variable_get('afl_available_payment_methods', '');
- $afl_approved_payment_methods = afl_variable_get('afl_approved_payment_methods', '');
- $approved_payment_methods = array();
- if(! empty($afl_available_payment_methods)){
- $afl_available_payment_method_array = list_extract_allowed_values($afl_available_payment_methods,'list_text',FALSE);
- $payment_val = $afl_available_payment_method_array['method_paypal'];
- $afl_available_payment_method_splits = explode('###', $payment_val);
- $afl_available_payment_fields = explode('&', $afl_available_payment_method_splits[1]);
- $field_val = drupal_json_decode($data);
- foreach($afl_available_payment_fields as $fileds){
- $fileds_prop = explode('*', $fileds);
- $field_key = $fileds_prop[0];
- $form[$field_key]= array(
- '#type' => 'textfield',
- '#required' => TRUE,
- '#title' => t($fileds_prop[1]),
- '#default_value' => isset($field_val[$field_key]) ? $field_val[$field_key] : '',
- );
- }
- }
- $form['method_uid']= array(
- '#type' => 'hidden',
- '#value' => $uid,
- );
- $form['submit']= array(
- '#type' => 'submit',
- '#value' => t('Save Payment methods'),
- );
- return $form;
- }
- function payment_method_paypal_conf_submit($form, &$form_state){
- $val = $form_state['values'];
- $q = db_update('afl_usr_payment_methods')
- ->fields(array('data' => drupal_json_encode($val), 'completed' => 1))
- ->condition('method', 'method_paypal', '=')
- ->condition('uid', check_plain($val['method_uid']), '=')
- ->execute();
- if ($q) {
- drupal_set_message(t('Your Paypal details saved successfully.'), 'status');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement