fbpx
  Saturday, 26 May 2018
  2 Replies
  2.3K Visits
  Subscribe
How do I get the value that is entered by the user (eg:CardNumber) . My current code only returns the default Value

<?xml version="1.0" encoding="utf-8"?>
<form>
<fieldset name="payment">
<fields name="params">
<field
name="CardOwner"
type="text"
label="Card Holder"
class="inputbox"
default="Sample Kawukudi"
/>
<field
name="CardNo"
type="text"
label="Card Number"
class="inputbox"
default="XXXXXXXXXXXXXXXX"
/>
<field
name="CVV"
type="password"
label="PIN"
class="inputbox"
default="1234"
/>
<field
name="Expiry_Month"
type="text"
label="Expiry Month"
class="inputbox"
default="12"
/>
<field
name="Expiry_Year"
type="text"
label="Expiry Year"
class="inputbox"
default="2018"
/>
</fields>
</fieldset>
</form>








/**
* Create a payment using a previously obtained credit card id.
* The corresponding credit card is used as the funding instrument.
*
* @param stdClass $invoice The data required by the payment gateway to execute the transaction
*
* @return mixed
* @throws Exception
*/
protected function initPayment($invoice)
{

// Let any exception here to propagate upward
$me = JFactory::getUser();
$date = JFactory::getDate()->toSql();
$helper = SellaciousHelper::getInstance();
$http = JHttpFactory::getHttp();
$config = $this->getParams();

$form = JForm::getInstance('kharis', __DIR__.'/forms/kharis.xml');
$fieldsets = $form->getFieldsets();

$api = new stdClass();
$data = array(
'id' => null,
'order_id' => $invoice->order_id,
'context' => 'user.id',
'context_id' => $me->id,
'reason' => $invoice->reason,
'crdr' => 'dr',
'amount' => $invoice->amount,
'currency' => $invoice->currency,
'balance' => null,
'txn_date' => $date,
'state' => 1,


);


// $form = JForm::getInstance('kharis', __DIR__.'/forms/kharis.xml');

if ($form)
{
//get all the fieldsets in the xml form
$fieldsets = $form->getFieldsets();

//display for example the label of each fieldset - var_dump($fieldsets) to see more properties
foreach ($fieldsets as $fieldset)
{
// echo JText::_($fieldset->label);

//loop through the fields
$fields = $form->getFieldset($fieldset->name);


foreach ($fields as $field)
{
$data[substr(substr($field->name,0,-1),7)]=$field->value;
//exclude for example image type media from display
if (strtolower($field->type) != 'media')
{
//render the field - see class the finition for more methods
echo $field->renderField();
}

}
}
}
//$balance = $helper->transaction->getBalance($me->id, $invoice->currency, 'user.id');
$kurl = 'https://kcash.kharissystems.com/kharis.php/';



//$data['url'] = $url;
//$this->app->redirect($kurl.http_build_query($data, '', '&'));
// $response = $http->post($kurl, $data);
// $response = (object) $response;

return $response;
}

/**
* Generate response data to be stored in the transaction log and save
*
* @param object $response
*
* @return bool
* @throws Exception
*/


5 years ago
·
#1984
Anybody ?
5 years ago
·
#2011
Hi,

To get the data submitted by the customer you can simply call the following method:


$data = $this->getState('params');


On sellacious versions before 1.5.3, it was available directly using:


$data = $this->app->getUserState('com_sellacious.payment.execution.params');


We strongly recommend you to use the new method `getState` so that your plugin remain functional when the underlying storage is changed in sellacious.

Please make sure that your plugin class extends from `SellaciousPluginPayment` and not from `JPlugin` directly.

Hope this helps. Let us know if you need further clarification.
  • Page :
  • 1
There are no replies made for this post yet.
Be one of the first to reply to this post!
  • +1 (408) 821-8283
  • Email hello@sellacious.com