$this->amount, "times" => $this->times, "startDate" => $this->startDate, "webhookUrl" => $this->webhookUrl, "description" => $this->description, "mandateId" => $this->mandateId, "metadata" => $this->metadata, "interval" => $this->interval]; $result = $this->client->subscriptions->update($this->customerId, $this->id, $body); return \Mollie\Api\Resources\ResourceFactory::createFromApiResult($result, new \Mollie\Api\Resources\Subscription($this->client)); } /** * Returns whether the Subscription is active or not. * * @return bool */ public function isActive() { return $this->status === \Mollie\Api\Types\SubscriptionStatus::STATUS_ACTIVE; } /** * Returns whether the Subscription is pending or not. * * @return bool */ public function isPending() { return $this->status === \Mollie\Api\Types\SubscriptionStatus::STATUS_PENDING; } /** * Returns whether the Subscription is canceled or not. * * @return bool */ public function isCanceled() { return $this->status === \Mollie\Api\Types\SubscriptionStatus::STATUS_CANCELED; } /** * Returns whether the Subscription is suspended or not. * * @return bool */ public function isSuspended() { return $this->status === \Mollie\Api\Types\SubscriptionStatus::STATUS_SUSPENDED; } /** * Returns whether the Subscription is completed or not. * * @return bool */ public function isCompleted() { return $this->status === \Mollie\Api\Types\SubscriptionStatus::STATUS_COMPLETED; } /** * Cancels this subscription * * @return Subscription * @throws \Mollie\Api\Exceptions\ApiException */ public function cancel() { if (!isset($this->_links->self->href)) { return $this; } $body = null; if ($this->client->usesOAuth()) { $body = \json_encode(["testmode" => $this->mode === "test" ? \true : \false]); } $result = $this->client->performHttpCallToFullUrl(\Mollie\Api\MollieApiClient::HTTP_DELETE, $this->_links->self->href, $body); return \Mollie\Api\Resources\ResourceFactory::createFromApiResult($result, new \Mollie\Api\Resources\Subscription($this->client)); } /** * Get subscription payments * * @return \Mollie\Api\Resources\PaymentCollection * @throws \Mollie\Api\Exceptions\ApiException */ public function payments() { if (!isset($this->_links->payments->href)) { return new \Mollie\Api\Resources\PaymentCollection($this->client, 0, null); } $result = $this->client->performHttpCallToFullUrl(\Mollie\Api\MollieApiClient::HTTP_GET, $this->_links->payments->href); return \Mollie\Api\Resources\ResourceFactory::createCursorResourceCollection($this->client, $result->_embedded->payments, \Mollie\Api\Resources\Payment::class, $result->_links); } }