Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7aea445

Browse filesBrowse files
committed
Pass transaction_id to verify transaction
1 parent 00b00fe commit 7aea445
Copy full SHA for 7aea445

File tree

1 file changed

+26
-27
lines changed
Filter options

1 file changed

+26
-27
lines changed

‎src/Paystack.php

Copy file name to clipboardExpand all lines: src/Paystack.php
+26-27Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public function setKey()
8686
*/
8787
private function setRequestOptions()
8888
{
89-
$authBearer = 'Bearer '. $this->secretKey;
89+
$authBearer = 'Bearer ' . $this->secretKey;
9090

9191
$this->client = new Client(
9292
[
@@ -101,7 +101,7 @@ private function setRequestOptions()
101101
}
102102

103103

104-
/**
104+
/**
105105
106106
* Initiate a payment request to Paystack
107107
* Included the option to pass the payload to this method for situations
@@ -111,7 +111,7 @@ private function setRequestOptions()
111111

112112
public function makePaymentRequest($data = null)
113113
{
114-
if ( $data == null ) {
114+
if ($data == null) {
115115

116116
$quantity = intval(request()->quantity ?? 1);
117117

@@ -214,7 +214,7 @@ public function getAuthorizationUrl($data = null)
214214
return $this;
215215
}
216216

217-
/**
217+
/**
218218
* Get the authorization callback response
219219
* In situations where Laravel serves as an backend for a detached UI, the api cannot redirect
220220
* and might need to take different actions based on the success or not of the transaction
@@ -232,9 +232,9 @@ public function getAuthorizationResponse($data)
232232
/**
233233
* Hit Paystack Gateway to Verify that the transaction is valid
234234
*/
235-
private function verifyTransactionAtGateway()
235+
private function verifyTransactionAtGateway($transaction_id = null)
236236
{
237-
$transactionRef = request()->query('trxref');
237+
$transactionRef = $transaction_id ?? request()->query('trxref');
238238

239239
$relativeUrl = "/transaction/verify/{$transactionRef}";
240240

@@ -245,9 +245,9 @@ private function verifyTransactionAtGateway()
245245
* True or false condition whether the transaction is verified
246246
* @return boolean
247247
*/
248-
public function isTransactionVerificationValid()
248+
public function isTransactionVerificationValid($transaction_id = null)
249249
{
250-
$this->verifyTransactionAtGateway();
250+
$this->verifyTransactionAtGateway($transaction_id);
251251

252252
$result = $this->getResponse()['message'];
253253

@@ -375,7 +375,6 @@ public function createPlan()
375375
$this->setRequestOptions();
376376

377377
return $this->setHttpResponse("/plan", 'POST', $data)->getResponse();
378-
379378
}
380379

381380
/**
@@ -436,7 +435,7 @@ public function createCustomer()
436435
public function fetchCustomer($customer_id)
437436
{
438437
$this->setRequestOptions();
439-
return $this->setHttpResponse('/customer/'. $customer_id, 'GET', [])->getResponse();
438+
return $this->setHttpResponse('/customer/' . $customer_id, 'GET', [])->getResponse();
440439
}
441440

442441
/**
@@ -456,7 +455,7 @@ public function updateCustomer($customer_id)
456455
];
457456

458457
$this->setRequestOptions();
459-
return $this->setHttpResponse('/customer/'. $customer_id, 'PUT', $data)->getResponse();
458+
return $this->setHttpResponse('/customer/' . $customer_id, 'PUT', $data)->getResponse();
460459
}
461460

462461
/**
@@ -566,7 +565,7 @@ public function disableSubscription()
566565
public function fetchSubscription($subscription_id)
567566
{
568567
$this->setRequestOptions();
569-
return $this->setHttpResponse('/subscription/'.$subscription_id, 'GET', [])->getResponse();
568+
return $this->setHttpResponse('/subscription/' . $subscription_id, 'GET', [])->getResponse();
570569
}
571570

572571
/**
@@ -602,7 +601,7 @@ public function getAllPages()
602601
public function fetchPage($page_id)
603602
{
604603
$this->setRequestOptions();
605-
return $this->setHttpResponse('/page/'.$page_id, 'GET', [])->getResponse();
604+
return $this->setHttpResponse('/page/' . $page_id, 'GET', [])->getResponse();
606605
}
607606

608607
/**
@@ -619,16 +618,17 @@ public function updatePage($page_id)
619618
];
620619

621620
$this->setRequestOptions();
622-
return $this->setHttpResponse('/page/'.$page_id, 'PUT', $data)->getResponse();
621+
return $this->setHttpResponse('/page/' . $page_id, 'PUT', $data)->getResponse();
623622
}
624623

625-
/**
624+
/**
626625
* Creates a subaccount to be used for split payments . Required params are business_name , settlement_bank , account_number , percentage_charge
627626
*
628627
* @return array
629628
*/
630629

631-
public function createSubAccount(){
630+
public function createSubAccount()
631+
{
632632
$data = [
633633
"business_name" => request()->business_name,
634634
"settlement_bank" => request()->settlement_bank,
@@ -643,31 +643,30 @@ public function createSubAccount(){
643643

644644
$this->setRequestOptions();
645645
return $this->setHttpResponse('/subaccount', 'POST', array_filter($data))->getResponse();
646-
647646
}
648647

649-
/**
648+
/**
650649
* Fetches details of a subaccount
651650
* @param subaccount code
652651
* @return array
653652
*/
654-
public function fetchSubAccount($subaccount_code){
653+
public function fetchSubAccount($subaccount_code)
654+
{
655655

656656
$this->setRequestOptions();
657-
return $this->setHttpResponse("/subaccount/{$subaccount_code}","GET",[])->getResponse();
658-
657+
return $this->setHttpResponse("/subaccount/{$subaccount_code}", "GET", [])->getResponse();
659658
}
660659

661-
/**
660+
/**
662661
* Lists all the subaccounts associated with the account
663662
* @param $per_page - Specifies how many records to retrieve per page , $page - SPecifies exactly what page to retrieve
664663
* @return array
665664
*/
666-
public function listSubAccounts($per_page,$page){
665+
public function listSubAccounts($per_page, $page)
666+
{
667667

668668
$this->setRequestOptions();
669-
return $this->setHttpResponse("/subaccount/?perPage=".(int) $per_page."&page=".(int) $page,"GET")->getResponse();
670-
669+
return $this->setHttpResponse("/subaccount/?perPage=" . (int) $per_page . "&page=" . (int) $page, "GET")->getResponse();
671670
}
672671

673672

@@ -677,7 +676,8 @@ public function listSubAccounts($per_page,$page){
677676
* @return array
678677
*/
679678

680-
public function updateSubAccount($subaccount_code){
679+
public function updateSubAccount($subaccount_code)
680+
{
681681
$data = [
682682
"business_name" => request()->business_name,
683683
"settlement_bank" => request()->settlement_bank,
@@ -693,6 +693,5 @@ public function updateSubAccount($subaccount_code){
693693

694694
$this->setRequestOptions();
695695
return $this->setHttpResponse("/subaccount/{$subaccount_code}", "PUT", array_filter($data))->getResponse();
696-
697696
}
698697
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.