A resource representing a bank account that can be used to fund a payment.
Inheritance: extends PayPal\Common\PayPalModel
Example #1
0
 /**
  * Obtain the Bank Account resource for the given identifier.
  *
  * @param string $bankAccountId
  * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
  * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
  * @return BankAccount
  */
 public static function get($bankAccountId, $apiContext = null, $restCall = null)
 {
     ArgumentValidator::validate($bankAccountId, 'bankAccountId');
     $payLoad = "";
     $json = self::executeCall("/v1/vault/bank-accounts/{$bankAccountId}", "GET", $payLoad, null, $apiContext, $restCall);
     $ret = new BankAccount();
     $ret->fromJson($json);
     return $ret;
 }
Example #2
0
 /**
  * @dataProvider mockProvider
  * @param BankAccount $obj
  */
 public function testUpdate($obj, $mockApiContext)
 {
     $mockPayPalRestCall = $this->getMockBuilder('\\PayPal\\Transport\\PayPalRestCall')->disableOriginalConstructor()->getMock();
     $mockPayPalRestCall->expects($this->any())->method('execute')->will($this->returnValue(self::getJson()));
     $patchRequest = PatchRequestTest::getObject();
     $result = $obj->update($patchRequest, $mockApiContext, $mockPayPalRestCall);
     $this->assertNotNull($result);
 }
<?php

// # Get Bank Account Sample
// The Bank Account resource allows you to
// retrieve previously saved Bank Accounts.
// API called: '/v1/vault/bank-accounts'
// The following code takes you through
// the process of retrieving a saved Bank Account
/** @var \PayPal\Api\BankAccount $bankAccount */
$bankAccount = (require 'CreateBankAccount.php');
/// ### Retrieve Bank Account
// (See bootstrap.php for more on `ApiContext`)
try {
    $bankAccount = \PayPal\Api\BankAccount::get($bankAccount->getId(), $apiContext);
} catch (Exception $ex) {
    // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
    ResultPrinter::printError("Get Bank Account", "Bank Account", $bankAccount->getId(), null, $ex);
    exit(1);
}
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
ResultPrinter::printResult("Get Bank Account", "Bank Account", $bankAccount->getId(), null, $bankAccount);
return $bankAccount;
Example #4
0
            "country_code": "US",
            "first_name": "Ramraj",
            "last_name": "K",
            "birth_date": "1987-08-13",
            "billing_address": {
                "line1": "52 N Main ST",
                "city": "Johnstown",
                "country_code": "US",
                "postal_code": "43210",
                "state": "OH",
                "phone": "408-334-8890"
            },
            "external_customer_id": "external_id"
        }
*/
$bankAccount = new BankAccount();
$bankAccount->setAccountNumber("4417119669820331")->setAccountNumberType("IBAN")->setAccountType("SAVINGS")->setAccountName("Ramraj")->setCheckType("PERSONAL")->setAuthType("WEB")->setBankName("CITI")->setCountryCode("US")->setFirstName("Ramraj")->setLastName("K")->setBirthDate("1987-08-13")->setExternalCustomerId(uniqid());
$billingAddress = new \PayPal\Api\Address();
$billingAddress->setLine1("52 N Main St")->setCity("Johnstown")->setState("OH")->setCountryCode("US")->setPostalCode("43210")->setPhone("408-334-8890");
$bankAccount->setBillingAddress($billingAddress);
// For Sample Purposes Only.
$request = clone $bankAccount;
// ### Save bank account
// Creates the bank account as a resource
// in the PayPal vault. The response contains
// an 'id' that you can use to refer to it
// in future payments.
// (See bootstrap.php for more on `ApiContext`)
try {
    $bankAccount->create($apiContext);
} catch (Exception $ex) {
 /**
  * @depends testSerializationDeserialization
  * @param BankAccount $obj
  */
 public function testGetters($obj)
 {
     $this->assertEquals($obj->getId(), "TestSample");
     $this->assertEquals($obj->getAccountNumber(), "TestSample");
     $this->assertEquals($obj->getAccountNumberType(), "TestSample");
     $this->assertEquals($obj->getRoutingNumber(), "TestSample");
     $this->assertEquals($obj->getAccountType(), "TestSample");
     $this->assertEquals($obj->getAccountName(), "TestSample");
     $this->assertEquals($obj->getCheckType(), "TestSample");
     $this->assertEquals($obj->getAuthType(), "TestSample");
     $this->assertEquals($obj->getAuthCaptureTimestamp(), "TestSample");
     $this->assertEquals($obj->getBankName(), "TestSample");
     $this->assertEquals($obj->getCountryCode(), "TestSample");
     $this->assertEquals($obj->getFirstName(), "TestSample");
     $this->assertEquals($obj->getLastName(), "TestSample");
     $this->assertEquals($obj->getBirthDate(), "TestSample");
     $this->assertEquals($obj->getBillingAddress(), AddressTest::getObject());
     $this->assertEquals($obj->getState(), "TestSample");
     $this->assertEquals($obj->getConfirmationStatus(), "TestSample");
     $this->assertEquals($obj->getPayerId(), "TestSample");
     $this->assertEquals($obj->getExternalCustomerId(), "TestSample");
     $this->assertEquals($obj->getMerchantId(), "TestSample");
     $this->assertEquals($obj->getCreateTime(), "TestSample");
     $this->assertEquals($obj->getUpdateTime(), "TestSample");
     $this->assertEquals($obj->getValidUntil(), "TestSample");
     $this->assertEquals($obj->getLinks(), LinksTest::getObject());
 }