eldzee Posted October 22, 2020 Report Posted October 22, 2020 Hi guys, I'm trying to build a custom merchant payment gateway with custom CC form (so I can inject custom js from the merchant page to handle 3DS stuff) seems like blesta doesn't pass information about the card to the buildCcForm function thus it is unable to pre-fill the data when client want to edit the card (using custom form) is there a better way to be able to grab that particular card data to prefill the custom form? right now my solution was to edit a few stuffs in: (passing $vars to the function) /components/gateway_payments/gateway_payments.php :: public function getBuildCcForm($currency, $vars = null) { $html = ''; $gateway = $this->GatewayManager->getInstalledMerchant($this->company_id, $currency); $errors = null; if ($gateway) { // Initialize the gateway $gateway_obj = $this->initGateway($gateway, $currency); if ($gateway_obj instanceof MerchantCcForm) { //Check how if buildCCForm function accept parameter or not $method = new ReflectionMethod($gateway_obj, 'buildCCForm'); $numParam = $method->getNumberOfParameters(); //Pass param $vars to the function if it accept parameter $html = $numParam ? $gateway_obj->buildCcForm($vars) : $gateway_obj->buildCcForm(); $errors = $gateway_obj->errors(); } } if ($errors) { $this->Input->setErrors($errors); } return $html; } /app/models/payment.php :: public function getBuildCcForm($currency, $vars = null) { $result = $this->GatewayPayments->getBuildCcForm($currency, $vars); ... /plugins/order/controllers/checkout.php :: private function setCcView(stdClass $vars, $edit = false, $save_account = false) { $this->uses(['Payments']); // Fetch the cc form to be used with this company and currency $gateway_form = $this->Payments->getBuildCcForm(isset($this->client) ? $this->client->settings['default_currency'] : null , $vars ); ... /app/controllers/client_pay.php :: private function setCcView(stdClass $vars, $edit = false, $save_account = false) { $this->uses(['Payments']); // Fetch the cc form to be used with this company and currency $gateway_form = $this->Payments->getBuildCcForm($this->client->settings['default_currency'], $vars); ... /app/controllers/client_account.php :: private function getCcView(stdClass $vars, $edit = false, $save_account = false) { $this->uses(['Payments']); // Fetch the cc form to be used with this company and currency $gateway_form = $this->Payments->getBuildCcForm($this->client->settings['default_currency'], $vars); ... /app/controllers/admin_clients.php :: private function setCcView(stdClass $vars, stdClass $client, $edit = false, $save_account = false) { $this->uses(['Payments']); // Fetch the cc form to be used with this company and currency $gateway_form = $this->Payments->getBuildCcForm($client->settings['default_currency'], $vars); and then on the custom Gateway can pass the vars to the View CustomGateway :: public function buildCcForm($vars = null) { // Load the view into this object, so helpers can be automatically added to the view $this->view = $this->makeView('cc_form', 'default', str_replace(ROOTWEBDIR, '', dirname(__FILE__) . DS)); // Load the helpers required for this view Loader::loadHelpers($this, ['Form', 'Html']); $this->view->set('meta', $this->meta); $this->view->set('vars', $vars); return $this->view->fetch(); } Quote
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.