/**
  * Tests the getters and setters of the model
  * @test
  */
 public function setGetTest()
 {
     $sample = array('client' => 'client_88a388d9dd48f86c3136', 'offer' => 'offer_40237e20a7d5a231d99b', 'payment' => 'pay_95ba26ba2c613ebb0ca8');
     $this->_subscription->setPayment($sample['payment'])->setOffer($sample['offer'])->setClient($sample['client']);
     $this->assertEquals($this->_subscription->getClient(), $sample['client']);
     $this->assertEquals($this->_subscription->getOffer(), $sample['offer']);
     $this->assertEquals($this->_subscription->getPayment(), $sample['payment']);
     return $this->_subscription;
 }
Esempio n. 2
0
 /**
  * @test
  * @depends createSubscriptionWithoutOffer
  */
 public function completelyDeleteSubscription($model)
 {
     $this->_model->setId($model->getId())->setRemove(true);
     $result = $this->_service->delete($this->_model);
     $this->assertTrue($result->getIsCanceled(), var_export($result, true));
     $this->assertTrue($result->getIsDeleted(), var_export($result, true));
 }
Esempio n. 3
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. 4
0
 /**
  * @test
  * @codeCoverageIgnore
  *
  *
  */
 public function deleteOfferWithoutSubscriptions()
 {
     $offer = $this->createOffer();
     $subscriptionResponse = $this->getRequestSubscription($offer);
     $subscriptionRequest = new Models\Request\Subscription();
     $subscriptionRequest->setId($subscriptionResponse->getId());
     $this->assertInstanceOf('Paymill\\Models\\Response\\Subscription', $subscriptionWithOffer = $this->_service->getOne($subscriptionRequest), var_export($subscriptionWithOffer, true));
     $this->_model->setRemoveWithSubscriptions(false)->setId($offer->getId());
     $result = $this->_service->delete($this->_model);
     $this->assertInternalType('array', $result, var_export($result, true));
     $subscriptionRequest->setId($subscriptionWithOffer->getId());
     $subscriptionResponse = $this->_service->getOne($subscriptionRequest);
     $this->assertFalse($subscriptionResponse->getIsCanceled());
     $this->assertFalse($subscriptionResponse->getIsDeleted());
 }