Skip to content

Commit

Permalink
v1.0.1-alpha updated initializeTransaction by making $incomeSplitConf…
Browse files Browse the repository at this point in the history
…ig and optional argument
  • Loading branch information
henryejemuta committed Jul 20, 2020
1 parent d8280de commit 123c649
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/Console/InstallLaravelMonnify.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function handle()
$this->writeChanges($path, "MONNIFY_WALLET_ID", "wallet_id", "2A47114E88904626955A6BD333A6B164");
$this->writeChanges($path, "MONNIFY_DEFAULT_SPLIT_PERCENTAGE", "default_split_percentage", 20);
$this->writeChanges($path, "MONNIFY_DEFAULT_CURRENCY_CODE", "default_currency_code", 'NGN');
$this->writeChanges($path, "MONNIFY_DEFAULT_PAYMENT_REDIRECT_URL", "redirect_url", '"${APP_URL}"');
$this->writeChanges($path, "MONNIFY_DEFAULT_PAYMENT_REDIRECT_URL", "redirect_url", '"${APP_URL}/transaction/confirm"');

}

Expand Down
20 changes: 13 additions & 7 deletions src/Monnify.php
Original file line number Diff line number Diff line change
Expand Up @@ -562,12 +562,12 @@ public function sourceAccountRestriction(string $accountReference, MonnifyAllowe
* @throws MonnifyFailedRequestException
* @link https://docs.teamapt.com/display/MON/Initialize+Transaction
*/
public function initializeTransaction(float $amount, string $customerName, string $customerEmail, string $paymentReference, string $paymentDescription, string $redirectUrl, MonnifyPaymentMethods $monnifyPaymentMethods, MonnifyIncomeSplitConfig $incomeSplitConfig, string $currencyCode = null)
public function initializeTransaction(float $amount, string $customerName, string $customerEmail, string $paymentReference, string $paymentDescription, string $redirectUrl, MonnifyPaymentMethods $monnifyPaymentMethods, MonnifyIncomeSplitConfig $incomeSplitConfig = null, string $currencyCode = null)
{
$endpoint = "{$this->baseUrl}{$this->v1}merchant/transactions/init-transaction";

$this->withBasicAuth();
$response = $this->httpClient->post($endpoint, [
$formData = [
"amount" => $amount,
"customerName" => trim($customerName),
"customerEmail" => $customerEmail,
Expand All @@ -577,8 +577,11 @@ public function initializeTransaction(float $amount, string $customerName, strin
"contractCode" => $this->config['contract_code'],
"redirectUrl" => trim($redirectUrl),
"paymentMethods" => $monnifyPaymentMethods->toArray(),
"incomeSplitConfig" => $incomeSplitConfig->toArray()
]);
];
if ($incomeSplitConfig !== null)
$formData["incomeSplitConfig"] = $incomeSplitConfig->toArray();

$response = $this->httpClient->post($endpoint, $formData);

$responseObject = json_decode($response->body());
if (!$response->successful())
Expand Down Expand Up @@ -971,7 +974,8 @@ public function getAllBulkTransferTransactions(int $pageNo = 0, int $pageSize =
*
* @link https://docs.teamapt.com/display/MON/Validate+Bank+Account
*/
public function validateBankAccount(MonnifyBankAccount $bankAccount){
public function validateBankAccount(MonnifyBankAccount $bankAccount)
{

$endpoint = "{$this->baseUrl}{$this->v1}disbursements/account/validate?accountNumber={$bankAccount->getAccountNumber()}&bankCode={$bankAccount->getBankCode()}";
$this->withBasicAuth();
Expand All @@ -993,7 +997,8 @@ public function validateBankAccount(MonnifyBankAccount $bankAccount){
*
* @link https://docs.teamapt.com/display/MON/Get+Wallet+Balance
*/
public function getWalletBalance(){
public function getWalletBalance()
{
$endpoint = "{$this->baseUrl}{$this->v1}disbursements/wallet-balance?walletId={$this->config['wallet_id']}";
$this->withBasicAuth();
$response = $this->httpClient->get($endpoint);
Expand All @@ -1014,7 +1019,8 @@ public function getWalletBalance(){
* @throws MonnifyFailedRequestException
* @link https://docs.teamapt.com/display/MON/Resend+OTP
*/
public function resendOTP(string $reference){
public function resendOTP(string $reference)
{
$endpoint = "{$this->baseUrl}{$this->v1}disbursements/single/resend-otp";
$this->withBasicAuth();
$response = $this->httpClient->post($endpoint, [
Expand Down

0 comments on commit 123c649

Please sign in to comment.