Skip to content
Merged
Show file tree
Hide file tree
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
32 changes: 32 additions & 0 deletions src/Hyperwallet/Hyperwallet.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Hyperwallet\Model\Program;
use Hyperwallet\Model\ProgramAccount;
use Hyperwallet\Model\Receipt;
use Hyperwallet\Model\TransferMethod;
use Hyperwallet\Model\TransferMethodConfiguration;
use Hyperwallet\Model\User;
use Hyperwallet\Response\ListResponse;
Expand Down Expand Up @@ -560,6 +561,37 @@ public function listBankAccountStatusTransitions($userToken, $bankAccountToken,
});
}

//--------------------------------------
// Transfer Methods
//--------------------------------------

/**
* Create a transfer method
*
* @param string $userToken The user token
* @param string $jsonCacheToken The json cache token supplied by the widget
* @param TransferMethod $transferMethod The transfer method data (to override certain fields)
* @return BankAccount|PrepaidCard
*
* @throws HyperwalletArgumentException
* @throws HyperwalletApiException
*/
public function createTransferMethod($userToken, $jsonCacheToken, TransferMethod $transferMethod = null) {
if (empty($userToken)) {
throw new HyperwalletArgumentException('userToken is required!');
}
if (empty($jsonCacheToken)) {
throw new HyperwalletArgumentException('jsonCacheToken is required!');
}
$body = $this->client->doPost('/rest/v3/users/{user-token}/transfer-methods', array('user-token' => $userToken), $transferMethod, array(), array(
'Json-Cache-Token' => $jsonCacheToken
));
if ($body['type'] === PrepaidCard::TYPE_PREPAID_CARD) {
return new PrepaidCard($body);
}
return new BankAccount($body);
}

//--------------------------------------
// Balances
//--------------------------------------
Expand Down
Loading