/** * Create a new invoice for the given customer ID. * @param string $customerId * @param array $options * @return $this */ public function createForCustomer($customerId, $options = array()) { $request = new Request($this->client); $path = "/invoices"; $data = array("name" => $this->getName(), "amount" => $this->getAmount(), "currency" => $this->getCurrency(), "metadata" => $this->getMetadata(), "request_email" => $this->getRequestEmail(), "request_shipping" => $this->getRequestShipping(), "return_url" => $this->getReturnUrl(), "cancel_url" => $this->getCancelUrl(), "customer_id" => $customerId); $response = $request->post($path, $data, $options); $returnValues = array(); // Handling for field invoice $body = $response->getBody(); $body = $body['invoice']; $returnValues['createForCustomer'] = $this->fillWithData($body); return array_values($returnValues)[0]; }
/** * Create a new authorization request for the given customer ID. * @param string $customerId * @param array $options * @return $this */ public function create($customerId, $options = array()) { $request = new Request($this->client); $path = "/authorization-requests"; $data = array("name" => $this->getName(), "currency" => $this->getCurrency(), "return_url" => $this->getReturnUrl(), "cancel_url" => $this->getCancelUrl(), "customer_id" => $customerId); $response = $request->post($path, $data, $options); $returnValues = array(); // Handling for field authorization_request $body = $response->getBody(); $body = $body['authorization_request']; $returnValues['create'] = $this->fillWithData($body); return array_values($returnValues)[0]; }
/** * Create a new subscription for the customer from the given plan ID. * @param string $customerId * @param string $planId * @param array $options * @return $this */ public function createFromPlan($customerId, $planId, $options = array()) { $request = new Request($this->client); $path = "/subscriptions"; $data = array("cancel_at" => $this->getCancelAt(), "name" => $this->getName(), "amount" => $this->getAmount(), "currency" => $this->getCurrency(), "metadata" => $this->getMetadata(), "interval" => $this->getInterval(), "trial_end_at" => $this->getTrialEndAt(), "return_url" => $this->getReturnUrl(), "cancel_url" => $this->getCancelUrl(), "customer_id" => $customerId, "plan_id" => $planId); $response = $request->post($path, $data, $options); $returnValues = array(); // Handling for field subscription $body = $response->getBody(); $body = $body['subscription']; $returnValues['createFromPlan'] = $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]; }
/** * Create a new coupon. * @param array $options * @return $this */ public function create($options = array()) { $request = new Request($this->client); $path = "/coupons"; $data = array("id" => $this->getId(), "amount_off" => $this->getAmountOff(), "percent_off" => $this->getPercentOff(), "currency" => $this->getCurrency(), "iteration_count" => $this->getIterationCount(), "max_redemptions" => $this->getMaxRedemptions(), "expires_at" => $this->getExpiresAt(), "metadata" => $this->getMetadata()); $response = $request->post($path, $data, $options); $returnValues = array(); // Handling for field coupon $body = $response->getBody(); $body = $body['coupon']; $returnValues['create'] = $this->fillWithData($body); return array_values($returnValues)[0]; }
/** * Create a new customer. * @param array $options * @return $this */ public function create($options = array()) { $request = new Request($this->client); $path = "/customers"; $data = array("balance" => $this->getBalance(), "currency" => $this->getCurrency(), "email" => $this->getEmail(), "first_name" => $this->getFirstName(), "last_name" => $this->getLastName(), "address1" => $this->getAddress1(), "address2" => $this->getAddress2(), "city" => $this->getCity(), "state" => $this->getState(), "zip" => $this->getZip(), "country_code" => $this->getCountryCode(), "metadata" => $this->getMetadata()); $response = $request->post($path, $data, $options); $returnValues = array(); // Handling for field customer $body = $response->getBody(); $body = $body['customer']; $returnValues['create'] = $this->fillWithData($body); return array_values($returnValues)[0]; }
/** * Create a new token for the given customer ID from an authorization request * @param string $customerId * @param string $source * @param string $target * @param array $options * @return $this */ public function createFromRequest($customerId, $source, $target, $options = array()) { $request = new Request($this->client); $path = "/customers/" . urlencode($customerId) . "/tokens"; $data = array("metadata" => $this->getMetadata(), "source" => $source, "target" => $target); $response = $request->post($path, $data, $options); $returnValues = array(); // Handling for field token $body = $response->getBody(); $body = $body['token']; $returnValues['createFromRequest'] = $this->fillWithData($body); return array_values($returnValues)[0]; }
/** * Create a new plan. * @param array $options * @return $this */ public function create($options = array()) { $request = new Request($this->client); $path = "/plans"; $data = array("id" => $this->getId(), "name" => $this->getName(), "amount" => $this->getAmount(), "currency" => $this->getCurrency(), "interval" => $this->getInterval(), "trial_period" => $this->getTrialPeriod(), "metadata" => $this->getMetadata(), "return_url" => $this->getReturnUrl(), "cancel_url" => $this->getCancelUrl()); $response = $request->post($path, $data, $options); $returnValues = array(); // Handling for field plan $body = $response->getBody(); $body = $body['plan']; $returnValues['create'] = $this->fillWithData($body); return array_values($returnValues)[0]; }
/** * Apply a new discount on the subscription from a coupon ID. * @param string $subscriptionId * @param string $couponId * @param array $options * @return $this */ public function applyCoupon($subscriptionId, $couponId, $options = array()) { $request = new Request($this->client); $path = "/subscriptions/" . urlencode($subscriptionId) . "/discounts"; $data = array("coupon_id" => $couponId); $response = $request->post($path, $data, $options); $returnValues = array(); // Handling for field discount $body = $response->getBody(); $body = $body['discount']; $returnValues['applyCoupon'] = $this->fillWithData($body); return array_values($returnValues)[0]; }