emmajiugo
-
Posts
8 -
Joined
-
Last visited
-
Days Won
1
Posts posted by emmajiugo
-
-
Hi Tyson.
I appreciate your help. Please, I really need your help on the above in order to close this project by tomorrow.
-
So how do I now call the ::validate method. Or should I call it from the ::success method?
This is how our gateway works...The user is taken to the gateway's website to complete the transaction which the gateway returns to the user's website through the provided return_url or callback_url, appending unique references to the url for verification. We retrieve this reference using GET and run a check to make sure that the payment was successful or not.
The gateway also supports webhook where we send only successful payments, but the user needs to add the url to the webhook on their dashboard. I might not recommend this because the individual might forget to enter the webhook url on their dashboard thereby creating more problems. We would like to handle everything for the user.My current problem is how do I call the ::validate method after successful payment and returned back to the Blesta website, for me to run my check and update the invoice accordingly.
-
So the ::validate and ::success methods are called at the same time when gateway is returning back to Blesta website?
-
Hi
I have successfully integrated our gateway and I am running a test before deploying....but I am still experiencing one issue.
After payment on our gateway website, the success function is called where I verify the payment and return the array details as described in the doc. But if I go to the transactions list from the staff end, I don't see any proof of payment. The invoice is still open for another payment. It means I am still missing something please help.
public function buildProcess(array $contact_info, $amount, array $invoice_amounts = null, array $options = null){// Load the models requiredLoader::loadModels($this, ['Clients']);$client = $this->Clients->get($contact_info['client_id']);// Get the url to send paramsif ($this->meta['live_mode']) {$url = $this->live_url;$pkey = $this->meta['live_public_key'];$skey = $this->meta['live_secret_key'];} else {$url = $this->test_url;$pkey = $this->meta['test_public_key'];$skey = $this->meta['test_secret_key'];}// Load Rave API$api = $this->getApi($skey, $pkey, $url);// set parameter to send to API$invoices = json_encode($invoice_amounts);$params = ['amount'=>$amount,'customer_email'=>$client->email,'currency'=>$this->currency,'txref'=>"BLST-".time(),'PBFPubKey'=>$pkey,'redirect_url'=>$this->ifSet($options['return_url']),'meta' => array(['metaname' => 'clientID','metavalue' => $contact_info['client_id']],['metaname' => 'invoices','metavalue' => $invoices]),];// Get the url to redirect the client to rave standard$result = $api->buildPayment($params);$data = $result->data();$rave_url = isset($data->link) ? $data->link : '';return $this->buildForm($rave_url);}/*** Builds the HTML form.** @return string The HTML form*/private function buildForm($post_to){$this->view = $this->makeView('process', 'default', str_replace(ROOTWEBDIR, '', dirname(__FILE__) . DS));// Load the helpers required for this viewLoader::loadHelpers($this, ['Form', 'Html']);$this->view->set('post_to', $post_to);return $this->view->fetch();}/*** Validates the incoming POST/GET response from the gateway to ensure it is* legitimate and can be trusted.**/public function validate(array $get, array $post) {// Log the successful response$this->log($this->ifSet($_SERVER['REQUEST_URI']), serialize($post), "output", true);return array();}/**public function success(array $get, array $post) {// Get the url to send paramsif ($this->meta['live_mode']) {$url = $this->live_url;$pkey = $this->meta['live_public_key'];$skey = $this->meta['live_secret_key'];} else {$url = $this->test_url;$pkey = $this->meta['test_public_key'];$skey = $this->meta['test_secret_key'];}// Load Rave API$api = $this->getApi($skey, $pkey, $url);// verify transaction$verifyParams = ['txref' => $this->ifSet($get['txref']),'SECKEY' => $skey];$result = $api->checkPayment($verifyParams);$data = $result->data();// Get client ID and invoice from metadata$metadata = $this->ifSet($data->meta);foreach ($metadata as $value) {if ($value->metaname == 'clientID') {$client_id = $value->metavalue;}if ($value->metaname == 'invoices') {$invoices = $value->metavalue;}}// decode the invoices$final_invoices = json_decode($invoices, true);//return final response for blestareturn ['client_id' => $this->ifSet($client_id),'amount' => $this->ifSet($data->amount),'currency' => $this->ifSet($data->currency),'status' => $this->ifSet($data->chargecode) == '00' || $this->ifSet($data->chargecode) == '0' ? 'approved' : 'declined', // we wouldn't be here if it weren't, right?'transaction_id' => $this->ifSet($data->txref),'invoices' => $this->ifSet($final_invoices)];// return $x;} -
Please also...the $this->serializeInvoices(.....)...what those it return... it's preventing my code from running if I put it in the metadata that will be pass to the gateway
-
15 hours ago, Tyson said:
I think we'd need to know more about the payment flow for Rave in order to be of more help.
Blesta non-merchant gateways typically set a form in a view (e.g. /rave/views/default/process.pdt), which is what your code snippet fetches. Assuming the Form helper is being used, which defaults the method to POST, you can override the form method by updating the view as such:
<?php $this->Form->create($post_to, ['method' => 'GET']); ...
Working fine now. Thanks.
If I want to replace the button "Pay with Rave" with an image, how should I do it?
-
Hi Guys,
I really need help.
I was given the task to build our gateway payment plugin for Blesta and I am having a little issue.
Anytime I click on "Pay With Rave" button, it redirects me to our payment page but it says page not found.
We tried checking our headers to make sure that it is not a cross-origin issue but everything is fine from our end. We noticed when we click the "Pay with Rave" button, the Request Method is POST but we need it to be GET. Is there a function to use in replace of the below:
$this->view->set('post_to', $post_to);return $this->view->fetch();
Invoice not reflecting in Admin (staff) end
in Extensions
Posted
Thanks Tyson.
It's working perfectly well now.
Cheers.