Example #1
0
 /**
  * Builds a PushNotification object from the given JSON object
  * @param type $vo_json the JSON representation of the PushNotification
  * @return PushNotification a push notification object
  * @author Rob Kurst <*****@*****.**>
  */
 public static function buildFromJSON($vo_json)
 {
     $o_return = new PushNotification();
     if (array_key_exists("push_notification_type", $vo_json) && $vo_json["push_notification_type"] == "PING") {
         $o_return->setPING();
     }
     if (array_key_exists("push_notification_settlement_batch", $vo_json)) {
         $o_return->setSettlementBatch(SettlementBatch::buildFromJSON($vo_json["push_notification_settlement_batch"]));
     }
     if (array_key_exists("push_notification_bank_account_transaction", $vo_json)) {
         $o_return->setBankAccountTransaction(BankAccountTransaction::buildFromJSON($vo_json["push_notification_bank_account_transaction"]));
     }
     return $o_return;
 }
 /**
  * 
  * Processes the transaction using the specified BankAccountTransaction.
  * Returns an updated BankAccountTransaction containing the response information.
  * 
  * @param vo_bct    the bank account transaction
  * @return  the updated bank account transaction
  * @throws BaseCommerceClientException if invalid credentials were given or if there was an internal server error. Please contact tech support if there is an internal server error.
  * @author Rob Kurst <*****@*****.**>
  */
 public function processBankAccountTransaction(BankAccountTransaction $vo_bat)
 {
     $triple_des = new TripleDESService($this->is_key);
     $o_query = array();
     $o_query['gateway_username'] = $this->is_gateway_username;
     $o_query['gateway_password'] = $this->is_gateway_password;
     $o_query['payload'] = $triple_des->encrypt($vo_bat->getJSON());
     $s_query = json_encode($o_query);
     $response = $this->do_post_request('/pcms/?f=API_processBankAccountTransactionV4', $s_query, $triple_des, 0);
     $vo_bat = BankAccountTransaction::buildFromJSON($response["bank_account_transaction"]);
     if (array_key_exists("exception", $response) && !is_null($response['exception'])) {
         foreach ($response['exception'] as $s_key => $s_error) {
             $vo_bat->addMessage($s_error);
         }
     }
     return $vo_bat;
 }
 static function buildFromJSON($vo_json)
 {
     $o_bat = new BankAccountTransaction();
     if (array_key_exists("bank_account_transaction_id", $vo_json)) {
         $o_bat->setBankAccountTransactionId($vo_json["bank_account_transaction_id"]);
     }
     if (array_key_exists('bank_account_transaction_type', $vo_json)) {
         if (gettype($vo_json['bank_account_transaction_type']) === "array") {
             $o_type = (array) $vo_json['bank_account_transaction_type'];
             if (array_key_exists('bank_account_transaction_type_name', $o_type)) {
                 $o_bat->setType($o_type['bank_account_transaction_type_name']);
             }
         } else {
             $o_bat->setType($vo_json['bank_account_transaction_type']);
         }
     }
     if (array_key_exists('bank_account_transaction_method', $vo_json)) {
         if (gettype($vo_json['bank_account_transaction_method']) === "array") {
             $o_method = (array) $vo_json['bank_account_transaction_method'];
             if (array_key_exists('bank_account_transaction_method_name', $o_method)) {
                 $o_bat->setMethod($o_method['bank_account_transaction_method_name']);
             }
         } else {
             $o_bat->setMethod($vo_json['bank_account_transaction_method']);
         }
     }
     if (array_key_exists('bank_account_transaction_recurring_indicator', $vo_json)) {
         $o_bat->setRecurringIndicator($vo_json["bank_account_transaction_recurring_indicator"]);
     }
     if (array_key_exists('bank_account_transaction_routing_number', $vo_json)) {
         $o_bat->setRoutingNumber($vo_json["bank_account_transaction_routing_number"]);
     }
     if (array_key_exists('bank_account_transaction_account_number', $vo_json)) {
         $o_bat->setAccountNumber($vo_json["bank_account_transaction_account_number"]);
     }
     if (array_key_exists('bank_account_transaction_effective_date', $vo_json)) {
         $o_bat->setEffectiveDate(date("m/d/Y H:i:s", strtotime($vo_json["bank_account_transaction_effective_date"])));
     }
     if (array_key_exists('bank_account_transaction_settlement_date', $vo_json)) {
         $o_bat->setSettlementDate(date("m/d/Y H:i:s", strtotime($vo_json["bank_account_transaction_settlement_date"])));
     }
     if (array_key_exists('bank_account_transaction_return_date', $vo_json)) {
         $o_bat->setReturnDate(date("m/d/Y H:i:s", strtotime($vo_json["bank_account_transaction_return_date"])));
     }
     if (array_key_exists('bank_account_transaction_account_name', $vo_json)) {
         $o_bat->setAccountName($vo_json["bank_account_transaction_account_name"]);
     }
     if (array_key_exists('bank_account_transaction_status', $vo_json)) {
         if (gettype($vo_json['bank_account_transaction_status']) === "array") {
             $o_status = (array) $vo_json['bank_account_transaction_status'];
             if (array_key_exists('bank_account_transaction_status_name', $o_status)) {
                 $o_bat->setStatus($o_status['bank_account_transaction_status_name']);
             }
         } else {
             $o_bat->setStatus($vo_json['bank_account_transaction_status']);
         }
     }
     if (array_key_exists('bank_account_transaction_return_code', $vo_json)) {
         $o_bat->setReturnCode($vo_json["bank_account_transaction_return_code"]);
     }
     if (array_key_exists('bank_account_transaction_merchant_transaction_id', $vo_json)) {
         $o_bat->setMerchantTransactionID($vo_json["bank_account_transaction_merchant_transaction_id"]);
     }
     if (array_key_exists('bank_account_transaction_trace', $vo_json)) {
         $o_bat->setTrace($vo_json["bank_account_transaction_trace"]);
     }
     if (array_key_exists('bank_account_transaction_account_type', $vo_json)) {
         if (gettype($vo_json['bank_account_transaction_account_type']) === "array") {
             $o_account_type = (array) $vo_json['bank_account_transaction_account_type'];
             if (array_key_exists('bank_account_transaction_account_type_name', $o_account_type)) {
                 $o_bat->setAccountType($o_account_type['bank_account_transaction_account_type_name']);
             }
         } else {
             $o_bat->setAccountType($vo_json['bank_account_transaction_account_type']);
         }
     }
     // Added to allow intercommunication between CLIENT objects during unit testing//
     if (array_key_exists('messages', $vo_json) && !is_null($vo_json['messages'])) {
         foreach ($vo_json['messages'] as $s_key => $s_msg) {
             $o_bat->addMessage($s_msg);
         }
     }
     if (array_key_exists('bank_account_transaction_amount', $vo_json)) {
         $o_bat->setAmount($vo_json["bank_account_transaction_amount"]);
     }
     if (array_key_exists("bank_account_token", $vo_json)) {
         $o_bat->setToken($vo_json["bank_account_token"]);
     }
     if (array_key_exists("bank_account_transaction_micr_data", $vo_json)) {
         $o_bat->setMICRData($vo_json["bank_account_transaction_micr_data"]);
     }
     if (array_key_exists("bank_account_transaction_custom_field1", $vo_json)) {
         $o_bat->setCustomField1($vo_json["bank_account_transaction_custom_field1"]);
     }
     if (array_key_exists("bank_account_transaction_custom_field2", $vo_json)) {
         $o_bat->setCustomField2($vo_json["bank_account_transaction_custom_field2"]);
     }
     if (array_key_exists("bank_account_transaction_custom_field3", $vo_json)) {
         $o_bat->setCustomField3($vo_json["bank_account_transaction_custom_field3"]);
     }
     if (array_key_exists("bank_account_transaction_custom_field4", $vo_json)) {
         $o_bat->setCustomField4($vo_json["bank_account_transaction_custom_field4"]);
     }
     if (array_key_exists("bank_account_transaction_custom_field5", $vo_json)) {
         $o_bat->setCustomField5($vo_json["bank_account_transaction_custom_field5"]);
     }
     if (array_key_exists("bank_account_transaction_custom_field6", $vo_json)) {
         $o_bat->setCustomField6($vo_json["bank_account_transaction_custom_field6"]);
     }
     if (array_key_exists("bank_account_transaction_custom_field7", $vo_json)) {
         $o_bat->setCustomField7($vo_json["bank_account_transaction_custom_field7"]);
     }
     if (array_key_exists("bank_account_transaction_custom_field8", $vo_json)) {
         $o_bat->setCustomField8($vo_json["bank_account_transaction_custom_field8"]);
     }
     if (array_key_exists("bank_account_transaction_custom_field9", $vo_json)) {
         $o_bat->setCustomField9($vo_json["bank_account_transaction_custom_field9"]);
     }
     if (array_key_exists("bank_account_transaction_custom_field10", $vo_json)) {
         $o_bat->setCustomField10($vo_json["bank_account_transaction_custom_field10"]);
     }
     if (array_key_exists("bank_account_transaction_check_number", $vo_json)) {
         $o_bat->setCheckNumber($vo_json["bank_account_transaction_check_number"]);
     }
     if (array_key_exists("bank_account_transaction_individual_identification_number", $vo_json)) {
         $o_bat->setIndividualIdentificationNumber($vo_json["bank_account_transaction_individual_identification_number"]);
     }
     if (array_key_exists('bank_account_transaction_billing_address', $vo_json)) {
         $o_bat->setBillingAddress(Address::buildFromJSON($vo_json['bank_account_transaction_billing_address']));
     }
     if (array_key_exists("bank_account_transaction_cipher_pay_uuid", $vo_json)) {
         $o_bat->setCipherPayUUID($vo_json["bank_account_transaction_cipher_pay_uuid"]);
     }
     return $o_bat;
 }
Example #4
0
 /**
  * Builds a PushNotification object from the given JSON object
  * @param type $vo_json the JSON representation of the PushNotification
  * @return PushNotification a push notification object
  * @author Rob Kurst <*****@*****.**>
  */
 public static function buildFromJSON($vo_json)
 {
     $o_return = new PushNotification();
     if (array_key_exists("push_notification_type", $vo_json) && $vo_json["push_notification_type"] == "PING") {
         $o_return->setPING();
     }
     if (array_key_exists("push_notification_type", $vo_json) && $vo_json["push_notification_type"] == "INCOMING CHARGEBACK") {
         if (array_key_exists("push_notification_chargeback", $vo_json)) {
             $o_return->setIncomingChargeback(Chargeback::buildFromJSON($vo_json["push_notification_chargeback"]));
         }
     }
     if (array_key_exists("push_notification_settlement_batch", $vo_json)) {
         $o_return->setSettlementBatch(SettlementBatch::buildFromJSON($vo_json["push_notification_settlement_batch"]));
     }
     if (array_key_exists("push_notification_bank_account_transaction", $vo_json)) {
         $o_return->setBankAccountTransaction(BankAccountTransaction::buildFromJSON($vo_json["push_notification_bank_account_transaction"]));
     }
     if (array_key_exists("push_notification_id", $vo_json)) {
         $o_return->setID($vo_json["push_notification_id"]);
     }
     return $o_return;
 }
 protected function processBankAccountTransaction($data, $as_partner = 0)
 {
     $o_bat = new BankAccountTransaction();
     $o_bat->setType(BankAccountTransaction::$XS_BAT_TYPE_DEBIT);
     $o_bat->setMethod(BankAccountTransaction::$XS_BAT_METHOD_CCD);
     $o_bat->setEffectiveDate(date('m-d-Y H:i:s'));
     $o_bat->setToken($data['payer_vault_id']);
     $o_bat->setAmount($data['total_amt']);
     if (isset($data['fee_amt']) && !empty($data['fee_amt']) && isset($data['rsq_vault_id']) && !empty($data['rsq_vault_id'])) {
         $cf10val = $data['rsq_vault_id'] . "," . $data['fee_amt'];
         $o_bat->setCustomField10($cf10val);
     }
     if ($as_partner == 0) {
         $o_bcpc = new BaseCommerceClient(RENTSQUARE_MERCH_USER, RENTSQUARE_MERCH_PASS, RENTSQUARE_MERCH_KEY);
     } else {
         $o_bcpc = new BaseCommerceClient(RENTSQUARE_PARTNER_USER, RENTSQUARE_PARTNER_PASS, RENTSQUARE_PARTNER_KEY);
     }
     $o_bcpc->setSandbox(BC_SANDBOXVALUE);
     $o_bat = $o_bcpc->processBankAccountTransaction($o_bat);
     if ($o_bat->isStatus(BankAccountTransaction::$XS_BAT_STATUS_FAILED)) {
         //Transaction Failed
         return array('status' => '0', 'info' => $o_bat->getMessages());
     } else {
         if ($o_bat->isStatus(BankAccountTransaction::$XS_BAT_STATUS_CREATED)) {
             //Transaction went through successfully
             return array('status' => '1', 'info' => $o_bat->getBankAccountTransactionId());
         }
     }
 }