Skip to content

Instantly share code, notes, and snippets.

@johnnye
Last active March 22, 2019 09:06
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnnye/e4858e311c1cdd15b606 to your computer and use it in GitHub Desktop.
Save johnnye/e4858e311c1cdd15b606 to your computer and use it in GitHub Desktop.
<?php
/**
* There is a bunch of things we could do here. I would suggest at a minimum we have
* * account name
* * institution //Name of the bank
* * routing //local routing key, routing or sort code
* * account number
* * international routing //SWIFT routing key
* * IBAN //http://en.wikipedia.org/wiki/International_Bank_Account_Number
* * customer[] //customers details
*
*/
/**
* This class will act a lot like the CreditCard class
*/
class BankAccount
{
protected $parameters;
public function __construct($parameters = null)
{
$this->initialize($parameters);
}
public function initialize($parameters = null)
{
$this->parameters = new ParameterBag;
Helper::initialize($this, $parameters);
return $this;
}
}
<?php
class AbstractBankGateway
{
public function createAccount();
public function deleteAccount();
public function collect();
public function voidCollect();
public function deposit();
public function voidDeposit();
public function supportsFees(); //Probably not a necesity, but I'd like to be able to collect fees
}
<?php
$gateway = Omnipay::create('stripe');
$gateway->setApiKey('11111111');
//Charging a customer.
$token = $_POST['stripeToken'];
$response = $gateway->purchase(['amount' => '10.00', 'currency' => 'USD', 'token' => $token])->send();
/**
* We can share keys and tokens and reply
* in a nice way if it doesnt exist
*/
$bankGateway = $gateway->getBankGateway();
$newAccount = new BankAccount([
'account_name' => 'Savings Account',
'institution' => 'mega corp',
'routing' => '00-00-00', //Sortcode
'account_number'=> '00011100'
]);
$bankGateway->createAccount($newAccount);
//Oh.. maybe this should be part of the gateway.
$response = $bankGateway->collect([
'amount' => '10.00',
'account' => $newAccount
])->send();
//So could this - if every action had an opposite.
$response = $bankGateway->deposit([
'amount' => '15.00',
'account' => $newAccount,
'fees' => '5.00'
])->send();
//This is an example of something that isnt possible in the current API
// However, we could do it with a charge & payout.
$response = $bankGateway->initiateTransfer([
'amount' => '10.00',
'source' => $oldAccount,
'destination' => $newAccount,
'fees' => '1.00'
])->send();
$response = $bankGateway->deleteAccount([
'account' => $oldAccount
])->send();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment