mirror of
https://github.com/FOSSBilling/FOSSBilling.git
synced 2026-11-21 20:34:57 +09:00
Finish issue-proccesTransaction
This commit is contained in:
commit
20706cb6ff
3 files changed
+80
-9
No files matched your search
@@ -403,12 +403,12 @@ class ServiceTransaction implements InjectionAwareInterface
|
||||
|
||||
$payGatewayService = $this->di['mod_service']('Invoice', 'PayGateway');
|
||||
$adapter = $payGatewayService->getPaymentAdapter($gtw);
|
||||
if(!method_exists($adapter, 'process')) {
|
||||
if(!method_exists($adapter, 'processTransaction')) {
|
||||
throw new \Box_Exception('Payment adapter :adapter does not support action :action', array(':adapter'=>$gtw->name, ':action'=>'processTransaction'), 705);
|
||||
}
|
||||
|
||||
$ipn = json_decode($tx->ipn, 1);
|
||||
return $adapter->process($this->di['api_admin'], $id, $ipn, $tx->gateway_id);
|
||||
return $adapter->processTransaction($this->di['api_admin'], $id, $ipn, $tx->gateway_id);
|
||||
}
|
||||
|
||||
public function getReceived()
|
||||
@@ -496,7 +496,7 @@ class ServiceTransaction implements InjectionAwareInterface
|
||||
return false;
|
||||
}
|
||||
|
||||
$res = $this->di['db']->findOne('Transaction', 'status = processed and txn_id = ?', array($tx->txn_id));
|
||||
$res = $this->di['db']->findOne('Transaction', 'status = "processed" and txn_id = ?', array($tx->txn_id));
|
||||
return empty($res);
|
||||
}
|
||||
|
||||
@@ -553,6 +553,10 @@ class ServiceTransaction implements InjectionAwareInterface
|
||||
$tx->output = $adapter->getOutput();
|
||||
}
|
||||
|
||||
if(!method_exists($adapter, 'getTransaction')) {
|
||||
throw new \Box_Exception('Payment adapter :adapter does not support action :action', array(':adapter'=>$gtw->name, ':action'=>'getTransaction'), 705);
|
||||
}
|
||||
|
||||
$response = $adapter->getTransaction($ipn, $mpi);
|
||||
if(!$response instanceof \Payment_Transaction) {
|
||||
throw new \Box_Exception('Payment gateway :id method getTransaction should return Payment_Transaction object', array(':id'=>$gtw->gateway), 705);
|
||||
|
||||
@@ -525,7 +525,73 @@ class ServiceTransactionTest extends \PHPUnit_Framework_TestCase {
|
||||
$serviceMock->preProcessTransaction($transactionModel);
|
||||
}
|
||||
|
||||
public function testprocessTransaction()
|
||||
public function paymentsAdapterProvider_withoutProcessTransaction()
|
||||
{
|
||||
return array(
|
||||
array('\Payment_Adapter_AlertPay'),
|
||||
array('\Payment_Adapter_AliPay'),
|
||||
array('\Payment_Adapter_AuthorizeNet'),
|
||||
array('\Payment_Adapter_Interkassa'),
|
||||
array('\Payment_Adapter_Onebip'),
|
||||
array('\Payment_Adapter_Payza'),
|
||||
array('\Payment_Adapter_WebToPay'),
|
||||
array('\Payment_Adapter_Custom'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider paymentsAdapterProvider_withoutProcessTransaction
|
||||
*/
|
||||
public function testprocessTransactionWithPayment_Adapter($adapter)
|
||||
{
|
||||
$id = 1;
|
||||
$transactionModel = new \Model_Transaction();
|
||||
$transactionModel->loadBean(new \RedBeanPHP\OODBBean());
|
||||
$transactionModel->gateway_id = 2;
|
||||
$transactionModel->ipn = '{}';
|
||||
|
||||
$payGatewayModel = new \Model_PayGateway();
|
||||
$payGatewayModel->loadBean(new \RedBeanPHP\OODBBean());
|
||||
$payGatewayModel->name = substr($adapter, strpos($adapter, '\Payment_Adapter_')+1);
|
||||
|
||||
$dbMock = $this->getMockBuilder('\Box_Database')->getMock();
|
||||
$dbMock->expects($this->atLeastOnce())
|
||||
->method('load')
|
||||
->will($this->onConsecutiveCalls($transactionModel, $payGatewayModel));
|
||||
|
||||
$paymentAdapterMock = $this->getMockBuilder('\Payment_Adapter_Custom')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$payGatewayService = $this->getMockBuilder('\Box\Mod\Invoice\ServicePayGateway')->getMock();
|
||||
$payGatewayService->expects($this->atLeastOnce())
|
||||
->method('getPaymentAdapter')
|
||||
->will($this->returnValue($paymentAdapterMock));
|
||||
|
||||
$di = new \Box_Di();
|
||||
$di['db'] = $dbMock;
|
||||
$di['mod_service'] = $di->protect(function() use($payGatewayService) {return $payGatewayService;});
|
||||
$di['api_admin'] = new \Api_Handler(new \Model_Admin());
|
||||
$this->service->setDi($di);
|
||||
|
||||
$this->setExpectedException('\Box_Exception', sprintf("Payment adapter %s does not support action %s", $payGatewayModel->name, 'processTransaction'));
|
||||
$this->service->processTransaction($id);
|
||||
}
|
||||
|
||||
public function paymentsAdapterProvider_withprocessTransaction()
|
||||
{
|
||||
return array(
|
||||
array('\Payment_Adapter_BluePay'),
|
||||
array('\Payment_Adapter_PayPalEmail'),
|
||||
array('\Payment_Adapter_TwoCheckout'),
|
||||
array('\Payment_Adapter_WebMoney'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider paymentsAdapterProvider_withprocessTransaction
|
||||
*/
|
||||
public function testprocessTransaction_supportProcessTransaction($adapter)
|
||||
{
|
||||
$id = 1;
|
||||
$transactionModel = new \Model_Transaction();
|
||||
@@ -541,11 +607,12 @@ class ServiceTransactionTest extends \PHPUnit_Framework_TestCase {
|
||||
->method('load')
|
||||
->will($this->onConsecutiveCalls($transactionModel, $payGatewayModel));
|
||||
|
||||
$paymentAdapterMock = $this->getMockBuilder('\Payment_Adapter_Custom')
|
||||
$paymentAdapterMock = $this->getMockBuilder($adapter)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$paymentAdapterMock->expects($this->atLeastOnce())
|
||||
->method('process');
|
||||
->method('processTransaction');
|
||||
|
||||
$payGatewayService = $this->getMockBuilder('\Box\Mod\Invoice\ServicePayGateway')->getMock();
|
||||
$payGatewayService->expects($this->atLeastOnce())
|
||||
|
||||
Vendored
+3
-3
@@ -31,11 +31,11 @@
|
||||
|
||||
<transaction id="5" invoice_id="4" gateway_id="2" ip="123.123.123.123" validate_ipn="0" created_at="2011-01-01T12:00:00+00:00" updated_at="2011-01-01T12:00:00+00:00" ipn='{"get":{"bb_invoice_id":"4"}, "post":{"txn_id":"555asd", "txn_type":"unknown"}}'/>
|
||||
<transaction id="6" invoice_id="4" gateway_id="2" ip="123.123.123.123" validate_ipn="0" created_at="2011-01-01T12:00:00+00:00" updated_at="2011-01-01T12:00:00+00:00" ipn='{"get":{"bb_invoice_id":"4"}, "post":{"txn_type":"web_accept", "txn_id":"555asd", "mc_gross":"14.99", "mc_currency":"USD", "payment_status":"Completed"}}'/>
|
||||
<transaction id="7" invoice_id="4" gateway_id="2" ip="123.123.123.123" validate_ipn="0" created_at="2011-01-01T12:00:00+00:00" updated_at="2011-01-01T12:00:00+00:00" ipn='{"get":{"bb_invoice_id":"4"}, "post":{"txn_id":"555asd", "mc_gross":"-8.99", "mc_currency":"USD", "payment_status":"Refunded"}}'/>
|
||||
<transaction id="8" invoice_id="4" gateway_id="2" ip="123.123.123.123" validate_ipn="0" created_at="2011-01-01T12:00:00+00:00" updated_at="2011-01-01T12:00:00+00:00" ipn='{"get":{"bb_invoice_id":"4"}, "post":{"txn_type":"subscr_signup","subscr_id":"12123", "txn_id":"555asd", "mc_gross":"14.99", "mc_currency":"USD", "payment_status":"Completed"}}'/>
|
||||
<transaction id="7" invoice_id="4" gateway_id="2" ip="123.123.123.123" validate_ipn="0" created_at="2011-01-01T12:00:00+00:00" updated_at="2011-01-01T12:00:00+00:00" ipn='{"get":{"bb_invoice_id":"4"}, "post":{"txn_type":"web_accept", "txn_id":"555asd79798989", "parent_txn_id":"555asdasdadasdasdqwe" "mc_gross":"-8.99", "mc_currency":"USD", "payment_status":"Refunded"}}'/>
|
||||
<transaction id="8" invoice_id="4" gateway_id="2" ip="123.123.123.123" validate_ipn="0" created_at="2011-01-01T12:00:00+00:00" updated_at="2011-01-01T12:00:00+00:00" ipn='{"get":{"bb_invoice_id":"4"}, "post":{"txn_type":"subscr_signup","amount3" : "14.99", "period3" : "3", "subscr_id":"12123", "txn_id":"555asd", "mc_gross":"14.99", "mc_currency":"USD", "payment_status":"Completed"}}'/>
|
||||
<transaction id="9" invoice_id="4" gateway_id="2" ip="123.123.123.123" validate_ipn="0" created_at="2011-01-01T12:00:00+00:00" updated_at="2011-01-01T12:00:00+00:00" ipn='{"get":{"bb_invoice_id":"4"}, "post":{"txn_type":"subscr_cancel","subscr_id":"12123", "txn_id":"555asd", "mc_gross":"14.99", "mc_currency":"USD", "payment_status":"Completed"}}'/>
|
||||
<transaction id="10" invoice_id="" gateway_id="2" created_at="2011-01-01T12:00:00+00:00" updated_at="2011-01-01T12:00:00+00:00" ipn='{"get":{"bb_gateway_id":"4","bb_invoice_id":"2"},"post":{"transaction_subject":"Payment for invoice 02 [BoxBilling Pro License]","txn_type":"web_accept","payment_date":"10:50:58 Sep 09, 2012 PDT","last_name":"Doe","residence_country":"US","item_name":"Payment for invoice 02 [BoxBilling Pro License]","payment_gross":"17.85","mc_currency":"USD","business":"sales@boxbilling.com","payment_type":"echeck","protection_eligibility":"Ineligible","verify_sign":"AWV-DF.sxuuqGRHykbk8E7.C7EVoAIgJEU6Ry9yF5RV6hZcgx4j6QIUJ","payer_status":"verified","tax":"0.00","payer_email":"john.doe@gmail.com","txn_id":"321499792P233823Y","quantity":"1","receiver_email":"sales@boxbilling.com","first_name":"John","payer_id":"D83FZCL7G529J","receiver_id":"YAU6UPNDCYP5E","item_number":"2","handling_amount":"0.00","payment_status":"Denied","shipping":"0.00","mc_gross":"17.85","custom":"","charset":"windows-1252","notify_version":"3.6","ipn_track_id":"2131e6325918f"}}'/>
|
||||
<transaction id="11" invoice_id="" gateway_id="3" created_at="2011-01-01T12:00:00+00:00" updated_at="2011-01-01T12:00:00+00:00" ipn='{"get":{"bb_gateway_id":"9","bb_invoice_id":"1","bb_invoice_hash":"078c38b84cb656b731b31fdb80f7e7d070453488","bb_redirect":"1","middle_initial":"","li_0_name":"BoxBilling Pro License","sid":"1679235","key":"43432579174404CE83D99756665420D8","state":"XX","email":"john.smith@gmail.com","li_0_type":"product","subscription":"1","li_0_duration":"Forever","order_number":"4805732520","lang":"en","invoice_id":"4805254741","li_0_price":"5.95","total":"5.95","credit_card_processed":"Y","zip":"834001","li_0_quantity":"1","cart_weight":"0","fixed":"Y","last_name":"Smith","li_0_product_id":"","street_address":"road no-13","city":"New York","li_0_tangible":"N","li_0_description":"BoxBilling Pro License","merchant_order_id":"7124","country":"IND","ip_country":"India","demo":"","pay_method":"CC","cart_tangible":"N","phone":"1234567890 ","li_0_recurrence":"1 Month","street_address2":"","x_receipt_link_url":"","first_name":"John","card_holder_name":"John Smith"},"post":[]}'/>
|
||||
<transaction id="11" invoice_id="" gateway_id="3" created_at="2011-01-01T12:00:00+00:00" updated_at="2011-01-01T12:00:00+00:00" ipn='{"get":{"bb_gateway_id":"9","bb_invoice_id":"1","bb_invoice_hash":"078c38b84cb656b731b31fdb80f7e7d070453488","bb_redirect":"1","middle_initial":"","li_0_name":"BoxBilling Pro License","sid":"1679235","key":"43432579174404CE83D99756665420D8","state":"XX","email":"john.smith@gmail.com","li_0_type":"product","subscription":"1","li_0_duration":"Forever","order_number":"4805732520","lang":"en","invoice_id":"4805254741","li_0_price":"5.95","total":"5.95","credit_card_processed":"Y","zip":"834001","li_0_quantity":"1","cart_weight":"0","fixed":"Y","last_name":"Smith","li_0_product_id":"","street_address":"road no-13","city":"New York","li_0_tangible":"N","li_0_description":"BoxBilling Pro License","merchant_order_id":"7124","country":"IND","ip_country":"India","demo":"","pay_method":"CC","cart_tangible":"N","phone":"1234567890 ","li_0_recurrence":"1 Month","street_address2":"","x_receipt_link_url":"","first_name":"John","card_holder_name":"John Smith"},"post":{"message_type":"ORDER_CREATED"}}'/>
|
||||
|
||||
<tax id="1" name="United Kingdom" country="UK" state="" taxrate="20" created_at="2011-01-01T12:00:00+00:00" updated_at="2011-01-01T12:00:00+00:00"/>
|
||||
<tax id="2" name="Global" country="" state="" taxrate="10" created_at="2011-01-01T12:00:00+00:00" updated_at="2011-01-01T12:00:00+00:00"/>
|
||||
|
||||
Reference in new issue
Block a user