Skip to content

Add Methods for Assigning and Creating Dedicated Virtual Accounts (DVA) #191

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 77 additions & 2 deletions src/Paystack.php
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ public function createCustomer($data = null)

];
}

$this->setRequestOptions();
return $this->setHttpResponse('/customer', 'POST', $data)->getResponse();
}
Expand Down Expand Up @@ -699,7 +699,7 @@ public function updateSubAccount($subaccount_code)
return $this->setHttpResponse("/subaccount/{$subaccount_code}", "PUT", array_filter($data))->getResponse();
}


/**
* Get a list of all supported banks and their properties
* @param $country - The country from which to obtain the list of supported banks, $per_page - Specifies how many records to retrieve per page ,
Expand All @@ -726,4 +726,79 @@ public function confirmAccount(string $account_number, string $bank_code)
$this->setRequestOptions();
return $this->setHttpResponse("/bank/resolve/?account_number=" . $account_number . "&bank_code=" . $bank_code, "GET")->getResponse();
}

/**
* Create a customer, validate the customer, and assign a DVA to the customer.
* @param array|null
* @return array
*/

public function assignDedicatedAccount($data = null)
{
if (!$data)
$data = [
"email" => request()->email,
"first_name" => request()->first_name,
"middle_name" => request()->middle_name,
"last_name" => request()->last_name,
"phone" => request()->phone,
"preferred_bank" => request()->preferred_bank,
"country" => request()->country ?? "NG"
];

$this->setRequestOptions();
return $this->setHttpResponse('/dedicated_account/assign', 'POST', array_filter($data))->getResponse();
}

/**
* Create a customer, validate the customer, and assign a DVA to the customer.
* @param array|null
* @return array
*/

public function createDedicatedAccount($data = null)
{
if (!$data)
$data = [
"customer" => request()->customer,
"first_name" => request()->first_name,
"middle_name" => request()->middle_name,
"last_name" => request()->last_name,
"phone" => request()->phone,
"preferred_bank" => request()->preferred_bank,
"country" => request()->country ?? "NG"
];

$this->setRequestOptions();
return $this->setHttpResponse('/dedicated_account', 'POST', array_filter($data))->getResponse();
}


/**
* Create a transfer recipient.
* This method registers a recipient for future transfers.
*
* @param array $data - An array containing recipient details such as account number, bank code, and other relevant information.
* @return array - Response from the API containing the recipient details.
*/
public function createRecipient(array $data)
{

$this->setRequestOptions();
return $this->setHttpResponse("/transferrecipient", "POST", array_filter($data))->getResponse();
}

/**
* Initiate a fund transfer.
* This method starts a transfer to a registered recipient.
*
* @param array $data - An array containing transfer details such as recipient code, amount, currency, and other relevant information.
* @return array - Response from the API with transfer status and details.
*/
public function startTransfer(array $data)
{

$this->setRequestOptions();
return $this->setHttpResponse("/transfer", "POST", array_filter($data))->getResponse();
}
}