/** * Testing payment Success */ public function testPaymentSuccess() { $this->paymillMethod->expects($this->once())->method('getApiToken')->will($this->returnValue(self::API_TOKEN)); $this->paymentBridge->expects($this->once())->method('getOrder')->will($this->returnValue(1)); $this->paymillMethod->expects($this->any())->method('setTransactionId')->with($this->equalTo('123'))->will($this->returnValue($this->paymillMethod)); $this->paymillMethod->expects($this->any())->method('setTransactionStatus')->with($this->equalTo('closed'))->will($this->returnValue($this->paymillMethod)); $this->paymentBridge->expects($this->once())->method('getCurrency')->will($this->returnValue(self::CURRENCY)); $this->paymentBridge->expects($this->once())->method('getAmount')->will($this->returnValue(self::ORDER_AMOUNT)); $this->paymentBridge->expects($this->once())->method('getExtraData')->will($this->returnValue(array('order_description' => self::ORDER_DESCRIPTION))); $this->paymillResponseTransaction->expects($this->once())->method('getStatus')->will($this->returnValue('closed')); $this->paymillResponseTransaction->expects($this->once())->method('getId')->will($this->returnValue(123)); $this->paymillTransactionWrapper->expects($this->once())->method('create')->with($this->equalTo(self::ORDER_AMOUNT), $this->equalTo(self::CURRENCY), $this->equalTo(self::API_TOKEN), $this->equalTo(self::ORDER_DESCRIPTION))->will($this->returnValue($this->paymillResponseTransaction)); $this->paymentEventDispatcher->expects($this->once())->method('notifyPaymentOrderLoad')->with($this->equalTo($this->paymentBridge), $this->equalTo($this->paymillMethod)); $this->paymentEventDispatcher->expects($this->once())->method('notifyPaymentOrderCreated')->with($this->equalTo($this->paymentBridge), $this->equalTo($this->paymillMethod)); $this->paymentEventDispatcher->expects($this->once())->method('notifyPaymentOrderDone')->with($this->equalTo($this->paymentBridge), $this->equalTo($this->paymillMethod)); $this->paymentEventDispatcher->expects($this->any())->method('notifyPaymentOrderFail'); $this->paymentEventDispatcher->expects($this->once())->method('notifyPaymentOrderSuccess')->with($this->equalTo($this->paymentBridge), $this->equalTo($this->paymillMethod)); $this->paymillManager->processPayment($this->paymillMethod, self::ORDER_AMOUNT); }
/** * Testing payment error * */ public function testPaymentSuccess() { $this->redsysApiMethod->expects($this->once())->method('getCreditCartNumber')->will($this->returnValue(self::CART_NUMBER)); $this->redsysApiMethod->expects($this->once())->method('getCreditCartExpirationMonth')->will($this->returnValue(self::CART_EXPIRE_MONTH)); $this->redsysApiMethod->expects($this->once())->method('getCreditCartExpirationYear')->will($this->returnValue(self::CART_EXPIRE_YEAR)); $this->paymentBridge->expects($this->once())->method('getOrder')->will($this->returnValue(1)); $this->redsysApiMethod->expects($this->any())->method('setTransactionId')->with($this->equalTo('123'))->will($this->returnValue($this->redsysApiMethod)); $this->redsysApiMethod->expects($this->any())->method('setTransactionStatus')->with($this->equalTo('paid'))->will($this->returnValue($this->redsysApiMethod)); $this->paymentBridge->expects($this->once())->method('getCurrency')->will($this->returnValue(self::CURRENCY)); $this->paymentBridge->expects($this->once())->method('getAmount')->will($this->returnValue(self::CART_AMOUNT)); $cart = array('number' => self::CART_NUMBER, 'exp_month' => self::CART_EXPIRE_MONTH, 'exp_year' => self::CART_EXPIRE_YEAR); $chargeParams = array('card' => $cart, 'amount' => self::CART_AMOUNT, 'currency' => strtolower(self::CURRENCY)); $this->redsysApiTransactionWrapper->expects($this->once())->method('create')->with($chargeParams)->will($this->returnValue(array('paid' => '1', 'id' => '123'))); $this->paymentEventDispatcher->expects($this->once())->method('notifyPaymentOrderLoad')->with($this->equalTo($this->paymentBridge), $this->equalTo($this->redsysApiMethod)); $this->paymentEventDispatcher->expects($this->once())->method('notifyPaymentOrderCreated')->with($this->equalTo($this->paymentBridge), $this->equalTo($this->redsysApiMethod)); $this->paymentEventDispatcher->expects($this->once())->method('notifyPaymentOrderDone')->with($this->equalTo($this->paymentBridge), $this->equalTo($this->redsysApiMethod)); $this->paymentEventDispatcher->expects($this->any())->method('notifyPaymentOrderFail'); $this->paymentEventDispatcher->expects($this->once())->method('notifyPaymentOrderSuccess')->with($this->equalTo($this->paymentBridge), $this->equalTo($this->redsysApiMethod)); $this->redsysApiManager->processPayment($this->redsysApiMethod, self::CART_AMOUNT); }
public function testPaymentSuccess() { $dsResponse = 0; $dsAuthorisationCode = '222FFF'; $dsCardCountry = 'ESP'; $dsCardType = 'y'; $dsConsumerLanguage = 'y'; $dsDate = 'X'; $dsHour = 'X'; $dsSecurePayment = '1'; $parameters = array('Ds_Date' => $dsDate, 'Ds_Hour' => $dsHour, 'Ds_Terminal' => '1', 'Ds_SecurePayment' => $dsSecurePayment, 'Ds_Signature' => '9A163AA5034368367665866E62D603A5A92C5D35', 'Ds_Response' => $dsResponse, 'Ds_Amount' => '99', 'Ds_Order' => '0001', 'Ds_MerchantCode' => '999008881', 'Ds_Currency' => '978', 'Ds_TransactionType' => '2', 'Ds_MerchantData' => 'Mis datos', 'Ds_Card_Country' => $dsCardCountry, 'Ds_AuthorisationCode' => $dsAuthorisationCode, 'Ds_ConsumerLanguage' => $dsConsumerLanguage, 'Ds_Card_Type' => $dsCardType); $this->paymentEventDispatcher->expects($this->once())->method('notifyPaymentOrderDone')->with($this->equalTo($this->paymentBridge)); $this->redsysMethod->expects($this->any())->method('setDsResponse')->with($this->equalTo($dsResponse))->will($this->returnValue($this->redsysMethod)); $this->redsysMethod->expects($this->any())->method('setDsAuthorisationCode')->with($this->equalTo($dsAuthorisationCode))->will($this->returnValue($this->redsysMethod)); $this->redsysMethod->expects($this->any())->method('setDsCardCountry')->with($this->equalTo($dsCardCountry))->will($this->returnValue($this->redsysMethod)); $this->redsysMethod->expects($this->any())->method('setDsCardType')->with($this->equalTo($dsCardType))->will($this->returnValue($this->redsysMethod)); $this->redsysMethod->expects($this->any())->method('setDsConsumerLanguage')->with($this->equalTo($dsConsumerLanguage))->will($this->returnValue($this->redsysMethod)); $this->redsysMethod->expects($this->any())->method('setDsDate')->with($this->equalTo($dsDate))->will($this->returnValue($this->redsysMethod)); $this->redsysMethod->expects($this->any())->method('setDsHour')->with($this->equalTo($dsHour))->will($this->returnValue($this->redsysMethod)); $this->redsysMethod->expects($this->any())->method('setDsSecurePayment')->with($this->equalTo($dsSecurePayment))->will($this->returnValue($this->redsysMethod)); $this->paymentEventDispatcher->expects($this->once())->method('notifyPaymentOrderDone')->with($this->equalTo($this->paymentBridge)); $this->paymentEventDispatcher->expects($this->once())->method('notifyPaymentOrderSuccess')->with($this->equalTo($this->paymentBridge)); $this->redsysManager->processResult($parameters); }