/** * @test * @codeCoverageIgnore * @depends createTransactionWithToken * @param TransactionResponse $model */ public function updateTransaction(TransactionResponse $model) { $this->_model->setId($model->getId())->setDescription('TEST'); $result = $this->_service->update($this->_model); $this->assertInstanceOf('Paymill\\Models\\Response\\Transaction', $result, var_export($result, true)); $this->assertEquals('TEST', $result->getDescription()); }
/** * Tests the getters and setters of the model * @test */ public function setGetTest() { $amount = "4200"; $originAmount = 4200; $status = "closed"; $description = "Test Desc"; $livemode = false; $refunds = null; $currency = "EUR"; $responseCode = 200000; $shortId = "This is a short string?!"; $invoices = array(); $payment = new Response\Payment(); $client = new Response\Client(); $preAuth = new Response\Preauthorization(); $fees = array(); $this->_transaction->setAmount($amount)->setOriginAmount($originAmount)->setStatus($status)->setDescription($description)->setLivemode($livemode)->setRefunds($refunds)->setCurrency($currency)->setResponseCode($responseCode)->setShortId($shortId)->setInvoices($invoices)->setPayment($payment)->setClient($client)->setPreauthorization($preAuth)->setFees($fees); $this->assertEquals($this->_transaction->getAmount(), $amount); $this->assertEquals($this->_transaction->getOriginAmount(), $originAmount); $this->assertEquals($this->_transaction->getStatus(), $status); $this->assertEquals($this->_transaction->getDescription(), $description); $this->assertEquals($this->_transaction->getLivemode(), $livemode); $this->assertEquals($this->_transaction->getRefunds(), $refunds); $this->assertEquals($this->_transaction->getCurrency(), $currency); $this->assertEquals($this->_transaction->getResponseCode(), $responseCode); $this->assertEquals($this->_transaction->getShortId(), $shortId); $this->assertEquals($this->_transaction->getInvoices(), $invoices); $this->assertEquals($this->_transaction->getPayment(), $payment); $this->assertEquals($this->_transaction->getClient(), $client); $this->assertEquals($this->_transaction->getPreauthorization(), $preAuth); $this->assertEquals($this->_transaction->getFees(), $fees); }
/** * Given a paymillTransaction response, as an array, prform desired operations * * @param Transaction $transaction Transaction * @param PaymillMethod $paymentMethod Payment method * * @return PaymillManager Self object * * @throws PaymentException */ private function processTransaction(Transaction $transaction, PaymillMethod $paymentMethod) { /** * Payment paid done * * Paid process has ended ( No matters result ) */ $this->paymentEventDispatcher->notifyPaymentOrderDone($this->paymentBridge, $paymentMethod); /** * when a transaction is successful, it is marked as 'closed' */ $transactionStatus = $transaction->getStatus(); if (empty($transactionStatus) || $transactionStatus != 'closed') { /** * Payment paid failed * * Paid process has ended failed */ $paymentMethod->setTransaction($transaction); $this->paymentEventDispatcher->notifyPaymentOrderFail($this->paymentBridge, $paymentMethod); throw new PaymentException(); } /** * Adding to PaymentMethod transaction information * * This information is only available in PaymentOrderSuccess event */ $paymentMethod->setTransactionId($transaction->getId())->setTransactionStatus($transactionStatus)->setTransaction($transaction); /** * Payment paid successfully * * Paid process has ended successfully */ $this->paymentEventDispatcher->notifyPaymentOrderSuccess($this->paymentBridge, $paymentMethod); return $this; }
/** * Creates and fills a transactionmodel * * @param array $response * @return \Paymill\Models\Response\Transaction */ private function _createTransaction($response) { $model = new Models\Transaction(); $model->setId($response['id']); $model->setAmount($response['amount']); $model->setOriginAmount($response['origin_amount']); $model->setStatus($response['status']); $model->setDescription($response['description']); $model->setLivemode($response['livemode']); $model->setRefunds($this->_handleRecursive($response['refunds'], 'refund')); $model->setCurrency($response['currency']); $model->setCreatedAt($response['created_at']); $model->setUpdatedAt($response['updated_at']); $model->setResponseCode($response['response_code']); $model->setShortId($response['short_id']); $model->setInvoices($response['invoices']); $model->setPayment($this->_convertResponseToModel($response['payment'], "payment")); $model->setClient($this->_convertResponseToModel($response['client'], "client")); $model->setPreauthorization($this->_convertResponseToModel($response['preauthorization'], "preauthorization")); $model->setFees($response['fees']); $model->setAppId($response['app_id']); return $model; }
/** * Creates and fills a transaction model * * @param array $response * @return Transaction */ private function _createTransaction(array $response) { $model = new Transaction(); $model->setId($response['id']); $model->setAmount($response['amount']); $model->setOriginAmount($response['origin_amount']); $model->setStatus($response['status']); $model->setDescription($response['description']); $model->setLivemode($response['livemode']); $model->setRefunds($this->_handleRecursive($response['refunds'], 'refund')); $model->setCurrency($response['currency']); $model->setCreatedAt($response['created_at']); $model->setUpdatedAt($response['updated_at']); $model->setResponseCode($response['response_code']); $model->setShortId($response['short_id']); $model->setInvoices($response['invoices']); $model->setPayment($this->_convertResponseToModel($response['payment'], "payment")); $model->setClient($this->_convertResponseToModel($response['client'], "client")); $model->setPreauthorization($this->_convertResponseToModel($response['preauthorization'], "preauthorization")); $model->setFees($response['fees']); $model->setAppId($response['app_id']); if (isset($response[Transaction::RESPONSE_FIELD_SHIPPING_ADDRESS])) { $model->setShippingAddress($this->_convertResponseToModel($response[Transaction::RESPONSE_FIELD_SHIPPING_ADDRESS], AbstractAddress::TYPE_SHIPPING)); } if (isset($response[Transaction::RESPONSE_FIELD_BILLING_ADDRESS])) { $model->setBillingAddress($this->_convertResponseToModel($response[Transaction::RESPONSE_FIELD_BILLING_ADDRESS], AbstractAddress::TYPE_BILLING)); } if (isset($response[Transaction::RESPONSE_FIELD_ITEMS])) { $model->setItems($this->_handleRecursive($response[Transaction::RESPONSE_FIELD_ITEMS], 'item')); } return $model; }