public function testapi() { $o_bcpc = new BaseCommerceClient(RENTSQUARE_MERCH_USER, RENTSQUARE_MERCH_PASS, RENTSQUARE_MERCH_KEY); $o_bcpc->setSandbox(BC_SANDBOXVALUE); $o_address = new Address(); $o_address->setName(Address::$XS_ADDRESS_NAME_BILLING); $o_address->setLine1("123 Some Address"); $o_address->setCity("Tempe"); $o_address->setState("AZ"); $o_address->setZipcode("12345"); $o_bc = new BankCard(); $o_bc->setBillingAddress($o_address); $o_bc->setExpirationMonth("02"); $o_bc->setExpirationYear("2015"); $o_bc->setName("Nick 2"); $o_bc->setNumber("4111111111111111"); $o_bc->setToken("myToken12asdfas3"); $o_bc = $o_bcpc->addBankCard($o_bc); if ($o_bc->isStatus(BankCard::$XS_BC_STATUS_FAILED)) { //the add Failed, look at messages array for reason(s) why //var_dump( $o_bc->getMessages() ); $this->set('message', $o_bc->getMessages()); } else { if ($o_bc->isStatus(BankCard::$XS_BC_STATUS_ACTIVE)) { //Card added successfully //var_dump( $o_bc->getToken() ); $this->set('message', $o_bc->getToken()); } } }
protected function processCreditCardTransaction($data, $as_partner = 0) { Debugger::log($data); $o_bct = new BankCardTransaction(); $o_bct->setToken($data['payer_vault_id']); $o_bct->setType(BankCardTransaction::$XS_BCT_TYPE_SALE); $o_bct->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_bct->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); Debugger::log($o_bct); Debugger::log($o_bcpc); $o_bct = $o_bcpc->processBankCardTransaction($o_bct); if ($o_bct->isStatus(BankCardTransaction::$XS_BCT_STATUS_FAILED)) { //Transaction Failed return array('status' => '0', 'info' => $o_bct->getMessages()); } else { if ($o_bct->isStatus(BankCardTransaction::$XS_BCT_STATUS_DECLINED)) { //Transaction Failed return array('status' => '0', 'info' => $o_bct->getMessages()); } else { if ($o_bct->isStatus(BankCardTransaction::$XS_BCT_STATUS_CAPTURED)) { //Transaction went through successfully return array('status' => '1', 'info' => $o_bct->getTransactionID()); } } } }