/** * Update entry property * * @param int $entry_id Entry ID * @param string $property Name of the property to update * @param string $value Value for the property */ public static function update_entry_property($entry_id, $property, $value) { if (Pronamic_WP_Pay_Class::method_exists('GFAPI', 'update_entry_property')) { GFAPI::update_entry_property($entry_id, $property, $value); } elseif (Pronamic_WP_Pay_Class::method_exists('GFFormsModel', 'update_lead_property')) { GFFormsModel::update_lead_property($entry_id, $property, $value); } }
public function expire_subscription($entry, $action) { $this->log_debug(__METHOD__ . '(): Processing request.'); if (!$action['note']) { $action['note'] = sprintf(esc_html__('Subscription has expired. Subscriber Id: %s', 'gravityforms'), $action['subscription_id']); } GFAPI::update_entry_property($entry['id'], 'payment_status', 'Expired'); $this->add_note($entry['id'], $action['note']); $this->post_payment_action($entry, $action); return true; }
public function cancel_subscription($entry, $feed, $note = null) { if (!$note) { $note = sprintf(__('Subscription has been cancelled. Subscription Id: %s.', 'gravityforms'), $entry['transaction_id']); } if (strtolower($entry['payment_status']) == 'cancelled') { $this->log('Subscription is already canceled.'); return false; } GFAPI::update_entry_property($entry['id'], 'payment_status', "Cancelled"); $this->modify_post(rgar($entry, 'post_id'), rgars($feed, 'meta/update_post_action')); $this->add_note($entry['id'], $note); // include $subscriber_id as 3rd parameter for backwards compatability do_action('gform_subscription_canceled', $entry, $feed, $entry['transaction_id']); return true; }
public function expire_subscription($entry, $action) { $this->log_debug("Setting entry as expired"); if (!$action['note']) { $action['note'] = sprintf(__('Subscription has expired. Subscriber Id: %s', 'gravityforms'), $action['subscription_id']); } GFAPI::update_entry_property($entry['id'], 'payment_status', "Expired"); $this->add_note($entry['id'], $action['note']); return true; }
public function put_entry_properties($property_values, $entry_id) { $this->authorize("gravityforms_edit_entries"); if (is_array($property_values)) { foreach ($property_values as $key => $property_value) { $result = GFAPI::update_entry_property($entry_id, $key, $property_value); if (is_wp_error($result)) { break; } } if (is_wp_error($result)) { $response = $this->get_error_response($result); $status = $this->get_error_status($result); } else { $status = 200; $response = __("Success", "gravityforms"); } } else { $status = 400; if (empty($property_values)) { $response = __("No property values were found in the request body", "gravityforms"); } else { $response = __("Property values should be sent as an array", "gravityforms"); } } $this->end($status, $response); }
private function process_ipn($config, $entry, $status, $transaction_type, $transaction_id, $parent_transaction_id, $subscriber_id, $amount, $pending_reason, $reason, $recurring_amount) { $this->log_debug(__METHOD__ . "(): Payment status: {$status} - Transaction Type: {$transaction_type} - Transaction ID: {$transaction_id} - Parent Transaction: {$parent_transaction_id} - Subscriber ID: {$subscriber_id} - Amount: {$amount} - Pending reason: {$pending_reason} - Reason: {$reason}"); $action = array(); switch (strtolower($transaction_type)) { case 'subscr_payment': //transaction created $action['id'] = $transaction_id; $action['transaction_id'] = $transaction_id; $action['type'] = 'add_subscription_payment'; $action['subscription_id'] = $subscriber_id; $action['amount'] = $amount; $action['entry_id'] = $entry['id']; $action['payment_method'] = 'PayPal'; return $action; break; case 'subscr_signup': //no transaction created $action['id'] = $subscriber_id . '_' . $transaction_type; $action['type'] = 'create_subscription'; $action['subscription_id'] = $subscriber_id; $action['amount'] = $recurring_amount; $action['entry_id'] = $entry['id']; $action['ready_to_fulfill'] = !$entry['is_fulfilled'] ? true : false; if (!$this->is_valid_initial_payment_amount($entry['id'], $recurring_amount)) { //create note and transaction $this->log_debug(__METHOD__ . '(): Payment amount does not match subscription amount. Subscription will not be activated.'); GFPaymentAddOn::add_note($entry['id'], sprintf(__('Payment amount (%s) does not match subscription amount. Subscription will not be activated. Transaction Id: %s', 'gravityformspaypal'), GFCommon::to_money($recurring_amount, $entry['currency']), $subscriber_id)); GFPaymentAddOn::insert_transaction($entry['id'], 'payment', $subscriber_id, $recurring_amount); $action['abort_callback'] = true; } return $action; break; case 'subscr_cancel': //no transaction created $action['id'] = $subscriber_id . '_' . $transaction_type; $action['type'] = 'cancel_subscription'; $action['subscription_id'] = $subscriber_id; $action['entry_id'] = $entry['id']; return $action; break; case 'subscr_eot': //no transaction created if (empty($transaction_id)) { $action['id'] = $subscriber_id . '_' . $transaction_type; } else { $action['id'] = $transaction_id; } $action['type'] = 'expire_subscription'; $action['subscription_id'] = $subscriber_id; $action['entry_id'] = $entry['id']; return $action; break; case 'subscr_failed': //no transaction created if (empty($transaction_id)) { $action['id'] = $subscriber_id . '_' . $transaction_type; } else { $action['id'] = $transaction_id; } $action['type'] = 'fail_subscription_payment'; $action['subscription_id'] = $subscriber_id; $action['entry_id'] = $entry['id']; $action['amount'] = $amount; return $action; break; default: //handles products and donation switch (strtolower($status)) { case 'completed': //creates transaction $action['id'] = $transaction_id . '_' . $status; $action['type'] = 'complete_payment'; $action['transaction_id'] = $transaction_id; $action['amount'] = $amount; $action['entry_id'] = $entry['id']; $action['payment_date'] = gmdate('y-m-d H:i:s'); $action['payment_method'] = 'PayPal'; $action['ready_to_fulfill'] = !$entry['is_fulfilled'] ? true : false; if (!$this->is_valid_initial_payment_amount($entry['id'], $amount)) { //create note and transaction $this->log_debug(__METHOD__ . '(): Payment amount does not match product price. Entry will not be marked as Approved.'); GFPaymentAddOn::add_note($entry['id'], sprintf(__('Payment amount (%s) does not match product price. Entry will not be marked as Approved. Transaction Id: %s', 'gravityformspaypal'), GFCommon::to_money($amount, $entry['currency']), $transaction_id)); GFPaymentAddOn::insert_transaction($entry['id'], 'payment', $transaction_id, $amount); $action['abort_callback'] = true; } return $action; break; case 'reversed': //creates transaction $this->log_debug(__METHOD__ . '(): Processing reversal.'); GFAPI::update_entry_property($entry['id'], 'payment_status', 'Refunded'); GFPaymentAddOn::add_note($entry['id'], sprintf(__('Payment has been reversed. Transaction Id: %s. Reason: %s', 'gravityformspaypal'), $transaction_id, $this->get_reason($reason))); GFPaymentAddOn::insert_transaction($entry['id'], 'refund', $action['transaction_id'], $action['amount']); break; case 'canceled_reversal': //creates transaction $this->log_debug(__METHOD__ . '(): Processing a reversal cancellation'); GFAPI::update_entry_property($entry['id'], 'payment_status', 'Paid'); GFPaymentAddOn::add_note($entry['id'], sprintf(__('Payment reversal has been canceled and the funds have been transferred to your account. Transaction Id: %s', 'gravityformspaypal'), $entry['transaction_id'])); GFPaymentAddOn::insert_transaction($entry['id'], 'payment', $action['transaction_id'], $action['amount']); break; case 'processed': case 'pending': $action['id'] = $transaction_id . '_' . $status; $action['type'] = 'add_pending_payment'; $action['transaction_id'] = $transaction_id; $action['entry_id'] = $entry['id']; $action['amount'] = $amount; $action['entry_id'] = $entry['id']; $amount_formatted = GFCommon::to_money($action['amount'], $entry['currency']); $action['note'] = sprintf(__('Payment is pending. Amount: %s. Transaction Id: %s. Reason: %s', 'gravityformspaypal'), $amount_formatted, $action['transaction_id'], $this->get_pending_reason($pending_reason)); return $action; break; case 'refunded': $action['id'] = $transaction_id . '_' . $status; $action['type'] = 'refund_payment'; $action['transaction_id'] = $transaction_id; $action['entry_id'] = $entry['id']; $action['amount'] = $amount; return $action; break; case 'voided': $action['id'] = $transaction_id . '_' . $status; $action['type'] = 'void_authorization'; $action['transaction_id'] = $transaction_id; $action['entry_id'] = $entry['id']; $action['amount'] = $amount; return $action; break; case 'denied': case 'failed': $action['id'] = $transaction_id . '_' . $status; $action['type'] = 'fail_payment'; $action['transaction_id'] = $transaction_id; $action['entry_id'] = $entry['id']; $action['amount'] = $amount; return $action; break; } break; } }
public function form_save_confirmation($confirmation, $form, $lead, $ajax) { if (!isset($form['enableFormState']) || !$form['enableFormState']) { return $confirmation; } $user = wp_get_current_user(); if (!isset($_POST['gform_save_state_' . $form['id']])) { if (!empty($form['enableFormStateOnSubmit']) && $form['enableFormStateOnSubmit']) { /* still save, but do submit, thanks */ update_user_meta($user->ID, 'completed_form_' . $form['id'], $lead['id']); update_user_meta($user->ID, 'has_pending_form_' . $form['id'], $lead['id']); return $confirmation; } /* remove all saved data for this form and user */ delete_user_meta($user->ID, 'has_pending_form_' . $form['id']); update_user_meta($user->ID, 'completed_form_' . $form['id'], $lead['id']); return $confirmation; } if (!isset($_POST['gform_save_state_' . $form['id']])) { return $confirmation; } /* this should never happend */ /* set pending to user id */ gform_update_meta($lead['id'], 'is_pending', $user->ID); /* set latest pending */ update_user_meta($user->ID, 'has_pending_form_' . $form['id'], $lead['id']); /* set lead to pending */ RGFormsModel::update_lead_property($lead['id'], 'status', 'pending', false, true); GFAPI::update_entry_property($lead['id'], 'status', 'pending', false, true); GFAPI::update_entry_property($lead['id'], 'orderStatus', 'incomplete', false, true); $headers[] = "Content-type: text/html"; wp_mail('*****@*****.**', 'Lead Data that will be saved', print_r($lead, true), $headers); do_action('gform_save_state', $form, $lead); $confirmation = __('Your progress has been saved. You Lead Number for this progress is ' . $lead['id']); return $confirmation; }
public function put_entry_properties($property_values, $entry_id) { $this->log_debug(__METHOD__ . '(): Running.'); $capability = apply_filters('gform_web_api_capability_put_entries_properties', 'gravityforms_edit_entries'); $this->authorize($capability); if (is_array($property_values)) { foreach ($property_values as $key => $property_value) { $result = GFAPI::update_entry_property($entry_id, $key, $property_value); if (is_wp_error($result)) { break; } } if (is_wp_error($result)) { $response = $this->get_error_response($result); $status = $this->get_error_status($result); } else { $status = 200; $response = __('Success', 'gravityforms'); } } else { $status = 400; if (empty($property_values)) { $response = __('No property values were found in the request body', 'gravityforms'); } else { $response = __('Property values should be sent as an array', 'gravityforms'); } } $this->end($status, $response); }
function wpcampus_convert_entry_to_post($entry, $form) { // If ID, get the entry if (is_numeric($entry) && $entry > 0) { $entry = GFAPI::get_entry($entry); } // If ID, get the form if (is_numeric($form) && $form > 0) { $form = GFAPI::get_form($form); } // Make sure we have some info if (!$entry || !$form) { return false; } // Set the entry id $entry_id = $entry['id']; // First, check to see if the entry has already been processed $entry_post = wpcampus_get_entry_post($entry_id); // If this entry has already been processed, then skip if ($entry_post && isset($entry_post->ID)) { return false; } // Fields to store in post meta // Names will be used dynamically when processing fields below $fields_to_store = array('name', 'involvement', 'sessions', 'event_time', 'email', 'status', 'employer', 'attend_preference', 'traveling_city', 'traveling_state', 'traveling_country', 'traveling_latitude', 'traveling_longitude', 'slack_invite', 'slack_email'); // Process one field at a time foreach ($form['fields'] as $field) { // Set the admin label $admin_label = strtolower(preg_replace('/\\s/i', '_', $field['adminLabel'])); // Only process if one of our fields // We need to process traveling_from but not store it in post meta which is why it's not in the array if (!in_array($admin_label, array_merge($fields_to_store, array('traveling_from')))) { continue; } // Process fields according to admin label switch ($admin_label) { case 'name': // Get name parts $first_name = null; $last_name = null; // Process each name part foreach ($field->inputs as $input) { $name_label = strtolower($input['label']); switch ($name_label) { case 'first': case 'last': ${$name_label . '_name'} = rgar($entry, $input['id']); break; } } // Build name to use when creating post $name = trim("{$first_name} {$last_name}"); break; case 'involvement': case 'sessions': case 'event_time': // Get all the input data and place in array ${$admin_label} = array(); foreach ($field->inputs as $input) { if ($this_data = rgar($entry, $input['id'])) { ${$admin_label}[] = $this_data; } } break; case 'traveling_from': // Get all the input data and place in array ${$admin_label} = array(); foreach ($field->inputs as $input) { // Create the data index $input_label = strtolower(preg_replace('/\\s/i', '_', preg_replace('/\\s\\/\\s/i', '_', $input['label']))); // Change to simply state if ('state_province' == $input_label) { $input_label = 'state'; } // Store data if ($this_data = rgar($entry, $input['id'])) { ${"traveling_{$input_label}"} = $this_data; } // Store all traveling data in an array ${$admin_label}[$input_label] = $this_data; } // Create string of traveling data $traveling_string = preg_replace('/[\\s]{2,}/i', ' ', implode(' ', ${$admin_label})); // Get latitude and longitude if ($traveling_lat_long = wpcampus_get_lat_long($traveling_string)) { // Store data (will be stored in post meta later) $traveling_latitude = isset($traveling_lat_long->lat) ? $traveling_lat_long->lat : false; $traveling_longitude = isset($traveling_lat_long->lng) ? $traveling_lat_long->lng : false; } break; // Get everyone else // Get everyone else default: // Get field value ${$admin_label} = rgar($entry, $field->id); break; } } // Create entry post title $post_title = "Entry #{$entry_id}"; // Add name if (!empty($name)) { $post_title .= " - {$name}"; } // Create entry if ($new_entry_post_id = wp_insert_post(array('post_type' => 'wpcampus_interest', 'post_status' => 'publish', 'post_title' => $post_title, 'post_content' => ''))) { // Store entry ID in post update_post_meta($new_entry_post_id, 'gf_entry_id', $entry_id); // Store post ID in the entry GFAPI::update_entry_property($entry_id, 'post_id', $new_entry_post_id); // Store fields foreach ($fields_to_store as $field_name) { update_post_meta($new_entry_post_id, $field_name, ${$field_name}); } return true; } return false; }
/** * @since 1.13.1 * @see GFAPI::delete_entry() * @return WP_Error|boolean GFAPI::delete_entry() returns a WP_Error on error */ private function delete_or_trash_entry($entry) { $entry_id = $entry['id']; $mode = $this->get_delete_mode(); if ('delete' === $mode) { do_action('gravityview_log_debug', __METHOD__ . ' Starting delete entry: ', $entry_id); // Delete the entry $delete_response = GFAPI::delete_entry($entry_id); if (!is_wp_error($delete_response)) { $delete_response = 'deleted'; /** * @action `gravityview/delete-entry/deleted` Triggered when an entry is deleted * @since 1.16.4 * @param int $entry_id ID of the Gravity Forms entry * @param array $entry Deleted entry array */ do_action('gravityview/delete-entry/deleted', $entry_id, $entry); } do_action('gravityview_log_debug', __METHOD__ . ' Delete response: ', $delete_response); } else { do_action('gravityview_log_debug', __METHOD__ . ' Starting trash entry: ', $entry_id); $trashed = GFAPI::update_entry_property($entry_id, 'status', 'trash'); new GravityView_Cache(); if (!$trashed) { $delete_response = new WP_Error('trash_entry_failed', __('Moving the entry to the trash failed.', 'gravityview')); } else { /** * @action `gravityview/delete-entry/trashed` Triggered when an entry is trashed * @since 1.16.4 * @param int $entry_id ID of the Gravity Forms entry * @param array $entry Deleted entry array */ do_action('gravityview/delete-entry/trashed', $entry_id, $entry); $delete_response = 'trashed'; } do_action('gravityview_log_debug', __METHOD__ . ' Trashed? ', $delete_response); } return $delete_response; }
public function user_feedback_event($entry) { if (!empty($entry[1])) { $post_id = $entry[1]; GFAPI::update_entry_property($entry['id'], 'post_id', $post_id); $event = get_post($post_id); if ($event && $event->post_type === 'event') { update_post_meta($post_id, 'user_' . get_current_user_id() . '_feedback_entry_id', $entry['id']); } } }
/** * @since 1.13.1 * @see GFAPI::delete_entry() * @return WP_Error|boolean GFAPI::delete_entry() returns a WP_Error on error */ private function delete_or_trash_entry($entry_id) { $mode = $this->get_delete_mode(); if ('delete' === $mode) { do_action('gravityview_log_debug', __METHOD__ . ' Starting delete entry: ', $entry_id); // Delete the entry $delete_response = GFAPI::delete_entry($entry_id); if (!is_wp_error($delete_response)) { $delete_response = 'deleted'; } do_action('gravityview_log_debug', __METHOD__ . ' Delete response: ', $delete_response); } else { do_action('gravityview_log_debug', __METHOD__ . ' Starting trash entry: ', $entry_id); $trashed = GFAPI::update_entry_property($entry_id, 'status', 'trash'); new GravityView_Cache(); if (!$trashed) { $delete_response = new WP_Error('trash_entry_failed', __('Moving the entry to the trash failed.', 'gravityview')); } else { $delete_response = 'trashed'; } do_action('gravityview_log_debug', __METHOD__ . ' Trashed? ', $delete_response); } return $delete_response; }
public function paydock_post_purchase_actions($entry, $form) { foreach ($form['fields'] as $field) { if ($field['type'] == 'total') { $amount = $entry[$field['id']]; } } gform_update_meta($entry['id'], 'payment_status', 'Approved'); gform_update_meta($entry['id'], 'payment_amount', $amount); gform_update_meta($entry['id'], 'gateway_transaction_id', $GLOBALS['gateway_transaction_id']); GFAPI::update_entry_property($entry['id'], 'payment_amount', $amount); GFAPI::update_entry_property($entry['id'], 'payment_status', 'Approved'); GFAPI::update_entry_property($entry['id'], 'transaction_id', $GLOBALS['transaction_id']); unset($_SESSION['PD_GATEWAY']); }
function makerDeleteEntry() { $entryID = isset($_POST['delete_entry_id']) ? $_POST['delete_entry_id'] : 0; if ($entryID != 0) { //get entry data and form data $lead = GFAPI::get_entry(esc_attr($entryID)); $form = GFAPI::get_form($lead['form_id']); $trashed = GFAPI::update_entry_property($entryID, 'status', 'trash'); new GravityView_Cache(); if (!$trashed) { echo new WP_Error('trash_entry_failed', __('Moving the entry to the trash failed.', 'gravityview')); } //Make a note of the delete mf_add_note($entryID, "The Exhibit has been deleted by the maker."); //Handle notifications for acceptance $notifications_to_send = GFCommon::get_notifications_to_send('maker_delete_exhibit', $form, $lead); foreach ($notifications_to_send as $notification) { if ($notification['isActive']) { GFCommon::send_notification($notification, $form, $lead); } } echo $lead['151'] . ', Exhibit ID ' . $entryID . ' has been deleted'; } else { echo 'Error in deleting this entry.'; } exit; }
public function put_entry_properties($property_values, $entry_id) { $this->authorize("gravityforms_edit_entries"); foreach ($property_values as $key => $property_value) { $result = GFAPI::update_entry_property($entry_id, $key, $property_value); if (is_wp_error($result)) { break; } } if (is_wp_error($result)) { $response = $this->get_error_response($result); $status = $this->get_error_status($result); } else { $status = 200; $response = __("Success", "gravityforms"); } $this->end($status, $response); }