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 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 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 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 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 find(self, invoice_id, options = {}): """Find an invoice by its ID. Keyword argument: invoice_id -- ID of the invoice options -- Options for the request""" self.fill_with_data(options) request = Request(self._client) path = "/invoices/" + quote_plus(invoice_id) + "" data = { } response = Response(request.get(path, data, options)) return_values = [] body = response.body body = body["invoice"] obj = processout.Invoice(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 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 coupon attributes. Keyword argument: options -- Options for the request""" self.fill_with_data(options) request = Request(self._client) path = "/coupons/" + quote_plus(self.id) + "" data = { 'metadata': self.metadata } response = Response(request.put(path, data, options)) return_values = [] body = response.body body = body["coupon"] return_values.append(self.fill_with_data(body)) return return_values[0]
def all(self, options = {}): """Get all the gateway configurations. Keyword argument: options -- Options for the request""" self.fill_with_data(options) request = Request(self._client) path = "/gateway-configurations" data = { } response = Response(request.get(path, data, options)) return_values = [] a = [] body = response.body for v in body['gateway_configurations']: tmp = processout.GatewayConfiguration(self._client) tmp.fill_with_data(v) a.append(tmp) return_values.append(a) return return_values[0]
def capture(self, source, options = {}): """Capture the invoice using the given source (customer or token) Keyword argument: source -- Source used to authorization the payment. Can be a card, a token or a gateway request options -- Options for the request""" self.fill_with_data(options) request = Request(self._client) path = "/invoices/" + quote_plus(self.id) + "/capture" data = { 'authorize_only': options.get("authorize_only"), 'synchronous': options.get("synchronous"), 'retry_drop_liability_shift': options.get("retry_drop_liability_shift"), 'capture_amount': options.get("capture_amount"), 'source': source } response = Response(request.post(path, data, options)) return_values = [] body = response.body body = body["transaction"] transaction = processout.Transaction(self._client) return_values.append(transaction.fill_with_data(body)) return return_values[0]
def create(self, options = {}): """Create a new authorization request for the given customer ID. Keyword argument: options -- Options for the request""" self.fill_with_data(options) request = Request(self._client) path = "/authorization-requests" data = { 'customer_id': self.customer_id, 'name': self.name, 'currency': self.currency, 'return_url': self.return_url, 'cancel_url': self.cancel_url } response = Response(request.post(path, data, options)) return_values = [] body = response.body body = body["authorization_request"] return_values.append(self.fill_with_data(body)) return return_values[0]
def find(self, authorization_request_id, options = {}): """Find an authorization request by its ID. Keyword argument: authorization_request_id -- ID of the authorization request options -- Options for the request""" self.fill_with_data(options) request = Request(self._client) path = "/authorization-requests/" + quote_plus(authorization_request_id) + "" data = { } response = Response(request.get(path, data, options)) return_values = [] body = response.body body = body["authorization_request"] obj = processout.AuthorizationRequest(self._client) return_values.append(obj.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 create_supervised(self, options={}): """Create a new supervised project. Keyword argument: options -- Options for the request""" self.fill_with_data(options) request = Request(self._client) path = "/supervised-projects" data = { 'id': self.id, 'name': self.name, 'default_currency': self.default_currency, 'dunning_configuration': self.dunning_configuration, 'applepay_settings': options.get("applepay_settings") } response = Response(request.post(path, data, options)) return_values = [] body = response.body body = body["project"] return_values.append(self.fill_with_data(body)) return return_values[0]
def find(self, subscription_id, discount_id, options = {}): """Find a subscription's discount by its ID. Keyword argument: subscription_id -- ID of the subscription on which the discount was applied discount_id -- ID of the discount options -- Options for the request""" self.fill_with_data(options) request = Request(self._client) path = "/subscriptions/" + quote_plus(subscription_id) + "/discounts/" + quote_plus(discount_id) + "" data = { } response = Response(request.get(path, data, options)) return_values = [] body = response.body body = body["discount"] obj = processout.Discount(self._client) return_values.append(obj.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 fetch_subscription_discounts(self, subscription_id, options = {}): """Get the discounts applied to the subscription. Keyword argument: subscription_id -- ID of the subscription options -- Options for the request""" self.fill_with_data(options) request = Request(self._client) path = "/subscriptions/" + quote_plus(subscription_id) + "/discounts" data = { } response = Response(request.get(path, data, options)) return_values = [] a = [] body = response.body for v in body['discounts']: tmp = processout.Discount(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 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 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 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 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 all(self, options = {}): """Get all the invoices. Keyword argument: options -- Options for the request""" self.fill_with_data(options) request = Request(self._client) path = "/invoices" data = { } response = Response(request.get(path, data, options)) return_values = [] a = [] body = response.body for v in body['invoices']: tmp = processout.Invoice(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 discount for 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) + "/discounts" data = { 'coupon_id': self.coupon_id, 'name': self.name, 'amount': self.amount, 'expires_at': self.expires_at, 'metadata': self.metadata } response = Response(request.post(path, data, options)) return_values = [] body = response.body body = body["discount"] 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_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]