Esempio n. 1
0
 /**
  * Tests the getters and setters of the model
  * @test
  */
 public function setGetTest()
 {
     $sample = array('client' => 'client_88a388d9dd48f86c3136', 'token' => '098f6bcd4621d373cade4e832627b4f6');
     $this->_payment->setClient($sample['client'])->setToken($sample['token']);
     $this->assertEquals($this->_payment->getClient(), $sample['client']);
     $this->assertEquals($this->_payment->getToken(), $sample['token']);
     return $this->_payment;
 }
Esempio n. 2
0
 /**
  * @test
  * @codeCoverageIgnore
  */
 public function createSubscriptionWithoutOffer()
 {
     $this->_model->setAmount(2000)->setCurrency('EUR')->setInterval('2 WeEK, tUEsDAY');
     $PaymentModel = new Models\Request\Payment();
     $PaymentModel->setToken("098f6bcd4621d373cade4e832627b4f6");
     $PaymentModelResponse = $this->_service->create($PaymentModel);
     $this->assertInstanceOf('Paymill\\Models\\Response\\Payment', $PaymentModelResponse, var_export($PaymentModelResponse, true));
     $this->_model->setClient($PaymentModelResponse->getClient())->setPayment($PaymentModelResponse->getId());
     $result = $this->_service->create($this->_model);
     $this->assertInstanceOf('Paymill\\Models\\Response\\Subscription', $result, var_export($result, true));
     return $result;
 }
Esempio n. 3
0
 public function start()
 {
     $payment = new Payment();
     $payment->setToken($this->environment->request('token'));
     $payment->setClient($this->order->getCustomer());
     $response = null;
     try {
         $this->log($payment);
         $response = $this->paymill->create($payment);
         $this->log($response);
     } catch (Exception $e) {
         $this->log($e);
         throw $e;
     } finally {
         if ($paymentId = $response->getId()) {
             return $this->makeTransaction($paymentId);
         }
     }
 }
Esempio n. 4
0
 public function process(ProcessRequest $request)
 {
     // Initialize paymill request
     // Create credit card payment
     $payment = new Payment();
     $payment->setToken($request->get('token'));
     $paymentResponse = $paymillRequest->create($payment);
     // Create subscription
     $subscription = new Subscription();
     $subscription->setAmount(30)->setPayment($paymentResponse->getId())->setCurrency('EUR')->setInterval('1 week,monday')->setName('Nova sub')->setPeriodOfValidity('2 YEAR')->setStartAt(time());
     $subscriptionResponse = $paymillRequest->create($subscription);
     // Save in database
     $paymentModel = new PaymentModel();
     $paymentModel->user_id = Auth::user()->id;
     $paymentModel->paymill_payment_id = $paymentResponse->getId();
     $paymentModel->save();
     // Save subscription
     $subscriptionModel = new SubscriptionModel();
     $subscriptionModel->user_id = Auth::user()->id;
     $subscriptionModel->paymill_subscription_id = $subscriptionResponse->getId();
     $subscriptionModel->save();
 }
Esempio n. 5
0
 /**
  * @test
  * @depends createOffer
  */
 public function getRequestSubscription($offer)
 {
     $subscriptionModel = new Models\Request\Subscription();
     $subscriptionModel->setOffer($offer->getId());
     $PaymentModel = new Models\Request\Payment();
     $PaymentModel->setToken("098f6bcd4621d373cade4e832627b4f6");
     $PaymentModelResponse = $this->_service->create($PaymentModel);
     $this->assertInstanceOf('Paymill\\Models\\Response\\Payment', $PaymentModelResponse, var_export($PaymentModelResponse, true));
     $subscriptionModel->setClient($PaymentModelResponse->getClient())->setPayment($PaymentModelResponse->getId());
     $subscription = $this->_service->create($subscriptionModel);
     $this->assertEquals($offer->getId(), $subscription->getOffer()->getId());
     return $subscription;
 }
Esempio n. 6
0
 /**
  * @test
  * @codeCoverageIgnore
  * @depends createPayment
  * @depends getOnePayment
  * @depends updatePayment
  */
 public function deletePayment($model)
 {
     $this->_model->setId($model->getId());
     $result = $this->_service->delete($this->_model);
     $this->assertEquals(null, $result, var_export($result, true));
 }