def create(self, gateway_name, options = {}): """Create a new gateway configuration. Keyword argument: gateway_name -- Name of the gateway options -- Options for the request""" self.fill_with_data(options) request = Request(self._client) path = "/gateways/" + quote_plus(gateway_name) + "/gateway-configurations" data = { 'id': self.id, 'name': self.name, 'enabled': self.enabled, 'fee_fixed': self.fee_fixed, 'fee_percentage': self.fee_percentage, 'default_currency': self.default_currency, 'settings': options.get("settings") } response = Response(request.post(path, data, options)) return_values = [] body = response.body body = body["gateway_configuration"] return_values.append(self.fill_with_data(body)) return return_values[0]
def find(self, event_id, options = {}): """Find an event by its ID. Keyword argument: event_id -- ID of the event options -- Options for the request""" self.fill_with_data(options) request = Request(self._client) path = "/events/" + quote_plus(event_id) + "" data = { } response = Response(request.get(path, data, options)) return_values = [] body = response.body body = body["event"] obj = processout.Event(self._client) return_values.append(obj.fill_with_data(body)) return return_values[0]
def save(self, options={}): """Save the updated plan attributes. This action won't affect subscriptions already linked to this plan. Keyword argument: options -- Options for the request""" self.fill_with_data(options) request = Request(self._client) path = "/plans/" + quote_plus(self.id) + "" data = { 'name': self.name, 'trial_period': self.trial_period, 'metadata': self.metadata, 'return_url': self.return_url, 'cancel_url': self.cancel_url } response = Response(request.put(path, data, options)) return_values = [] body = response.body body = body["plan"] return_values.append(self.fill_with_data(body)) return return_values[0]
def create(self, options={}): """Create a new product. Keyword argument: options -- Options for the request""" self.fill_with_data(options) request = Request(self._client) path = "/products" data = { 'name': self.name, 'amount': self.amount, 'currency': self.currency, 'metadata': self.metadata, 'return_url': self.return_url, 'cancel_url': self.cancel_url } response = Response(request.post(path, data, options)) return_values = [] body = response.body body = body["product"] return_values.append(self.fill_with_data(body)) return return_values[0]
def fetch_webhooks(self, options = {}): """Get all the webhooks of the event. Keyword argument: options -- Options for the request""" self.fill_with_data(options) request = Request(self._client) path = "/events/" + quote_plus(self.id) + "/webhooks" data = { } response = Response(request.get(path, data, options)) return_values = [] a = [] body = response.body for v in body['webhooks']: tmp = processout.Webhook(self._client) tmp.fill_with_data(v) a.append(tmp) return_values.append(a) return return_values[0]
def save(self, options={}): """Save the updated subscription attributes. Keyword argument: options -- Options for the request""" self.fill_with_data(options) request = Request(self._client) path = "/subscriptions/" + quote_plus(self.id) + "" data = { 'plan_id': self.plan_id, 'name': self.name, 'amount': self.amount, 'interval': self.interval, 'trial_end_at': self.trial_end_at, 'metadata': self.metadata, 'coupon_id': options.get("coupon_id"), 'source': options.get("source"), 'prorate': options.get("prorate"), 'proration_date': options.get("proration_date"), 'preview': options.get("preview") } response = Response(request.put(path, data, options)) return_values = [] body = response.body body = body["subscription"] return_values.append(self.fill_with_data(body)) return return_values[0]
def save(self, options={}): """Save the updated product attributes. Keyword argument: options -- Options for the request""" self.fill_with_data(options) request = Request(self._client) path = "/products/" + quote_plus(self.id) + "" data = { 'name': self.name, 'amount': self.amount, 'currency': self.currency, 'metadata': self.metadata, 'return_url': self.return_url, 'cancel_url': self.cancel_url } response = Response(request.put(path, data, options)) return_values = [] body = response.body body = body["product"] return_values.append(self.fill_with_data(body)) return return_values[0]
def all(self, options = {}): """Get all the coupons. Keyword argument: options -- Options for the request""" self.fill_with_data(options) request = Request(self._client) path = "/coupons" data = { } response = Response(request.get(path, data, options)) return_values = [] a = [] body = response.body for v in body['coupons']: tmp = processout.Coupon(self._client) tmp.fill_with_data(v) a.append(tmp) return_values.append(a) return return_values[0]
def create(self, options={}): """Create a new subscription for the given customer. Keyword argument: options -- Options for the request""" self.fill_with_data(options) request = Request(self._client) path = "/subscriptions" data = { 'plan_id': self.plan_id, 'cancel_at': self.cancel_at, 'name': self.name, 'amount': self.amount, 'currency': self.currency, 'metadata': self.metadata, 'interval': self.interval, 'trial_end_at': self.trial_end_at, 'customer_id': self.customer_id, 'return_url': self.return_url, 'cancel_url': self.cancel_url, 'source': options.get("source"), 'coupon_id': options.get("coupon_id") } response = Response(request.post(path, data, options)) return_values = [] body = response.body body = body["subscription"] return_values.append(self.fill_with_data(body)) return return_values[0]
def find(self, coupon_id, options = {}): """Find a coupon by its ID. Keyword argument: coupon_id -- ID of the coupon options -- Options for the request""" self.fill_with_data(options) request = Request(self._client) path = "/coupons/" + quote_plus(coupon_id) + "" data = { } response = Response(request.get(path, data, options)) return_values = [] body = response.body body = body["coupon"] obj = processout.Coupon(self._client) return_values.append(obj.fill_with_data(body)) return return_values[0]
def create(self, options = {}): """Create a new coupon. Keyword argument: options -- Options for the request""" self.fill_with_data(options) request = Request(self._client) path = "/coupons" data = { 'id': self.id, 'amount_off': self.amount_off, 'percent_off': self.percent_off, 'currency': self.currency, 'iteration_count': self.iteration_count, 'max_redemptions': self.max_redemptions, 'expires_at': self.expires_at, 'metadata': self.metadata } response = Response(request.post(path, data, options)) return_values = [] body = response.body body = body["coupon"] return_values.append(self.fill_with_data(body)) return return_values[0]
def fetch_items(self, options = {}): """Get all the items linked to the payout. Keyword argument: options -- Options for the request""" self.fill_with_data(options) request = Request(self._client) path = "/payouts/" + quote_plus(self.id) + "/items" data = { } response = Response(request.get(path, data, options)) return_values = [] a = [] body = response.body for v in body['items']: tmp = processout.PayoutItem(self._client) tmp.fill_with_data(v) a.append(tmp) return_values.append(a) return return_values[0]
def save(self, options={}): """Save the updated addon attributes. Keyword argument: options -- Options for the request""" self.fill_with_data(options) request = Request(self._client) path = "/subscriptions/" + quote_plus( self.subscription_id) + "/addons/" + quote_plus(self.id) + "" data = { 'plan_id': self.plan_id, 'type': self.type, 'name': self.name, 'amount': self.amount, 'quantity': self.quantity, 'metadata': self.metadata, 'prorate': options.get("prorate"), 'proration_date': options.get("proration_date"), 'preview': options.get("preview"), 'increment_quantity_by': options.get("increment_quantity_by") } response = Response(request.put(path, data, options)) return_values = [] body = response.body body = body["addon"] return_values.append(self.fill_with_data(body)) return return_values[0]
def create(self, options={}): """Create a new addon to the given subscription ID. Keyword argument: options -- Options for the request""" self.fill_with_data(options) request = Request(self._client) path = "/subscriptions/" + quote_plus(self.subscription_id) + "/addons" data = { 'plan_id': self.plan_id, 'type': self.type, 'name': self.name, 'amount': self.amount, 'quantity': self.quantity, 'metadata': self.metadata, 'prorate': options.get("prorate"), 'proration_date': options.get("proration_date"), 'preview': options.get("preview") } response = Response(request.post(path, data, options)) return_values = [] body = response.body body = body["addon"] return_values.append(self.fill_with_data(body)) return return_values[0]
def fetch(self, iin, options = {}): """Fetch card information from the IIN. Keyword argument: iin -- IIN of the card (first 6 digits) options -- Options for the request""" self.fill_with_data(options) request = Request(self._client) path = "/iins/" + quote_plus(iin) + "" data = { } response = Response(request.get(path, data, options)) return_values = [] body = response.body body = body["card_information"] obj = processout.CardInformation(self._client) return_values.append(obj.fill_with_data(body)) return return_values[0]
def save(self, options = {}): """Save the updated gateway configuration attributes and settings. Keyword argument: options -- Options for the request""" self.fill_with_data(options) request = Request(self._client) path = "/gateway-configurations/" + quote_plus(self.id) + "" data = { 'id': self.id, 'name': self.name, 'enabled': self.enabled, 'fee_fixed': self.fee_fixed, 'fee_percentage': self.fee_percentage, 'default_currency': self.default_currency, 'settings': options.get("settings") } response = Response(request.put(path, data, options)) return_values = [] body = response.body body = body["gateway_configuration"] return_values.append(self.fill_with_data(body)) return return_values[0]
def delete(self, options={}): """Delete the project. Be careful! Executing this request will prevent any further interaction with the API that uses this project. Keyword argument: options -- Options for the request""" self.fill_with_data(options) request = Request(self._client) path = "/projects/{project_id}" data = {} response = Response(request.delete(path, data, options)) return_values = [] return_values.append(response.success) return return_values[0]
def delete(self, options={}): """Delete the product. Keyword argument: options -- Options for the request""" self.fill_with_data(options) request = Request(self._client) path = "/products/" + quote_plus(self.id) + "" data = {} response = Response(request.delete(path, data, options)) return_values = [] return_values.append(response.success) return return_values[0]
def end(self, options={}): """Delete a plan. Subscriptions linked to this plan won't be affected. Keyword argument: options -- Options for the request""" self.fill_with_data(options) request = Request(self._client) path = "/plans/" + quote_plus(self.id) + "" data = {} response = Response(request.delete(path, data, options)) return_values = [] return_values.append(response.success) return return_values[0]
def delete_discount(self, discount_id, options={}): """Delete a discount applied to a subscription. Keyword argument: discount_id -- ID of the discount or coupon to be removed from the subscription options -- Options for the request""" self.fill_with_data(options) request = Request(self._client) path = "/subscriptions/" + quote_plus( self.id) + "/discounts/" + quote_plus(discount_id) + "" data = {} response = Response(request.delete(path, data, options)) return_values = [] return_values.append(response.success) return return_values[0]
def delete_token(self, token_id, options={}): """Delete a customer's token by its ID. Keyword argument: token_id -- ID of the token options -- Options for the request""" self.fill_with_data(options) request = Request(self._client) path = "/customers/" + quote_plus( self.id) + "/tokens/" + quote_plus(token_id) + "" data = {} response = Response(request.delete(path, data, options)) return_values = [] return_values.append(response.success) return return_values[0]
def save(self, options={}): """Save the updated project's attributes. Keyword argument: options -- Options for the request""" self.fill_with_data(options) request = Request(self._client) path = "/projects/" + quote_plus(self.id) + "" data = {} response = Response(request.put(path, data, options)) return_values = [] body = response.body body = body["project"] return_values.append(self.fill_with_data(body)) return return_values[0]
def fetch(self, options={}): """Fetch the current project information. Keyword argument: options -- Options for the request""" self.fill_with_data(options) request = Request(self._client) path = "/projects/" + quote_plus(self.id) + "" data = {} response = Response(request.get(path, data, options)) return_values = [] body = response.body body = body["project"] return_values.append(self.fill_with_data(body)) return return_values[0]
def fetch_customer(self, options={}): """Get the customer owning the subscription. Keyword argument: options -- Options for the request""" self.fill_with_data(options) request = Request(self._client) path = "/subscriptions/" + quote_plus(self.id) + "/customers" data = {} response = Response(request.get(path, data, options)) return_values = [] body = response.body body = body["customer"] customer = processout.Customer(self._client) return_values.append(customer.fill_with_data(body)) return return_values[0]
def create_invoice(self, options={}): """Create a new invoice from the product. Keyword argument: options -- Options for the request""" self.fill_with_data(options) request = Request(self._client) path = "/products/" + quote_plus(self.id) + "/invoices" data = {} response = Response(request.post(path, data, options)) return_values = [] body = response.body body = body["invoice"] invoice = processout.Invoice(self._client) return_values.append(invoice.fill_with_data(body)) return return_values[0]
def regenerate_private_key(self, options={}): """Regenerate the project private key. Make sure to store the new private key and use it in any future request. Keyword argument: options -- Options for the request""" self.fill_with_data(options) request = Request(self._client) path = "/private-keys" data = {} response = Response(request.post(path, data, options)) return_values = [] body = response.body body = body["project"] obj = processout.Project(self._client) return_values.append(obj.fill_with_data(body)) return return_values[0]
def find(self, api_request_id, options={}): """Find an API request by its ID. Keyword argument: api_request_id -- ID of the API request options -- Options for the request""" self.fill_with_data(options) request = Request(self._client) path = "/api-requests/{request_id}" data = {} response = Response(request.get(path, data, options)) return_values = [] body = response.body body = body["api_request"] obj = processout.APIRequest(self._client) return_values.append(obj.fill_with_data(body)) return return_values[0]
def find_discount(self, discount_id, options={}): """Find a subscription's discount by its ID. Keyword argument: discount_id -- ID of the discount options -- Options for the request""" self.fill_with_data(options) request = Request(self._client) path = "/subscriptions/" + quote_plus( self.id) + "/discounts/" + quote_plus(discount_id) + "" data = {} response = Response(request.get(path, data, options)) return_values = [] body = response.body body = body["discount"] discount = processout.Discount(self._client) return_values.append(discount.fill_with_data(body)) return return_values[0]
def find_refund(self, refund_id, options={}): """Find a transaction's refund by its ID. Keyword argument: refund_id -- ID of the refund options -- Options for the request""" self.fill_with_data(options) request = Request(self._client) path = "/transactions/" + quote_plus( self.id) + "/refunds/" + quote_plus(refund_id) + "" data = {} response = Response(request.get(path, data, options)) return_values = [] body = response.body body = body["refund"] refund = processout.Refund(self._client) return_values.append(refund.fill_with_data(body)) return return_values[0]
def find_token(self, token_id, options={}): """Find a customer's token by its ID. Keyword argument: token_id -- ID of the token options -- Options for the request""" self.fill_with_data(options) request = Request(self._client) path = "/customers/" + quote_plus( self.id) + "/tokens/" + quote_plus(token_id) + "" data = {} response = Response(request.get(path, data, options)) return_values = [] body = response.body body = body["token"] token = processout.Token(self._client) return_values.append(token.fill_with_data(body)) return return_values[0]