JackMagic Posted June 19, 2015 Share Posted June 19, 2015 Hi guys, Just wondering if you can help me out. I'm using the https://wordpress.org/plugins/gravityforms-eway/ plugin and I need to modify the gfeway_invoice_ref hook to show sequential numbers so that it reflects real invoice numbers (for example 00001, 00002, 00003, 00004 etc) rather than the form id of my Gravity Form which is '1' and is displayed as the invoice number on all my transactions. Any assistance would be amazing, the code is as below: ----------------------------------------------------------------------------------------------------------------------------------------------------- /** * process recurring payments * @param array $data an array with elements is_valid (boolean) and form (array of form elements) * @param GFEwayFormData $formData pre-parsed data from $data * @return array */ protected function processRecurringPayment($data, $formData) { try { $eway = new GFEwayRecurringPayment($this->getCustomerID(), !$this->options['useTest']); $eway->sslVerifyPeer = $this->options['sslVerifyPeer']; if (empty($formData->firstName) && empty($formData->lastName)) { $eway->firstName = '-'; // no first name, $eway->lastName = $formData->ccName; // pick up card holder's name for last name } else { $eway->title = $formData->namePrefix; $eway->firstName = $formData->firstName; $eway->lastName = $formData->lastName; } $eway->emailAddress = $formData->email; $eway->address = $formData->address_street; $eway->suburb = $formData->address_suburb; $eway->state = $formData->address_state; $eway->postcode = $formData->postcode; $eway->country = $formData->address_country; $eway->phone = $formData->phone; $eway->customerReference = $data['form']['id']; $eway->invoiceReference = $data['form']['id']; $eway->invoiceDescription = get_bloginfo('name') . " -- {$data['form']['title']}"; $eway->cardHoldersName = $formData->ccName; $eway->cardNumber = $formData->ccNumber; $eway->cardExpiryMonth = $formData->ccExpMonth; $eway->cardExpiryYear = $formData->ccExpYear; $eway->amountInit = $formData->recurring['amountInit']; $eway->dateInit = $formData->recurring['dateInit']; $eway->amountRecur = $formData->recurring['amountRecur']; $eway->dateStart = $formData->recurring['dateStart']; $eway->dateEnd = $formData->recurring['dateEnd']; $eway->intervalSize = $formData->recurring['intervalSize']; $eway->intervalType = $formData->recurring['intervalType']; // allow plugins/themes to modify invoice description and reference, and set option fields $eway->invoiceDescription = apply_filters('gfeway_invoice_desc', $eway->invoiceDescription, $data['form']); $eway->customerReference = apply_filters('gfeway_invoice_ref', $eway->customerReference, $data['form']); $eway->invoiceReference = apply_filters('gfeway_invoice_trans_number', $eway->invoiceReference, $data['form']); $eway->customerComments = apply_filters('gfeway_invoice_cust_comments', '', $data['form']); self::log_debug(sprintf('%s: %s gateway, invoice ref: %s, customer ref: %s, init amount: %s, recurring amount: %s, date start: %s, date end: %s, interval size: %s, interval type: %s, cc: %s', __FUNCTION__, $eway->isLiveSite ? 'live' : 'test', $eway->invoiceReference, $eway->customerReference, $eway->amountInit, $eway->amountRecur, $eway->dateStart->format('Y-m-d'), $eway->dateEnd->format('Y-m-d'), $eway->intervalSize, $eway->intervalType, $eway->cardNumber)); // record basic transaction data, for updating the entry with later $this->txResult = array ( 'payment_gateway' => 'gfeway', 'gfeway_unique_id' => GFFormsModel::get_form_unique_id($data['form']['id']), // reduces risk of double-submission ); $response = $eway->processPayment(); if ($response->status) { // transaction was successful, so record transaction number and continue $this->txResult['payment_status'] = 'Approved'; $this->txResult['payment_date'] = date('Y-m-d H:i:s'); $this->txResult['transaction_type'] = 1; self::log_debug(sprintf('%s: success, date = %s, status = %s', __FUNCTION__, $this->txResult['payment_date'], $this->txResult['payment_status'])); } else { $data['is_valid'] = false; $formData->ccField['failed_validation'] = true; $formData->ccField['validation_message'] = nl2br($this->getErrMsg(GFEWAY_ERROR_EWAY_FAIL) . ":\n{$response->error}"); $this->txResult['payment_status'] = 'Failed'; self::log_debug(sprintf('%s: failed; %s', __FUNCTION__, $response->error)); } } catch (GFEwayException $e) { $data['is_valid'] = false; $formData->ccField['failed_validation'] = true; $formData->ccField['validation_message'] = nl2br($this->getErrMsg(GFEWAY_ERROR_EWAY_FAIL) . ":\n{$e->getMessage()}"); $this->txResult['payment_status'] = 'Failed'; self::log_error(__METHOD__ . ": " . $e->getMessage()); } return $data; } ----------------------------------------------------------------------------------------------------------------------------------------------------- Thanks in Advance! Quote Link to comment https://forums.phpfreaks.com/topic/296908-eway-and-gravity-forms-plugin-code-modification/ Share on other sites More sharing options...
JackMagic Posted June 19, 2015 Author Share Posted June 19, 2015 Just to note, the plugin author said that you'd need to manage it with a squential counter ising a WordPress option, https://codex.wordpress.org/Options_API Would still love some help with this. Quote Link to comment https://forums.phpfreaks.com/topic/296908-eway-and-gravity-forms-plugin-code-modification/#findComment-1514303 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.