public function setUp() { $this->_payloadStub = $this->getMock(self::PAYMENT_PAYLOAD_CLASS); $paymentIterable = $this->getMock(self::PAYMENT_ITERABLE_CLASS); $paymentIterable->expects($this->any())->method('getEmptyStoredValueCardPayment')->will($this->returnValue($this->_payloadStub)); $this->_paymentContainer = $this->getMock(self::PAYMENT_CONTAINER_CLASS); $this->_paymentContainer->expects($this->any())->method('getPayments')->will($this->returnValue($paymentIterable)); $this->_giftcardStub = $this->getModelMock('ebayenterprise_giftcard/giftcard'); $this->_giftcardContainerStub = $this->getModelMock('ebayenterprise_giftcard/container', ['getRedeemedGiftCards']); $this->_giftcardContainerStub->expects($this->any())->method('getRedeemedGiftCards')->will($this->returnValue(array($this->_giftcardStub))); $this->_orderStub = $this->getModelMock('sales/order'); }
/** * Make stored value card payloads for any redeemed * gift cards * * @param Mage_Sales_Model_Order $order * @param IPaymentContainer $paymentContainer * @param SplObjectStorage $processedPayments */ public function addPaymentsToPayload(Mage_Sales_Model_Order $order, IPaymentContainer $paymentContainer, SplObjectStorage $processedPayments) { foreach ($this->_giftcardContainer->getRedeemedGiftcards() as $giftcard) { $iterable = $paymentContainer->getPayments(); $payload = $iterable->getEmptyStoredValueCardPayment(); $payload->setOrderId($order->getIncrementId())->setTenderType($giftcard->getTenderType())->setAccountUniqueId($giftcard->getCardNumber())->setPanIsToken((bool) $giftcard->getPanIsToken())->setCreateTimestamp($giftcard->getRedeemedAt())->setAmount($giftcard->getAmountRedeemed())->setPin($giftcard->getPin())->setPaymentRequestId($giftcard->getRedeemRequestId()); // add the new payload $iterable->OffsetSet($payload, $payload); // put the payment in the processed payments set $processedPayments->attach($giftcard); } }
public function setUp() { $this->_payloadStub = $this->getMock(self::PAYMENT_PAYLOAD_CLASS); $paymentIterable = $this->getMock(self::PAYMENT_ITERABLE_CLASS); $paymentIterable->expects($this->any())->method('getEmptyCreditCardPayment')->will($this->returnValue($this->_payloadStub)); $this->_paymentContainer = $this->getMock(self::PAYMENT_CONTAINER_CLASS); $this->_paymentContainer->expects($this->any())->method('getPayments')->will($this->returnValue($paymentIterable)); $methodCode = Mage::getModel('ebayenterprise_creditcard/method_ccpayment')->getCode(); $this->_paymentStub = $this->getModelMock('sales/order_payment', ['getId', 'getCcNumberEnc', 'decrypt']); $this->_paymentStub->setMethod($methodCode)->setCreatedAt('2012-01-01 00:00:00')->setCcExpYear(2020)->setCcExpMonth(1)->setAdditionalInformation('start_date', '2012-01-01 00:00:00'); $this->_orderStub = $this->getModelMock('sales/order', ['getAllPayments']); $this->_orderStub->expects($this->once())->method('getAllPayments')->will($this->returnValue([$this->_paymentStub])); }
/** * Make prepaid credit card payloads for any payments * remaining in the list * @param Mage_Sales_Model_Order $order * @param IPaymentContainer $paymentContainer * @param SplObjectStorage $processedPayments */ public function addPaymentsToPayload(Mage_Sales_Model_Order $order, IPaymentContainer $paymentContainer, SplObjectStorage $processedPayments) { foreach ($order->getAllPayments() as $payment) { if ($this->_shouldIgnorePayment($payment, $processedPayments)) { continue; } $iterable = $paymentContainer->getPayments(); $payload = $iterable->getEmptyPrepaidCreditCardPayment(); $ccType = $payment->getCcType(); if ($ccType) { $payload->setBrand($this->_getCcTypeName($ccType)); } $payload->setAmount($payment->getAmountOrdered()); $iterable[$payload] = $payload; } }
public function setUp() { $this->_payloadStub = $this->getMock(self::PAYMENT_PAYLOAD_CLASS); $paymentIterable = $this->getMock(self::PAYMENT_ITERABLE_CLASS); $paymentIterable->expects($this->any())->method('getEmptyPayPalPayment')->will($this->returnValue($this->_payloadStub)); $this->_paymentContainer = $this->getMock(self::PAYMENT_CONTAINER_CLASS); $this->_paymentContainer->expects($this->any())->method('getPayments')->will($this->returnValue($paymentIterable)); $payment1 = $this->getModelMock('sales/order_payment', ['getId']); $payment1->expects($this->any())->method('getId')->will($this->returnValue(1)); $payment1->setCreatedAt('2012-01-01 00:00:00')->setMethod(Mage::getModel('ebayenterprise_paypal/method_express')->getCode()); $payment2 = $this->getModelMock('sales/order_payment', ['getId']); $payment2->expects($this->any())->method('getId')->will($this->returnValue(2)); $payment2->setMethod('non-paypal'); $this->_paymentStubs[] = $payment1; $this->_paymentStubs[] = $payment2; $this->_orderStub = $this->getModelMock('sales/order', ['getAllPayments']); $this->_orderStub->expects($this->once())->method('getAllPayments')->will($this->returnValue($this->_paymentStubs)); }
/** * Make prepaid credit card payloads for any payments * remaining in the list * @param Mage_Sales_Model_Order $order * @param IPaymentContainer $paymentContainer * @param SplObjectStorage $processedPayments */ public function addPaymentsToPayload(Mage_Sales_Model_Order $order, IPaymentContainer $paymentContainer, SplObjectStorage $processedPayments) { foreach ($order->getAllPayments() as $payment) { if ($this->_shouldIgnorePayment($payment, $processedPayments)) { continue; } $iterable = $paymentContainer->getPayments(); $payload = $iterable->getEmptyPayPalPayment(); $additionalInfo = new Varien_Object($payment->getAdditionalInformation()); // use the grand total since it has already been adjusted for redeemed giftcards // by the the giftcard module's total collector. $amount = $order->getGrandTotal(); $payload->setAmount($amount)->setAmountAuthorized($amount)->setCreateTimestamp($this->_getAsDateTime($payment->getCreatedAt()))->setAuthorizationResponseCode(self::AUTH_RESPONSE_CODE)->setOrderId($order->getIncrementId())->setTenderType(self::TENDER_TYPE)->setPanIsToken(true)->setAccountUniqueId(self::ACCOUNT_UNIQUE_ID)->setPaymentRequestId($additionalInfo->getAuthRequestId()); // add the new payload $iterable->OffsetSet($payload, $payload); // put the payment in the processed payments set $processedPayments->attach($payment); } }
/** * Make prepaid credit card payloads for any payments * remaining in the list * @param Mage_Sales_Model_Order $order * @param IPaymentContainer $paymentContainer * @param SplObjectStorage $processedPayments */ public function addPaymentsToPayload(Mage_Sales_Model_Order $order, IPaymentContainer $paymentContainer, SplObjectStorage $processedPayments) { foreach ($order->getAllPayments() as $payment) { if ($this->_shouldIgnorePayment($payment, $processedPayments)) { continue; } $iterable = $paymentContainer->getPayments(); $payload = $iterable->getEmptyCreditCardPayment(); $additionalInfo = new Varien_Object($payment->getAdditionalInformation()); $payload->setOrderId($order->getIncrementId())->setTenderType($additionalInfo->getTenderType())->setAccountUniqueId($this->_getAccountUniqueId($payment))->setPanIsToken($additionalInfo->getPanIsToken())->setPaymentRequestId($additionalInfo->getRequestId())->setCreateTimestamp($this->_getAsDateTime($payment->getCreatedAt()))->setAmount($payment->getAmountAuthorized())->setBankAuthorizationCode($additionalInfo->getBankAuthorizationCode())->setResponseCode($additionalInfo->getResponseCode())->setCVV2ResponseCode($additionalInfo->getCvv2ResponseCode())->setAVSResponseCode($additionalInfo->getAvsResponseCode())->setPhoneResponseCode($additionalInfo->getPhoneResponseCode())->setNameResponseCode($additionalInfo->getNameResponseCode())->setEmailResponseCode($additionalInfo->getEmailResponseCode())->setAmountAuthorized($additionalInfo->getAmountAuthorized())->setExpirationDate($this->_getExpirationDateTime($payment))->setExtendedAuthDescription($additionalInfo->getExtendedAuthDescription())->setExtendedAuthReasonCode($additionalInfo->getExtendedAuthReasonCode())->setIssueNumber($additionalInfo->getIssueNumber())->setAuthenticationAvailable($additionalInfo->getAuthenticationAvailable())->setAuthenticationStatus($additionalInfo->getAuthenticationStatus())->setCavvUcaf($additionalInfo->getCavvUcaf())->setTransactionId($additionalInfo->getTransactionId())->setECI($additionalInfo->getECI())->setPayerAuthenticationResponse($additionalInfo->getPayerAuthenticationResponse())->setPurchasePlanCode($additionalInfo->getPurchasePlanCode())->setPurchasePlanDescription($additionalInfo->getPurchasePlanDescription()); if ($additionalInfo->getStartDate()) { // prevent death by type error if getStartDate returns null $payload->setStartDate($this->_getAsDateTime($additionalInfo->getStartDate())); } // add the new payload $iterable->OffsetSet($payload, $payload); // put the payment in the processed payments set $processedPayments->attach($payment); } }
public function setUp() { $this->_processedPayments = new SplObjectStorage(); $this->_payloadStub = $this->getMock(self::PAYMENT_PAYLOAD_CLASS); $paymentIterable = $this->getMock(self::PAYMENT_ITERABLE_CLASS); $paymentIterable->expects($this->any())->method('getEmptyPrepaidCreditCardPayment')->will($this->returnValue($this->_payloadStub)); $this->_paymentContainer = $this->getMock(self::PAYMENT_CONTAINER_CLASS); $this->_paymentContainer->expects($this->any())->method('getPayments')->will($this->returnValue($paymentIterable)); $paymentMethod = $this->getModelMock('payment/method_abstract', ['getCode']); $paymentMethod->expects($this->any())->method('getCode')->will($this->returnValue('abstractPaymentMethodStub')); $plainPayment = $this->getModelMock('sales/order_payment', ['getId', 'getMethod']); $plainPayment->expects($this->any())->method('getId')->will($this->returnValue(1)); $plainPayment->expects($this->any())->method('getMethod')->will($this->returnValue($paymentMethod)); $discoverCardPayment = $this->getModelMock('sales/order_payment', ['getId', 'getCcType', 'getMethod']); $discoverCardPayment->expects($this->any())->method('getId')->will($this->returnValue(2)); $discoverCardPayment->expects($this->any())->method('getCcType')->will($this->returnValue('DC')); $discoverCardPayment->expects($this->any())->method('getMethod')->will($this->returnValue($paymentMethod)); $freePayment = $this->getModelMock('sales/order_payment', ['getId', 'getMethod']); $freePayment->expects($this->any())->method('getId')->will($this->returnValue(3)); $freePayment->expects($this->any())->method('getMethod')->will($this->returnValue(Mage::getModel('payment/method_free')->getCode())); $this->_paymentStubs = [$plainPayment, $discoverCardPayment, $freePayment]; $this->_orderStub = $this->getModelMock('sales/order', ['getAllPayments']); }