コード例 #1
0
 public function vault_add_bank_account($paydata)
 {
     $status = '';
     $result = '';
     $o_bank_account = new BankAccount();
     $o_bank_account->setName($paydata['first_name'] . " " . $paydata['last_name']);
     $o_bank_account->setAccountNumber($paydata['account_number']);
     $o_bank_account->setRoutingNumber($paydata['routing_number']);
     if ($paydata['bank_acct_type'] == "Savings") {
         $o_bank_account->setAccountType(BankAccount::$XS_BA_TYPE_SAVINGS);
     } else {
         $o_bank_account->setAccountType(BankAccount::$XS_BA_TYPE_CHECKING);
     }
     $o_billing_address = new Address(Address::$XS_ADDRESS_NAME_BILLING);
     $o_billing_address->setLine1($paydata['billing_address1']);
     if (!empty($paydata['billing_address2'])) {
         $o_billing_address->setLine2($paydata['billing_address2']);
     } else {
         $o_billing_address->setLine2(" ");
     }
     $o_billing_address->setCity($paydata['billing_city']);
     if (!empty($paydata['billing_state_id'])) {
         $States = new State();
         $billing_state = $States->findById($paydata['billing_state_id']);
         $billing_state = $billing_state['State']['abbr'];
     }
     $o_billing_address->setState($billing_state);
     $o_billing_address->setZipcode($property['billing_zip']);
     $o_billing_address->setCountry("USA");
     $o_bank_account->setBillingAddress($o_billing_address);
     if ($paydata['usertype'] == 2) {
         $o_bcpc = new BaseCommerceClient(RENTSQUARE_PARTNER_USER, RENTSQUARE_PARTNER_PASS, RENTSQUARE_PARTNER_KEY);
     } else {
         $o_bcpc = new BaseCommerceClient(RENTSQUARE_MERCH_USER, RENTSQUARE_MERCH_PASS, RENTSQUARE_MERCH_KEY);
     }
     $o_bcpc->setSandbox(BC_SANDBOXVALUE);
     $o_bank_account = $o_bcpc->addBankAccount($o_bank_account);
     $status = $o_bank_account->getStatus();
     if ($status == BankAccount::$XS_BA_STATUS_FAILED) {
         // Fail
         $status = 0;
         $result = $o_bank_account->getMessages();
     } else {
         if ($status == BankAccount::$XS_BA_STATUS_ACTIVE) {
             // Success
             $status = 1;
             $result = $o_bank_account->getToken();
         }
     }
     return array($status, $result);
 }
コード例 #2
0
ファイル: BankAccount.php プロジェクト: omusico/RentSquare
 /**
  * Builds a BankAccount PHP object from the passed in json object.
  * 
  * @param  $vo_json - The json representation of the object to be built.
  * @return A BankAccount object with fields based on the input json object.
  * @author Ryan Murphy <*****@*****.**>
  * @author Steven Wright <*****@*****.**>
  */
 static function buildFromJSON($vo_json)
 {
     $o_bank_account = new BankAccount();
     if (array_key_exists("bank_account_name", $vo_json)) {
         $o_bank_account->setName($vo_json["bank_account_name"]);
     }
     if (array_key_exists("bank_account_alias", $vo_json)) {
         $o_bank_account->setAlias($vo_json["bank_account_alias"]);
     }
     if (array_key_exists("bank_account_account_number", $vo_json)) {
         $o_bank_account->setAccountNumber($vo_json["bank_account_account_number"]);
     }
     if (array_key_exists("bank_account_routing_number", $vo_json)) {
         $o_bank_account->setRoutingNumber($vo_json["bank_account_routing_number"]);
     }
     if (array_key_exists("bank_account_token", $vo_json)) {
         $o_bank_account->setToken($vo_json["bank_account_token"]);
     }
     if (array_key_exists("bank_account_billing_address", $vo_json)) {
         $o_bank_account->setBillingAddress(Address::buildFromJSON($vo_json["bank_account_billing_address"]));
     }
     if (array_key_exists('bank_account_status', $vo_json)) {
         if (gettype($vo_json['bank_account_status']) === "array ") {
             $o_status = (array) $vo_json['bank_account_status'];
             if (array_key_exists('bank_account_status_name', $o_status)) {
                 $o_bank_account->setStatus($o_status['bank_account_status_name']);
             }
         } else {
             $o_bank_account->setStatus($vo_json['bank_account_status']);
         }
     }
     if (array_key_exists('bank_account_type', $vo_json)) {
         if (gettype($vo_json['bank_account_type']) === "array") {
             $o_type = (array) $vo_json['bank_account_type'];
             if (array_key_exists('bank_account_type_name', $o_type)) {
                 $o_bank_account->setAccountType($o_type['bank_account_type_name']);
             }
         } else {
             $o_bank_account->setAccountType($vo_json['bank_account_type']);
         }
     }
     return $o_bank_account;
 }