Beispiel #1
0
 /**
  * @param Customer $customer
  * @return CustomerBankAccount
  */
 public function get_customer_full_bank_account(Customer $customer = null)
 {
     $customer = $customer ?: $this->get_full_customer();
     $account = CustomerBankAccount::fromArray($this->full_bank_account_details());
     $account->setOwner($customer);
     return $account;
 }
 /** @test */
 function it_has_a_shortcut_to_fill_uk_bank_details()
 {
     $account = new CustomerBankAccount();
     $customer = new Customer();
     $account->withAccountDetails('John Doe', '12345678', '112233', 'GB', $customer);
     $this->assertEquals('John Doe', $account->getAccountHolderName());
     $this->assertEquals('12345678', $account->getAccountNumber());
     $this->assertEquals('112233', $account->getSortCode());
     $this->assertEquals('GB', $account->getCountryCode());
     $this->assertAttributeSame($customer, 'customer', $account);
 }
Beispiel #3
0
 /**
  * @return array
  */
 public function toArray()
 {
     $mandate = array_filter(get_object_vars($this));
     if ($this->customer_bank_account instanceof CustomerBankAccount) {
         unset($mandate['customer_bank_account']);
         $mandate['links']['customer_bank_account'] = $this->customer_bank_account->getId();
     }
     if ($this->creditor instanceof Creditor) {
         unset($mandate['creditor']);
         $mandate['links']['creditor'] = $this->creditor->getId();
     }
     return $mandate;
 }
Beispiel #4
0
 /**
  * Look up the name and reachability of a bank.
  *
  * @see https://developer.gocardless.com/pro/#helper-endpoints-bank-details-lookups
  *
  * @param CustomerBankAccount $account Customer Bank Account
  *
  * @return array
  */
 public function lookupBankDetails(CustomerBankAccount $account)
 {
     $request = ['iban' => $account->getIban()];
     if (!$account->hasIban()) {
         $request = ['account_number' => $account->getAccountNumber(), 'branch_code' => $account->getBranchCode(), 'country_code' => $account->getCountryCode()];
     }
     return $this->post(self::BANK_DETAILS_LOOKUPS, $request);
 }
Beispiel #5
0
 /** @depends test_it_can_create_a_customer_bank_account */
 function test_it_can_get_a_single_bank_account(CustomerBankAccount $old)
 {
     $new = $this->api->getCustomerBankAccount($old->getId());
     $this->assertInstanceOf('GoCardless\\Pro\\Models\\CustomerBankAccount', $new);
     $this->assertEquals($old->toArray(), $new->toArray());
 }
Beispiel #6
0
 /** @test */
 function it_can_be_converted_an_array_for_the_api()
 {
     $mandate = (new Mandate(CustomerBankAccount::fromArray(['id' => 'BA111']), Creditor::fromArray(['id' => 'CR111'])))->useSepaCore();
     $this->assertEquals(['scheme' => 'sepa_core', 'links' => ['customer_bank_account' => 'BA111', 'creditor' => 'CR111']], $mandate->toArray());
 }
Beispiel #7
0
 /**
  * @see https://developer.gocardless.com/pro/#customer-bank-accounts-disable-a-customer-bank-account
  *
  * @param $id
  *
  * @return CustomerBankAccount
  */
 public function disableCustomerBankAccount($id)
 {
     $response = $this->post(self::CUSTOMER_BANK_ACCOUNTS, [], $id . '/actions/disable');
     return CustomerBankAccount::fromArray($response);
 }