Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
NafezlyDotCom committed Mar 8, 2023
1 parent 0f961c8 commit 022d6a6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
2 changes: 2 additions & 0 deletions src/Classes/TapPayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ public function __construct()
public function pay($amount = null, $user_id = null, $user_first_name = null, $user_last_name = null, $user_email = null, $user_phone = null, $source = null)
{
$this->setPassedVariablesToGlobal($amount,$user_id,$user_first_name,$user_last_name,$user_email,$user_phone,$source);

$required_fields = ['amount', 'user_first_name', 'user_last_name', 'user_email', 'user_phone'];

$this->checkRequiredFields($required_fields, 'Tap', func_get_args());

$unique_id = uniqid();
Expand Down
18 changes: 9 additions & 9 deletions src/Traits/SetRequiredFields.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ trait SetRequiredFields
*
* @param array $required_fields
* @param string $gatway_name
* @param array $arguments
* @return void
*/
public function checkRequiredFields($required_fields, $gatway_name, $arguments)
public function checkRequiredFields($required_fields, $gatway_name)
{
$amount = $arguments[0] ?? null;
$user_id = $arguments[1] ?? null;
$user_first_name = $arguments[2] ?? null;
$user_last_name = $arguments[3] ?? null;
$user_email = $arguments[4] ?? null;
$user_phone = $arguments[5] ?? null;
$source = $arguments[6] ?? null;

$amount = $this->amount ?? null;
$user_id = $this->user_id ?? null;
$user_first_name = $this->user_first_name ?? null;
$user_last_name = $this->user_last_name ?? null;
$user_email = $this->user_email ?? null;
$user_phone = $this->user_phone ?? null;
$source = $this->source ?? null;
foreach($required_fields as $field){
$this->{$field} = $this->{$field} ?? ${$field};
if (is_null($this->{$field})) throw new MissingPaymentInfoException($field, $gatway_name);
Expand Down
14 changes: 7 additions & 7 deletions src/Traits/SetVariables.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,13 @@ public function setAmount($value)
*/
public function setPassedVariablesToGlobal($amount = null, $user_id = null, $user_first_name = null, $user_last_name = null, $user_email = null, $user_phone = null, $source = null)
{
$this->setAmount($amount);
$this->setUserId($user_id);
$this->setUserFirstName($user_first_name);
$this->setUserLastName($user_last_name);
$this->setUserEmail($user_email);
$this->setUserPhone($user_phone);
$this->setSource($source);
if($amount!=null)$this->setAmount($amount);
if($user_id!=null)$this->setUserId($user_id);
if($user_first_name!=null)$this->setUserFirstName($user_first_name);
if($user_last_name!=null)$this->setUserLastName($user_last_name);
if($user_email!=null)$this->setUserEmail($user_email);
if($user_phone!=null)$this->setUserPhone($user_phone);
if($source!=null)$this->setSource($source);
}


Expand Down

0 comments on commit 022d6a6

Please sign in to comment.