/** * Find an event by its ID. * @param string $eventId * @param array $options * @return $this */ public function find($eventId, $options = array()) { $request = new Request($this->client); $path = "/events/" . urlencode($eventId) . ""; $data = array(); $response = $request->get($path, $data, $options); $returnValues = array(); // Handling for field event $body = $response->getBody(); $body = $body['event']; $returnValues['find'] = $this->fillWithData($body); return array_values($returnValues)[0]; }
/** * Apply a refund to a transaction. * @param string $transactionId * @param array $options * @return bool */ public function apply($transactionId, $options = array()) { $request = new Request($this->client); $path = "/transactions/" . urlencode($transactionId) . "/refunds"; $data = array("amount" => $this->getAmount(), "metadata" => $this->getMetadata(), "reason" => $this->getReason(), "information" => $this->getInformation()); $response = $request->post($path, $data, $options); $returnValues = array(); $returnValues['success'] = $response->isSuccess(); return array_values($returnValues)[0]; }
/** * Schedule the cancellation of the subscription. The reason may be provided as well. * @param string $cancelAt * @param string $cancellationReason * @param array $options * @return $this */ public function cancelAtDate($cancelAt, $cancellationReason, $options = array()) { $request = new Request($this->client); $path = "/subscriptions/" . urlencode($this->getId()) . ""; $data = array("cancel_at" => $cancelAt, "cancellation_reason" => $cancellationReason); $response = $request->delete($path, $data, $options); $returnValues = array(); // Handling for field subscription $body = $response->getBody(); $body = $body['subscription']; $returnValues['cancelAtDate'] = $this->fillWithData($body); return array_values($returnValues)[0]; }
/** * Get all the gateway configurations of the project * @param array $options * @return array */ public function fetchGatewayConfigurations($options = array()) { $request = new Request($this->client); $path = "/projects/" . urlencode($this->getId()) . "/gateway-configurations"; $data = array(); $response = $request->get($path, $data, $options); $returnValues = array(); // Handling for field gateway_configurations $a = array(); $body = $response->getBody(); foreach ($body['gateway_configurations'] as $v) { $tmp = new GatewayConfiguration($this->client); $tmp->fillWithData($v); $a[] = $tmp; } $returnValues['GatewayConfigurations'] = $a; return array_values($returnValues)[0]; }
/** * Delete the coupon. * @param array $options * @return bool */ public function delete($options = array()) { $request = new Request($this->client); $path = "/coupons/" . urlencode($this->getId()) . ""; $data = array(); $response = $request->delete($path, $data, $options); $returnValues = array(); $returnValues['success'] = $response->isSuccess(); return array_values($returnValues)[0]; }