本文整理匯總了PHP中Magento\Sales\Model\Order\Payment類的典型用法代碼示例。如果您正苦於以下問題:PHP Payment類的具體用法?PHP Payment怎麽用?PHP Payment使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Payment類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testCanVoid
/**
* @dataProvider canVoidDataProvider
* @param bool $canVoid
*/
public function testCanVoid($canVoid)
{
$this->_orderMock->expects($this->once())->method('getPayment')->will($this->returnValue($this->_paymentMock));
$this->_paymentMock->expects($this->once())->method('canVoid', '__wakeup')->with($this->equalTo($this->_model))->will($this->returnValue($canVoid));
$this->_model->setState(\Magento\Sales\Model\Order\Invoice::STATE_PAID);
$this->assertEquals($canVoid, $this->_model->canVoid());
}
示例2: testCanVoid
/**
* @dataProvider canVoidDataProvider
* @param bool $canVoid
*/
public function testCanVoid($canVoid)
{
$entityName = 'invoice';
$this->orderMock->expects($this->once())->method('getPayment')->will($this->returnValue($this->_paymentMock));
$this->orderMock->expects($this->once())->method('setHistoryEntityName')->with($entityName)->will($this->returnSelf());
$this->_paymentMock->expects($this->once())->method('canVoid', '__wakeup')->will($this->returnValue($canVoid));
$this->model->setState(\Magento\Sales\Model\Order\Invoice::STATE_PAID);
$this->assertEquals($canVoid, $this->model->canVoid());
}
示例3: testHandle
/**
* @covers \Magento\BraintreeTwo\Gateway\Response\CaptureDetailsHandler::handle
*/
public function testHandle()
{
$paymentData = $this->getPaymentDataObjectMock();
$subject['payment'] = $paymentData;
$this->payment->expects(static::once())->method('setIsTransactionClosed')->with(false);
$response = ['object' => ['success' => true]];
$this->subjectReader->expects(self::once())->method('readPayment')->with($subject)->willReturn($paymentData);
$this->captureHandler->handle($subject, $response);
}
示例4: setUp
protected function setUp()
{
$this->payment = $this->getMockBuilder(Payment::class)->disableOriginalConstructor()->setMethods(['setCcTransId', 'setLastTransId', 'setAdditionalInformation'])->getMock();
$this->subjectReader = $this->getMockBuilder(SubjectReader::class)->disableOriginalConstructor()->getMock();
$this->payment->expects(static::once())->method('setCcTransId');
$this->payment->expects(static::once())->method('setLastTransId');
$this->payment->expects(static::any())->method('setAdditionalInformation');
$this->paymentHandler = new PaymentDetailsHandler($this->subjectReader);
}
示例5: testBuild
public function testBuild()
{
$additionalData = [DataAssignObserver::DEVICE_DATA => self::DEVICE_DATA];
$expectedResult = [KountPaymentDataBuilder::DEVICE_DATA => self::DEVICE_DATA];
$buildSubject = ['payment' => $this->paymentDO];
$this->paymentMock->expects(static::exactly(count($additionalData)))->method('getAdditionalInformation')->willReturn($additionalData);
$this->configMock->expects(static::once())->method('hasFraudProtection')->willReturn(true);
$this->paymentDO->expects(static::once())->method('getPayment')->willReturn($this->paymentMock);
$this->subjectReaderMock->expects(self::once())->method('readPayment')->with($buildSubject)->willReturn($this->paymentDO);
static::assertEquals($expectedResult, $this->builder->build($buildSubject));
}
示例6: testHandle
/**
* @covers \Magento\BraintreeTwo\Gateway\Response\CloneDetailsHandler::handle
*/
public function testHandle()
{
$paymentData = $this->getPaymentDataObjectMock();
$transaction = $this->getBraintreeTransaction();
$subject['payment'] = $paymentData;
$this->payment->expects(static::once())->method('setTransactionId')->with(self::TRANSACTION_ID);
$response = ['object' => $transaction];
$this->subjectReader->expects(self::once())->method('readPayment')->with($subject)->willReturn($paymentData);
$this->subjectReader->expects(self::once())->method('readTransaction')->with($response)->willReturn($transaction);
$this->cloneHandler->handle($subject, $response);
}
示例7: testBuild
public function testBuild()
{
$additionalData = [[DataAssignObserver::PAYMENT_METHOD_NONCE, self::PAYMENT_METHOD_NONCE]];
$expectedResult = [PaymentDataBuilder::AMOUNT => 10.0, PaymentDataBuilder::PAYMENT_METHOD_NONCE => self::PAYMENT_METHOD_NONCE, PaymentDataBuilder::MERCHANT_ACCOUNT_ID => self::MERCHANT_ACCOUNT_ID];
$buildSubject = ['payment' => $this->paymentDO, 'amount' => 10.0];
$this->paymentMock->expects(static::exactly(count($additionalData)))->method('getAdditionalInformation')->willReturnMap($additionalData);
$this->configMock->expects(static::once())->method('getValue')->with(Config::KEY_MERCHANT_ACCOUNT_ID)->willReturn(self::MERCHANT_ACCOUNT_ID);
$this->paymentDO->expects(static::once())->method('getPayment')->willReturn($this->paymentMock);
$this->subjectReaderMock->expects(self::once())->method('readPayment')->with($buildSubject)->willReturn($this->paymentDO);
$this->subjectReaderMock->expects(self::once())->method('readAmount')->with($buildSubject)->willReturn(10.0);
static::assertEquals($expectedResult, $this->builder->build($buildSubject));
}
示例8: testHandle
/**
* @covers \Magento\BraintreeTwo\Gateway\Response\ThreeDSecureDetailsHandler::handle
*/
public function testHandle()
{
$paymentData = $this->getPaymentDataObjectMock();
$transaction = $this->getBraintreeTransaction();
$subject = ['payment' => $paymentData];
$response = ['object' => $transaction];
$this->subjectReaderMock->expects(self::once())->method('readPayment')->with($subject)->willReturn($paymentData);
$this->subjectReaderMock->expects(self::once())->method('readTransaction')->with($response)->willReturn($transaction);
$this->payment->expects(static::at(1))->method('setAdditionalInformation')->with('liabilityShifted', 'Yes');
$this->payment->expects(static::at(2))->method('setAdditionalInformation')->with('liabilityShiftPossible', 'Yes');
$this->handler->handle($subject, $response);
}
示例9: testHandle
/**
* @covers \Magento\BraintreeTwo\Gateway\Response\PayPalDetailsHandler::handle
*/
public function testHandle()
{
$paymentData = $this->getPaymentDataObjectMock();
$transaction = $this->getBraintreeTransaction();
$subject = ['payment' => $paymentData];
$response = ['object' => $transaction];
$this->subjectReader->expects(self::once())->method('readPayment')->with($subject)->willReturn($paymentData);
$this->subjectReader->expects(self::once())->method('readTransaction')->with($response)->willReturn($transaction);
$this->subjectReader->expects(static::once())->method('readPayPal')->with($transaction)->willReturn($transaction->paypal);
$this->payment->expects(static::exactly(2))->method('setAdditionalInformation');
$this->payPalHandler->handle($subject, $response);
}
示例10: testBuild
/**
* @covers \Magento\Braintree\Gateway\Request\CaptureDataBuilder::build
*/
public function testBuild()
{
$transactionId = 'b3b99d';
$amount = 10.0;
$expected = ['transaction_id' => $transactionId, 'amount' => $amount];
$buildSubject = ['payment' => $this->paymentDO, 'amount' => $amount];
$this->payment->expects(static::once())->method('getCcTransId')->willReturn($transactionId);
$this->paymentDO->expects(static::once())->method('getPayment')->willReturn($this->payment);
$this->subjectReaderMock->expects(self::once())->method('readPayment')->with($buildSubject)->willReturn($this->paymentDO);
$this->subjectReaderMock->expects(self::once())->method('readAmount')->with($buildSubject)->willReturn($amount);
static::assertEquals($expected, $this->builder->build($buildSubject));
}
示例11: aroundIsCaptureFinal
public function aroundIsCaptureFinal(\Magento\Sales\Model\Order\Payment $subject, \Closure $proceed, $amountToCapture)
{
$result = $proceed($amountToCapture);
if (!$result) {
$order = $subject->getOrder();
$invoices = $order->getInvoiceCollection();
$invoice = $invoices->getFirstItem();
$grandTotalBase = $invoice->getBaseGrandTotal();
/* validate with partial amount if exists */
$result = $grandTotalBase == $amountToCapture;
}
return $result;
}
示例12: testBuild
/**
* \Magento\BraintreeTwo\Gateway\Request\VaultCaptureDataBuilder::build
*/
public function testBuild()
{
$amount = 30.0;
$token = '5tfm4c';
$buildSubject = ['payment' => $this->paymentDO, 'amount' => $amount];
$expected = ['amount' => $amount, 'paymentMethodToken' => $token];
$this->subjectReader->expects(self::once())->method('readPayment')->with($buildSubject)->willReturn($this->paymentDO);
$this->subjectReader->expects(self::once())->method('readAmount')->with($buildSubject)->willReturn($amount);
$paymentExtension = $this->getMockBuilder(OrderPaymentExtension::class)->setMethods(['getVaultPaymentToken'])->disableOriginalConstructor()->getMock();
$paymentToken = $this->getMockBuilder(PaymentToken::class)->disableOriginalConstructor()->getMock();
$paymentExtension->expects(static::once())->method('getVaultPaymentToken')->willReturn($paymentToken);
$this->payment->expects(static::once())->method('getExtensionAttributes')->willReturn($paymentExtension);
$paymentToken->expects(static::once())->method('getGatewayToken')->willReturn($token);
$result = $this->builder->build($buildSubject);
static::assertEquals($expected, $result);
}
示例13: initPayment
/**
* @param $context
*/
protected function initPayment($context)
{
$this->payment = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this))->getObject('Magento\\Sales\\Model\\Order\\Payment', ['context' => $context, 'serviceOrderFactory' => $this->serviceOrderFactory, 'paymentData' => $this->helperMock, 'priceCurrency' => $this->priceCurrencyMock, 'transactionFactory' => $this->transactionFactory, 'transactionCollectionFactory' => $this->transactionCollectionFactory]);
$this->payment->setMethod('any');
$this->payment->setOrder($this->orderMock);
$this->transactionId = 100;
}
示例14: testGetShouldCloseParentTransaction
/**
* @covers \Magento\Sales\Model\Order\Payment::getShouldCloseParentTransaction()
* @return void
*/
public function testGetShouldCloseParentTransaction()
{
$this->payment->setShouldCloseParentTransaction(1);
static::assertTrue($this->payment->getShouldCloseParentTransaction());
$this->payment->setShouldCloseParentTransaction(0);
static::assertFalse($this->payment->getShouldCloseParentTransaction());
}
示例15: aroundGetAuthorizationTransaction
/**
* Magento will consider a transaction for voiding only if it is an authorization
* Braintree allows voiding captures too
*
* Lookup an authorization transaction using parent transaction id, if set
*
* @param Payment $subject
* @param callable $proceed
*
* @return \Magento\Sales\Model\Order\Payment\Transaction|false
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
public function aroundGetAuthorizationTransaction(Payment $subject, \Closure $proceed)
{
if ($subject->getMethodInstance()->getCode() != PaymentMethod::METHOD_CODE) {
return $proceed();
}
$invoice = $this->registry->registry('current_invoice');
if ($invoice && $invoice->getId()) {
$transactionId = $this->paymentHelper->clearTransactionId($invoice->getTransactionId());
$collection = $this->salesTransactionCollectionFactory->create()->addFieldToFilter('txn_id', ['eq' => $transactionId]);
if ($collection->getSize() < 1) {
return $proceed();
} else {
return $collection->getFirstItem();
}
}
return $proceed();
}