public function success() { $transaction = new Transaction(); $transaction->setId($this->environment->request('paymill_trx_id')); $response = $this->paymill->getOne($transaction); if ($response->getStatus() == 'closed') { $this->order->setPaid(); } }
/** * @test * @codeCoverageIgnore */ public function createRefund() { $transactionModel = new Models\Request\Transaction(); $transactionModel->setAmount(200)->setCurrency('EUR')->setToken("098f6bcd4621d373cade4e832627b4f6"); $transactionModelResponse = $this->_service->create($transactionModel); $this->assertInstanceOf('Paymill\\Models\\Response\\Transaction', $transactionModelResponse, var_export($transactionModelResponse, true)); $this->_model->setAmount(100)->setDescription('EUR')->setId($transactionModelResponse->getId()); $result = $this->_service->create($this->_model); $this->assertInstanceOf('Paymill\\Models\\Response\\Refund', $result, var_export($result, true)); return $result; }
/** * Create new Transaction with a set of params * * @param string $amount amount as int (ex: 4200 for 42.00) * @param string $currency currency code (EUR, USD...) * @param string $token transaction token * @param string $description transaction description (optional, default "") * * @return \Paymill\Models\Response\Base * * @throws PaymillException if transaction creation fails */ public function create($amount, $currency, $token, $description = "") { $service = new Request($this->apiKey); $transaction = new RequestTransaction(); $transaction->setAmount($amount)->setCurrency($currency)->setToken($token)->setDescription($description); /** * @var \Paymill\Models\Response\Base $response */ $response = $service->create($transaction); return $response; }
/** * Test the Parameterize function of the model * * @param Transaction $transaction * * @test * @depends setGetTest */ public function parameterizeTest(Transaction $transaction) { $sample = $this->getSampleData(); $testId = "transaction_88a388d9dd48f86c3136"; $transaction->setId($testId); $creationArray = $transaction->parameterize("create"); $updateArray = $transaction->parameterize("update"); $getOneArray = $transaction->parameterize("getOne"); $this->assertEquals(array('amount' => $sample['amount'], 'currency' => $sample['currency'], 'client' => $sample['client'], 'preauthorization' => $sample['preauthorization'], 'fee_amount' => $sample['fee_amount'], 'fee_payment' => $sample['fee_payment'], 'fee_currency' => $sample['fee_currency'], 'description' => $sample['description'], 'source' => $sample['source'], 'mandate_reference' => $sample['mandate_reference'], 'shipping_address' => $sample['shipping_address'], 'billing_address' => $sample['billing_address'], 'items' => $sample['items']), $creationArray); $this->assertEquals(array('description' => 'Test Transaction'), $updateArray); $this->assertEquals(array('count' => 1, 'offset' => 0), $getOneArray); }
protected function makeTransaction($paymentId) { $transaction = new Transaction(); $transaction->setAmount($this->getTotalToPay())->setCurrency($this->order->getCurrency())->setPayment($paymentId)->setDescription($this->order->getDescription()); $response = null; try { $this->log($transaction); $response = $this->paymill->create($transaction); $this->log($response); } catch (Exception $e) { $this->log($e); throw $e; } finally { if ($response->getStatus() == 'closed') { $this->order->setPaid(); return true; } } }
/** * Tests the getters and setters of the model * @test */ public function setGetTest() { $sample = array('amount' => '4200', 'currency' => 'EUR', 'payment' => 'pay_2f82a672574647cd911d', 'token' => '098f6bcd4621d373cade4e832627b4f6', 'client' => 'client_c781b1d2f7f0f664b4d9', 'preauthorization' => 'preauth_ec54f67e52e92051bd65', 'fee_amount' => '420', 'fee_payment' => 'pay_098f6bcd4621d373cade4e832627b4f6', 'fee_currency' => 'EUR', 'description' => 'Test Transaction', 'source' => 'merchantcenter'); $this->_transaction->setAmount($sample['amount'])->setCurrency($sample['currency'])->setPayment($sample['payment'])->setToken($sample['token'])->setClient($sample['client'])->setPreauthorization($sample['preauthorization'])->setFeeAmount($sample['fee_amount'])->setFeePayment($sample['fee_payment'])->setFeeCurrency($sample['fee_currency'])->setDescription($sample['description'])->setSource($sample['source']); $this->assertEquals($this->_transaction->getAmount(), $sample['amount']); $this->assertEquals($this->_transaction->getCurrency(), $sample['currency']); $this->assertEquals($this->_transaction->getPayment(), $sample['payment']); $this->assertEquals($this->_transaction->getToken(), $sample['token']); $this->assertEquals($this->_transaction->getClient(), $sample['client']); $this->assertEquals($this->_transaction->getPreauthorization(), $sample['preauthorization']); $this->assertEquals($this->_transaction->getFeeAmount(), $sample['fee_amount']); $this->assertEquals($this->_transaction->getFeePayment(), $sample['fee_payment']); $this->assertEquals($this->_transaction->getFeeCurrency(), $sample['fee_currency']); $this->assertEquals($this->_transaction->getDescription(), $sample['description']); $this->assertEquals($this->_transaction->getSource(), $sample['source']); return $this->_transaction; }
/** * @test * @codeCoverageIgnore * @depends createTransactionWithToken * @depends getOneTransaction * @depends updateTransaction * @expectedException \Paymill\Services\PaymillException * @expectedExceptionMessage Method not Found */ public function deleteTransaction($model) { $this->_model->setId($model->getId()); $this->_service->delete($this->_model); }