public function testInsert() { $columns = array('column_name' => 'column_value', 'column_name1' => 'column_value1'); $table = 'table'; $result = $this->object->insert($columns, $table)->getDbComponent()->getInsertPart(); $compare = "INSERT INTO table ( `column_name`, `column_name1`) VALUES ('column_value', 'column_value1')"; $this->assertEquals($compare, $result); }
function retrieveTransactioResults($success, $transaction, $info) { $card = $transaction->creditCard; //last4, debit, prepaid $info['authCode'] = $transaction->processorAuthorizationCode; $info['success'] = $success; $info['message'] = ''; $info['header'] = ''; $info['paymentType'] = 'Credit card'; $info['gatewayRejectReason'] = $transaction->gatewayRejectionReason; $info['transStatus'] = $transaction->status; $info['processorResponseCode'] = $transaction->processorResponseCode; $info['resultAmount'] = $transaction->amount; $info['last4'] = $card['last4']; $info['cardType'] = $card['cardType']; $info['cardHolderName'] = $card['cardholderName']; $transDate = $transaction->createdAt; $info['serverTransDate'] = $transDate->format('Y-m-d H:i:s'); $transDate->setTimezone(new DateTimeZone($_POST['client-tz'])); $info['clientTransDate'] = $transDate->format('n/j/Y g:i A'); if (strtolower($card['debit']) == 'yes') { $info['paymentType'] = 'Debit card'; } else { if (strtolower($card['prepaid']) == 'yes') { $info['paymentType'] = 'Prepaid card'; } } $sql = 'INSERT INTO donations (cardholder_name, result_amount, request_amount, email, payment_type, card_type, trans_status, processor_response_code,trans_date,gateway_reject_reason,last4, subscription_id) '; $sql .= "VALUES ('" . $info['cardHolderName'] . "', " . $info['resultAmount'] . ", " . $info['amount'] . ", '" . $info['email'] . "', '" . $info['paymentType'] . "',\n \t\t\t\t'" . $info['cardType'] . "', '" . $info['transStatus'] . "', " . $info['processorResponseCode'] . ", '" . $info['serverTransDate'] . "',\n\t\t\t\t'" . $info['gatewayRejectReason'] . "', '" . $info['last4'] . "', " . (isset($info['subscriptionId']) ? $info['subscriptionId'] : 0) . ");"; $info['confirmationNumber'] = MysqlAccess::insert($sql); if ($info['success']) { $info['header'] = 'Thank you for your donation!'; $info['message'] = "Your donation has been successully processed. Thank you for helping us help you."; } else { $info['header'] = 'There was a problem processing your request'; if ($info['transStatus'] == 'gateway_rejected') { $info['message'] = $this->getGatewayRejectMessagee($info['gatewayRejectReason']); } else { if ($info['transStatus'] == 'processor_declined') { $info['message'] = $this->getProcessorRejectMessagee($info['processorResponseCode']); } else { $info['message'] = "The transaction was declined due to an unknown reason. Please contact your merchant for more information."; } } } $this->emailReceipt($info); return $info; }