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 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 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 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_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 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 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, 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 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 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 create(self, options={}): """Create a refund for a transaction. Keyword argument: options -- Options for the request""" self.fill_with_data(options) request = Request(self._client) path = "/transactions/" + quote_plus(self.transaction_id) + "/refunds" data = { 'amount': self.amount, 'metadata': self.metadata, 'reason': self.reason, 'information': self.information } response = Response(request.post(path, data, options)) return_values = [] return_values.append(response.success) return return_values[0]
def void(self, options = {}): """Void the invoice Keyword argument: options -- Options for the request""" self.fill_with_data(options) request = Request(self._client) path = "/invoices/" + quote_plus(self.id) + "/void" data = { } 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 initiate_three_d_s(self, source, options = {}): """Initiate a 3-D Secure authentication Keyword argument: source -- Source used to initiate the 3-D Secure authentication. Can be a card, or a token representing a card options -- Options for the request""" self.fill_with_data(options) request = Request(self._client) path = "/invoices/" + quote_plus(self.id) + "/three-d-s" data = { 'source': source } response = Response(request.post(path, data, options)) return_values = [] body = response.body body = body["customer_action"] customerAction = processout.CustomerAction(self._client) return_values.append(customerAction.fill_with_data(body)) return return_values[0]
def assign_customer(self, customer_id, options = {}): """Assign a customer to the invoice. Keyword argument: customer_id -- ID of the customer to be linked to the invoice options -- Options for the request""" self.fill_with_data(options) request = Request(self._client) path = "/invoices/" + quote_plus(self.id) + "/customers" data = { 'customer_id': customer_id } response = Response(request.post(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(self, options = {}): """Create a new invoice. Keyword argument: options -- Options for the request""" self.fill_with_data(options) request = Request(self._client) path = "/invoices" data = { 'customer_id': self.customer_id, 'name': self.name, 'amount': self.amount, 'currency': self.currency, 'metadata': self.metadata, 'details': self.details, 'statement_descriptor': self.statement_descriptor, 'statement_descriptor_phone': self.statement_descriptor_phone, 'statement_descriptor_city': self.statement_descriptor_city, 'statement_descriptor_company': self.statement_descriptor_company, 'statement_descriptor_url': self.statement_descriptor_url, 'return_url': self.return_url, 'cancel_url': self.cancel_url } response = Response(request.post(path, data, options)) return_values = [] body = response.body body = body["invoice"] return_values.append(self.fill_with_data(body)) return return_values[0]
def create(self, options={}): """Create a new customer. Keyword argument: options -- Options for the request""" self.fill_with_data(options) request = Request(self._client) path = "/customers" data = { 'balance': self.balance, 'currency': self.currency, 'email': self.email, 'first_name': self.first_name, 'last_name': self.last_name, 'address1': self.address1, 'address2': self.address2, 'city': self.city, 'state': self.state, 'zip': self.zip, 'country_code': self.country_code, 'ip_address': self.ip_address, 'phone_number': self.phone_number, 'legal_document': self.legal_document, 'metadata': self.metadata } response = Response(request.post(path, data, options)) return_values = [] body = response.body body = body["customer"] return_values.append(self.fill_with_data(body)) return return_values[0]