From 78ef0aeafadff965ce1d91d2a033d00312e29c8e Mon Sep 17 00:00:00 2001 From: Bobby Date: Sun, 16 Oct 2016 22:14:50 +0100 Subject: [PATCH] access callback response as objects --- src/Interswitch.php | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/Interswitch.php b/src/Interswitch.php index a1350a5..992dc09 100644 --- a/src/Interswitch.php +++ b/src/Interswitch.php @@ -82,7 +82,7 @@ public function raw(array $options = []) ); $inputs['txn_ref'] = $this->setTxnRef( - array_get($options, 'txn_ref', TransRef::getHashedToken(7)) + array_get($options, 'txn_ref', TransRef::getHashedToken(11)) ); $hashValues = $this->txnref. @@ -98,6 +98,10 @@ public function raw(array $options = []) $inputs['cust_name'] = $this->setCustName(array_get($options, 'cust_name')); $inputs['cust_id'] = $this->txnref; + foreach ($inputs as $key => $value) { + $this->$key = $value; + } + return $inputs; } @@ -108,20 +112,23 @@ public function raw(array $options = []) * * @return HTML */ - public function form(array $options = []) + public function form(array $options = [], string $id, $submitBtn = true) { $array = $this->raw($options); $action = array_get($array, 'action'); - $form = '
'.PHP_EOL; + $form = ''.PHP_EOL; $array = array_except($array, ['action']); foreach ($array as $key => $value) { $form .= ''.PHP_EOL; } - $form .= ''.PHP_EOL; + if ($submitBtn) { + $form .= ''.PHP_EOL; + } + $form .= '
'.PHP_EOL; return $form; @@ -138,8 +145,13 @@ public function callback() { $array = request()->all(); $query = $this->query($array); + $json = json_decode($query, true); + + foreach ($json as $key => $value) { + $this->$key = $value; + } - return json_decode($query, true); + return $this; } /**