/** * Update entry * * @param array $entry */ public static function update_entry($entry) { /* * GFFormsModel::update_lead() is no longer in use since version 1.8.8! Instead use GFAPI::update_entry(). * * @see https://github.com/wp-premium/gravityforms/blob/1.8.13/forms_model.php#L587-L624 * @see https://github.com/wp-premium/gravityforms/blob/1.8.13/includes/api.php#L495-L654 * @see https://github.com/wp-premium/gravityforms/blob/1.8.7.11/forms_model.php#L587-L621 */ if (Pronamic_WP_Pay_Class::method_exists('GFAPI', 'update_entry')) { GFAPI::update_entry($entry); } elseif (Pronamic_WP_Pay_Class::method_exists('GFFormsModel', 'update_lead')) { GFFormsModel::update_lead($entry); } }
/** * update payment status if it has changed * @param array $form * @param int $lead_id */ public function gformAfterUpdateEntry($form, $lead_id) { // make sure we have permission check_admin_referer('gforms_save_entry', 'gforms_save_entry'); // check that save action is for update if (strtolower(rgpost('save')) != 'update') { return; } // make sure payment is one of ours (probably) $payment_gateway = gform_get_meta($lead_id, 'payment_gateway'); if (empty($payment_gateway) && GFEwayPlugin::isEwayForm($form['id'], $form['fields']) || $payment_gateway != 'gfeway') { return; } // make sure we have a new payment status $payment_status = rgpost('payment_status'); if (empty($payment_status)) { return; } // update payment status $lead = GFFormsModel::get_lead($lead_id); $lead['payment_status'] = $payment_status; GFFormsModel::update_lead($lead); }
function euzakupki_dotpay_callback($response) { $lead = GFFormsModel::get_lead($response['control']); if (!$lead) { return; } // Return if payment completed if ($lead['payment_status'] == 'completed') { return; } $t_status = $response['t_status']; switch ($t_status) { case 2: $payment_status = 'completed'; $customer_balance = get_user_meta($lead['created_by'], 'balance', true); @($customer_balance = preg_replace('!s:(\\d+):"(.*?)";!e', "'s:'.strlen('\$2').':\"\$2\";'", $customer_balance)); $customer_balance = unserialize($customer_balance); $new_amount = euzakupki_pln_to_euro($response['amount']); $new_fund = array('amount' => $new_amount, 'date' => $response['t_date'], 'reason' => __('Пополнение баланса DotPay', 'euzakupki')); $customer_balance[] = $new_fund; $res = update_user_meta($lead['created_by'], 'balance', serialize($customer_balance)); break; default: $payment_status = 'error'; break; } $lead['payment_status'] = $payment_status; $lead['payment_date'] = $response['t_date']; $lead['payment_amount'] = $response['amount']; $lead['transaction_id'] = $response['t_id']; $lead['transaction_type'] = $response['channel']; $lead['payment_method'] = $response['p_info']; // Update lead and entry. Set transaction result data. GFFormsModel::update_lead($lead); // Write log $filename = get_template_directory() . '/logs/dotpay.log'; if (!file_exists($filename)) { $log = array(); } else { $log = file_get_contents($filename); @($log = preg_replace('!s:(\\d+):"(.*?)";!e', "'s:'.strlen('\$2').':\"\$2\";'", $log)); $log = unserialize($log); } $log[] = $response; $log = serialize($log); $handle = fopen($filename, 'w+'); fwrite($handle, $log); fclose($handle); }
protected function process_subscription($authorization, $feed, $submission_data, $form, $entry) { $subscription = rgar($authorization, "subscription"); if (empty($subscription)) { return; } //If setup fee / trial is captured as part of a separate transaction $payment = rgar($subscription, "captured_payment"); $payment_name = rgempty("name", $payment) ? __("Initial payment", "gravityforms") : $payment["name"]; if ($payment && $payment["is_success"]) { $this->insert_transaction($entry["id"], "payment", $payment["transaction_id"], $payment["amount"]); GFFormsModel::add_note($entry["id"], 0, "System", sprintf(__("%s has been captured successfully. Amount: %s. Transaction Id: %s", "gravityforms"), $payment_name, GFCommon::to_money($payment["amount"], $entry["currency"]), $payment["transaction_id"])); } else { if ($payment && !$payment["is_success"]) { GFFormsModel::add_note($entry["id"], 0, "System", sprintf(__("Failed to capture %s. Reason: %s.", "gravityforms"), $payment("error_message"), $payment_name)); } } //Updating subscription information if ($subscription["is_success"]) { $entry["transaction_id"] = $subscription["subscription_id"]; $entry["transaction_type"] = "2"; $entry["is_fulfilled"] = true; $entry["currency"] = GFCommon::get_currency(); $entry["payment_amount"] = $subscription["amount"]; $entry["payment_status"] = "Active"; $entry["payment_date"] = gmdate("Y-m-d H:i:s"); GFFormsModel::add_note($entry["id"], 0, "System", sprintf(__("Subscription successfully created. Subscription Id: %s.", "gravityforms"), $subscription["subscription_id"])); } else { $entry["payment_status"] = "Failed"; GFFormsModel::add_note($entry["id"], 0, "System", sprintf(__("Subscription failed to be created. Reason: %s", "gravityforms"), $subscription["error_message"])); } GFFormsModel::update_lead($entry); return $entry; }
/** * form entry post-submission processing * @param array $entry * @param array $form * @return array */ public function gformEntryPostSave($entry, $form) { if (!empty($this->txResult['payment_status'])) { foreach ($this->txResult as $key => $value) { switch ($key) { case 'payment_status': case 'payment_date': case 'payment_amount': case 'transaction_id': case 'transaction_type': case 'payment_gateway': // custom entry meta must be saved with entry // custom entry meta must be saved with entry case 'authcode': // custom entry meta must be saved with entry // update entry $entry[$key] = $value; break; default: // update entry meta gform_update_meta($entry['id'], $key, $value); break; } } // update the entry if (class_exists('GFAPI')) { GFAPI::update_entry($entry); } else { GFFormsModel::update_lead($entry); } } return $entry; }