示例#1
0
 /**
  * @test
  * @codeCoverageIgnore
  */
 public function createTransactionWithToken()
 {
     $this->_model->setAmount(100)->setCurrency('EUR')->setToken('098f6bcd4621d373cade4e832627b4f6');
     $result = $this->_service->create($this->_model);
     $this->assertInstanceOf('Paymill\\Models\\Response\\Transaction', $result);
     return $result;
 }
 /**
  * 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
  */
 public function createTransactionWithToken()
 {
     $this->_model->setAmount(100)->setCurrency('EUR')->setToken($this->createToken())->setShippingAddress($this->_shippingAddress)->setBillingAddress($this->_billingAddress)->setItems($this->_items);
     /** @var Models\Response\Transaction $result */
     $result = $this->_service->create($this->_model);
     $this->assertInstanceOf('Paymill\\Models\\Response\\Transaction', $result);
     $this->assertInstanceOf('Paymill\\Models\\Internal\\ShippingAddress', $result->getShippingAddress());
     $this->assertInstanceOf('Paymill\\Models\\Internal\\BillingAddress', $result->getBillingAddress());
     $this->assertInternalType('array', $result->getItems());
     $items = $result->getItems();
     foreach ($items as $item) {
         $this->assertInstanceOf('Paymill\\Models\\Internal\\Item', $item);
     }
     $this->assertEquals($this->_items[0], $items[0]->toArray());
     $this->assertEquals($this->_items[1], $items[1]->toArray());
     $this->assertEquals($this->_shippingAddress, $result->getShippingAddress()->toArray());
     $this->assertEquals($this->_billingAddress, $result->getBillingAddress()->toArray());
     return $result;
 }
示例#4
0
 /**
  * Tests the getters and setters of the model
  * @test
  */
 public function setGetTest()
 {
     $sample = $this->getSampleData();
     $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'])->setShippingAddress($sample['shipping_address'])->setBillingAddress($sample['billing_address'])->setMandateReference($sample['mandate_reference']);
     $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']);
     $this->assertEquals($this->_transaction->getShippingAddress(), $sample['shipping_address']);
     $this->assertEquals($this->_transaction->getBillingAddress(), $sample['billing_address']);
     $this->assertEquals($this->_transaction->getMandateReference(), $sample['mandate_reference']);
     return $this->_transaction;
 }
示例#5
0
 /**
  * @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;
 }
示例#7
0
 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;
         }
     }
 }