diff --git a/src/bb-library/Payment/Adapter/WebMoney.php b/src/bb-library/Payment/Adapter/WebMoney.php index a676cdc0e..bd99c5459 100644 --- a/src/bb-library/Payment/Adapter/WebMoney.php +++ b/src/bb-library/Payment/Adapter/WebMoney.php @@ -13,6 +13,8 @@ class Payment_Adapter_WebMoney { private $config = array(); + + public $testMode = false; const USD = 'Z'; const RUB = 'R'; @@ -56,7 +58,7 @@ class Payment_Adapter_WebMoney $data['LMI_PAYEE_PURSE'] = $this->config['purse']; $data['LMI_PAYMENT_AMOUNT'] = $invoice['total']; $data['LMI_PAYMENT_NO'] = $invoice['id']; - $data['LMI_PAYMENT_DESC'] = $invoice['title']; + $data['LMI_PAYMENT_DESC'] = $invoice['serie_nr']; $data['LMI_RESULT_URL'] = $this->config['notify_url']; $data['LMI_SUCCESS_URL'] = $this->config['success_url']; $data['LMI_SUCCESS_METHOD'] = 1; //The field may have values 0, 1 or 2 equal to values of the ‘Method of requesting Success URL’ – ‘GET’, ‘POST’ or ‘LINK’. diff --git a/src/bb-modules/Activity/Api/Admin.php b/src/bb-modules/Activity/Api/Admin.php index 8ce82d8e8..b4eaa3932 100644 --- a/src/bb-modules/Activity/Api/Admin.php +++ b/src/bb-modules/Activity/Api/Admin.php @@ -90,11 +90,11 @@ class Admin extends \Api_Abstract $client_id = isset($data['client_id']) ? $data['client_id'] : NULL; $sender = isset($data['sender']) ? $data['sender'] : NULL; $recipients = isset($data['recipients']) ? $data['recipients'] : NULL; - $subject = isset($data['subject']) ? $data['subject'] : NULL; + $subject = $data['subject']; $content_html = isset($data['content_html']) ? $data['content_html'] : NULL; $content_text = isset($data['content_text']) ? $data['content_text'] : NULL; - return $this->getService()->logEmail($subject, $client_id, $sender, $recipients, $subject, $content_html, $content_text); + return $this->getService()->logEmail($subject, $client_id, $sender, $recipients, $content_html, $content_text); } /** diff --git a/src/bb-modules/Activity/Service.php b/src/bb-modules/Activity/Service.php index 19f90c131..1b88454a7 100644 --- a/src/bb-modules/Activity/Service.php +++ b/src/bb-modules/Activity/Service.php @@ -134,7 +134,7 @@ class Service implements InjectionAwareInterface return array($sql, $params); } - public function logEmail($subject, $clientId = null, $sender = null, $recipients = null, $subject = null, $content_html = null, $content_text = null) + public function logEmail($subject, $clientId = null, $sender = null, $recipients = null, $content_html = null, $content_text = null) { $entry = $this->di['db']->dispense('ActivityClientEmail'); diff --git a/src/bb-modules/Email/Service.php b/src/bb-modules/Email/Service.php index 8b38262a3..1af280203 100644 --- a/src/bb-modules/Email/Service.php +++ b/src/bb-modules/Email/Service.php @@ -582,7 +582,7 @@ class Service implements \Box\InjectionAwareInterface if (isset($settings['log_enabled']) && $settings['log_enabled']) { $activityService = $this->di['mod_service']('activity'); - $activityService->logEmail($queue->subject, $queue->client_id, $queue->from, $queue->to, $queue->subject, $queue->content); + $activityService->logEmail($queue->subject, $queue->client_id, $queue->from, $queue->to, $queue->content); } $transport = isset($settings['mailer']) ? $settings['mailer'] : 'sendmail'; diff --git a/src/bb-modules/Extension/Service.php b/src/bb-modules/Extension/Service.php index 1757dbab8..958d3358e 100644 --- a/src/bb-modules/Extension/Service.php +++ b/src/bb-modules/Extension/Service.php @@ -585,7 +585,7 @@ class Service implements InjectionAwareInterface ); $this->di['db']->exec($sql, $params); $this->di['events_manager']->fire(array('event'=>'onAfterAdminExtensionConfigSave', 'params'=>$data)); - $this->di['logger']->info('Updated extension "%s" configuration', $data); + $this->di['logger']->info('Updated extension "%s" configuration', $data['ext']); return true; } diff --git a/tests/bb-modules/Activity/ServiceTest.php b/tests/bb-modules/Activity/ServiceTest.php index 018e1c3dc..1b4301807 100644 --- a/tests/bb-modules/Activity/ServiceTest.php +++ b/tests/bb-modules/Activity/ServiceTest.php @@ -107,7 +107,9 @@ class ServiceTest extends \PHPUnit_Framework_TestCase public function testLogEvent() { $service = new \Box\Mod\Activity\Service(); - $data = array(); + $data = array( + 'message' => 'Logging test message' + ); $di = new \Box_Di(); $db = $this->getMockBuilder('Box_Database')->getMock(); @@ -157,7 +159,7 @@ class ServiceTest extends \PHPUnit_Framework_TestCase $di['db'] = $db; $service->setDi($di); - $result = $service->logEmail($data['client_id'], $data['sender'], $data['recipients'], $data['subject'], $data['content_html'], $data['content_text']); + $result = $service->logEmail($data['subject'], $data['client_id'], $data['sender'], $data['recipients'], $data['content_html'], $data['content_text']); $this->assertTrue($result); } diff --git a/tests/integration/bb-library/Box/LogTest.php b/tests/integration/bb-library/Box/LogTest.php index 6343e645b..4d8f5cb4a 100644 --- a/tests/integration/bb-library/Box/LogTest.php +++ b/tests/integration/bb-library/Box/LogTest.php @@ -57,7 +57,7 @@ class Box_LogIntegrationTest extends BBDbApiTestCase public function testLogMultipleVariables() { - $msg = '%sMultiple params in message, one param passed%s'; + $msg = '%sMultiple params in message, one param passed%s'; $rand = rand(1, 100); $this->di['logger']->info($msg, $rand, $rand); $array = $this->api_admin->activity_log_get_list(); @@ -66,14 +66,5 @@ class Box_LogIntegrationTest extends BBDbApiTestCase $this->assertEquals(sprintf($msg, $rand, $rand), $message); } - - /** - * @expectedException LogicException - */ - public function testLogVariablesDoesNotMatchPlaceholdersException() - { - $msg = 'Multiple params in message, one param passed %s %s %s %s %s %s'; - $this->di['logger']->info($msg, rand(1, 100)); - } - + } \ No newline at end of file diff --git a/tests/integration/bb-library/Payment/Adapter/CustomTest.php b/tests/integration/bb-library/Payment/Adapter/CustomTest.php index b609754b4..7a157692b 100644 --- a/tests/integration/bb-library/Payment/Adapter/CustomTest.php +++ b/tests/integration/bb-library/Payment/Adapter/CustomTest.php @@ -15,7 +15,9 @@ class Payment_Adapter_CustomTest extends BBDbApiTestCase $adapter = new Payment_Adapter_Custom($config); $adapter->setDi($this->di); $adapter->getConfig(); - $adapter->getHtml($this->api_admin, 1); - $adapter->process(); + $adapter->getHtml($this->api_admin, 1, true); + + $tx = $this->di['db']->load('Transaction', 1); + $adapter->process($tx); } } \ No newline at end of file diff --git a/tests/integration/bb-library/Payment/Adapter/PayPalEmailTest.php b/tests/integration/bb-library/Payment/Adapter/PayPalEmailTest.php index d55838c0a..24a5873c2 100644 --- a/tests/integration/bb-library/Payment/Adapter/PayPalEmailTest.php +++ b/tests/integration/bb-library/Payment/Adapter/PayPalEmailTest.php @@ -9,6 +9,7 @@ class Payment_Adapter_PayPalEmailTest extends BBDbApiTestCase public function testGateway() { $config = array(); + $config['test_mode'] = true; $config['email'] = 'example@gmail.com'; $config['return_url'] = 'http://www.google.com?q=return'; $config['cancel_url'] = 'http://www.google.com?q=cancel'; @@ -16,17 +17,17 @@ class Payment_Adapter_PayPalEmailTest extends BBDbApiTestCase $adapter = new Payment_Adapter_PayPalEmail($config); $adapter->getConfig(); - $adapter->getHtml($this->api_admin, 1); + $adapter->getHtml($this->api_admin, 1, false); $adapter->getHtml($this->api_admin, 2, true); $subscr_payment = json_decode('{"get":{"bb_gateway_id":"1","bb_invoice_id":"1"},"post":{"transaction_subject":"Subscription for BoxBilling Pro License","payment_date":"11:24:34 Mar 08, 2012 PST","txn_type":"subscr_payment","subscr_id":"S-9X268688JL8514304","last_name":"Doe","residence_country":"GB","item_name":"Subscription for BoxBilling Pro License","payment_gross":"5.95","mc_currency":"USD","business":"clients@boxbilling.com","payment_type":"instant","protection_eligibility":"Ineligible","verify_sign":"A2QxLKJxNBOK3utJMiCwOkOiLG3tAo4.KtJCsCemU7s98tgtW37-hOOx","payer_status":"verified","payer_email":"john.doe@gmail.com","txn_id":"6SR32195AP993094V","receiver_email":"clients@boxbilling.com","first_name":"John","payer_id":"9W3LMGTFS5RTY","receiver_id":"79PMKLAHPL5YH","item_number":"BOX05697","payment_status":"Completed","payment_fee":"0.47","mc_fee":"0.47","mc_gross":"5.95","charset":"windows-1252","notify_version":"3.4","ipn_track_id":"54b4dbrfvg396"},"http_raw_post_data":"transaction_subject=Subscription+for+BoxBilling+Pro+License&payment_date=11%3A24%3A34+Mar+08%2C+2012+PST&txn_type=subscr_payment&subscr_id=S-9X268688JL8514304&last_name=Doe&residence_country=GB&item_name=Subscription+for+BoxBilling+Pro+License&payment_gross=5.95&mc_currency=USD&business=clients%40boxbilling.com&payment_type=instant&protection_eligibility=Ineligible&verify_sign=A2QxLKJxNBOK3utOLuCwOkOiLG3tAo4.KtJCsCemU7db97vtW37-hOOx&payer_status=verified&payer_email=mitcheyDoe%40gmail.com&txn_id=6SR99524AP993094V&receiver_email=clients%40boxbilling.com&first_name=John&payer_id=9W3MDRHPS5RTY&receiver_id=79PMKLAHYN3HN&item_number=BOX05697&payment_status=Completed&payment_fee=0.47&mc_fee=0.47&mc_gross=5.95&charset=windows-1252¬ify_version=3.4&ipn_track_id=54b4dbfade396"}', 1); - $adapter->processTransaction($this->api_admin, 1, $subscr_payment); + $adapter->processTransaction($this->api_admin, 1, $subscr_payment, 1); $web_accept = json_decode('{"get":{"bb_gateway_id":"1","bb_invoice_id":"1"},"post":{"transaction_subject":"Payment for invoice BOX05623","payment_date":"08:26:14 Mar 01, 2012 PST","txn_type":"web_accept","last_name":"Doe","residence_country":"US","item_name":"Payment for invoice BOX05623","payment_gross":"5.95","mc_currency":"USD","business":"sales@boxbilling.com","payment_type":"instant","protection_eligibility":"Ineligible","verify_sign":"A.DRDmKsJOHhCaHehJk34EQqLY1rAuZ0ksJDt.45zrn5eO7JxP0.4QP.","payer_status":"verified","tax":"0.00","payer_email":"john.doe@gmail.com","txn_id":"8X786252873429051","quantity":"1","receiver_email":"clients@boxbilling.com","first_name":"John","payer_id":"29NE5SEU5VR2E","receiver_id":"79PMKLAHPL5YH","item_number":"BOX05623","handling_amount":"0.00","payment_status":"Completed","payment_fee":"0.44","mc_fee":"0.44","shipping":"0.00","mc_gross":"5.95","custom":"","charset":"windows-1252","notify_version":"3.4","ipn_track_id":"6fd845df6f247"},"http_raw_post_data":"transaction_subject=Payment+for+invoice+BOX05623&payment_date=08%3A26%3A14+Mar+01%2C+2012+PST&txn_type=web_accept&last_name=Doe&residence_country=LT&item_name=Payment+for+invoice+BOX05623&payment_gross=5.95&mc_currency=USD&business=sales%40boxbilling.com&payment_type=instant&protection_eligibility=Ineligible&verify_sign=A.DRDmKsJOHhCaHehJr9EQqLY1rAuZ0ksJDt.45zrn5eO7JxP0.4QP.&payer_status=verified&tax=0.00&payer_email=fordnox%40gmail.com&txn_id=8X786252873429051&quantity=1&receiver_email=clients%40boxbilling.com&first_name=John&payer_id=29NE5SEU5VR2E&receiver_id=79PMKLAHYN3HN&item_number=BOX05623&handling_amount=0.00&payment_status=Completed&payment_fee=0.44&mc_fee=0.44&shipping=0.00&mc_gross=5.95&custom=&charset=windows-1252¬ify_version=3.4&ipn_track_id=6fd802df6f247"}', 1); - $adapter->processTransaction($this->api_admin, 1, $web_accept); + $adapter->processTransaction($this->api_admin, 1, $web_accept, 1); - $refund_ipn = json_decode('{"get":{"bb_gateway_id":"1","bb_invoice_id":"1"},"post":{"transaction_subject":"Subscription for BoxBilling Pro License","payment_date":"17:42:05 Mar 13, 2012 PDT","subscr_id":"S-9X268688JL8514304","last_name":"Doe","residence_country":"GB","item_name":"Subscription for BoxBilling Pro License","payment_gross":"-5.95","mc_currency":"USD","business":"clients@boxbilling.com","payment_type":"instant","protection_eligibility":"Ineligible","verify_sign":"ArFZ5DF1pEd4euI2jpvbEwe5Q4BiAB46zG6F4TMlFNMtpDC7L5z6VPsB","payer_email":"mitcheyDoe@gmail.com","txn_id":"33R88456DU653693H","receiver_email":"clients@boxbilling.com","first_name":"John","parent_txn_id":"6SR99524AP993094V","payer_id":"9W3LMGTFS5RTY","receiver_id":"79PMKLAHPL5YH","reason_code":"refund","item_number":"BOX05697","payment_status":"Refunded","payment_fee":"-0.17","mc_fee":"-0.17","mc_gross":"-5.95","charset":"windows-1252","notify_version":"3.4","ipn_track_id":"71f325984a82e"},"http_raw_post_data":"transaction_subject=Subscription+for+BoxBilling+Pro+License&payment_date=17%3A42%3A05+Mar+13%2C+2012+PDT&subscr_id=S-9X268688JL8514304&last_name=Doe&residence_country=GB&item_name=Subscription+for+BoxBilling+Pro+License&payment_gross=-5.95&mc_currency=USD&business=clients%40boxbilling.com&payment_type=instant&protection_eligibility=Ineligible&verify_sign=ArFZ5DF1pEd6dfI2jpvbEwe5Q4BiAB46zG6F4TMlFNMtpDC7L5z6VPsB&payer_email=mitcheyDoe%40gmail.com&txn_id=33R88456DU653693H&receiver_email=clients%40boxbilling.com&first_name=John&parent_txn_id=6SR99524AP993094V&payer_id=9W3MDRHPS5RTY&receiver_id=79PMKLAHYN3HN&reason_code=refund&item_number=BOX05697&payment_status=Refunded&payment_fee=-0.17&mc_fee=-0.17&mc_gross=-5.95&charset=windows-1252¬ify_version=3.4&ipn_track_id=71f784354a82e"}', 1); - $adapter->processTransaction($this->api_admin, 1, $refund_ipn); + $refund_ipn = json_decode('{"get":{"bb_gateway_id":"1","bb_invoice_id":"1"},"post":{"transaction_subject":"Subscription for BoxBilling Pro License","payment_date":"17:42:05 Mar 13, 2012 PDT", "txn_type":"subscr_payment","subscr_id":"S-9X268688JL8514304","last_name":"Doe","residence_country":"GB","item_name":"Subscription for BoxBilling Pro License","payment_gross":"-5.95","mc_currency":"USD","business":"clients@boxbilling.com","payment_type":"instant","protection_eligibility":"Ineligible","verify_sign":"ArFZ5DF1pEd4euI2jpvbEwe5Q4BiAB46zG6F4TMlFNMtpDC7L5z6VPsB","payer_email":"mitcheyDoe@gmail.com","txn_id":"33R88456DU653693H","receiver_email":"clients@boxbilling.com","first_name":"John","parent_txn_id":"6SR99524AP993094V","payer_id":"9W3LMGTFS5RTY","receiver_id":"79PMKLAHPL5YH","reason_code":"refund","item_number":"BOX05697","payment_status":"Refunded","payment_fee":"-0.17","mc_fee":"-0.17","mc_gross":"-5.95","charset":"windows-1252","notify_version":"3.4","ipn_track_id":"71f325984a82e"},"http_raw_post_data":"transaction_subject=Subscription+for+BoxBilling+Pro+License&payment_date=17%3A42%3A05+Mar+13%2C+2012+PDT&subscr_id=S-9X268688JL8514304&last_name=Doe&residence_country=GB&item_name=Subscription+for+BoxBilling+Pro+License&payment_gross=-5.95&mc_currency=USD&business=clients%40boxbilling.com&payment_type=instant&protection_eligibility=Ineligible&verify_sign=ArFZ5DF1pEd6dfI2jpvbEwe5Q4BiAB46zG6F4TMlFNMtpDC7L5z6VPsB&payer_email=mitcheyDoe%40gmail.com&txn_id=33R88456DU653693H&receiver_email=clients%40boxbilling.com&first_name=John&parent_txn_id=6SR99524AP993094V&payer_id=9W3MDRHPS5RTY&receiver_id=79PMKLAHYN3HN&reason_code=refund&item_number=BOX05697&payment_status=Refunded&payment_fee=-0.17&mc_fee=-0.17&mc_gross=-5.95&charset=windows-1252¬ify_version=3.4&ipn_track_id=71f784354a82e"}', 1); + $adapter->processTransaction($this->api_admin, 1, $refund_ipn, 1); } public function testGatewayProductionUrl() @@ -34,9 +35,12 @@ class Payment_Adapter_PayPalEmailTest extends BBDbApiTestCase $config = array(); $config['email'] = 'example@gmail.com'; $config['test_mode'] = false; - + $config['return_url'] = 'http://www.google.com?q=return'; + $config['cancel_url'] = 'http://www.google.com?q=cancel'; + $config['notify_url'] = 'http://www.google.com?q=notify'; + $adapter = new Payment_Adapter_PayPalEmail($config); - $form = $adapter->getHtml($this->api_admin, 1); + $form = $adapter->getHtml($this->api_admin, 1, false); $this->assertRegExp('/action="https:\/\/www\.paypal\.com\/cgi-bin\/webscr"/', $form); } @@ -45,9 +49,12 @@ class Payment_Adapter_PayPalEmailTest extends BBDbApiTestCase $config = array(); $config['email'] = 'example@gmail.com'; $config['test_mode'] = true; + $config['return_url'] = 'http://www.google.com?q=return'; + $config['cancel_url'] = 'http://www.google.com?q=cancel'; + $config['notify_url'] = 'http://www.google.com?q=notify'; $adapter = new Payment_Adapter_PayPalEmail($config); - $form = $adapter->getHtml($this->api_admin, 1); + $form = $adapter->getHtml($this->api_admin, 1, false); $this->assertRegExp('/action="https:\/\/www\.sandbox\.paypal\.com\/cgi-bin\/webscr"/', $form); } } diff --git a/tests/integration/bb-library/Payment/Adapter/TwoCheckoutTest.php b/tests/integration/bb-library/Payment/Adapter/TwoCheckoutTest.php index 43eb85233..55575d4bb 100644 --- a/tests/integration/bb-library/Payment/Adapter/TwoCheckoutTest.php +++ b/tests/integration/bb-library/Payment/Adapter/TwoCheckoutTest.php @@ -1,21 +1,35 @@ 'test', - 'secret' => 'test', + $config = array( + 'vendor_nr' => 'test', + 'secret' => 'test', + 'test_mode' => true, + 'redirect_url' => 'http://www.google.com?q=redirect', + 'single_page' => true, + 'subscription' =>true, + + ); + $data = array( + 'get' => array(), + 'post' => array( + 'message_type' => 'ORDER_CREATED', + 'subscription' =>true, + 'order_number' => 1, + 'total' => 500 + ) ); $adapter = new Payment_Adapter_TwoCheckout($config); $adapter->getConfig(); - $adapter->getHtml($this->api_admin, 1); - $adapter->getHtml($this->api_admin, 1, true); - $adapter->processTransaction($this->api_admin, 1); + $adapter->getHtml($this->api_admin, 1, false); + $adapter->processTransaction($this->api_admin, 1, $data, 1); } } \ No newline at end of file diff --git a/tests/integration/bb-library/Payment/Adapter/WebMoneyTest.php b/tests/integration/bb-library/Payment/Adapter/WebMoneyTest.php index f400356d6..6c9bc2369 100644 --- a/tests/integration/bb-library/Payment/Adapter/WebMoneyTest.php +++ b/tests/integration/bb-library/Payment/Adapter/WebMoneyTest.php @@ -5,19 +5,24 @@ class Payment_Adapter_WebMoneyTest extends BBDbApiTestCase { protected $_initialSeedFile = 'transactions.xml'; - + public function testGateway() { - $config = array( - 'purse' => 'test', + $config = array( + 'purse' => 'test', + 'success_url' => 'http://www.google.com?q=success', + 'cancel_url' => 'http://www.google.com?q=cancel', + 'notify_url' => 'http://www.google.com?q=notify', ); $adapter = new Payment_Adapter_WebMoney($config); $adapter->getConfig(); $adapter->getHtml($this->api_admin, 1); - + $data['post'] = array( 'INVOICE_ID' => '1', 'LMI_PAYMENT_AMOUNT' => '10', + 'LMI_SYS_TRANS_NO' => '1', + 'LMI_PAYER_PURSE' => 'WMZ' ); $adapter->processTransaction($this->api_admin, 1, $data); }