Skip to content

Commit 64bcc5f

Browse files
Add support for other currencies
1 parent a37a7c3 commit 64bcc5f

File tree

3 files changed

+17
-14
lines changed

3 files changed

+17
-14
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ All Notable changes to `laravel-paystack` will be documented in this file
77

88
## 2020-05-23
99
- Support for Laravel 7
10-
- Support for splitting payments into subaccounts
10+
- Support for splitting payments into subaccounts
11+
- Support for more than one currency. Now you can use USD!

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@ A sample form will look like so:
277277
<input type="hidden" name="orderID" value="345">
278278
<input type="hidden" name="amount" value="800"> {{-- required in kobo --}}
279279
<input type="hidden" name="quantity" value="3">
280+
<input type="hidden" name="currency" value="NGN">
280281
<input type="hidden" name="metadata" value="{{ json_encode($array = ['key_name' => 'value',]) }}" > {{-- For other necessary things you want to add to your payload. it is optional though --}}
281282
<input type="hidden" name="reference" value="{{ Paystack::genTranxRef() }}"> {{-- required --}}
282283
<input type="hidden" name="key" value="{{ config('paystack.secretKey') }}"> {{-- required --}}

src/Paystack.php

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,11 @@ private function setRequestOptions()
100100
);
101101
}
102102

103-
103+
104104
/**
105-
105+
106106
* Initiate a payment request to Paystack
107-
* Included the option to pass the payload to this method for situations
107+
* Included the option to pass the payload to this method for situations
108108
* when the payload is built on the fly (not passed to the controller from a view)
109109
* @return Paystack
110110
*/
@@ -120,8 +120,9 @@ public function makePaymentRequest( $data = null)
120120
"first_name" => request()->first_name,
121121
"last_name" => request()->last_name,
122122
"callback_url" => request()->callback_url,
123+
"currency" => (request()->currency != "" ? request()->currency : "NGN"),
123124
/*
124-
Paystack allows for transactions to be split into a subaccount -
125+
Paystack allows for transactions to be split into a subaccount -
125126
The following lines trap the subaccount ID - as well as the ammount to charge the subaccount (if overriden in the form)
126127
both values need to be entered within hidden input fields
127128
*/
@@ -137,7 +138,7 @@ public function makePaymentRequest( $data = null)
137138
* .
138139
* .
139140
* ]
140-
*
141+
*
141142
* ]
142143
*/
143144
'metadata' => request()->metadata
@@ -186,10 +187,10 @@ public function getAuthorizationUrl()
186187

187188
return $this;
188189
}
189-
190+
190191
/**
191192
* Get the authorization callback response
192-
* In situations where Laravel serves as an backend for a detached UI, the api cannot redirect
193+
* In situations where Laravel serves as an backend for a detached UI, the api cannot redirect
193194
* and might need to take different actions based on the success or not of the transaction
194195
* @return array
195196
*/
@@ -597,13 +598,13 @@ public function updatePage($page_id)
597598

598599
/**
599600
* Creates a subaccount to be used for split payments . Required params are business_name , settlement_bank , account_number , percentage_charge
600-
*
601+
*
601602
* @return array
602603
*/
603-
604+
604605
public function createSubAccount(){
605606
$data = [
606-
"business_name" => request()->business_name,
607+
"business_name" => request()->business_name,
607608
"settlement_bank" => request()->settlement_bank,
608609
"account_number" => request()->account_number,
609610
"percentage_charge" => request()->percentage_charge,
@@ -646,13 +647,13 @@ public function listSubAccounts($per_page,$page){
646647

647648
/**
648649
* Updates a subaccount to be used for split payments . Required params are business_name , settlement_bank , account_number , percentage_charge
649-
* @param subaccount code
650+
* @param subaccount code
650651
* @return array
651652
*/
652-
653+
653654
public function updateSubAccount($subaccount_code){
654655
$data = [
655-
"business_name" => request()->business_name,
656+
"business_name" => request()->business_name,
656657
"settlement_bank" => request()->settlement_bank,
657658
"account_number" => request()->account_number,
658659
"percentage_charge" => request()->percentage_charge,

0 commit comments

Comments
 (0)