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 required
Loader::loadModels($this, ['Clients']);
$client = $this->Clients->get($contact_info['client_id']);
// Get the url to send params
if ($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 view
Loader::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 params
if ($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 blesta
return [
'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;
}