diff --git a/.gitignore b/.gitignore index 47a72b1..207a68b 100644 --- a/.gitignore +++ b/.gitignore @@ -40,3 +40,4 @@ dist/ .idea/ _build/ coverage.xml +scenario.cache \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 83e5baa..07c01bd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,17 @@ language: python python: - - 2.6 - - 2.7 +- 2.6 +- 2.7 install: - - python setup.py develop - - pip install -r requirements.txt - - pip install -r test-requirements.txt -script: - - python setup.py test +- python setup.py develop +- pip install -r requirements.txt +- pip install -r test-requirements.txt +script: +- python setup.py test +deploy: + provider: pypi + user: balanced-butler + password: + secure: jH1XW+hl+KInnde014cvX8mH5ZRiqXsxMRflR2DEs/na5mK/1LFzFt2iwgN9XwkkmXJYLPr6LA3pSLqHTMKXs8RrHaM1uXmEckXL48jcy0YkQ0+2Cl0EKcbmS8OnqIcjY3g5xFBbsFPjuRx6uJYFksJ3QatTuxkDcY/hQOc6IZg= + on: + tags: true diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..ed98d26 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,31 @@ +## 1.2 + +* Account and Settlement support + +## 1.1.1 + +* Fix allowing for voiding holds + +## 1.1.0 + +* Push to card support + +## 1.0.2 + +* Return None when there is actually none instead of a page object (#115) +* Fix polymorphic types coming back as resource (#114) +* Fix for query pagination (#109) +* Fix iterator (#21) + + +## 1.0.1 + +* Fix for returned generic Resource instead of expected resource class + + +## 1.0 + +* Requires Balanced API 1.1 +* Hypermedia API support +* Debits and credits are now performed directly on funding instruments and not via Customer +* Support for new Order resource \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..9c6060a --- /dev/null +++ b/LICENSE @@ -0,0 +1,22 @@ +Copyright (c) 2014 Balanced + +MIT License + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md index b32b361..e710576 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,9 @@ Online Marketplace Payments -[![Build Status](https://secure.travis-ci.org/balanced/balanced-python.png?branch=master)](http://travis-ci.org/balanced/balanced-python) +[![Build Status](https://secure.travis-ci.org/balanced/balanced-python.png?branch=master)](http://travis-ci.org/balanced/balanced-python) [![Latest Version](https://pypip.in/version/balanced/badge.svg)](https://pypi.python.org/pypi/balanced/) [![Downloads](https://pypip.in/download/balanced/badge.svg)](https://pypi.python.org/pypi/balanced/) [![Supported Python versions](https://pypip.in/py_versions/balanced/badge.svg)](https://pypi.python.org/pypi/balanced/) [![License](https://pypip.in/license/balanced/badge.svg)](https://pypi.python.org/pypi/balanced/) + +**v1.x requires Balanced API 1.1. Use [v0.x](https://github.com/balanced/balanced-python/tree/rev0) for Balanced API 1.0.** ## Installation diff --git a/balanced/__init__.py b/balanced/__init__.py index 53edc81..ccc88e3 100644 --- a/balanced/__init__.py +++ b/balanced/__init__.py @@ -1,68 +1,42 @@ -__version__ = '0.11.15' -from collections import defaultdict -import contextlib +from __future__ import unicode_literals -from balanced._http_client import HTTPClient +__version__ = '1.2' + +from balanced.config import configure +from balanced import resources from balanced.resources import ( - Resource, Marketplace, Account, APIKey, - Hold, Credit, Debit, Refund, - Merchant, Transaction, BankAccount, Card, + Resource, Marketplace, APIKey, + CardHold, Credit, Debit, Refund, Reversal, + Transaction, BankAccount, Card, Dispute, Callback, Event, EventCallback, EventCallbackLog, - BankAccountVerification, Customer, + BankAccountVerification, Customer, Order, + ExternalAccount, Account, Settlement ) from balanced import exc __all__ = [ - Resource.__name__, - Marketplace.__name__, Account.__name__, APIKey.__name__, - Hold.__name__, - Credit.__name__, - Debit.__name__, - Refund.__name__, - Merchant.__name__, - Transaction.__name__, - Card.__name__, BankAccount.__name__, + BankAccountVerification.__name__, Callback.__name__, + Card.__name__, + CardHold.__name__, + Credit.__name__, + Customer.__name__, + Debit.__name__, + Dispute.__name__, Event.__name__, EventCallback.__name__, EventCallbackLog.__name__, - BankAccountVerification.__name__, - Customer.__name__, - exc.__name__.partition('.')[-1], + Marketplace.__name__, + Order.__name__, + Resource.__name__, + Refund.__name__, + Reversal.__name__, + Settlement.__name__, + Transaction.__name__, + ExternalAccount.__name__, + str(exc.__name__.partition('.')[-1]) ] - -# See https://github.com/balanced/balanced-python/issues/44 re: naming. -http_client = HTTPClient() -config = http_client.config - - -CACHE = defaultdict(dict) - - -def bust_cache(): - CACHE.clear() - - -def configure(api_key_secret): - config.api_key_secret = api_key_secret - - -def is_configured(): - return bool(config.api_key_secret) - - -Resource.http_client = http_client - - -@contextlib.contextmanager -def key_switcher(the_new_api_key_secret): - old_api_key = config.api_key_secret - config.api_key_secret = the_new_api_key_secret - try: - yield - finally: - config.api_key_secret = old_api_key diff --git a/balanced/_http_client.py b/balanced/_http_client.py deleted file mode 100644 index a125c7b..0000000 --- a/balanced/_http_client.py +++ /dev/null @@ -1,186 +0,0 @@ -import json -import threading - -import requests -from requests.sessions import REDIRECT_STATI - -from balanced import exc -from balanced.config import Config -from balanced.utils import to_json, urljoin - -serializers = { - 'application/json': to_json -} - - -deserializers = { - 'application/json': json.loads -} - - -REDIRECT_STATI = list(REDIRECT_STATI) -REDIRECT_STATI.append(300) - - -before_request_hooks = [] - - -def wrap_raise_for_status(http_client): - - def handle_exception(response): - deserialized = http_client.deserialize( - response - ) - response.deserialized = deserialized - extra = deserialized.get('additional') or '' - if extra: - extra = ' -- {0}.'.format(extra) - error_msg = '{name}: {code}: {msg} {extra}'.format( - name=deserialized['status'], - code=deserialized['status_code'], - msg=deserialized['description'].encode('utf8'), - extra=extra.encode('utf8'), - ) - category_code = deserialized.get('category_code', None) - error_cls = exc.category_code_map.get( - category_code, exc.HTTPError) - http_error = error_cls(error_msg) - for error, value in deserialized.iteritems(): - setattr(http_error, error, value) - raise http_error - - def handle_redirect(response): - reason = '%s Client Error: %s' % ( - response.status_code, - response.reason, - ) - redirection = exc.MoreInformationRequiredError(reason) - redirection.status_code = response.status_code - redirection.response = response - redirection.redirect_uri = response.headers['Location'] - raise redirection - - def wrapper(response, **kwargs): - - try: - response.raise_for_status() - except requests.HTTPError: - handle_exception(response) - else: - if response.status_code in REDIRECT_STATI: - handle_redirect(response) - - return wrapper - - -# requests does define a 'pre_request' hook but we want to get in there before -# it does the encoding of authorization headers etc. -def _before_request(*args): - for hook in before_request_hooks: - hook(*args) - - -def munge_request(http_op): - - # follows the spec for requests. - def transform_into_absolute_url(config, url): - if url.startswith(config.uri): - return url - url = url.lstrip('/') - if url.startswith(config.version): - url = urljoin(config.root_uri, url) - else: - url = urljoin(config.uri, url) - return url - - def prepend_version(config, url): - url = url.lstrip('/') - if not url.startswith(config.version): - url = urljoin(config.version, url) - return url - - def make_absolute_url(client, url, **kwargs): - url = transform_into_absolute_url(client.config, url) - request_body = kwargs.get('data', {}) - fixed_up_body = {} - for key, value in request_body.iteritems(): - if key.endswith('_uri') and value: - fixed_up_body[key] = prepend_version(client.config, value) - request_body.update(fixed_up_body) - kwargs['data'] = request_body - # TODO: merge config dictionaries if it exists. - headers = kwargs.pop('headers', {}) - headers.update(client.config.requests['base_headers']) - kwargs['headers'] = headers - kwargs['allow_redirects'] = False - - kwargs['hooks'] = { - 'response': wrap_raise_for_status(client) - } - - if client.config.api_key_secret: - kwargs['auth'] = (client.config.api_key_secret, None) - - _before_request(client, http_op, url, kwargs) - - return http_op(client, url, **kwargs) - - return make_absolute_url - - -class HTTPClient(threading.local, object): - - config = Config() - _before_request_hooks = before_request_hooks - - def __init__(self, keep_alive=True, *args, **kwargs): - super(HTTPClient, self).__init__(*args, **kwargs) - self.interface = requests.session() if keep_alive else requests - - # we don't use the requests hook here because we want to expose - # that for any developer to access it directly. - # - # maybe eventually we should include requests configuration in the - # config? - @munge_request - def get(self, uri, **kwargs): - kwargs = self.serialize(kwargs.copy()) - resp = self.interface.get(uri, **kwargs) - resp.deserialized = self.deserialize(resp) - return resp - - @munge_request - def post(self, uri, data=None, **kwargs): - data = self.serialize({'data': data}).pop('data') - resp = self.interface.post(uri, data=data, **kwargs) - resp.deserialized = self.deserialize(resp) - return resp - - @munge_request - def put(self, uri, data=None, **kwargs): - data = self.serialize({'data': data}).pop('data') - resp = self.interface.put(uri, data=data, **kwargs) - resp.deserialized = self.deserialize(resp) - return resp - - @munge_request - def delete(self, uri, **kwargs): - kwargs = self.serialize(kwargs.copy()) - resp = self.interface.delete(uri, **kwargs) - if resp.status_code != 204: - resp.deserialized = self.deserialize(resp) - return resp - - def deserialize(self, resp): - try: - return deserializers[resp.headers['Content-Type']](resp.content) - except KeyError: - raise exc.BalancedError('Invalid content type "{0}": {1}'.format( - resp.headers['Content-Type'], resp.content, - )) - - def serialize(self, kwargs): - content_type = self.config.requests['base_headers']['Content-Type'] - data = kwargs.pop('data', None) - kwargs['data'] = serializers[content_type](data) if data else data - return kwargs diff --git a/balanced/config.py b/balanced/config.py index 2f20b70..c746501 100644 --- a/balanced/config.py +++ b/balanced/config.py @@ -1,34 +1,92 @@ -from balanced import __version__ -from balanced.utils import urljoin - - -def _make_user_agent(): - return 'balanced-python/' + __version__ - - -class Config(object): - - def __init__(self): - super(Config, self).__init__() - self.api_key_secret = None - self.api_version = '1' - self.root_uri = 'https://api.balancedpayments.com' - # this is requests' config that get passed down on - # every http operation. - # - # see: http://docs.python-requests.org/en/v0.10.4/api/#configurations - self.requests = { - 'base_headers': { - 'Accept': 'application/json', - 'Content-Type': 'application/json', - 'User-agent': _make_user_agent(), - }, - } - - @property - def uri(self): - return urljoin(self.root_uri, self.version) - - @property - def version(self): - return 'v' + self.api_version +from __future__ import unicode_literals +from datetime import datetime + +import simplejson as json +from iso8601 import iso8601 +import wac + +from balanced import exc +from . import __version__ + + +API_ROOT = 'https://api.balancedpayments.com' + + +# config +def configure( + user=None, + root_url=API_ROOT, + api_revision='1.1', + user_agent='balanced-python/' + __version__, + accept_type='application/vnd.api+json', + **kwargs +): + kwargs.setdefault('headers', {}) + + for key, value in ( + ('content-type', 'application/json;revision=' + api_revision), + ('accept', '{0};revision={1}'.format(accept_type, api_revision)) + ): + kwargs['headers'].setdefault(key, value) + + if 'error_cls' not in kwargs: + kwargs['error_cls'] = exc.convert_error + + if user: + kwargs['auth'] = (user, None) + + # apply + Client.config = Config(root_url, user_agent=user_agent, **kwargs) + + +class Config(wac.Config): + + api_revision = None + + user_agent = None + + +default_config = Config(API_ROOT) + + +# client + +class Client(wac.Client): + + config = default_config + + @staticmethod + def _default_serialize(o): + if isinstance(o, datetime): + return o.isoformat() + 'Z' + raise TypeError( + 'Object of type {} with value of {} is not ' + 'JSON serializable'.format(type(o), repr(o)) + ) + + def _serialize(self, data): + data = json.dumps(data, default=self._default_serialize) + return 'application/json', data + + @staticmethod + def _parse_deserialized(e): + if isinstance(e, dict): + for k in e.iterkeys(): + if k.endswith('_at') and isinstance(e[k], basestring): + e[k] = iso8601.parse_date(e[k]) + return e + + def _deserialize(self, response): + if response.headers['Content-Type'] != 'application/json': + raise Exception("Unsupported content-type '{}'".format( + response.headers['Content-Type'] + )) + if not response.content: + return None + data = json.loads(response.content) + return self._parse_deserialized(data) + + +configure() + +client = Client() diff --git a/balanced/exc.py b/balanced/exc.py index b0b97ac..9ec3811 100644 --- a/balanced/exc.py +++ b/balanced/exc.py @@ -1,8 +1,18 @@ -import requests +from __future__ import unicode_literals + +import httplib + +import wac class BalancedError(Exception): - pass + + def __str__(self): + attrs = ', '.join([ + '{0}={1}'.format(k, repr(v)) + for k, v in self.__dict__.iteritems() + ]) + return '{0}({1})'.format(self.__class__.__name__, attrs) class ResourceError(BalancedError): @@ -17,15 +27,59 @@ class MultipleResultsFound(BalancedError): pass -class HTTPError(BalancedError, requests.HTTPError): - """ - Baseclass for all HTTP exceptions. - """ - status_code = None +class FundingSourceNotCreditable(Exception): + pass -class MoreInformationRequiredError(HTTPError): - redirect_uri = None +def convert_error(ex): + if not hasattr(ex.response, 'data'): + return ex + return HTTPError.from_response(**ex.response.data)(ex) + + +class HTTPError(BalancedError, wac.Error): + + class __metaclass__(type): + + def __new__(meta_cls, name, bases, dikt): + cls = type.__new__(meta_cls, name, bases, dikt) + cls.types = [ + getattr(cls, k) + for k in dir(cls) + if k.isupper() and isinstance(getattr(cls, k), basestring) + ] + cls.type_to_error.update(zip(cls.types, [cls] * len(cls.types))) + return cls + + def __init__(self, requests_ex): + super(wac.Error, self).__init__(requests_ex) + self.status_code = requests_ex.response.status_code + data = getattr(requests_ex.response, 'data', {}) + for k, v in data.get('errors', [{}])[0].iteritems(): + setattr(self, k, v) + + @classmethod + def format_message(cls, requests_ex): + data = getattr(requests_ex.response, 'data', {}) + status = httplib.responses[requests_ex.response.status_code] + error = data['errors'][0] + status = error.pop('status', status) + status_code = error.pop('status_code', + requests_ex.response.status_code) + desc = error.pop('description', None) + message = ': '.join(str(v) for v in [status, status_code, desc] if v) + return message + + @classmethod + def from_response(cls, **data): + try: + err = data['errors'][0] + exc = cls.type_to_error.get(err['category_code'], HTTPError) + except: + exc = HTTPError + return exc + + type_to_error = {} class FundingInstrumentVerificationFailure(HTTPError): @@ -33,14 +87,6 @@ class FundingInstrumentVerificationFailure(HTTPError): class BankAccountVerificationFailure(FundingInstrumentVerificationFailure): - pass - - -category_code_map = { - 'bank-account-authentication-not-pending': - BankAccountVerificationFailure, - 'bank-account-authentication-failed': - BankAccountVerificationFailure, - 'bank-account-authentication-already-exists': - BankAccountVerificationFailure, -} + AUTH_NOT_PENDING = 'bank-account-authentication-not-pending' + AUTH_FAILED = 'bank-account-authentication-failed' + AUTH_DUPLICATED = 'bank-account-authentication-already-exists' diff --git a/balanced/resources.py b/balanced/resources.py index 8f0603f..a4671bf 100644 --- a/balanced/resources.py +++ b/balanced/resources.py @@ -1,1185 +1,558 @@ -import functools -import itertools -import logging -import urlparse -import warnings - -import iso8601 - -from balanced.utils import ( - cached_property, url_encode, classproperty, requires_participant, -) -from balanced.exc import ( - NoResultFound, MultipleResultsFound, ResourceError, -) - - -LOGGER = logging.getLogger(__name__) - - -class _ResourceRegistry(dict): - - def add(self, resource_class): - self[resource_class.__name__] = resource_class - self[resource_class.RESOURCE['singular']] = resource_class - self[resource_class.RESOURCE['collection']] = resource_class - if resource_class.RESOURCE['nested_under']: - # nested_as = ['marketplaces', 'events'] - # collection = 'logs' - # store nested_under as |marketplaces/events/logs - nested_under = self._as_nested( - resource_class.RESOURCE['nested_under'] + [ - resource_class.RESOURCE['collection'] - ] - ) - self[nested_under] = resource_class - - def from_uri(self, uri): - if not uri: - return None - - split_uri = urlparse.urlsplit(uri.rstrip('/')) - # split_uri.path == '/v1/marketplaces/M123/events/E123' - # url == ['', 'v1', 'marketplaces', 'M123', 'events', 'E123'] - url = split_uri.path.split('/') # pylint: disable-msg=E1103 +from __future__ import unicode_literals - resource = self._from_nested(url) or self._from_url(url) +import uritemplate +import wac - return resource +from balanced import exc, config, utils - def _from_url(self, url_parts): - if url_parts[-1] in self: - resource = self[url_parts[-1]] - else: - resource = self[url_parts[-2]] - return resource - - def _from_nested(self, url_parts): - # ['marketplaces', 'events'] - parts = url_parts[2::2] - # we have a possible nested resource, check if it's specifically nested - if len(parts) > 1: - nested = self._as_nested(parts) - if nested in self: - resource = self[nested] - return resource - return None - - def _as_nested(self, parts): - """ - >>> _ResourceRegistry()._as_nested(['marketplaces', 'events']) - '|marketplaces/events' - :param parts: list of parts to turn into a nested resource - :return: munged fungible - """ - return '|' + '/'.join(parts) +registry = wac.ResourceRegistry(route_prefix='/') -_RESOURCES = _ResourceRegistry() +class JSONSchemaCollection(wac.ResourceCollection): -class Page(object): - - def __init__(self, uri): - self.uri = uri - self.qs = {} - - def __getitem__(self, item): - if isinstance(item, slice): - start, stop, step = item.start, item.stop, item.step + @property + def href(self): + return self.uri - # can't use all() here because it doesnt - # fail fast. - if (isinstance(stop, int) and - isinstance(start, int) and - stop - start <= 0): - return [] - elif any((isinstance(start, int) and start < 0, - isinstance(stop, int) and stop < 0)): - return self.all()[item] +class ObjectifyMixin(wac._ObjectifyMixin): - res = self._slice(start, stop) - if step is not None: - return list(res)[None:None:item.step] - else: - return list(res) + def _objectify(self, resource_cls, **fields): + # setting values locally, not from server + if 'links' not in fields: + for key, value in fields.iteritems(): + setattr(self, key, value) else: - # negative index - if item < 0: - # e.g. let len(self) = 3 and item = -1 - # self[length of collection - item : length of collection] - # self[3 - 1: 3] - length = len(self) - return list(self[length + item:length])[0] - # positive index - # let item = 2 - # self[2:3][0] - return list(self[item:item + 1])[0] - - def _slice(self, start, stop): - if start is not None and stop is not None: - self.qs['offset'] = (self.offset or 0) + start - self.qs['limit'] = stop - start - elif stop is not None: - self.qs['limit'] = stop - elif start is not None: - self.qs['offset'] = (self.offset or 0) + start - return itertools.islice(self, start, stop) - - def __len__(self): - return self.total - - def __iter__(self): - if self.next_page is not None: - for resource in itertools.chain(self.items, self.next_page): - yield resource - else: - # New-style, no pagination - for resource in self.items: - yield resource - - @classmethod - def from_uri_and_params(cls, uri, params): - parsed_uri = urlparse.urlparse(uri) - parsed_qs = urlparse.parse_qs(parsed_uri.query) - if params and isinstance(params, (dict, )): - parsed_qs.update(params) - uri = parsed_uri.path - if parsed_qs: - uri = uri + '?' + url_encode(parsed_qs) - return cls(uri) + self._construct_from_response(**fields) + + def _construct_from_response(self, **payload): + payload = self._hydrate(payload) + meta = payload.pop('meta', None) + + if isinstance(self, wac.Page): + for key, value in meta.iteritems(): + setattr(self, key, value) + + # the remaining keys here are just hypermedia resources + for _type, resources in payload.iteritems(): + # Singular resources are represented as JSON objects. However, + # they are still wrapped inside an array: + cls = Resource.registry[_type] + + for resource_body in resources: + # if we couldn't determine the type of this object we use a + # generic resource object, target that instead. + if isinstance(self, (cls, Resource)): + # we are loading onto our self, self is the target + target = self + else: + target = cls() + for key, value in resource_body.iteritems(): + if key in ('links',): + continue + setattr(target, key, value) + + # if loading into a collection + if target != self: + # ensure that we have a collection to hold this item + if not hasattr(self, _type): + setattr(self, _type, []) + getattr(self, _type).append(target) @classmethod - def from_response(cls, uri, **kwargs): - instance = cls.from_uri_and_params(uri, None) - setattr(instance, '_lazy_loaded', kwargs) - return instance - - def __repr__(self): - _resource = _RESOURCES.from_uri(self.uri) - return ''.format(_resource, self.qs) - - def all(self): - return list(self) - - def one(self): - ret = list(self[0:2]) - - if len(ret) == 1: - return ret[0] - elif not len(ret): - raise NoResultFound( - 'Nothing found for one(). Make sure balanced.configure() ' - 'is invoked with your API key secret') - else: - raise MultipleResultsFound('Multiple items were found for one()') + def _hydrate(cls, payload): + """ + Construct links for objects + """ + links = payload.pop('links', {}) + for key, uri in links.iteritems(): + variables = uritemplate.variables(uri) + # marketplaces.card_holds + collection, resource_type = key.split('.') + item_attribute = item_property = resource_type + # if parsed from uri then retrieve. e.g. customer.id + for item in payload[collection]: + # find type, fallback to Resource if we can't determine the + # type e.g. marketplace.owner_customer + collection_type = Resource.registry.get(resource_type, + Resource) + + def extract_variables_from_item(item, variables): + for v in variables: + _, item_attribute = v.split('.') + # HACK: https://github.com/PoundPay/balanced/issues/184 + if item_attribute == 'self': + item_attribute = 'id' + item_value = item['links'].get( + item_attribute, item.get(item_attribute) + ) + if item_value: + yield v, item_value + + item_variables = dict( + extract_variables_from_item(item, variables)) + + # expand variables if we have them, else this is a link like + # /debits + if item_variables: + parsed_link = uritemplate.expand(uri, item_variables) + else: + parsed_link = uri + + # check if this is a collection or a singular item + if any( + parsed_link.endswith(value) + for value in item_variables.itervalues() + ): + # singular + if not item_property.endswith('_href'): + item_property += '_href' + lazy_href = parsed_link + + elif '{' in parsed_link and '}' in parsed_link: + # the link is of the form /asdf/{asdf} which means + # that the variables could not be resolved as it + # was None. Instead of making it into a page object + # we explicitly set it to None to represent the + # attribute is None + lazy_href = None + else: + # collection + lazy_href = JSONSchemaCollection( + collection_type, parsed_link) + item.setdefault(item_property, lazy_href) + return payload - @cached_property - def _lazy_loaded(self): - page = self._fetch(self.uri) - response = Resource.http_client.get(page.uri) - return response.deserialized - def _fetch(self, uri): - if not uri: - return [] - return Page.from_uri_and_params(uri, self.qs) +class JSONSchemaPage(wac.Page, ObjectifyMixin): @property def items(self): - for item in self._lazy_loaded['items']: - _resource = _RESOURCES.from_uri(item['uri']) - yield _resource(**item) - - @property - def total(self): - return self._lazy_loaded['total'] - - def count(self): - copied_dict = self.qs.copy() - copied_dict['offset'] = 0 - copied_dict['limit'] = 1 - return Page.from_uri_and_params(self.uri, copied_dict).total - - @property - def offset(self): - return self._lazy_loaded['offset'] - - @property - def limit(self): - return self._lazy_loaded['limit'] - - @property - def next_page(self): - if 'next_uri' in self._lazy_loaded: - uri = self._lazy_loaded['next_uri'] - return self._fetch(uri) - return None - - @property - def last_page(self): - uri = self._lazy_loaded['last_uri'] - return self._fetch(uri) - - @property - def first_page(self): - uri = self._lazy_loaded['first_uri'] - return self._fetch(uri) - - @property - def previous_page(self): - uri = self._lazy_loaded['previous_uri'] - return self._fetch(uri) - - def filter(self, *args, **kwargs): - """ - Allows query string filters to be passed down as keyword arguments - for easier filtering: - - credits = marketplace.credits.filter(limit=10) - for c in credits: - .... - - """ - query_arguments = {} - for expression in args: - if not isinstance(expression, FilterExpression): - raise ValueError('"{0}" is not a FilterExpression'.format( - expression)) - if expression.op == '=': - f = '{0}'.format(expression.field.name) - else: - f = '{0}[{1}]'.format(expression.field.name, expression.op) - values = expression.value - if not isinstance(values, (list, tuple)): - values = [values] - query_arguments[f] = ','.join(str(v) for v in values) - for k, values in kwargs.iteritems(): - f = '{0}'.format(k) - if not isinstance(values, (list, tuple)): - values = [values] - v = ','.join(str(v) for v in values) - query_arguments[f] = v - qs = self.qs.copy() - qs.update(query_arguments) - return Page.from_uri_and_params(self.uri, qs) - - def sort(self, *args): - sorts = [] - for expression in args: - if not isinstance(expression, SortExpression): - raise ValueError('"{0}" is not a SortExpression'.format( - expression)) - v = '{0},{1}'.format( - expression.field.name, - 'asc' if expression.ascending else 'desc') - sorts.append(v) - if 'sort' in self.qs: - self.qs['sort'].extend(sorts) - else: - self.qs['sort'] = sorts - return self - - -class Resource(object): + try: + try: + return getattr(self, self.resource_cls.type) + except AttributeError: + # horrid hack because event callbacks are misnamed. + return self.event_callbacks + except AttributeError: + # Notice: + # there is no resources key in the response from server + # if the list is empty, so when we try to get something like + # `debits`, an AttributeError will be raised. Not sure is this + # behavior a bug of server, but anyway, this is just a workaround + # here for solving the problem. The issue was posted here + # https://github.com/balanced/balanced-python/issues/93 + return [] - #: http_client is the class variable representing a - #: :class:`~balanced.http_client.HTTPClient` - http_client = None - def __repr__(self): - attrs = ', '.join(['%s=%s' % (k, repr(v)) for k, v in - self.__dict__.iteritems()]) - return '%s(%s)' % (self.__class__.__name__, attrs) +class JSONSchemaResource(wac.Resource, ObjectifyMixin): - @classproperty - def query(cls): - uri = uri_discovery(cls) - return Page.from_uri_and_params(uri, params=None) + collection_cls = JSONSchemaCollection - @classmethod - def find(cls, uri, **kwargs): - resp = cls.http_client.get(uri, **kwargs) - return cls(**resp.deserialized) + page_cls = JSONSchemaPage def save(self): - instance_attributes = self.__dict__.copy() + cls = type(self) + attrs = self.__dict__.copy() + href = attrs.pop('href', None) + + if not href: + if not cls.uri_gen or not cls.uri_gen.root_uri: + raise TypeError( + 'Unable to create {0} resources directly'.format( + cls.__name__ + ) + ) + href = cls.uri_gen.root_uri - uri = instance_attributes.pop('uri', None) - if not uri: - uri = self.RESOURCE['collection'] + method = cls.client.put if 'id' in attrs else cls.client.post - for key, value in instance_attributes.items(): - if isinstance(value, Resource): - instance_attributes.pop(key) + attrs = dict( + (k, v.href if isinstance(v, Resource) else v) + for k, v in attrs.iteritems() + if not isinstance(v, (cls.collection_cls)) + ) - http_method = 'put' if self.id else 'post' - method = getattr(self.http_client, http_method) + resp = method(href, data=attrs) - resource = method(uri, data=instance_attributes) - new_klass = self.__class__(**resource.deserialized) + instance = self.__class__(**resp.data) self.__dict__.clear() - self.__dict__.update(new_klass.__dict__) + self.__dict__.update(instance.__dict__) + return self def delete(self): - self.http_client.delete(self.uri) - - def unstore(self): - self.delete() - - -def uri_discovery(resource): - uri = resource.RESOURCE['collection'] - if resource.RESOURCE['resides_under_marketplace']: - uri = '{0}/{1}'.format( - Marketplace.my_marketplace.uri, - resource.RESOURCE['collection'] + self.client.delete(self.href) + + def __dir__(self): + return self.__dict__.keys() + + def __getattr__(self, item): + if isinstance(item, basestring): + suffix = '_href' + if suffix not in item: + href = getattr(self, item + suffix, None) + if href: + item_type = Resource.registry.get(item + 's', Resource) + setattr(self, item, item_type.get(href)) + return getattr(self, item) + raise AttributeError( + "'{0}' has no attribute '{1}'".format( + self.__class__.__name__, item + ) ) - return uri - - -def is_collection(uri): - uri = urlparse.urlparse(uri).path - _, _, end_identifier = uri.rstrip('/').rpartition('/') - return end_identifier in _RESOURCES -def from_uri(uri, **kwargs): - resource = _RESOURCES.from_uri(uri) - if is_collection(uri): - return Page.from_uri_and_params(uri, params=kwargs) - else: - return resource.find(uri, **kwargs) +class Resource(JSONSchemaResource): + client = config.client -def is_subresource(value): - return isinstance(value, dict) and 'uri' in value + registry = registry + uri_gen = wac.URIGen('/resources', '{resource}') -def is_date(value): - return ( - value and - isinstance(value, basestring) and - 'Z' in value - ) - - -def is_uri(key): - return isinstance(key, basestring) and key.endswith('_uri') - - -class _LazyURIDescriptor(object): - - def __init__(self, key): - self.key = key + def unstore(self): + return self.delete() - def __get__(self, obj, objtype=None): - if obj is None: - return self - uri = getattr(obj, self.key) - if uri is None: - return None - return from_uri(uri) + @classmethod + def fetch(cls, href): + return cls.get(href) + @classmethod + def get(cls, href): + if href.startswith('/resources'): + # hackety hack hax + # resource is an abstract type, we shouldn't have it comeing back itself + # instead we need to figure out the type based off the api response + resp = cls.client.get(href) + resource = [ + k for k in resp.data.keys() if k != 'links' and k != 'meta' + ] + if resource: + return Resource.registry.get(resource[0], cls)(**resp.data) + return cls(**resp.data) + return super(Resource, cls).get(href) -def make_constructors(): - """Makes an initializer constructor that decends - recursively into all schema specified for sub resources. +class Marketplace(Resource): """ + A Marketplace represents your central broker for all operations on the + Balanced API. - # these keys have key/value data but it should not be expanded into a - # resource. - NON_EXPANDABLE_KEYS = ['meta'] - - def the_new(cls, **kwargs): - for key in kwargs.iterkeys(): - - if not is_uri(key): - continue - - new_key = key.replace('_uri', '') - - if hasattr(cls, new_key): - continue - - setattr(cls, new_key, _LazyURIDescriptor(key)) - - return object.__new__(cls, **kwargs) - - def the_init(self, **kwargs): - self.id = None - - # iterate through the schema that comes back - for key, value in kwargs.iteritems(): - if key not in NON_EXPANDABLE_KEYS and is_subresource(value): - # sub resources have a uri in them - uri = value['uri'] - try: - resource = _RESOURCES.from_uri(uri) - except KeyError: - LOGGER.warning( - "Unknown resource '%s'. Make sure it is " - "added in resources.py. Defaulting to dictionary " - "based access", key) - else: - if is_collection(uri): - value = Page.from_response(**value) - else: - value = resource(**value) - elif key.endswith('_at') and is_date(value): - value = iso8601.parse_date(value) - setattr(self, key, value) - - if not hasattr(self, 'uri'): - self.uri = uri_discovery(self) - - return the_init, the_new - - -class _ResourceField(object): - - def __init__(self, name): - self.name = name - - def __getattr__(self, name): - return _ResourceField('{0}.{1}'.format(self.name, name)) - - def asc(self): - return SortExpression(self, ascending=True) - - def desc(self): - return SortExpression(self, ascending=False) + A Marketplace has a single `owner_customer` which represents your person or + business. - def in_(self, *args): - return FilterExpression(self, 'in', args, '!in') + All Resources apart from APIKeys are associated with a Marketplace. - def startswith(self, prefix): - if not isinstance(prefix, basestring): - raise ValueError('"startswith" prefix must be a string') - return FilterExpression(self, 'startswith', prefix, None) + A Marketplace has an escrow account which receives all funds from Debits + that are not associated with Orders. The sum of the escrow (`in_escrow`) is + (Debits - Refunds + Reversals - Credits). + """ - def endswith(self, suffix): - if not isinstance(suffix, basestring): - raise ValueError('"endswith" suffix must be a string') - return FilterExpression(self, 'endswith', suffix, None) + type = 'marketplaces' - def contains(self, fragment): - if not isinstance(fragment, basestring): - raise ValueError('"contains" fragment must be a string') - return FilterExpression(self, 'contains', fragment, '!contains') + uri_gen = wac.URIGen('/marketplaces', '{marketplace}') - def __lt__(self, other): - if isinstance(other, (list, tuple)): - raise ValueError('"<" operand must be a single value') - return FilterExpression(self, '<', other, '>=') + @utils.classproperty + def mine(cls): + """ + Returns an instance representing the marketplace associated with the + current API key used for this request. + """ + return cls.query.one() - def __le__(self, other): - if isinstance(other, (list, tuple)): - raise ValueError('"<=" operand must be a single value') - return FilterExpression(self, '<=', other, '>') + my_marketplace = mine - def __eq__(self, other): - if isinstance(other, (list, tuple)): - raise ValueError('"==" operand must be a single value') - return FilterExpression(self, '=', other, '!=') - def __ne__(self, other): - if isinstance(other, (list, tuple)): - raise ValueError('"!=" operand must be a single value') - return FilterExpression(self, '!=', other, '=') +class APIKey(Resource): + """ + Your APIKey is used to authenticate when performing operations on the + Balanced API. You must create an APIKey before you create a Marketplace. - def __gt__(self, other): - if isinstance(other, (list, tuple)): - raise ValueError('">" operand must be a single value') - return FilterExpression(self, '>', other, '<=') + **NOTE:** Never give out or expose your APIKey. You may POST to this + endpoint to create new APIKeys and then DELETE any old keys. + """ + type = 'api_keys' - def __ge__(self, other): - if isinstance(other, (list, tuple)): - raise ValueError('">=" operand must be a single value') - return FilterExpression(self, '>=', other, '<') + uri_gen = wac.URIGen('/api_keys', '{api_key}') -class _ResourceFields(object): +class CardHold(Resource): - def __getattr__(self, name): - field = _ResourceField(name) - setattr(self, name, field) - return field + type = 'card_holds' + uri_gen = wac.URIGen('/card_holds', '{card_hold}') -def resource_base(singular=None, - collection=None, - metadata=None, - resides_under_marketplace=True, - nested_under=None): + def cancel(self): + self.is_void = True + return self.save() - class Base(type): + def capture(self, **kwargs): + return Debit( + href=self.debits.href, + **kwargs + ).save() - def __new__(mcs, classname, bases, clsdict): - the_init, the_new = make_constructors() - fields = _ResourceFields() - clsdict.update({ - 'RESOURCE': metadata or { - 'singular': singular or classname.lower(), - 'collection': collection, - 'resides_under_marketplace': resides_under_marketplace, - 'nested_under': nested_under, - }, - '__init__': the_init, - '__new__': the_new, - 'fields': fields, - 'f': fields, - }) +class Transaction(Resource): + """ + Any transfer, funds from or to, your Marketplace's escrow account or the + escrow account of an Order associated with your Marketplace. + E.g. a Credit, Debit, Refund, or Reversal. - the_class = type.__new__(mcs, classname, bases, clsdict) - _RESOURCES.add(the_class) - return the_class + If the Transaction is associated with an Order then it will be applied to + the Order's escrow account, not to the Marketplace's escrow account. + """ - return Base + type = 'transactions' -class Account(Resource): - """ - An Account represents a user within your Marketplace. An Account can have - two `roles`. If the Account has the `buyer` role then you may create - Debits using this Account. If they have the `merchant` role then you may - create Credits to transfer funds to this Account. +class Credit(Transaction): """ - __metaclass__ = resource_base(collection='accounts') - - def debit(self, - amount=None, - appears_on_statement_as=None, - hold_uri=None, - meta=None, - description=None, - source_uri=None, - merchant_uri=None, - on_behalf_of=None): - """ - :rtype: A `Debit` representing a flow of money from this Account to - your Marketplace's escrow account. - :param amount: Amount to hold in cents, must be >= 50 - :param appears_on_statement_as: description of the payment as it needs - to appear on customers card statement - :param meta: Key/value collection - :param description: Human readable description - :param source_uri: A specific funding source such as a `Card` - associated with this account. If not specified the `Card` most - recently added to this `Account` is used. - :param merchant_uri: merchant providing service or delivering product. - (deprecated - use on_behalf_of instead) - :param on_behalf_of: the account uri of whomever is providing the - service or delivering the product. - """ - if not any((amount, hold_uri)): - raise ResourceError('Must have an amount or hold uri') - if all([hold_uri, source_uri]): - raise ResourceError('Must specify either hold_uri OR source_uri') - - if merchant_uri and not on_behalf_of: - warnings.warn( - 'merchant_uri is DEPRECATED - use the on_behalf_of ' - 'parameter', - UserWarning, - stacklevel=2 - ) - merchant_uri = None - on_behalf_of = merchant_uri - - if on_behalf_of: - - if hasattr(on_behalf_of, 'uri'): - on_behalf_of = on_behalf_of.uri + A Credit represents a transfer of funds from your Marketplace's + escrow account to a FundingInstrument. - if not isinstance(on_behalf_of, basestring): - raise ValueError( - 'The on_behalf_of parameter needs to be an account uri' - ) + Credits are created by calling the `credit` method on a FundingInstrument. + """ - if on_behalf_of == self.uri: - raise ValueError( - 'The on_behalf_of parameter MAY NOT be the same account' - ' as the account you are debiting!' - ) + type = 'credits' - meta = meta or {} - return Debit( - uri=self.debits_uri, - amount=amount, - appears_on_statement_as=appears_on_statement_as, - hold_uri=hold_uri, - meta=meta, - description=description, - source_uri=source_uri, - merchant_uri=merchant_uri, - on_behalf_of_uri=on_behalf_of, - ).save() + uri_gen = wac.URIGen('/credits', '{credit}') - def hold(self, amount, description=None, meta=None, source_uri=None, - appears_on_statement_as=None): - """ - Creates a new Hold that represents a reservation of money on this - Account which can be transferred via a Debit to your Marketplace - up to 7 days later. - - :param amount: Amount to hold in cents, must be >= 50 - :param description: Human readable description - :param source_uri: A specific funding source such as a `Card` - associated with this account. If not specified the `Card` most - recently added to this `Account` is used. - :param meta: Key/value collection - - :rtype: A `Hold` representing the reservation of funds from this - Account to your Marketplace. + def reverse(self, **kwargs): """ - meta = meta or {} - return Hold( - uri=self.holds_uri, - amount=amount, - meta=meta, - description=description, - source_uri=source_uri, - appears_on_statement_as=appears_on_statement_as, - ).save() + Reverse a Credit. If no amount is specified it will reverse the entire + amount of the Credit, you may create many Reversals up to the sum of + the total amount of the original Credit. - def credit(self, - amount, - description=None, - meta=None, - destination_uri=None, - appears_on_statement_as=None, - debit_uri=None): - """ - Returns a new Credit representing a transfer of funds from your - Marketplace's escrow account to this Account. - - :param amount: Amount to hold in cents - :param description: Human readable description - :param meta: Key/value collection - :param destination_uri: A specific funding destination such as a - `BankAccount` associated with this account. - :param appears_on_statement_as: description of the payment as it needs - :param debit_uri: the debit corresponding to this particular credit - - Returns: - A `Credit` representing the transfer of funds from your - Marketplace's escrow account to this Account. + :rtype: Reversal """ - meta = meta or {} - return Credit( - uri=self.credits_uri, - amount=amount, - meta=meta, - description=description, - appears_on_statement_as=appears_on_statement_as, - destination_uri=destination_uri, - debit_uri=debit_uri, + return Reversal( + href=self.reversals.href, + **kwargs ).save() - def add_card(self, card_uri): - """ - Associates the `Card` represented by `card_uri` with this `Account`. - """ - self.card_uri = card_uri - self.save() - - def add_bank_account(self, bank_account_uri): - """ - Associates the BankAccount represented by `bank_account_uri` with this - Account. - """ - self.bank_account_uri = bank_account_uri - self.save() - def promote_to_merchant(self, merchant): - """ - Underwrites this account as a merchant. The `merchant` parameter can - be either a dictionary of merchant data, or a URI. - """ - if isinstance(merchant, basestring): - self.merchant_uri = merchant - else: - self.merchant = merchant - self.save() - - def add_merchant(self, merchant): - """ - Deprecated alias of `promote_to_merchant` method. - """ - warnings.warn('The add_merchant method will be deprecated in the ' - 'next minor version of balanced-python, use the ' - 'promote_to_merchant method instead', - UserWarning) - self.promote_to_merchant(merchant) - - -def cached_per_api_key(bust_cache=False): - def cacher(f): - @functools.wraps(f) - def wrapped(*args, **kwargs): - from balanced import config, CACHE - cached = CACHE[config.api_key_secret].get(f.__name__) - if bust_cache or not cached: - cached = f(*args, **kwargs) - CACHE[config.api_key_secret][f.__name__] = cached - return cached - - return wrapped - return cacher - - -class Merchant(Resource): +class Debit(Transaction): """ + A Debit represents a transfer of funds from a FundingInstrument to your + Marketplace's escrow account. + A Debit may be created directly, or it will be created as a side-effect + of capturing a CardHold. If you create a Debit directly it will implicitly + create the associated CardHold if the FundingInstrument supports this. """ - __metaclass__ = resource_base( - collection='merchants', - resides_under_marketplace=False) - - @classproperty - @cached_per_api_key() - def me(cls): - """ - Returns the Merchant associated with your Marketplace. - :rtype: `Merchant` - """ - return cls.query.one() - @cached_per_api_key(bust_cache=True) - def save(self): - return super(Merchant, self).save() + type = 'debits' + uri_gen = wac.URIGen('/debits', '{debit}') -class Marketplace(Resource): - """ - - """ - __metaclass__ = resource_base( - collection='marketplaces', - resides_under_marketplace=False) - - def create_card(self, - name, - card_number, - expiration_month, - expiration_year, - security_code=None, - street_address=None, - city=None, - region=None, - postal_code=None, - country_code=None, - phone_number=None, - ): + def refund(self, **kwargs): """ - Tokenizes a `Card` which can then be associated with an Account. + Refunds this Debit. If no amount is specified it will refund the entire + amount of the Debit, you may create many Refunds up to the sum total + of the original Debit's amount. - :rtype: `Card` + :rtype: Refund """ - - if region: - warnings.warn('The region parameter will be deprecated in the ' - 'next minor version of balanced-python', - UserWarning) - - return Card( - card_number=card_number, - expiration_month=expiration_month, - expiration_year=expiration_year, - name=name, - security_code=security_code, - street_address=street_address, - postal_code=postal_code, - city=city, - region=region, - country_code=country_code, - phone_number=phone_number, + return Refund( + href=self.refunds.href, + **kwargs ).save() - def create_bank_account(self, - name, - account_number, - bank_code, - ): - """ - Tokenizes a `BankAccount` which can then be associated with an Account. - - :rtype: `BankAccount` - """ - return BankAccount( - uri=self.bank_accounts_uri, - name=name, - account_number=account_number, - bank_code=bank_code, - ).save() - def create_buyer(self, email_address, card_uri, name=None, meta=None): - """ - Create a buyer Account associated with this Marketplace. - """ - meta = meta or {} - return Account( - uri=self.accounts_uri, - email_address=email_address, - card_uri=card_uri, - name=name, - meta=meta, - ).save() +class Refund(Transaction): + """ + A Refund represents a reversal of funds from a Debit. A Debit can have + many Refunds associated with it up to the total amount of the original + Debit. Funds are returned to your Marketplace's escrow account + proportional to the amount of the Refund. + """ - def create_merchant(self, email_address, merchant=None, - bank_account_uri=None, name=None, meta=None, - merchant_uri=None): - """ - Creates an Account associated with this Marketplace with the role - `merchant`. + type = 'refunds' - This method may return 300 if you have not supplied enough information - for Balanced to identify the Merchant. You may re-submit the request - with more information, or redirect the Merchant to the supplied url - so they may manually sign up. + uri_gen = wac.URIGen('/refunds', '{refund}') - When you receive a `merchant_uri` from balanced, pass it in: - Account.create_merchant('mrch@example.com', - merchant_uri='/v1/TEST-MRxxxx') +class Reversal(Transaction): + """ + A Reversal represents a reversal of funds from a Credit. A Credit can have + many Reversal associated with it up to the total amount of the original + Credit. Funds are returned to your Marketplace's escrow account + proportional to the amount of the Reversal. + """ - :rtype: Account - :raises: balanced.exc.HTTPError + type = 'reversals' - Check the `status_code` and `category_code` properties of the - exception. + uri_gen = wac.URIGen('/reversals', '{reversal}') - """ - if not any([merchant, merchant_uri]): - raise ResourceError('Must have merchant or merchant_uri') - meta = meta or {} - return Account( - uri=self.accounts_uri, - email_address=email_address, - merchant=merchant, - merchant_uri=merchant_uri, - bank_account_uri=bank_account_uri, - name=name, - meta=meta, - ).save() - @staticmethod - def create_customer(**kwargs): - """ - Creates a Customer under the marketplace associated with the current - API key used for this request. +class FundingInstrument(Resource): + """ + A FundingInstrument is either (or both) a source or destination of funds. + You may perform `debit` or `credit` operations on a FundingInstrument to + transfer funds to or from your Marketplace's escrow. + """ - :rtype: Customer - :raises: balanced.exc.HTTPError + type = 'funding_instruments' - Check the `status_code` and `category_code` properties of the - exception. + def associate_to_customer(self, customer): + try: + self.links + except AttributeError: + self.links = {} + self.links['customer'] = utils.extract_href_from_object(customer) + self.save() + def debit(self, amount, **kwargs): """ - kwargs['resides_under_marketplace'] = True - return Customer(**kwargs).save() + Creates a Debit of funds from this FundingInstrument to your + Marketplace's escrow account. - @classproperty - @cached_per_api_key() - def my_marketplace(cls): - """ - Returns an instance representing the marketplace associated with the - current API key used for this request. + :param appears_on_statement_as: If None then Balanced will use the + `domain_name` property from your Marketplace. + :rtype: Debit """ - return cls.query.one() - - mine = my_marketplace - - @cached_per_api_key(bust_cache=True) - def save(self): - return super(Marketplace, self).save() - - -class Debit(Resource): - """ - A Debit represents a transfer of funds from a buyer's Account to your - Marketplace's escrow account. - - A Debit may be created directly, or it will be created as a side-effect - of capturing a Hold. If you create a Debit directly it will implicitly - create the associated Hold if the funding source supports this. - - If no Hold is specified, the Debit will by default be created using the - most recently added funding source associated with the Account. You - cannot change the funding source between creating a Hold and capturing - it. - """ - __metaclass__ = resource_base(collection='debits') + return Debit( + href=self.debits.href, + amount=amount, + **kwargs + ).save() - def refund(self, amount=None, description=None, meta=None): + def credit(self, amount, **kwargs): """ - Refunds this Debit. If no amount is specified it will refund the entire - amount of the Debit, you may create many Refunds up to the sum total - of the original Debit's amount. + Creates a Credit of funds from your Marketplace's escrow account to + this FundingInstrument. - :rtype: Refund + :rtype: Credit """ - meta = meta or {} - return Refund( - uri=self.refunds_uri, - debit_uri=self.uri, + + if not hasattr(self, 'credits'): + raise exc.FundingSourceNotCreditable() + return Credit( + href=self.credits.href, amount=amount, - description=description, - meta=meta, + **kwargs ).save() -class Transaction(Resource): +class BankAccount(FundingInstrument): """ - Any transfer, or potential transfer of, funds from or to, your Marketplace. - E.g. a Credit, Debit, Refund, or Hold. + A BankAccount is both a source, and a destination of, funds. You may + create Debits and Credits to and from, this funding instrument. """ - __metaclass__ = resource_base(collection='transactions') - -class Credit(Resource): - """ - A Credit represents a transfer of funds from your Marketplace's - escrow account to a Merchant's Account within your Marketplace. + type = 'bank_accounts' - By default, a Credit is sent to the most recently added funding - destination associated with an Account. You may specify a specific - funding source. - """ - __metaclass__ = resource_base(collection='credits', - resides_under_marketplace=False) + uri_gen = wac.URIGen('/bank_accounts', '{bank_account}') - def reverse(self, amount=None, description=None, meta=None): + def verify(self): """ - Reverse a Credit. If no amount is specified it will reverse the entire - amount of the Credit, you may create many Reversals up to the sum of the - total of the original Credit amount. + Creates a verification of the associated BankAccount so it can + perform verified operations (debits). - :rtype: Reversal + :rtype: BankAccountVerification """ - meta = meta or {} - return Reversal( - uri=self.reversals_uri, - credits_uri=self.uri, - amount=amount, - description=description, - meta=meta, + return BankAccountVerification( + href=self.bank_account_verifications.href ).save() -class Refund(Resource): +class BankAccountVerification(Resource): """ - A Refund represents a reversal of funds from a Debit. A Debit can have - many Refunds associated with it up to the total amount of the original - Debit. Funds are returned to your Marketplace's Merchant Account - proportional to the amount of the Refund. + Represents an attempt to verify the associated BankAccount so it can + perform verified operations (debits). """ - __metaclass__ = resource_base(collection='refunds') -class Reversal(Resource): - """ - A Reverse represents a reversal of funds from a Credit. A Credit can have - many Reverses associated with it up to the total amount of the original - Credit. Funds are returned to your Marketplace's Merchant Account - proportional to the amount of the Refund. - """ - __metaclass__ = resource_base(collection='reversals') + type = 'bank_account_verifications' -class Hold(Resource): - """ - A Hold is a reservation of funds on a funding source such as a Card. This - reservation is guaranteed until the `expires_at` date. You may capture - the Hold at any time before then which will create a Debit and transfer - the funds to your Marketplace. If you do not capture the Hold it will - be marked as invalid which is represented by the `is_void` field being - set to `True`. + def confirm(self, amount_1, amount_2): + self.amount_1 = amount_1 + self.amount_2 = amount_2 + return self.save() - By default a Hold is created using the most recently added funding source - on the Account. You may specify a specific funding source such as a `Card` - or `BankAccount`. +class Card(FundingInstrument): + """ + A card represents a source of funds. You may Debit funds from the Card. """ - __metaclass__ = resource_base(collection='holds') - - def void(self): - """ - Cancels an active Hold. - """ - self.is_void = True - self.save() - - def capture(self, **kwargs): - """ - Captures a valid Hold and returns a Debit representing the transfer of - funds from the buyer's Account to your Marketplace. - - :rtype: Debit - """ - participant = getattr(self, 'account', None) or self.customer - return participant.debit(hold_uri=self.uri, **kwargs) + type = 'cards' -class APIKey(Resource): - """ - Your ApiKey is used to authenticate when performing operations on the - Balanced API. + uri_gen = wac.URIGen('/cards', '{card}') - **NOTE:** Never give out or expose your ApiKey. You may POST to this - endpoint to create new ApiKeys and then DELETE any old keys. - """ - __metaclass__ = resource_base( - singular='api_key', - collection='api_keys', - resides_under_marketplace=False) + def hold(self, amount, **kwargs): + return CardHold( + href=self.card_holds.href, + amount=amount, + **kwargs + ).save() -class Card(Resource): +class Customer(Resource): """ - A card represents a source of funds for an Account. You may Hold or Debit - funds from the account associated with the Card. + A Customer represents a business or person within your Marketplace. A + Customer can have many funding instruments such as cards and bank accounts + associated to them. Customers are logical grouping constructs for + associating many Transactions and FundingInstruments. """ - __metaclass__ = resource_base(collection='cards') - @requires_participant - def debit(self, amount=None, appears_on_statement_as=None, - hold_uri=None, meta=None, description=None): - """ - Creates a Debit of funds from this Card to your Marketplace's escrow - account. + type = 'customers' - If `appears_on_statement_as` is nil, then Balanced will use the - `domain_name` property from your Marketplace. + uri_gen = wac.URIGen('/customers', '{customer}') - :rtype: Debit - """ - if not any((amount, hold_uri)): - raise ResourceError('Must have amount or hold_uri') + def create_order(self, **kwargs): + return Order(href=self.orders.href, **kwargs).save() - meta = meta or {} - participant = getattr(self, 'account', None) or self.customer - return Debit( - uri=participant.debits_uri, - amount=amount, - appears_on_statement_as=appears_on_statement_as, - hold_uri=hold_uri, - meta=meta, - description=description, - source_uri=self.uri, - ).save() - - @requires_participant - def hold(self, amount, meta=None, description=None): - """ - Creates a Hold of funds from this Card to your Marketplace. - - :rtype: Hold - """ - meta = meta or {} - participant = getattr(self, 'account', None) or self.customer - return Hold( - uri=participant.holds_uri, - amount=amount, - meta=meta, - description=description, - source_uri=self.uri, - ).save() + @property + def payable_account(self): + return self.accounts.filter(type="payable").first() -class BankAccount(Resource): +class Order(Resource): """ - A BankAccount is both a source, and a destination of, funds. You may - create Debits and Credits to and from, this funding source. + An Order is a logical construct for grouping Transactions. - *NOTE:* The BankAccount resource does not support creating a Hold. + An Order may have 0:n Transactions associated with it so long as the sum + (`amount_escrowed`) which is calculated as + (Debits - Refunds - Credits + Reversals), is always >= 0. """ - __metaclass__ = resource_base(collection='bank_accounts', - resides_under_marketplace=False) - - @requires_participant - def debit(self, amount, appears_on_statement_as=None, - meta=None, description=None): - """ - Creates a Debit of funds from this BankAccount to your Marketplace's - escrow account. - :param appears_on_statement_as: If None then Balanced will use the - `domain_name` property from your Marketplace. - :rtype: Debit - """ - if not amount or amount <= 0: - raise ResourceError('Must have an amount') - meta = meta or {} - participant = getattr(self, 'account', None) or self.customer - return Debit( - uri=participant.debits_uri, - amount=amount, - appears_on_statement_as=appears_on_statement_as, - meta=meta, - description=description, - source_uri=self.uri, - ).save() + type = 'orders' - def credit(self, amount, description=None, meta=None, appears_on_statement_as=None): - """ - Creates a Credit of funds from your Marketplace's escrow account to - this BankAccount. + uri_gen = wac.URIGen('/orders', '{order}') - :rtype: Credit - """ - if not amount or amount <= 0: - raise ResourceError('Must have an amount') + def credit_to(self, destination, amount, **kwargs): + return destination.credit(order=self.href, + amount=amount, + **kwargs) - meta = meta or {} + def debit_from(self, source, amount, **kwargs): + return source.debit(order=self.href, + amount=amount, + **kwargs) - if getattr(self, 'account', None): - uri = self.account.credits_uri - elif getattr(self, 'customer', None): - uri = self.customer.credits_uri - else: - uri = self.credits_uri - destination_uri = self.uri - credit = Credit( - uri=uri, - amount=amount, - description=description, - meta=meta, - destination_uri=destination_uri, - appears_on_statement_as=appears_on_statement_as - ) - credit.save() - return credit +class Callback(Resource): + """ + A Callback is a publicly accessible location that can receive POSTed JSON + data whenever an Event is generated. + """ - def save(self): - # default type to 'checking' on create since it was not always required - if not getattr(self, 'id', None) and not hasattr(self, 'type'): - self.type = 'checking' - return super(BankAccount, self).save() + type = 'callbacks' - def verify(self): - return BankAccountVerification( - uri=self.verifications_uri, - ).save() + uri_gen = wac.URIGen('/callbacks', '{callback}') -class BankAccountVerification(Resource): +class Dispute(Resource): """ - Represents an attempt to authenticate a funding instrument so it can - perform verified operations. + A dispute occurs when a customer disputes a transaction that + occurred on their funding instrument. """ - __metaclass__ = resource_base(collection='verifications', - nested_under=['bank_accounts'], - resides_under_marketplace=False) + type = 'disputes' - def confirm(self, amount_1, amount_2): - self.amount_1 = amount_1 - self.amount_2 = amount_2 - return self.save() + uri_gen = wac.URIGen('/disputes', '{dispute}') class Event(Resource): @@ -1189,17 +562,18 @@ class Event(Resource): created, updated, deleted or otherwise change state such as a Credit being marked as failed. """ - __metaclass__ = resource_base(collection='events', - resides_under_marketplace=False) + + type = 'events' + + uri_gen = wac.URIGen('/events', '{event}') class EventCallback(Resource): """ Represents a single event being sent to a callback. """ - __metaclass__ = resource_base(collection='callbacks', - nested_under=['events'], - resides_under_marketplace=False) + + type = 'event_callbacks' class EventCallbackLog(Resource): @@ -1207,187 +581,45 @@ class EventCallbackLog(Resource): Represents a request and response from single attempt to notify a callback of an event. """ - __metaclass__ = resource_base(collection='logs', - nested_under=['events', 'callbacks'], - resides_under_marketplace=False) + type = 'event_callback_logs' -class Callback(Resource): - """ - A Callback is a publicly accessible location that can receive POSTed JSON - data whenever an Event is generated. - """ - __metaclass__ = resource_base(collection='callbacks', - resides_under_marketplace=True) - -class Customer(Resource): +class ExternalAccount(FundingInstrument): """ - A customer represents a business or person within your Marketplace. A - customer can have many funding instruments such as cards and bank accounts - associated to them. + An External Account represents a source of funds provided by an external, 3rd + party processor. You may Debit funds from the account if can_debit is true. """ - __metaclass__ = resource_base(collection='customers', - resides_under_marketplace=False) - def add_card(self, card): - """ - Associates the `Card` represented by `card` with this `Customer`. - """ - if isinstance(card, basestring): - self.card_uri = card - elif hasattr(card, 'uri'): - self.card_uri = card.uri - else: - self.card = card - self.save() + type = 'external_accounts' - def add_bank_account(self, bank_account): - """ - Associates the `BankAccount` represented by `bank_account` with this - `Customer`. - """ - if isinstance(bank_account, basestring): - self.bank_account_uri = bank_account - elif hasattr(bank_account, 'uri'): - self.bank_account_uri = bank_account.uri - else: - self.bank_account = bank_account - self.save() + uri_gen = wac.URIGen('/external_accounts', '{external_account}') - def debit(self, - amount=None, - appears_on_statement_as=None, - hold_uri=None, - meta=None, - description=None, - source_uri=None, - merchant_uri=None, - on_behalf_of=None, - **kwargs): - """ - :rtype: A `Debit` representing a flow of money from this Customer to - your Marketplace's escrow account. - :param amount: Amount to debit in cents, must be >= 50 - :param appears_on_statement_as: description of the payment as it needs - to appear on this customer's card statement - :param meta: Key/value collection - :param description: Human readable description - :param source_uri: A specific funding source such as a `Card` - associated with this customer. If not specified the `Card` most - recently added to this `Customer` is used. - :param on_behalf_of: the customer uri of whomever is providing the - service or delivering the product. - """ - if not any((amount, hold_uri)): - raise ResourceError('Must have an amount or hold uri') - if all([hold_uri, source_uri]): - raise ResourceError( - 'Must specify only one of hold_uri OR source_uri') - - if on_behalf_of: - if hasattr(on_behalf_of, 'uri'): - on_behalf_of = on_behalf_of.uri +class Account(FundingInstrument): + """ + An Account is a way to transfer funds from multiple Orders into one place, + which can later be bulk credited out. + """ - if not isinstance(on_behalf_of, basestring): - raise ValueError( - 'The on_behalf_of parameter should to be a customer uri' - ) + type = 'accounts' - if on_behalf_of == self.uri: - raise ValueError( - 'The on_behalf_of parameter MAY NOT be the same customer' - ' as the account you are debiting!' - ) + uri_gen = wac.URIGen('/accounts', '{account}') - meta = meta or {} - return Debit( - uri=self.debits_uri, - amount=amount, - appears_on_statement_as=appears_on_statement_as, - hold_uri=hold_uri, - meta=meta, - description=description, - source_uri=source_uri, - merchant_uri=merchant_uri, - on_behalf_of_uri=on_behalf_of, + def settle(self, funding_instrument, **kwargs): + return Settlement( + href=self.settlements.href, + funding_instrument=funding_instrument, **kwargs ).save() - def credit(self, - amount, - description=None, - meta=None, - destination_uri=None, - appears_on_statement_as=None, - debit_uri=None, - **kwargs): - """ - Returns a new Credit representing a transfer of funds from your - Marketplace's escrow account to this Customer. - - :param amount: Amount to hold in cents - :param description: Human readable description - :param meta: Key/value collection - :param destination_uri: A specific funding destination such as a - `BankAccount` associated with this customer. - :param appears_on_statement_as: description of the payment as it needs - :param debit_uri: the debit corresponding to this particular credit - - Returns: - A `Credit` representing the transfer of funds from your - Marketplace's escrow account to this Customer. - """ - meta = meta or {} - return Credit( - uri=self.credits_uri, - amount=amount, - description=description, - meta=meta, - destination_uri=destination_uri, - appears_on_statement_as=appears_on_statement_as, - debit_uri=debit_uri, - **kwargs - ).save() - @property - def active_card(self): - if isinstance(self.source, Card): - return self.source - cards = self.cards.filter(is_valid=True, sort='created_at,desc') - return cards[0] if cards else None +class Settlement(Transaction): + """ + A Settlement is the action of moving money out of an Account to a + bank account. + """ - @property - def active_bank_account(self): - if isinstance(self.destination, BankAccount): - return self.destination - bank_accounts = self.bank_accounts.filter(is_valid=True, - sort='created_at,desc') - return bank_accounts[0] if bank_accounts else None - - -class FilterExpression(object): - def __init__(self, field, op, value, inv_op): - self.field = field - self.op = op - self.value = value - self.inv_op = inv_op - - def __invert__(self): - if self.inv_op is None: - raise TypeError('"{0}" cannot be inverted', self) - return FilterExpression(self.field, self.inv_op, self.value, self.op) - - def __str__(self): - return '{0} {1} {2}'.format( - self.field.name, self.field.op, self.field.values) - - -class SortExpression(object): - def __init__(self, field, ascending): - self.field = field - self.ascending = ascending - - def __invert__(self): - return SortExpression(self.field, not self.ascending) + type = 'settlements' + + uri_gen = wac.URIGen('/settlements', '{settlements}') diff --git a/balanced/utils.py b/balanced/utils.py index 3201fa7..cba22c1 100644 --- a/balanced/utils.py +++ b/balanced/utils.py @@ -1,198 +1,4 @@ -"""pretty much ripped off from Werkzeug with logic to hack around MultiDict - -Copyright: (c) 2011 by the Werkzeug Team. - -""" -import base64 -import hashlib -import hmac -import inspect - -from balanced.exc import ResourceError - - -try: - import simplejson as json -except ImportError: - import json - - -_JSON_ERROR_MSG = ( - 'Object of type {0} with value of {1} is not JSON serializable' -) - - -def iter_multi_items(mapping): - """Iterates over the items of a mapping yielding keys and values - without dropping any from more complex structures. - - """ - # do this hack to avoid importing MultiDict from werkzeug - # -- mahmoud - if hasattr(mapping, 'iteritems'): - try: - argspec = inspect.getargspec(mapping.iteritems) - except TypeError: - if isinstance(mapping, dict): - for key, value in mapping.iteritems(): - if isinstance(value, (tuple, list)): - for value in value: - yield key, value - else: - yield key, value - else: - if 'multi' in argspec.args: - for item in mapping.iteritems(multi=True): - yield item - else: - for item in mapping: - yield item - - -#: list of characters that are always safe in URLs. -_always_safe = ('ABCDEFGHIJKLMNOPQRSTUVWXYZ' - 'abcdefghijklmnopqrstuvwxyz' - '0123456789_.-') -_safe_map = dict((c, c) for c in _always_safe) -for i in xrange(0x80): - c = chr(i) - if c not in _safe_map: - _safe_map[c] = '%%%02X' % i -_safe_map.update((chr(i), '%%%02X' % i) for i in xrange(0x80, 0x100)) -_safemaps = {} - - -def _quote(s, safe='/', _join=''.join): - assert isinstance(s, str), 'quote only works on bytes' - if not s or not s.rstrip(_always_safe + safe): - return s - try: - quoter = _safemaps[safe] - except KeyError: - safe_map = _safe_map.copy() - safe_map.update([(c, c) for c in safe]) - _safemaps[safe] = quoter = safe_map.__getitem__ - return _join(map(quoter, s)) - - -def _quote_plus(s, safe=''): - if ' ' in s: - return _quote(s, safe + ' ').replace(' ', '+') - return _quote(s, safe) - - -def url_encode(obj, charset='utf-8', encode_keys=False, sort=False, key=None, - separator='&'): - """URL encode a dict/`MultiDict`. If a value is `None` it will not appear - in the result string. Per default only values are encoded into the target - charset strings. If `encode_keys` is set to ``True`` unicode keys are - supported too. - - If `sort` is set to `True` the items are sorted by `key` or the default - sorting algorithm. - - .. versionadded:: 0.5 - `sort`, `key`, and `separator` were added. - - :param obj: the object to encode into a query string. - :param charset: the charset of the query string. - :param encode_keys: set to `True` if you have unicode keys. - :param sort: set to `True` if you want parameters to be sorted by `key`. - :param separator: the separator to be used for the pairs. - :param key: an optional function to be used for sorting. For more details - check out the :func:`sorted` documentation. - """ - iterable = iter_multi_items(obj) - if sort: - iterable = sorted(iterable, key=key) - tmp = [] - for key, value in iterable: - if value is None: - continue - if encode_keys and isinstance(key, unicode): - key = key.encode(charset) - else: - key = str(key) - if isinstance(value, unicode): - value = value.encode(charset) - else: - value = str(value) - tmp.append('%s=%s' % (_quote(key), - _quote_plus(value))) - return separator.join(tmp) - - -def calculate_callback_signature(url, auh_token, params={}): - """Calculates the expected signature for a callback based on - the callback url, developer auth token and request parameters. - - :param url: the callback url. - :param auth_token: your developer auth token. - :param params: parameters passed to your callback url as a dictionary. - """ - data = url - for key in sorted(params.keys()): - data += '{0}{1}'.format(key, params[key]) - signature = hmac.new(auh_token, data, hashlib.sha1).digest() - return base64.b64encode(signature) - - -class _Missing(object): - - def __repr__(self): - return 'no value' - - def __reduce__(self): - return '_missing' - -_missing = _Missing() - - -class cached_property(object): - """A decorator that converts a function into a lazy property. The - function wrapped is called the first time to retrieve the result - and then that calculated result is used the next time you access - the value:: - - class Foo(object): - - @cached_property - def foo(self): - # calculate something important here - return 42 - - The class has to have a `__dict__` in order for this property to - work. - - .. versionchanged:: 0.6 - the `writeable` attribute and parameter was deprecated. If a - cached property is writeable or not has to be documented now. - For performance reasons the implementation does not honor the - writeable setting and will always make the property writeable. - """ - - # implementation detail: this property is implemented as non-data - # descriptor. non-data descriptors are only invoked if there is - # no entry with the same name in the instance's __dict__. - # this allows us to completely get rid of the access function call - # overhead. If one choses to invoke __get__ by hand the property - # will still work as expected because the lookup logic is replicated - # in __get__ for manual invocation. - - def __init__(self, func, name=None, doc=None): - self.__name__ = name or func.__name__ - self.__module__ = func.__module__ - self.__doc__ = doc or func.__doc__ - self.func = func - - def __get__(self, obj, type=None): - if obj is None: - return self - value = obj.__dict__.get(self.__name__, _missing) - if value is _missing: - value = self.func(obj) - obj.__dict__[self.__name__] = value - return value +from __future__ import unicode_literals class ClassPropertyDescriptor(object): @@ -226,61 +32,9 @@ def classproperty(func): return ClassPropertyDescriptor(func) -class BalancedJSONSerializer(object): - - def __init__(self, explicit_none_check=False): - self.serialization_chain = [] - self.explicit_none_check = explicit_none_check - - def add(self, callable_serializer): - self.serialization_chain.append(callable_serializer) - return self - - def __call__(self, serializable): - for serializer in self.serialization_chain: - result = serializer(serializable) - if ((not self.explicit_none_check and result) or - (self.explicit_none_check and result is not None)): - return result - - error_msg = _JSON_ERROR_MSG.format(type(serializable), - repr(serializable)) - raise TypeError(error_msg) - - -def handle_datetime(serializable): - if hasattr(serializable, 'isoformat'): - # Serialize DateTime objects to RFC3339 protocol. - # http://www.ietf.org/rfc/rfc3339.txt - return serializable.isoformat() + 'Z' - - -# should be a singleton -json_serializer = BalancedJSONSerializer() -json_serializer.add(handle_datetime) - - -def to_json(*args, **kwargs): - return json.dumps(dict(*args, **kwargs), - use_decimal=True, - default=json_serializer) - - -def urljoin(*args): - return '/'.join(map(lambda x: str(x).strip('/'), args)) - - -def requires_participant(func): - - def wrapper(self, *args, **kwargs): - - if not any([getattr(self, 'account', None), - getattr(self, 'customer', None)]): - raise ResourceError( - '{} must be associated with an account or customer'.format( - self) - ) - - return func(self, *args, **kwargs) - - return wrapper +def extract_href_from_object(obj): + if isinstance(obj, basestring): + return obj + if isinstance(obj, dict): + return obj['href'] + return obj.href diff --git a/examples/bank_account_debits.py b/examples/bank_account_debits.py index 7e53c07..280fea0 100644 --- a/examples/bank_account_debits.py +++ b/examples/bank_account_debits.py @@ -18,12 +18,11 @@ def main(): # create a bank account bank_account = balanced.BankAccount( account_number='1234567890', - bank_code='321174851', + routing_number='321174851', name='Jack Q Merchant', ).save() customer = balanced.Customer().save() - customer.add_bank_account(bank_account) - bank_account = customer.bank_accounts[0] + bank_account.associate_to_customer(customer) print 'you can\'t debit until you authenticate' try: @@ -36,15 +35,21 @@ def main(): print 'PROTIP: for TEST bank accounts the valid amount is always 1 and 1' try: - verification.confirm(1, 2) + verification.confirm(amount_1=1, amount_2=2) except balanced.exc.BankAccountVerificationFailure as ex: print 'Authentication error , %s' % ex.message - if verification.confirm(1, 1).state != 'verified': + # reload + verification = balanced.BankAccount.fetch( + bank_account.href + ).bank_account_verification + + if verification.confirm(1, 1).verification_status != 'succeeded': raise Exception('unpossible') debit = bank_account.debit(100) + print 'debited the bank account %s for %d cents' % ( - debit.source.uri, + debit.source.href, debit.amount ) print 'and there you have it' diff --git a/examples/error_handling.py b/examples/error_handling.py new file mode 100644 index 0000000..9283d89 --- /dev/null +++ b/examples/error_handling.py @@ -0,0 +1,44 @@ +from __future__ import unicode_literals + +import balanced + + +api_key = balanced.APIKey().save() +balanced.configure(api_key.secret) +marketplace = balanced.Marketplace().save() + +# https://docs.balancedpayments.com/1.1/overview/resources/#test-credit-card-numbers + +declined_card = balanced.Card( + number='4444444444444448', + expiration_month='12', + expiration_year='2015', +).save() + +bank_account = balanced.BankAccount( + account_number='1234567890', + routing_number='321174851', + name='Jack Q Merchant', +).save() + +# see https://github.com/balanced/balanced-api/blob/master/fixtures/_models/error.json for all possible error codes +try: + declined_card.debit(amount=100) +except balanced.exc.BalancedError as ex: + assert ex.category_code == 'card-declined' + +try: + bank_account.credit(amount=1000) +except balanced.exc.HTTPError as ex: + assert ex.category_code == 'insufficient-funds' + +try: + balanced.Card().save() +except balanced.exc.BalancedError as ex: + # generic missing data has a category-code of request + assert ex.category_code == 'request' + # inspect extras to see the exact field that caused the error + print ex.extras + # if you want to talk to a Balanced support person about an error, give + # them the request ID + print ex.request_id diff --git a/examples/events_and_callbacks.py b/examples/events_and_callbacks.py index 40947b1..8597185 100644 --- a/examples/events_and_callbacks.py +++ b/examples/events_and_callbacks.py @@ -26,19 +26,19 @@ def main(): url=request_bin.callback_url, ).save() + print "let's create a customer" + balanced.Customer(name='Bob McTavish').save() + print 'let\'s create a card and associate it with a new account' card = balanced.Card( expiration_month='12', - security_code='123', - card_number='5105105105105100', + csc='123', + number='5105105105105100', expiration_year='2020', ).save() - buyer = balanced.Account( - card_uri=card.uri, - ).save() print 'generate a debit (which implicitly creates and captures a hold)' - buyer.debit(100) + card.debit(100) print 'event creation is an async operation, let\'s wait until we have ' \ 'some events!' @@ -56,7 +56,7 @@ def main(): ) print 'you can inspect each event to see the logs' - event = balanced.Event.query[0] + event = balanced.Event.query.first() for callback in event.callbacks: print 'inspecting callback to {0} for event {1}'.format( callback.url, diff --git a/examples/examples.py b/examples/examples.py index 1f58ae7..463fcd4 100644 --- a/examples/examples.py +++ b/examples/examples.py @@ -1,18 +1,8 @@ from __future__ import unicode_literals -import os import balanced -host = os.environ.get('BALANCED_HOST') -options = {} -if host: - options['scheme'] = 'http' - options['host'] = host - options['port'] = 5000 - -balanced.configure(options) - print "create our new api key" api_key = balanced.APIKey().save() print "Our secret is: ", api_key.secret @@ -23,10 +13,6 @@ print "create our marketplace" marketplace = balanced.Marketplace().save() -if not balanced.Merchant.me: - raise Exception("Merchant.me should not be nil") -print "what's my merchant?, easy: Merchant.me: ", balanced.Merchant.me - # what's my marketplace? if not balanced.Marketplace.my_marketplace: raise Exception("Marketplace.my_marketplace should not be nil") @@ -44,24 +30,24 @@ print "cool! let's create a new card." card = balanced.Card( - card_number="5105105105105100", + number="5105105105105100", expiration_month="12", expiration_year="2015", ).save() -print "Our card uri: " + card.uri + +print "Our card href: " + card.href print "create our **buyer** account" -buyer = marketplace.create_buyer("buyer@example.org", card.uri) -print "our buyer account: " + buyer.uri +buyer = balanced.Customer(email="buyer@example.org", source=card).save() +print "our buyer account: " + buyer.href print "hold some amount of funds on the buyer, lets say 15$" -the_hold = buyer.hold(1500) +the_hold = card.hold(1500) print "ok, no more holds! lets just capture it (for the full amount)" debit = the_hold.capture() print "hmm, how much money do i have in escrow? should equal the debit amount" -balanced.bust_cache() marketplace = balanced.Marketplace.my_marketplace if marketplace.in_escrow != 1500: raise Exception("1500 is not in escrow! this is wrong") @@ -75,59 +61,51 @@ bank_account = balanced.BankAccount( account_number="1234567890", - bank_code="321174851", + routing_number="321174851", name="Jack Q Merchant", ).save() -merchant = marketplace.create_merchant( - "merchant@example.org", - { - 'type': "person", - 'name': "Billy Jones", +merchant = balanced.Customer( + email_address="merchant@example.org", + name="Billy Jones", + address={ 'street_address': "801 High St.", 'postal_code': "94301", 'country': "USA", - 'dob': "1842-01", - 'phone_number': "+16505551234", - }, - bank_account.uri, - "Jack Q Merchant", - ) + }, + dob="1842-01", + phone_number="+16505551234", + destination=bank_account, +).save() print "oh our buyer is interested in buying something for 130.00$" -another_debit = buyer.debit(13000, "MARKETPLACE.COM") +another_debit = card.debit(13000, appears_on_statement_as="MARKETPLACE.COM") print "lets credit our merchant 110.00$" -credit = merchant.credit(11000, "Buyer purchased something on MARKETPLACE.COM") +credit = bank_account.credit( + 11000, description="Buyer purchased something on MARKETPLACE.COM") print "lets assume the marketplace charges 15%, so it earned $20" -mp_credit = marketplace.owner_account.credit(2000, - "Our commission from MARKETPLACE" - ".COM") +mp_credit = marketplace.owner_customer.bank_accounts.first().credit( + 2000, description="Our commission from MARKETPLACE.COM") print "ok lets invalid a card" -card.is_valid = False -card.save() +card.delete() -if hasattr(card, 'is_valid') and card.is_valid: - raise Exception("This card is INCORRECTLY VALID") +assert buyer.cards.count() == 0 print "invalidating a bank account" bank_account.delete() -# a little filtering -merchants = balanced.Account.query.filter(roles='merchant') -buyers = balanced.Account.query.filter(roles='buyer') -print ( - 'we have {0} accounts, {1} with the role "buyer", ' - 'and {2} with the role "merchant"'.format( - balanced.Account.query.count(), - buyers.count(), - merchants.count(), - ) -) +print "associate a card with an exiting customer" +card = balanced.Card( + number="5105105105105100", + expiration_month="12", + expiration_year="2015", +).save() + +card.associate_to_customer(buyer) -print 'here are our merchants: {0}'.format([a.name for a in merchants]) -print 'here are our buyers: {0}'.format([a.name for a in buyers]) +assert buyer.cards.count() == 1 print "and there you have it :)" diff --git a/examples/orders.py b/examples/orders.py new file mode 100644 index 0000000..95f8d34 --- /dev/null +++ b/examples/orders.py @@ -0,0 +1,69 @@ +from __future__ import unicode_literals + +import balanced + + +key = balanced.APIKey().save() +balanced.configure(key.secret) +balanced.Marketplace().save() + +# here's the merchant customer who is going to be the recipient of the order +merchant = balanced.Customer().save() +bank_account = balanced.BankAccount( + account_number="1234567890", + routing_number="321174851", + name="Jack Q Merchant", +).save() +bank_account.associate_to_customer(merchant) + +order = merchant.create_order(description='foo order') + +card = balanced.Card( + number="5105105105105100", + expiration_month="12", + expiration_year="2015", +).save() + +# debit the card and associate with the order. +card.debit(amount=100, order=order) + +order = balanced.Order.fetch(order.href) + +# the order captured the amount of the debit +assert order.amount_escrowed == 100 + +# pay out half +credit = bank_account.credit(amount=50, order=order) + +order = balanced.Order.fetch(order.href) + +# half the money remains +assert order.amount_escrowed == 50 + +# let's try paying out to another funding instrument that is not the recipient +# of the order. +another_bank_account = balanced.BankAccount( + account_number="1234567890", + routing_number="321174851", + name="Jack Q Merchant", +).save() + +another_merchant = balanced.Customer().save() +another_bank_account.associate_to_customer(another_merchant) + +# cannot credit to a bank account which is not assigned to either the +# marketplace or the merchant associated with the order. +try: + another_credit = another_bank_account.credit(amount=50, order=order) +except balanced.exc.BalancedError as ex: + print ex + +assert ex is not None + +# bring the money back again +reversal = credit.reverse() + +order = balanced.Order.fetch(order.href) + +# order escrow is topped up again +assert order.amount_escrowed == 100 diff --git a/render_scenarios.py b/render_scenarios.py index b41aa79..df68c9b 100644 --- a/render_scenarios.py +++ b/render_scenarios.py @@ -1,14 +1,56 @@ import glob2 import os import json +import balanced +import pprint +import requests +import sys + +from pprint import PrettyPrinter from mako.template import Template from mako.lookup import TemplateLookup +class colors: + GREEN = '\033[92m' + YELLOW = '\033[93m' + RED = '\033[91m' + RESET = '\033[0m' + +SCENARIO_CACHE_URL = 'https://raw.githubusercontent.com/balanced/balanced-docs/master/scenario.cache' + +def construct_response(scenario_name): + # load up response data + data = json.load(open('scenario.cache','r')) + lookup = TemplateLookup(directories=['./scenarios']) + + for path in glob2.glob('./scenarios/**/request.mako'): + if path != scenario_name: + continue + event_name = path.split('/')[-2] + template = Template("${response}") + try: + response = data[event_name].get('response', {}) + text = template.render(response=response).strip() + response = json.loads(text) + del response["links"] + for key, value in response.items(): + response = value[0] + type = key + resource = balanced.Resource() + object_type = resource.registry[type] + object_instance = object_type() + for key, value in response.items(): + setattr(object_instance, key, value) + text = template.render(response=object_instance) + except KeyError: + text = '' + return text + def render_executables(): # load up scenario data data = json.load(open('scenario.cache','r')) lookup = TemplateLookup(directories=['./scenarios']) - + for path in glob2.glob('./scenarios/**/request.mako'): event_name = path.split('/')[-2] template = Template(filename=path, lookup=lookup,) @@ -19,8 +61,8 @@ def render_executables(): request=request, payload=payload).strip() except KeyError: text = '' - print "WARN: Skipped {} since {} not in scenario.cache".format( - path, event_name) + print colors.YELLOW + "WARN: Skipped {} since {} not in scenario.cache".format( + path, event_name) + colors.RESET with open(os.path.join(os.path.dirname(path), 'executable.py'), 'w+') as write_to: write_to.write(text) @@ -29,29 +71,32 @@ def render_mako(): for path in glob2.glob('./scenarios/**/request.mako'): dir = os.path.dirname(path) with open(os.path.join(dir, 'python.mako'), 'w+b') as wfile: - top = open(os.path.join(dir, 'definition.mako'),'r').read() - bottom = open(os.path.join(dir, 'executable.py'),'r').read() - body = "% if mode == 'definition':\n{}".format(top) + "\n% " \ - "else:\n" + bottom + "\n% endif" + definition = open(os.path.join(dir, 'definition.mako'),'r').read() + request = open(os.path.join(dir, 'executable.py'),'r').read() + response = construct_response(path) + body = "% if mode == 'definition':\n{}".format(definition) + "\n" \ + "% elif mode == 'request':\n" + request + "\n" \ + "% elif mode == 'response':\n" + response + "\n% endif" wfile.write(body) -def issue_no_mako_warnings(): - - set_has_mako = set([]) - set_no_python_mako = set([]) - for path in glob2.glob('./scenarios/**/*.mako'): - set_has_mako.add(os.path.dirname(path)) - for path in glob2.glob('./scenarios/**/python.mako'): - set_no_python_mako.add(os.path.dirname(path)) - print 'The following dont have a python.mako file. Look into it!' - print set_has_mako.difference(set_no_python_mako) - +def fetch_scenario_cache(): + try: + os.remove('scenario.cache') + except OSError: + pass + with open('scenario.cache', 'wb') as fo: + response = requests.get(SCENARIO_CACHE_URL) + if not response.ok: + sys.exit() + for block in response.iter_content(): + fo.write(block) if __name__ == "__main__": - print "Making Executables" + print colors.GREEN + "Obtaining scenario cache..." + colors.RESET + fetch_scenario_cache() + print colors.GREEN + "Making Executables..." + colors.RESET render_executables() - print "Rendering new mako files" + print colors.GREEN + "Rendering new mako files..." + colors.RESET render_mako() - issue_no_mako_warnings() diff --git a/requirements-docs.txt b/requirements-docs.txt deleted file mode 100644 index 99bd51b..0000000 --- a/requirements-docs.txt +++ /dev/null @@ -1,4 +0,0 @@ -Sphinx -boto -glob2 -mako>=0.7 diff --git a/requirements.txt b/requirements.txt index d16e568..77e1d61 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,3 @@ -certifi==0.0.8 -chardet==1.0.1 -simplejson==2.3.2 +wac==0.23 iso8601==0.1.4 -requests==1.2.3 -mock>=0.8,<0.9 +uritemplate==0.6 diff --git a/scenario.cache b/scenario.cache deleted file mode 100644 index 8f3ce7c..0000000 --- a/scenario.cache +++ /dev/null @@ -1,553 +0,0 @@ -{ - "account_add_card": { - "request": { - "payload": { - "card_uri": "/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/cards/CC4Zor9L2DEKXy0LJJ8PtkMM" - }, - "uri": "/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU4WT2fC14gzGQIEcMKs5gm3" - }, - "response": "{\n \"_type\": \"account\", \n \"_uris\": {\n \"bank_accounts_uri\": {\n \"_type\": \"page\", \n \"key\": \"bank_accounts\"\n }, \n \"cards_uri\": {\n \"_type\": \"page\", \n \"key\": \"cards\"\n }, \n \"credits_uri\": {\n \"_type\": \"page\", \n \"key\": \"credits\"\n }, \n \"customer_uri\": {\n \"_type\": \"customer\", \n \"key\": \"customer\"\n }, \n \"debits_uri\": {\n \"_type\": \"page\", \n \"key\": \"debits\"\n }, \n \"holds_uri\": {\n \"_type\": \"page\", \n \"key\": \"holds\"\n }, \n \"refunds_uri\": {\n \"_type\": \"page\", \n \"key\": \"refunds\"\n }, \n \"reversals_uri\": {\n \"_type\": \"page\", \n \"key\": \"reversals\"\n }, \n \"transactions_uri\": {\n \"_type\": \"page\", \n \"key\": \"transactions\"\n }\n }, \n \"bank_accounts_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU4WT2fC14gzGQIEcMKs5gm3/bank_accounts\", \n \"cards_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU4WT2fC14gzGQIEcMKs5gm3/cards\", \n \"created_at\": \"2013-11-14T16:20:11.280063Z\", \n \"credits_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU4WT2fC14gzGQIEcMKs5gm3/credits\", \n \"customer_uri\": \"/v1/customers/CU4WT2fC14gzGQIEcMKs5gm3\", \n \"debits_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU4WT2fC14gzGQIEcMKs5gm3/debits\", \n \"email_address\": null, \n \"holds_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU4WT2fC14gzGQIEcMKs5gm3/holds\", \n \"id\": \"CU4WT2fC14gzGQIEcMKs5gm3\", \n \"meta\": {}, \n \"name\": null, \n \"refunds_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU4WT2fC14gzGQIEcMKs5gm3/refunds\", \n \"reversals_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU4WT2fC14gzGQIEcMKs5gm3/reversals\", \n \"roles\": [\n \"buyer\"\n ], \n \"transactions_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU4WT2fC14gzGQIEcMKs5gm3/transactions\", \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU4WT2fC14gzGQIEcMKs5gm3\"\n}" - }, - "account_create": { - "request": { - "uri": "/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts" - }, - "response": "{\n \"_type\": \"account\", \n \"_uris\": {\n \"bank_accounts_uri\": {\n \"_type\": \"page\", \n \"key\": \"bank_accounts\"\n }, \n \"cards_uri\": {\n \"_type\": \"page\", \n \"key\": \"cards\"\n }, \n \"credits_uri\": {\n \"_type\": \"page\", \n \"key\": \"credits\"\n }, \n \"customer_uri\": {\n \"_type\": \"customer\", \n \"key\": \"customer\"\n }, \n \"debits_uri\": {\n \"_type\": \"page\", \n \"key\": \"debits\"\n }, \n \"holds_uri\": {\n \"_type\": \"page\", \n \"key\": \"holds\"\n }, \n \"refunds_uri\": {\n \"_type\": \"page\", \n \"key\": \"refunds\"\n }, \n \"reversals_uri\": {\n \"_type\": \"page\", \n \"key\": \"reversals\"\n }, \n \"transactions_uri\": {\n \"_type\": \"page\", \n \"key\": \"transactions\"\n }\n }, \n \"bank_accounts_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU4S5l8l03hjVGvqrJNY0mqA/bank_accounts\", \n \"cards_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU4S5l8l03hjVGvqrJNY0mqA/cards\", \n \"created_at\": \"2013-11-14T16:20:07.018999Z\", \n \"credits_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU4S5l8l03hjVGvqrJNY0mqA/credits\", \n \"customer_uri\": \"/v1/customers/CU4S5l8l03hjVGvqrJNY0mqA\", \n \"debits_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU4S5l8l03hjVGvqrJNY0mqA/debits\", \n \"email_address\": null, \n \"holds_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU4S5l8l03hjVGvqrJNY0mqA/holds\", \n \"id\": \"CU4S5l8l03hjVGvqrJNY0mqA\", \n \"meta\": {}, \n \"name\": null, \n \"refunds_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU4S5l8l03hjVGvqrJNY0mqA/refunds\", \n \"reversals_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU4S5l8l03hjVGvqrJNY0mqA/reversals\", \n \"roles\": [], \n \"transactions_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU4S5l8l03hjVGvqrJNY0mqA/transactions\", \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU4S5l8l03hjVGvqrJNY0mqA\"\n}" - }, - "account_create_buyer": { - "request": { - "payload": { - "card_uri": "/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/cards/CC4WeeR0OUiQh9vvqNQvMl1o" - }, - "uri": "/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts" - }, - "response": "{\n \"_type\": \"account\", \n \"_uris\": {\n \"bank_accounts_uri\": {\n \"_type\": \"page\", \n \"key\": \"bank_accounts\"\n }, \n \"cards_uri\": {\n \"_type\": \"page\", \n \"key\": \"cards\"\n }, \n \"credits_uri\": {\n \"_type\": \"page\", \n \"key\": \"credits\"\n }, \n \"customer_uri\": {\n \"_type\": \"customer\", \n \"key\": \"customer\"\n }, \n \"debits_uri\": {\n \"_type\": \"page\", \n \"key\": \"debits\"\n }, \n \"holds_uri\": {\n \"_type\": \"page\", \n \"key\": \"holds\"\n }, \n \"refunds_uri\": {\n \"_type\": \"page\", \n \"key\": \"refunds\"\n }, \n \"reversals_uri\": {\n \"_type\": \"page\", \n \"key\": \"reversals\"\n }, \n \"transactions_uri\": {\n \"_type\": \"page\", \n \"key\": \"transactions\"\n }\n }, \n \"bank_accounts_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU4WT2fC14gzGQIEcMKs5gm3/bank_accounts\", \n \"cards_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU4WT2fC14gzGQIEcMKs5gm3/cards\", \n \"created_at\": \"2013-11-14T16:20:11.280063Z\", \n \"credits_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU4WT2fC14gzGQIEcMKs5gm3/credits\", \n \"customer_uri\": \"/v1/customers/CU4WT2fC14gzGQIEcMKs5gm3\", \n \"debits_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU4WT2fC14gzGQIEcMKs5gm3/debits\", \n \"email_address\": null, \n \"holds_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU4WT2fC14gzGQIEcMKs5gm3/holds\", \n \"id\": \"CU4WT2fC14gzGQIEcMKs5gm3\", \n \"meta\": {}, \n \"name\": null, \n \"refunds_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU4WT2fC14gzGQIEcMKs5gm3/refunds\", \n \"reversals_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU4WT2fC14gzGQIEcMKs5gm3/reversals\", \n \"roles\": [\n \"buyer\"\n ], \n \"transactions_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU4WT2fC14gzGQIEcMKs5gm3/transactions\", \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU4WT2fC14gzGQIEcMKs5gm3\"\n}" - }, - "account_create_merchant": { - "request": { - "payload": { - "bank_account_uri": "/v1/bank_accounts/BA53NVwHAXYx7fo98SdK41dg" - }, - "uri": "/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU4WT2fC14gzGQIEcMKs5gm3" - }, - "response": "{\n \"_type\": \"account\", \n \"_uris\": {\n \"bank_accounts_uri\": {\n \"_type\": \"page\", \n \"key\": \"bank_accounts\"\n }, \n \"cards_uri\": {\n \"_type\": \"page\", \n \"key\": \"cards\"\n }, \n \"credits_uri\": {\n \"_type\": \"page\", \n \"key\": \"credits\"\n }, \n \"customer_uri\": {\n \"_type\": \"customer\", \n \"key\": \"customer\"\n }, \n \"debits_uri\": {\n \"_type\": \"page\", \n \"key\": \"debits\"\n }, \n \"holds_uri\": {\n \"_type\": \"page\", \n \"key\": \"holds\"\n }, \n \"refunds_uri\": {\n \"_type\": \"page\", \n \"key\": \"refunds\"\n }, \n \"reversals_uri\": {\n \"_type\": \"page\", \n \"key\": \"reversals\"\n }, \n \"transactions_uri\": {\n \"_type\": \"page\", \n \"key\": \"transactions\"\n }\n }, \n \"bank_accounts_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU4WT2fC14gzGQIEcMKs5gm3/bank_accounts\", \n \"cards_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU4WT2fC14gzGQIEcMKs5gm3/cards\", \n \"created_at\": \"2013-11-14T16:20:11.280063Z\", \n \"credits_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU4WT2fC14gzGQIEcMKs5gm3/credits\", \n \"customer_uri\": \"/v1/customers/CU4WT2fC14gzGQIEcMKs5gm3\", \n \"debits_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU4WT2fC14gzGQIEcMKs5gm3/debits\", \n \"email_address\": null, \n \"holds_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU4WT2fC14gzGQIEcMKs5gm3/holds\", \n \"id\": \"CU4WT2fC14gzGQIEcMKs5gm3\", \n \"meta\": {}, \n \"name\": null, \n \"refunds_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU4WT2fC14gzGQIEcMKs5gm3/refunds\", \n \"reversals_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU4WT2fC14gzGQIEcMKs5gm3/reversals\", \n \"roles\": [\n \"buyer\"\n ], \n \"transactions_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU4WT2fC14gzGQIEcMKs5gm3/transactions\", \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU4WT2fC14gzGQIEcMKs5gm3\"\n}" - }, - "account_underwrite_business": { - "request": { - "accounts_uri": "/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts", - "payload": { - "merchant": { - "name": "Skripts4Kids", - "person": { - "dob": "1989-12", - "name": "Timmy Q. CopyPasta", - "phone_number": "+14089999999", - "postal_code": "94110", - "street_address": "121 Skriptkid Row" - }, - "phone_number": "+140899188155", - "postal_code": "91111", - "street_address": "555 VoidMain Road", - "tax_id": "211111111", - "type": "business" - } - } - }, - "response": "{\n \"_type\": \"account\", \n \"_uris\": {\n \"bank_accounts_uri\": {\n \"_type\": \"page\", \n \"key\": \"bank_accounts\"\n }, \n \"cards_uri\": {\n \"_type\": \"page\", \n \"key\": \"cards\"\n }, \n \"credits_uri\": {\n \"_type\": \"page\", \n \"key\": \"credits\"\n }, \n \"customer_uri\": {\n \"_type\": \"customer\", \n \"key\": \"customer\"\n }, \n \"debits_uri\": {\n \"_type\": \"page\", \n \"key\": \"debits\"\n }, \n \"holds_uri\": {\n \"_type\": \"page\", \n \"key\": \"holds\"\n }, \n \"refunds_uri\": {\n \"_type\": \"page\", \n \"key\": \"refunds\"\n }, \n \"reversals_uri\": {\n \"_type\": \"page\", \n \"key\": \"reversals\"\n }, \n \"transactions_uri\": {\n \"_type\": \"page\", \n \"key\": \"transactions\"\n }\n }, \n \"bank_accounts_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU5brkNgZQFhaaVoBuaGTGm2/bank_accounts\", \n \"cards_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU5brkNgZQFhaaVoBuaGTGm2/cards\", \n \"created_at\": \"2013-11-14T16:20:24.232747Z\", \n \"credits_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU5brkNgZQFhaaVoBuaGTGm2/credits\", \n \"customer_uri\": \"/v1/customers/CU5brkNgZQFhaaVoBuaGTGm2\", \n \"debits_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU5brkNgZQFhaaVoBuaGTGm2/debits\", \n \"email_address\": null, \n \"holds_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU5brkNgZQFhaaVoBuaGTGm2/holds\", \n \"id\": \"CU5brkNgZQFhaaVoBuaGTGm2\", \n \"meta\": {}, \n \"name\": \"Timmy Q. CopyPasta\", \n \"refunds_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU5brkNgZQFhaaVoBuaGTGm2/refunds\", \n \"reversals_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU5brkNgZQFhaaVoBuaGTGm2/reversals\", \n \"roles\": [\n \"merchant\"\n ], \n \"transactions_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU5brkNgZQFhaaVoBuaGTGm2/transactions\", \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU5brkNgZQFhaaVoBuaGTGm2\"\n}" - }, - "account_underwrite_person": { - "request": { - "accounts_uri": "/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts", - "payload": { - "merchant": { - "dob": "1989-12", - "name": "Timmy Q. CopyPasta", - "phone_number": "+14089999999", - "postal_code": "94110", - "street_address": "121 Skriptkid Row", - "type": "person" - } - } - }, - "response": "{\n \"_type\": \"account\", \n \"_uris\": {\n \"bank_accounts_uri\": {\n \"_type\": \"page\", \n \"key\": \"bank_accounts\"\n }, \n \"cards_uri\": {\n \"_type\": \"page\", \n \"key\": \"cards\"\n }, \n \"credits_uri\": {\n \"_type\": \"page\", \n \"key\": \"credits\"\n }, \n \"customer_uri\": {\n \"_type\": \"customer\", \n \"key\": \"customer\"\n }, \n \"debits_uri\": {\n \"_type\": \"page\", \n \"key\": \"debits\"\n }, \n \"holds_uri\": {\n \"_type\": \"page\", \n \"key\": \"holds\"\n }, \n \"refunds_uri\": {\n \"_type\": \"page\", \n \"key\": \"refunds\"\n }, \n \"reversals_uri\": {\n \"_type\": \"page\", \n \"key\": \"reversals\"\n }, \n \"transactions_uri\": {\n \"_type\": \"page\", \n \"key\": \"transactions\"\n }\n }, \n \"bank_accounts_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU58OQXiQbnSls6eAaDfeLzp/bank_accounts\", \n \"cards_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU58OQXiQbnSls6eAaDfeLzp/cards\", \n \"created_at\": \"2013-11-14T16:20:21.889378Z\", \n \"credits_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU58OQXiQbnSls6eAaDfeLzp/credits\", \n \"customer_uri\": \"/v1/customers/CU58OQXiQbnSls6eAaDfeLzp\", \n \"debits_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU58OQXiQbnSls6eAaDfeLzp/debits\", \n \"email_address\": null, \n \"holds_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU58OQXiQbnSls6eAaDfeLzp/holds\", \n \"id\": \"CU58OQXiQbnSls6eAaDfeLzp\", \n \"meta\": {}, \n \"name\": \"Timmy Q. CopyPasta\", \n \"refunds_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU58OQXiQbnSls6eAaDfeLzp/refunds\", \n \"reversals_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU58OQXiQbnSls6eAaDfeLzp/reversals\", \n \"roles\": [\n \"merchant\"\n ], \n \"transactions_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU58OQXiQbnSls6eAaDfeLzp/transactions\", \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU58OQXiQbnSls6eAaDfeLzp\"\n}" - }, - "api_key": "ak-test-2KZfoLyijij3Y6OyhDAvFRF9tXzelBLpD", - "api_location": "https://api.balancedpayments.com", - "bank_account_create": { - "request": { - "payload": { - "account_number": "9900000001", - "name": "Johann Bernoulli", - "routing_number": "121000358", - "type": "checking" - }, - "uri": "/v1/bank_accounts" - }, - "response": "{\n \"_type\": \"bank_account\", \n \"_uris\": {\n \"credits_uri\": {\n \"_type\": \"page\", \n \"key\": \"credits\"\n }, \n \"debits_uri\": {\n \"_type\": \"page\", \n \"key\": \"debits\"\n }, \n \"verifications_uri\": {\n \"_type\": \"page\", \n \"key\": \"verifications\"\n }\n }, \n \"account_number\": \"xxxxxx0001\", \n \"bank_name\": \"BANK OF AMERICA, N.A.\", \n \"can_debit\": false, \n \"created_at\": \"2013-11-14T16:21:31.019599Z\", \n \"credits_uri\": \"/v1/bank_accounts/BA6oxYWJXxeM63vMorgtSIhI/credits\", \n \"customer\": null, \n \"debits_uri\": \"/v1/bank_accounts/BA6oxYWJXxeM63vMorgtSIhI/debits\", \n \"fingerprint\": \"5f0ba9fa3f1122ef13b944a40abfe44e7eba9e16934e64200913cb4c402ace14\", \n \"id\": \"BA6oxYWJXxeM63vMorgtSIhI\", \n \"meta\": {}, \n \"name\": \"Johann Bernoulli\", \n \"routing_number\": \"121000358\", \n \"type\": \"checking\", \n \"uri\": \"/v1/bank_accounts/BA6oxYWJXxeM63vMorgtSIhI\", \n \"verification_uri\": null, \n \"verifications_uri\": \"/v1/bank_accounts/BA6oxYWJXxeM63vMorgtSIhI/verifications\"\n}" - }, - "bank_account_delete": { - "request": { - "uri": "/v1/bank_accounts/BA5uvDqG8xk4bGmwX3JTbIee" - } - }, - "bank_account_invalid_routing_number": { - "request": { - "payload": { - "account_number": "9900000001", - "name": "Johann Bernoulli", - "routing_number": "100000007", - "type": "checking" - }, - "uri": "/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/bank_accounts" - }, - "response": "{\n \"_uris\": {}, \n \"additional\": null, \n \"category_code\": \"invalid-routing-number\", \n \"category_type\": \"request\", \n \"description\": \"Routing number is invalid. Your request id is OHMea3158084d4c11e38a5302a1fe52a36c.\", \n \"extras\": {\n \"routing_number\": \"Routing number is invalid.\"\n }, \n \"request_id\": \"OHMea3158084d4c11e38a5302a1fe52a36c\", \n \"status\": \"Bad Request\", \n \"status_code\": 400\n}" - }, - "bank_account_list": { - "request": { - "uri": "/v1/bank_accounts" - }, - "response": "{\n \"_type\": \"page\", \n \"_uris\": {\n \"first_uri\": {\n \"_type\": \"page\", \n \"key\": \"first\"\n }, \n \"last_uri\": {\n \"_type\": \"page\", \n \"key\": \"last\"\n }, \n \"next_uri\": {\n \"_type\": \"page\", \n \"key\": \"next\"\n }, \n \"previous_uri\": {\n \"_type\": \"page\", \n \"key\": \"previous\"\n }\n }, \n \"first_uri\": \"/v1/bank_accounts?limit=2&offset=0\", \n \"items\": [\n {\n \"_type\": \"bank_account\", \n \"_uris\": {\n \"credits_uri\": {\n \"_type\": \"page\", \n \"key\": \"credits\"\n }, \n \"debits_uri\": {\n \"_type\": \"page\", \n \"key\": \"debits\"\n }, \n \"verifications_uri\": {\n \"_type\": \"page\", \n \"key\": \"verifications\"\n }\n }, \n \"account_number\": \"xxxxxx0001\", \n \"bank_name\": \"BANK OF AMERICA, N.A.\", \n \"can_debit\": false, \n \"created_at\": \"2013-11-14T16:20:46.183358Z\", \n \"credits_uri\": \"/v1/bank_accounts/BA5A8YcoSCEPQyCaPCTvmFnW/credits\", \n \"customer\": null, \n \"debits_uri\": \"/v1/bank_accounts/BA5A8YcoSCEPQyCaPCTvmFnW/debits\", \n \"fingerprint\": \"5f0ba9fa3f1122ef13b944a40abfe44e7eba9e16934e64200913cb4c402ace14\", \n \"id\": \"BA5A8YcoSCEPQyCaPCTvmFnW\", \n \"meta\": {}, \n \"name\": \"Johann Bernoulli\", \n \"routing_number\": \"121000358\", \n \"type\": \"checking\", \n \"uri\": \"/v1/bank_accounts/BA5A8YcoSCEPQyCaPCTvmFnW\", \n \"verification_uri\": null, \n \"verifications_uri\": \"/v1/bank_accounts/BA5A8YcoSCEPQyCaPCTvmFnW/verifications\"\n }, \n {\n \"_type\": \"bank_account\", \n \"_uris\": {\n \"credits_uri\": {\n \"_type\": \"page\", \n \"key\": \"credits\"\n }, \n \"debits_uri\": {\n \"_type\": \"page\", \n \"key\": \"debits\"\n }, \n \"verification_uri\": {\n \"_type\": \"bank_account_authentication\", \n \"key\": \"verification\"\n }, \n \"verifications_uri\": {\n \"_type\": \"page\", \n \"key\": \"verifications\"\n }\n }, \n \"account_number\": \"xxxxxx0001\", \n \"bank_name\": \"SAN MATEO CREDIT UNION\", \n \"can_debit\": true, \n \"created_at\": \"2013-11-14T16:20:41.178834Z\", \n \"credits_uri\": \"/v1/bank_accounts/BA5uvDqG8xk4bGmwX3JTbIee/credits\", \n \"customer\": {\n \"_type\": \"customer\", \n \"_uris\": {\n \"bank_accounts_uri\": {\n \"_type\": \"page\", \n \"key\": \"bank_accounts\"\n }, \n \"cards_uri\": {\n \"_type\": \"page\", \n \"key\": \"cards\"\n }, \n \"credits_uri\": {\n \"_type\": \"page\", \n \"key\": \"credits\"\n }, \n \"debits_uri\": {\n \"_type\": \"page\", \n \"key\": \"debits\"\n }, \n \"destination_uri\": {\n \"_type\": \"bank_account\", \n \"key\": \"destination\"\n }, \n \"holds_uri\": {\n \"_type\": \"page\", \n \"key\": \"holds\"\n }, \n \"refunds_uri\": {\n \"_type\": \"page\", \n \"key\": \"refunds\"\n }, \n \"reversals_uri\": {\n \"_type\": \"page\", \n \"key\": \"reversals\"\n }, \n \"source_uri\": {\n \"_type\": \"bank_account\", \n \"key\": \"source\"\n }, \n \"transactions_uri\": {\n \"_type\": \"page\", \n \"key\": \"transactions\"\n }\n }, \n \"address\": {\n \"country_code\": \"USA\"\n }, \n \"bank_accounts_uri\": \"/v1/customers/CU5uQkLqcmDGZtSV5BITGri0/bank_accounts\", \n \"business_name\": null, \n \"cards_uri\": \"/v1/customers/CU5uQkLqcmDGZtSV5BITGri0/cards\", \n \"created_at\": \"2013-11-14T16:20:41.479001Z\", \n \"credits_uri\": \"/v1/customers/CU5uQkLqcmDGZtSV5BITGri0/credits\", \n \"debits_uri\": \"/v1/customers/CU5uQkLqcmDGZtSV5BITGri0/debits\", \n \"destination_uri\": \"/v1/customers/CU5uQkLqcmDGZtSV5BITGri0/bank_accounts/BA5uvDqG8xk4bGmwX3JTbIee\", \n \"dob\": null, \n \"ein\": null, \n \"email\": null, \n \"facebook\": null, \n \"holds_uri\": \"/v1/customers/CU5uQkLqcmDGZtSV5BITGri0/holds\", \n \"id\": \"CU5uQkLqcmDGZtSV5BITGri0\", \n \"is_identity_verified\": false, \n \"meta\": {}, \n \"name\": null, \n \"phone\": null, \n \"refunds_uri\": \"/v1/customers/CU5uQkLqcmDGZtSV5BITGri0/refunds\", \n \"reversals_uri\": \"/v1/customers/CU5uQkLqcmDGZtSV5BITGri0/reversals\", \n \"source_uri\": \"/v1/customers/CU5uQkLqcmDGZtSV5BITGri0/bank_accounts/BA5uvDqG8xk4bGmwX3JTbIee\", \n \"ssn_last4\": null, \n \"transactions_uri\": \"/v1/customers/CU5uQkLqcmDGZtSV5BITGri0/transactions\", \n \"twitter\": null, \n \"uri\": \"/v1/customers/CU5uQkLqcmDGZtSV5BITGri0\"\n }, \n \"debits_uri\": \"/v1/bank_accounts/BA5uvDqG8xk4bGmwX3JTbIee/debits\", \n \"fingerprint\": \"5f0ba9fa3f1122ef13b944a40abfe44e7eba9e16934e64200913cb4c402ace14\", \n \"id\": \"BA5uvDqG8xk4bGmwX3JTbIee\", \n \"meta\": {}, \n \"name\": \"Johann Bernoulli\", \n \"routing_number\": \"321174851\", \n \"type\": \"checking\", \n \"uri\": \"/v1/bank_accounts/BA5uvDqG8xk4bGmwX3JTbIee\", \n \"verification_uri\": \"/v1/bank_accounts/BA5uvDqG8xk4bGmwX3JTbIee/verifications/BZ5wpXXDTZxqLCHiX6V4XXvA\", \n \"verifications_uri\": \"/v1/bank_accounts/BA5uvDqG8xk4bGmwX3JTbIee/verifications\"\n }\n ], \n \"last_uri\": \"/v1/bank_accounts?limit=2&offset=4\", \n \"limit\": 2, \n \"next_uri\": \"/v1/bank_accounts?limit=2&offset=2\", \n \"offset\": 0, \n \"previous_uri\": null, \n \"total\": 6, \n \"uri\": \"/v1/bank_accounts?limit=2&offset=0\"\n}" - }, - "bank_account_show": { - "request": { - "uri": "/v1/bank_accounts/BA5A8YcoSCEPQyCaPCTvmFnW" - }, - "response": "{\n \"_type\": \"bank_account\", \n \"_uris\": {\n \"credits_uri\": {\n \"_type\": \"page\", \n \"key\": \"credits\"\n }, \n \"debits_uri\": {\n \"_type\": \"page\", \n \"key\": \"debits\"\n }, \n \"verifications_uri\": {\n \"_type\": \"page\", \n \"key\": \"verifications\"\n }\n }, \n \"account_number\": \"xxxxxx0001\", \n \"bank_name\": \"BANK OF AMERICA, N.A.\", \n \"can_debit\": false, \n \"created_at\": \"2013-11-14T16:20:46.183358Z\", \n \"credits_uri\": \"/v1/bank_accounts/BA5A8YcoSCEPQyCaPCTvmFnW/credits\", \n \"customer\": null, \n \"debits_uri\": \"/v1/bank_accounts/BA5A8YcoSCEPQyCaPCTvmFnW/debits\", \n \"fingerprint\": \"5f0ba9fa3f1122ef13b944a40abfe44e7eba9e16934e64200913cb4c402ace14\", \n \"id\": \"BA5A8YcoSCEPQyCaPCTvmFnW\", \n \"meta\": {}, \n \"name\": \"Johann Bernoulli\", \n \"routing_number\": \"121000358\", \n \"type\": \"checking\", \n \"uri\": \"/v1/bank_accounts/BA5A8YcoSCEPQyCaPCTvmFnW\", \n \"verification_uri\": null, \n \"verifications_uri\": \"/v1/bank_accounts/BA5A8YcoSCEPQyCaPCTvmFnW/verifications\"\n}" - }, - "bank_account_verification_create": { - "request": { - "bank_account_uri": "/v1/bank_accounts/BA5gy1b8X8dIGaBWFuoWvkxO", - "uri": "/v1/bank_accounts/BA5gy1b8X8dIGaBWFuoWvkxO/verifications" - }, - "response": "{\n \"_type\": \"bank_account_authentication\", \n \"_uris\": {}, \n \"attempts\": 0, \n \"created_at\": \"2013-11-14T16:20:32.104822Z\", \n \"id\": \"BZ5kihRbLIgd64iMWFkWesdw\", \n \"remaining_attempts\": 3, \n \"state\": \"deposit_succeeded\", \n \"updated_at\": \"2013-11-14T16:20:32.600599Z\", \n \"uri\": \"/v1/bank_accounts/BA5gy1b8X8dIGaBWFuoWvkxO/verifications/BZ5kihRbLIgd64iMWFkWesdw\"\n}" - }, - "bank_account_verification_show": { - "request": { - "bank_account_uri": "/v1/bank_accounts/BA5nW8SMsXjaU3GVWdhR9d60", - "uri": "/v1/bank_accounts/BA5nW8SMsXjaU3GVWdhR9d60/verifications/BZ5rcuNvebC49kZyTGAaJu2A" - }, - "response": "{\n \"_type\": \"bank_account_authentication\", \n \"_uris\": {}, \n \"attempts\": 0, \n \"created_at\": \"2013-11-14T16:20:38.229597Z\", \n \"id\": \"BZ5rcuNvebC49kZyTGAaJu2A\", \n \"remaining_attempts\": 3, \n \"state\": \"deposit_succeeded\", \n \"updated_at\": \"2013-11-14T16:20:38.546816Z\", \n \"uri\": \"/v1/bank_accounts/BA5nW8SMsXjaU3GVWdhR9d60/verifications/BZ5rcuNvebC49kZyTGAaJu2A\"\n}" - }, - "bank_account_verification_update": { - "request": { - "bank_account_uri": "/v1/bank_accounts/BA5uvDqG8xk4bGmwX3JTbIee", - "payload": { - "amount_1": 1, - "amount_2": 1 - }, - "uri": "/v1/bank_accounts/BA5uvDqG8xk4bGmwX3JTbIee/verifications/BZ5wpXXDTZxqLCHiX6V4XXvA" - }, - "response": "{\n \"_type\": \"bank_account_authentication\", \n \"_uris\": {}, \n \"attempts\": 1, \n \"created_at\": \"2013-11-14T16:20:42.870606Z\", \n \"id\": \"BZ5wpXXDTZxqLCHiX6V4XXvA\", \n \"remaining_attempts\": 2, \n \"state\": \"verified\", \n \"updated_at\": \"2013-11-14T16:20:44.324057Z\", \n \"uri\": \"/v1/bank_accounts/BA5uvDqG8xk4bGmwX3JTbIee/verifications/BZ5wpXXDTZxqLCHiX6V4XXvA\"\n}" - }, - "callback_create": { - "request": { - "payload": { - "url": "http://www.example.com/callback" - }, - "uri": "/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/callbacks" - }, - "response": "{\n \"_type\": \"callback\", \n \"_uris\": {}, \n \"id\": \"CB5GFgGfugkhbKueLUJL6hAa\", \n \"method\": \"post\", \n \"uri\": \"/v1/callbacks/CB5GFgGfugkhbKueLUJL6hAa\", \n \"url\": \"http://www.example.com/callback\"\n}" - }, - "callback_delete": { - "request": { - "uri": "/v1/callbacks/CB5GFgGfugkhbKueLUJL6hAa" - } - }, - "callback_list": { - "request": { - "uri": "/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/callbacks" - }, - "response": "{\n \"_type\": \"page\", \n \"_uris\": {\n \"first_uri\": {\n \"_type\": \"page\", \n \"key\": \"first\"\n }, \n \"last_uri\": {\n \"_type\": \"page\", \n \"key\": \"last\"\n }, \n \"next_uri\": {\n \"_type\": \"page\", \n \"key\": \"next\"\n }, \n \"previous_uri\": {\n \"_type\": \"page\", \n \"key\": \"previous\"\n }\n }, \n \"first_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/callbacks?limit=2&offset=0\", \n \"items\": [\n {\n \"_type\": \"callback\", \n \"_uris\": {}, \n \"id\": \"CB5GFgGfugkhbKueLUJL6hAa\", \n \"method\": \"post\", \n \"uri\": \"/v1/callbacks/CB5GFgGfugkhbKueLUJL6hAa\", \n \"url\": \"http://www.example.com/callback\"\n }\n ], \n \"last_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/callbacks?limit=2&offset=0\", \n \"limit\": 2, \n \"next_uri\": null, \n \"offset\": 0, \n \"previous_uri\": null, \n \"total\": 1, \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/callbacks?limit=2&offset=0\"\n}" - }, - "callback_show": { - "request": { - "uri": "/v1/callbacks/CB5GFgGfugkhbKueLUJL6hAa" - }, - "response": "{\n \"_type\": \"callback\", \n \"_uris\": {}, \n \"id\": \"CB5GFgGfugkhbKueLUJL6hAa\", \n \"method\": \"post\", \n \"uri\": \"/v1/callbacks/CB5GFgGfugkhbKueLUJL6hAa\", \n \"url\": \"http://www.example.com/callback\"\n}" - }, - "card_create": { - "request": { - "payload": { - "card_number": "5105105105105100", - "expiration_month": "12", - "expiration_year": "2020", - "security_code": "123" - }, - "uri": "/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/cards" - }, - "response": "{\n \"_type\": \"card\", \n \"_uris\": {}, \n \"account\": null, \n \"brand\": \"MasterCard\", \n \"card_type\": \"mastercard\", \n \"country_code\": null, \n \"created_at\": \"2013-11-14T16:50:44.333724Z\", \n \"customer\": null, \n \"expiration_month\": 12, \n \"expiration_year\": 2020, \n \"hash\": \"fc4ccd5de54f42a5e75f76fbfde60948440c7a382ee7d21b2bc509ab9cfed788\", \n \"id\": \"CC72hXVwWbCJsozvJoRELzIc\", \n \"is_valid\": true, \n \"is_verified\": true, \n \"last_four\": \"5100\", \n \"meta\": {}, \n \"name\": null, \n \"postal_code\": null, \n \"postal_code_check\": \"unknown\", \n \"security_code_check\": \"passed\", \n \"street_address\": null, \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/cards/CC72hXVwWbCJsozvJoRELzIc\"\n}" - }, - "card_delete": { - "request": { - "uri": "/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/cards/CC5N3HHUDrAyvhNwQOoUd3UX" - } - }, - "card_id": "CC4MhLvXQPH3q8EAMDUKa57i", - "card_invalidate": { - "request": { - "payload": { - "is_valid": "false" - }, - "uri": "/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/cards/CC5N3HHUDrAyvhNwQOoUd3UX" - }, - "response": "{\n \"_type\": \"card\", \n \"_uris\": {}, \n \"brand\": \"MasterCard\", \n \"card_type\": \"mastercard\", \n \"expiration_month\": 12, \n \"expiration_year\": 2020, \n \"hash\": \"fc4ccd5de54f42a5e75f76fbfde60948440c7a382ee7d21b2bc509ab9cfed788\", \n \"last_four\": \"5100\", \n \"meta\": {\n \"facebook.user_id\": \"0192837465\", \n \"my-own-customer-id\": \"12345\", \n \"twitter.id\": \"1234987650\"\n }, \n \"name\": null\n}" - }, - "card_list": { - "request": { - "uri": "/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/cards" - }, - "response": "{\n \"_type\": \"page\", \n \"_uris\": {\n \"first_uri\": {\n \"_type\": \"page\", \n \"key\": \"first\"\n }, \n \"last_uri\": {\n \"_type\": \"page\", \n \"key\": \"last\"\n }, \n \"next_uri\": {\n \"_type\": \"page\", \n \"key\": \"next\"\n }, \n \"previous_uri\": {\n \"_type\": \"page\", \n \"key\": \"previous\"\n }\n }, \n \"first_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/cards?limit=2&offset=0\", \n \"items\": [\n {\n \"_type\": \"card\", \n \"_uris\": {}, \n \"account\": null, \n \"brand\": \"MasterCard\", \n \"card_type\": \"mastercard\", \n \"country_code\": null, \n \"created_at\": \"2013-11-14T16:20:57.668888Z\", \n \"customer\": null, \n \"expiration_month\": 12, \n \"expiration_year\": 2020, \n \"hash\": \"fc4ccd5de54f42a5e75f76fbfde60948440c7a382ee7d21b2bc509ab9cfed788\", \n \"id\": \"CC5N3HHUDrAyvhNwQOoUd3UX\", \n \"is_valid\": true, \n \"is_verified\": true, \n \"last_four\": \"5100\", \n \"meta\": {}, \n \"name\": null, \n \"postal_code\": null, \n \"postal_code_check\": \"unknown\", \n \"security_code_check\": \"passed\", \n \"street_address\": null, \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/cards/CC5N3HHUDrAyvhNwQOoUd3UX\"\n }, \n {\n \"_type\": \"card\", \n \"_uris\": {}, \n \"account\": {\n \"_type\": \"account\", \n \"_uris\": {\n \"bank_accounts_uri\": {\n \"_type\": \"page\", \n \"key\": \"bank_accounts\"\n }, \n \"cards_uri\": {\n \"_type\": \"page\", \n \"key\": \"cards\"\n }, \n \"credits_uri\": {\n \"_type\": \"page\", \n \"key\": \"credits\"\n }, \n \"customer_uri\": {\n \"_type\": \"customer\", \n \"key\": \"customer\"\n }, \n \"debits_uri\": {\n \"_type\": \"page\", \n \"key\": \"debits\"\n }, \n \"holds_uri\": {\n \"_type\": \"page\", \n \"key\": \"holds\"\n }, \n \"refunds_uri\": {\n \"_type\": \"page\", \n \"key\": \"refunds\"\n }, \n \"reversals_uri\": {\n \"_type\": \"page\", \n \"key\": \"reversals\"\n }, \n \"transactions_uri\": {\n \"_type\": \"page\", \n \"key\": \"transactions\"\n }\n }, \n \"bank_accounts_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU4WT2fC14gzGQIEcMKs5gm3/bank_accounts\", \n \"cards_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU4WT2fC14gzGQIEcMKs5gm3/cards\", \n \"created_at\": \"2013-11-14T16:20:11.280063Z\", \n \"credits_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU4WT2fC14gzGQIEcMKs5gm3/credits\", \n \"customer_uri\": \"/v1/customers/CU4WT2fC14gzGQIEcMKs5gm3\", \n \"debits_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU4WT2fC14gzGQIEcMKs5gm3/debits\", \n \"email_address\": null, \n \"holds_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU4WT2fC14gzGQIEcMKs5gm3/holds\", \n \"id\": \"CU4WT2fC14gzGQIEcMKs5gm3\", \n \"meta\": {}, \n \"name\": null, \n \"refunds_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU4WT2fC14gzGQIEcMKs5gm3/refunds\", \n \"reversals_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU4WT2fC14gzGQIEcMKs5gm3/reversals\", \n \"roles\": [\n \"buyer\"\n ], \n \"transactions_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU4WT2fC14gzGQIEcMKs5gm3/transactions\", \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU4WT2fC14gzGQIEcMKs5gm3\"\n }, \n \"brand\": \"MasterCard\", \n \"card_type\": \"mastercard\", \n \"country_code\": null, \n \"created_at\": \"2013-11-14T16:20:13.522503Z\", \n \"customer\": {\n \"_type\": \"customer\", \n \"_uris\": {\n \"bank_accounts_uri\": {\n \"_type\": \"page\", \n \"key\": \"bank_accounts\"\n }, \n \"cards_uri\": {\n \"_type\": \"page\", \n \"key\": \"cards\"\n }, \n \"credits_uri\": {\n \"_type\": \"page\", \n \"key\": \"credits\"\n }, \n \"debits_uri\": {\n \"_type\": \"page\", \n \"key\": \"debits\"\n }, \n \"destination_uri\": {\n \"_type\": \"bank_account\", \n \"key\": \"destination\"\n }, \n \"holds_uri\": {\n \"_type\": \"page\", \n \"key\": \"holds\"\n }, \n \"refunds_uri\": {\n \"_type\": \"page\", \n \"key\": \"refunds\"\n }, \n \"reversals_uri\": {\n \"_type\": \"page\", \n \"key\": \"reversals\"\n }, \n \"source_uri\": {\n \"_type\": \"card\", \n \"key\": \"source\"\n }, \n \"transactions_uri\": {\n \"_type\": \"page\", \n \"key\": \"transactions\"\n }\n }, \n \"address\": {}, \n \"bank_accounts_uri\": \"/v1/customers/CU4WT2fC14gzGQIEcMKs5gm3/bank_accounts\", \n \"business_name\": null, \n \"cards_uri\": \"/v1/customers/CU4WT2fC14gzGQIEcMKs5gm3/cards\", \n \"created_at\": \"2013-11-14T16:20:11.280063Z\", \n \"credits_uri\": \"/v1/customers/CU4WT2fC14gzGQIEcMKs5gm3/credits\", \n \"debits_uri\": \"/v1/customers/CU4WT2fC14gzGQIEcMKs5gm3/debits\", \n \"destination_uri\": \"/v1/customers/CU4WT2fC14gzGQIEcMKs5gm3/bank_accounts/BA53NVwHAXYx7fo98SdK41dg\", \n \"dob\": null, \n \"ein\": null, \n \"email\": null, \n \"facebook\": null, \n \"holds_uri\": \"/v1/customers/CU4WT2fC14gzGQIEcMKs5gm3/holds\", \n \"id\": \"CU4WT2fC14gzGQIEcMKs5gm3\", \n \"is_identity_verified\": false, \n \"meta\": {}, \n \"name\": null, \n \"phone\": null, \n \"refunds_uri\": \"/v1/customers/CU4WT2fC14gzGQIEcMKs5gm3/refunds\", \n \"reversals_uri\": \"/v1/customers/CU4WT2fC14gzGQIEcMKs5gm3/reversals\", \n \"source_uri\": \"/v1/customers/CU4WT2fC14gzGQIEcMKs5gm3/cards/CC4Zor9L2DEKXy0LJJ8PtkMM\", \n \"ssn_last4\": null, \n \"transactions_uri\": \"/v1/customers/CU4WT2fC14gzGQIEcMKs5gm3/transactions\", \n \"twitter\": null, \n \"uri\": \"/v1/customers/CU4WT2fC14gzGQIEcMKs5gm3\"\n }, \n \"expiration_month\": 12, \n \"expiration_year\": 2020, \n \"hash\": \"fc4ccd5de54f42a5e75f76fbfde60948440c7a382ee7d21b2bc509ab9cfed788\", \n \"id\": \"CC4Zor9L2DEKXy0LJJ8PtkMM\", \n \"is_valid\": true, \n \"is_verified\": true, \n \"last_four\": \"5100\", \n \"meta\": {}, \n \"name\": null, \n \"postal_code\": null, \n \"postal_code_check\": \"unknown\", \n \"security_code_check\": \"passed\", \n \"street_address\": null, \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU4WT2fC14gzGQIEcMKs5gm3/cards/CC4Zor9L2DEKXy0LJJ8PtkMM\"\n }\n ], \n \"last_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/cards?limit=2&offset=2\", \n \"limit\": 2, \n \"next_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/cards?limit=2&offset=2\", \n \"offset\": 0, \n \"previous_uri\": null, \n \"total\": 4, \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/cards?limit=2&offset=0\"\n}" - }, - "card_show": { - "request": { - "uri": "/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/cards/CC5N3HHUDrAyvhNwQOoUd3UX" - }, - "response": "{\n \"_type\": \"card\", \n \"_uris\": {}, \n \"account\": null, \n \"brand\": \"MasterCard\", \n \"card_type\": \"mastercard\", \n \"country_code\": null, \n \"created_at\": \"2013-11-14T16:20:57.668888Z\", \n \"customer\": null, \n \"expiration_month\": 12, \n \"expiration_year\": 2020, \n \"hash\": \"fc4ccd5de54f42a5e75f76fbfde60948440c7a382ee7d21b2bc509ab9cfed788\", \n \"id\": \"CC5N3HHUDrAyvhNwQOoUd3UX\", \n \"is_valid\": true, \n \"is_verified\": true, \n \"last_four\": \"5100\", \n \"meta\": {}, \n \"name\": null, \n \"postal_code\": null, \n \"postal_code_check\": \"unknown\", \n \"security_code_check\": \"passed\", \n \"street_address\": null, \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/cards/CC5N3HHUDrAyvhNwQOoUd3UX\"\n}" - }, - "card_update": { - "request": { - "payload": { - "meta": { - "facebook.user_id": "0192837465", - "my-own-customer-id": "12345", - "twitter.id": "1234987650" - } - }, - "uri": "/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/cards/CC5N3HHUDrAyvhNwQOoUd3UX" - }, - "response": "{\n \"_type\": \"card\", \n \"_uris\": {}, \n \"account\": null, \n \"brand\": \"MasterCard\", \n \"card_type\": \"mastercard\", \n \"country_code\": null, \n \"created_at\": \"2013-11-14T16:20:57.668888Z\", \n \"customer\": null, \n \"expiration_month\": 12, \n \"expiration_year\": 2020, \n \"hash\": \"fc4ccd5de54f42a5e75f76fbfde60948440c7a382ee7d21b2bc509ab9cfed788\", \n \"id\": \"CC5N3HHUDrAyvhNwQOoUd3UX\", \n \"is_valid\": true, \n \"is_verified\": true, \n \"last_four\": \"5100\", \n \"meta\": {\n \"facebook.user_id\": \"0192837465\", \n \"my-own-customer-id\": \"12345\", \n \"twitter.id\": \"1234987650\"\n }, \n \"name\": null, \n \"postal_code\": null, \n \"postal_code_check\": \"unknown\", \n \"security_code_check\": \"passed\", \n \"street_address\": null, \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/cards/CC5N3HHUDrAyvhNwQOoUd3UX\"\n}" - }, - "card_uri": "/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/cards/CC4MhLvXQPH3q8EAMDUKa57i", - "credit_bank_account_list": { - "request": { - "id": "BA5A8YcoSCEPQyCaPCTvmFnW", - "uri": "/v1/bank_accounts/BA5A8YcoSCEPQyCaPCTvmFnW" - }, - "response": "{\n \"_type\": \"page\", \n \"_uris\": {\n \"first_uri\": {\n \"_type\": \"page\", \n \"key\": \"first\"\n }, \n \"last_uri\": {\n \"_type\": \"page\", \n \"key\": \"last\"\n }, \n \"next_uri\": {\n \"_type\": \"page\", \n \"key\": \"next\"\n }, \n \"previous_uri\": {\n \"_type\": \"page\", \n \"key\": \"previous\"\n }\n }, \n \"first_uri\": \"/v1/bank_accounts/BA5A8YcoSCEPQyCaPCTvmFnW/credits?limit=2&offset=0\", \n \"items\": [\n {\n \"_type\": \"credit\", \n \"_uris\": {\n \"events_uri\": {\n \"_type\": \"page\", \n \"key\": \"events\"\n }, \n \"reversals_uri\": {\n \"_type\": \"page\", \n \"key\": \"reversals\"\n }\n }, \n \"amount\": 10000, \n \"appears_on_statement_as\": \"example.com\", \n \"bank_account\": {\n \"_type\": \"bank_account\", \n \"_uris\": {\n \"credits_uri\": {\n \"_type\": \"page\", \n \"key\": \"credits\"\n }, \n \"debits_uri\": {\n \"_type\": \"page\", \n \"key\": \"debits\"\n }, \n \"verifications_uri\": {\n \"_type\": \"page\", \n \"key\": \"verifications\"\n }\n }, \n \"account_number\": \"xxxxxx0001\", \n \"bank_name\": \"BANK OF AMERICA, N.A.\", \n \"can_debit\": false, \n \"created_at\": \"2013-11-14T16:20:46.183358Z\", \n \"credits_uri\": \"/v1/bank_accounts/BA5A8YcoSCEPQyCaPCTvmFnW/credits\", \n \"customer_uri\": null, \n \"debits_uri\": \"/v1/bank_accounts/BA5A8YcoSCEPQyCaPCTvmFnW/debits\", \n \"fingerprint\": \"5f0ba9fa3f1122ef13b944a40abfe44e7eba9e16934e64200913cb4c402ace14\", \n \"id\": \"BA5A8YcoSCEPQyCaPCTvmFnW\", \n \"meta\": {}, \n \"name\": \"Johann Bernoulli\", \n \"routing_number\": \"121000358\", \n \"type\": \"checking\", \n \"uri\": \"/v1/bank_accounts/BA5A8YcoSCEPQyCaPCTvmFnW\", \n \"verification_uri\": null, \n \"verifications_uri\": \"/v1/bank_accounts/BA5A8YcoSCEPQyCaPCTvmFnW/verifications\"\n }, \n \"created_at\": \"2013-11-14T16:21:10.756688Z\", \n \"description\": null, \n \"events_uri\": \"/v1/credits/CR61MbRIN0QG26HfN20Rbeb0/events\", \n \"id\": \"CR61MbRIN0QG26HfN20Rbeb0\", \n \"meta\": {}, \n \"reversals_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/credits/CR61MbRIN0QG26HfN20Rbeb0/reversals\", \n \"status\": \"paid\", \n \"uri\": \"/v1/credits/CR61MbRIN0QG26HfN20Rbeb0\"\n }\n ], \n \"last_uri\": \"/v1/bank_accounts/BA5A8YcoSCEPQyCaPCTvmFnW/credits?limit=2&offset=0\", \n \"limit\": 2, \n \"next_uri\": null, \n \"offset\": 0, \n \"previous_uri\": null, \n \"total\": 1, \n \"uri\": \"/v1/bank_accounts/BA5A8YcoSCEPQyCaPCTvmFnW/credits?limit=2&offset=0\"\n}" - }, - "credit_create_existing_bank_account": { - "request": { - "id": "BA5A8YcoSCEPQyCaPCTvmFnW", - "payload": { - "amount": 10000 - }, - "uri": "/v1/bank_accounts/BA5A8YcoSCEPQyCaPCTvmFnW" - }, - "response": "{\n \"_type\": \"credit\", \n \"_uris\": {\n \"events_uri\": {\n \"_type\": \"page\", \n \"key\": \"events\"\n }, \n \"reversals_uri\": {\n \"_type\": \"page\", \n \"key\": \"reversals\"\n }\n }, \n \"amount\": 10000, \n \"appears_on_statement_as\": \"example.com\", \n \"bank_account\": {\n \"_type\": \"bank_account\", \n \"_uris\": {\n \"credits_uri\": {\n \"_type\": \"page\", \n \"key\": \"credits\"\n }, \n \"debits_uri\": {\n \"_type\": \"page\", \n \"key\": \"debits\"\n }, \n \"verifications_uri\": {\n \"_type\": \"page\", \n \"key\": \"verifications\"\n }\n }, \n \"account_number\": \"xxxxxx0001\", \n \"bank_name\": \"BANK OF AMERICA, N.A.\", \n \"can_debit\": false, \n \"created_at\": \"2013-11-14T16:20:46.183358Z\", \n \"credits_uri\": \"/v1/bank_accounts/BA5A8YcoSCEPQyCaPCTvmFnW/credits\", \n \"customer_uri\": null, \n \"debits_uri\": \"/v1/bank_accounts/BA5A8YcoSCEPQyCaPCTvmFnW/debits\", \n \"fingerprint\": \"5f0ba9fa3f1122ef13b944a40abfe44e7eba9e16934e64200913cb4c402ace14\", \n \"id\": \"BA5A8YcoSCEPQyCaPCTvmFnW\", \n \"meta\": {}, \n \"name\": \"Johann Bernoulli\", \n \"routing_number\": \"121000358\", \n \"type\": \"checking\", \n \"uri\": \"/v1/bank_accounts/BA5A8YcoSCEPQyCaPCTvmFnW\", \n \"verification_uri\": null, \n \"verifications_uri\": \"/v1/bank_accounts/BA5A8YcoSCEPQyCaPCTvmFnW/verifications\"\n }, \n \"created_at\": \"2013-11-14T16:21:10.756688Z\", \n \"description\": null, \n \"events_uri\": \"/v1/credits/CR61MbRIN0QG26HfN20Rbeb0/events\", \n \"id\": \"CR61MbRIN0QG26HfN20Rbeb0\", \n \"meta\": {}, \n \"reversals_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/credits/CR61MbRIN0QG26HfN20Rbeb0/reversals\", \n \"status\": \"paid\", \n \"uri\": \"/v1/credits/CR61MbRIN0QG26HfN20Rbeb0\"\n}" - }, - "credit_create_new_bank_account": { - "request": { - "payload": { - "amount": 10000, - "bank_account": { - "account_number": "9900000001", - "name": "Johann Bernoulli", - "routing_number": "121000358", - "type": "checking" - } - }, - "uri": "/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/credits" - }, - "response": "{\n \"_type\": \"credit\", \n \"_uris\": {\n \"events_uri\": {\n \"_type\": \"page\", \n \"key\": \"events\"\n }, \n \"reversals_uri\": {\n \"_type\": \"page\", \n \"key\": \"reversals\"\n }\n }, \n \"account\": null, \n \"amount\": 10000, \n \"appears_on_statement_as\": \"example.com\", \n \"available_at\": null, \n \"bank_account\": {\n \"_type\": \"bank_account\", \n \"_uris\": {}, \n \"account_number\": \"xxxxxx0001\", \n \"bank_name\": \"BANK OF AMERICA, N.A.\", \n \"can_debit\": false, \n \"fingerprint\": \"1eH719hwbYRpEILVKyboPs_pn\", \n \"meta\": {}, \n \"name\": \"Johann Bernoulli\", \n \"routing_number\": \"121000358\", \n \"type\": \"checking\"\n }, \n \"created_at\": \"2013-11-14T16:21:08.065371Z\", \n \"customer\": null, \n \"description\": null, \n \"destination\": {\n \"_type\": \"bank_account\", \n \"_uris\": {}, \n \"account_number\": \"xxxxxx0001\", \n \"bank_name\": \"BANK OF AMERICA, N.A.\", \n \"can_debit\": false, \n \"fingerprint\": \"1eH719hwbYRpEILVKyboPs_pn\", \n \"meta\": {}, \n \"name\": \"Johann Bernoulli\", \n \"routing_number\": \"121000358\", \n \"type\": \"checking\"\n }, \n \"events_uri\": \"/v1/credits/CR5YK26rTyl5vlFK928nhxUI/events\", \n \"fee\": null, \n \"id\": \"CR5YK26rTyl5vlFK928nhxUI\", \n \"meta\": {}, \n \"reversals_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/credits/CR5YK26rTyl5vlFK928nhxUI/reversals\", \n \"state\": \"pending\", \n \"status\": \"pending\", \n \"transaction_number\": \"CR297-882-8786\", \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/credits/CR5YK26rTyl5vlFK928nhxUI\"\n}" - }, - "credit_customer_list": { - "request": { - "customer_uri": "/v1/customers/CU5f64LhFMO8cf7N1sQSRVOo", - "payload": { - "amount": 100 - }, - "uri": "/v1/customers/CU5f64LhFMO8cf7N1sQSRVOo/credits" - }, - "response": "{\n \"_type\": \"page\", \n \"_uris\": {\n \"first_uri\": {\n \"_type\": \"page\", \n \"key\": \"first\"\n }, \n \"last_uri\": {\n \"_type\": \"page\", \n \"key\": \"last\"\n }, \n \"next_uri\": {\n \"_type\": \"page\", \n \"key\": \"next\"\n }, \n \"previous_uri\": {\n \"_type\": \"page\", \n \"key\": \"previous\"\n }\n }, \n \"first_uri\": \"/v1/customers/CU5f64LhFMO8cf7N1sQSRVOo/credits?limit=2&offset=0\", \n \"items\": [\n {\n \"_type\": \"credit\", \n \"_uris\": {\n \"events_uri\": {\n \"_type\": \"page\", \n \"key\": \"events\"\n }, \n \"reversals_uri\": {\n \"_type\": \"page\", \n \"key\": \"reversals\"\n }\n }, \n \"amount\": 100, \n \"appears_on_statement_as\": \"example.com\", \n \"available_at\": \"2013-11-14T16:21:18.584003Z\", \n \"bank_account\": {\n \"_type\": \"bank_account\", \n \"_uris\": {\n \"credits_uri\": {\n \"_type\": \"page\", \n \"key\": \"credits\"\n }, \n \"debits_uri\": {\n \"_type\": \"page\", \n \"key\": \"debits\"\n }, \n \"verification_uri\": {\n \"_type\": \"bank_account_authentication\", \n \"key\": \"verification\"\n }, \n \"verifications_uri\": {\n \"_type\": \"page\", \n \"key\": \"verifications\"\n }\n }, \n \"account_number\": \"xxxxxx0001\", \n \"bank_code\": \"121000358\", \n \"bank_name\": \"BANK OF AMERICA, N.A.\", \n \"can_debit\": false, \n \"created_at\": \"2013-11-14T16:20:28.771031Z\", \n \"credits_uri\": \"/v1/bank_accounts/BA5gy1b8X8dIGaBWFuoWvkxO/credits\", \n \"customer_uri\": \"/v1/customers/CU5f64LhFMO8cf7N1sQSRVOo\", \n \"debits_uri\": \"/v1/bank_accounts/BA5gy1b8X8dIGaBWFuoWvkxO/debits\", \n \"fingerprint\": \"5f0ba9fa3f1122ef13b944a40abfe44e7eba9e16934e64200913cb4c402ace14\", \n \"id\": \"BA5gy1b8X8dIGaBWFuoWvkxO\", \n \"is_valid\": true, \n \"last_four\": \"0001\", \n \"meta\": {}, \n \"name\": \"Johann Bernoulli\", \n \"routing_number\": \"121000358\", \n \"type\": \"checking\", \n \"uri\": \"/v1/customers/CU5f64LhFMO8cf7N1sQSRVOo/bank_accounts/BA5gy1b8X8dIGaBWFuoWvkxO\", \n \"verification_uri\": \"/v1/bank_accounts/BA5gy1b8X8dIGaBWFuoWvkxO/verifications/BZ5kihRbLIgd64iMWFkWesdw\", \n \"verifications_uri\": \"/v1/bank_accounts/BA5gy1b8X8dIGaBWFuoWvkxO/verifications\"\n }, \n \"created_at\": \"2013-11-14T16:21:18.267102Z\", \n \"customer\": {\n \"_type\": \"customer\", \n \"_uris\": {\n \"bank_accounts_uri\": {\n \"_type\": \"page\", \n \"key\": \"bank_accounts\"\n }, \n \"cards_uri\": {\n \"_type\": \"page\", \n \"key\": \"cards\"\n }, \n \"credits_uri\": {\n \"_type\": \"page\", \n \"key\": \"credits\"\n }, \n \"debits_uri\": {\n \"_type\": \"page\", \n \"key\": \"debits\"\n }, \n \"destination_uri\": {\n \"_type\": \"bank_account\", \n \"key\": \"destination\"\n }, \n \"holds_uri\": {\n \"_type\": \"page\", \n \"key\": \"holds\"\n }, \n \"refunds_uri\": {\n \"_type\": \"page\", \n \"key\": \"refunds\"\n }, \n \"reversals_uri\": {\n \"_type\": \"page\", \n \"key\": \"reversals\"\n }, \n \"transactions_uri\": {\n \"_type\": \"page\", \n \"key\": \"transactions\"\n }\n }, \n \"address\": {}, \n \"bank_accounts_uri\": \"/v1/customers/CU5f64LhFMO8cf7N1sQSRVOo/bank_accounts\", \n \"business_name\": null, \n \"cards_uri\": \"/v1/customers/CU5f64LhFMO8cf7N1sQSRVOo/cards\", \n \"created_at\": \"2013-11-14T16:20:27.468419Z\", \n \"credits_uri\": \"/v1/customers/CU5f64LhFMO8cf7N1sQSRVOo/credits\", \n \"debits_uri\": \"/v1/customers/CU5f64LhFMO8cf7N1sQSRVOo/debits\", \n \"destination_uri\": \"/v1/customers/CU5f64LhFMO8cf7N1sQSRVOo/bank_accounts/BA5gy1b8X8dIGaBWFuoWvkxO\", \n \"dob\": null, \n \"ein\": null, \n \"email\": null, \n \"facebook\": null, \n \"holds_uri\": \"/v1/customers/CU5f64LhFMO8cf7N1sQSRVOo/holds\", \n \"id\": \"CU5f64LhFMO8cf7N1sQSRVOo\", \n \"is_identity_verified\": false, \n \"meta\": {}, \n \"name\": null, \n \"phone\": null, \n \"refunds_uri\": \"/v1/customers/CU5f64LhFMO8cf7N1sQSRVOo/refunds\", \n \"reversals_uri\": \"/v1/customers/CU5f64LhFMO8cf7N1sQSRVOo/reversals\", \n \"source_uri\": null, \n \"ssn_last4\": null, \n \"transactions_uri\": \"/v1/customers/CU5f64LhFMO8cf7N1sQSRVOo/transactions\", \n \"twitter\": null, \n \"uri\": \"/v1/customers/CU5f64LhFMO8cf7N1sQSRVOo\"\n }, \n \"description\": null, \n \"destination\": {\n \"_type\": \"bank_account\", \n \"_uris\": {\n \"credits_uri\": {\n \"_type\": \"page\", \n \"key\": \"credits\"\n }, \n \"debits_uri\": {\n \"_type\": \"page\", \n \"key\": \"debits\"\n }, \n \"verification_uri\": {\n \"_type\": \"bank_account_authentication\", \n \"key\": \"verification\"\n }, \n \"verifications_uri\": {\n \"_type\": \"page\", \n \"key\": \"verifications\"\n }\n }, \n \"account_number\": \"xxxxxx0001\", \n \"bank_code\": \"121000358\", \n \"bank_name\": \"BANK OF AMERICA, N.A.\", \n \"can_debit\": false, \n \"created_at\": \"2013-11-14T16:20:28.771031Z\", \n \"credits_uri\": \"/v1/bank_accounts/BA5gy1b8X8dIGaBWFuoWvkxO/credits\", \n \"customer_uri\": \"/v1/customers/CU5f64LhFMO8cf7N1sQSRVOo\", \n \"debits_uri\": \"/v1/bank_accounts/BA5gy1b8X8dIGaBWFuoWvkxO/debits\", \n \"fingerprint\": \"5f0ba9fa3f1122ef13b944a40abfe44e7eba9e16934e64200913cb4c402ace14\", \n \"id\": \"BA5gy1b8X8dIGaBWFuoWvkxO\", \n \"is_valid\": true, \n \"last_four\": \"0001\", \n \"meta\": {}, \n \"name\": \"Johann Bernoulli\", \n \"routing_number\": \"121000358\", \n \"type\": \"checking\", \n \"uri\": \"/v1/customers/CU5f64LhFMO8cf7N1sQSRVOo/bank_accounts/BA5gy1b8X8dIGaBWFuoWvkxO\", \n \"verification_uri\": \"/v1/bank_accounts/BA5gy1b8X8dIGaBWFuoWvkxO/verifications/BZ5kihRbLIgd64iMWFkWesdw\", \n \"verifications_uri\": \"/v1/bank_accounts/BA5gy1b8X8dIGaBWFuoWvkxO/verifications\"\n }, \n \"events_uri\": \"/v1/credits/CR6admOtZKuECF3I9UlCiWzm/events\", \n \"fee\": null, \n \"id\": \"CR6admOtZKuECF3I9UlCiWzm\", \n \"meta\": {}, \n \"reversals_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/credits/CR6admOtZKuECF3I9UlCiWzm/reversals\", \n \"state\": \"cleared\", \n \"status\": \"paid\", \n \"transaction_number\": \"CR004-468-9882\", \n \"uri\": \"/v1/customers/CU5f64LhFMO8cf7N1sQSRVOo/credits/CR6admOtZKuECF3I9UlCiWzm\"\n }\n ], \n \"last_uri\": \"/v1/customers/CU5f64LhFMO8cf7N1sQSRVOo/credits?limit=2&offset=0\", \n \"limit\": 2, \n \"next_uri\": null, \n \"offset\": 0, \n \"previous_uri\": null, \n \"total\": 1, \n \"uri\": \"/v1/customers/CU5f64LhFMO8cf7N1sQSRVOo/credits?limit=2&offset=0\"\n}" - }, - "credit_failed_state": { - "request": { - "payload": { - "amount": 10000, - "bank_account": { - "account_number": "9900000004", - "name": "Johann Bernoulli", - "routing_number": "121000358", - "type": "checking" - } - }, - "uri": "/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/credits" - }, - "response": "{\n \"_type\": \"credit\", \n \"_uris\": {\n \"events_uri\": {\n \"_type\": \"page\", \n \"key\": \"events\"\n }, \n \"reversals_uri\": {\n \"_type\": \"page\", \n \"key\": \"reversals\"\n }\n }, \n \"account\": null, \n \"amount\": 10000, \n \"appears_on_statement_as\": \"example.com\", \n \"available_at\": \"2013-11-14T16:50:56.446903Z\", \n \"bank_account\": {\n \"_type\": \"bank_account\", \n \"_uris\": {}, \n \"account_number\": \"xxxxxx0004\", \n \"bank_name\": \"BANK OF AMERICA, N.A.\", \n \"can_debit\": false, \n \"fingerprint\": \"67GbCVK8LlYAZ13WbmDQT9_fd\", \n \"meta\": {}, \n \"name\": \"Johann Bernoulli\", \n \"routing_number\": \"121000358\", \n \"type\": \"checking\"\n }, \n \"created_at\": \"2013-11-14T16:50:56.132757Z\", \n \"customer\": null, \n \"description\": null, \n \"destination\": {\n \"_type\": \"bank_account\", \n \"_uris\": {}, \n \"account_number\": \"xxxxxx0004\", \n \"bank_name\": \"BANK OF AMERICA, N.A.\", \n \"can_debit\": false, \n \"fingerprint\": \"67GbCVK8LlYAZ13WbmDQT9_fd\", \n \"meta\": {}, \n \"name\": \"Johann Bernoulli\", \n \"routing_number\": \"121000358\", \n \"type\": \"checking\"\n }, \n \"events_uri\": \"/v1/credits/CR7fyJUrLr9NSnvr2gt8CVra/events\", \n \"fee\": null, \n \"id\": \"CR7fyJUrLr9NSnvr2gt8CVra\", \n \"meta\": {}, \n \"reversals_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/credits/CR7fyJUrLr9NSnvr2gt8CVra/reversals\", \n \"state\": \"rejected\", \n \"status\": \"failed\", \n \"transaction_number\": \"CR468-698-5178\", \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/credits/CR7fyJUrLr9NSnvr2gt8CVra\"\n}" - }, - "credit_list": { - "request": {}, - "response": "{\n \"_type\": \"page\", \n \"_uris\": {\n \"first_uri\": {\n \"_type\": \"page\", \n \"key\": \"first\"\n }, \n \"last_uri\": {\n \"_type\": \"page\", \n \"key\": \"last\"\n }, \n \"next_uri\": {\n \"_type\": \"page\", \n \"key\": \"next\"\n }, \n \"previous_uri\": {\n \"_type\": \"page\", \n \"key\": \"previous\"\n }\n }, \n \"first_uri\": \"/v1/credits?limit=10&offset=0\", \n \"items\": [\n {\n \"_type\": \"credit\", \n \"_uris\": {\n \"events_uri\": {\n \"_type\": \"page\", \n \"key\": \"events\"\n }, \n \"reversals_uri\": {\n \"_type\": \"page\", \n \"key\": \"reversals\"\n }\n }, \n \"amount\": 10000, \n \"appears_on_statement_as\": \"example.com\", \n \"bank_account\": {\n \"_type\": \"bank_account\", \n \"_uris\": {\n \"credits_uri\": {\n \"_type\": \"page\", \n \"key\": \"credits\"\n }, \n \"debits_uri\": {\n \"_type\": \"page\", \n \"key\": \"debits\"\n }, \n \"verifications_uri\": {\n \"_type\": \"page\", \n \"key\": \"verifications\"\n }\n }, \n \"account_number\": \"xxxxxx0001\", \n \"bank_name\": \"BANK OF AMERICA, N.A.\", \n \"can_debit\": false, \n \"created_at\": \"2013-11-14T16:20:46.183358Z\", \n \"credits_uri\": \"/v1/bank_accounts/BA5A8YcoSCEPQyCaPCTvmFnW/credits\", \n \"customer_uri\": null, \n \"debits_uri\": \"/v1/bank_accounts/BA5A8YcoSCEPQyCaPCTvmFnW/debits\", \n \"fingerprint\": \"5f0ba9fa3f1122ef13b944a40abfe44e7eba9e16934e64200913cb4c402ace14\", \n \"id\": \"BA5A8YcoSCEPQyCaPCTvmFnW\", \n \"meta\": {}, \n \"name\": \"Johann Bernoulli\", \n \"routing_number\": \"121000358\", \n \"type\": \"checking\", \n \"uri\": \"/v1/bank_accounts/BA5A8YcoSCEPQyCaPCTvmFnW\", \n \"verification_uri\": null, \n \"verifications_uri\": \"/v1/bank_accounts/BA5A8YcoSCEPQyCaPCTvmFnW/verifications\"\n }, \n \"created_at\": \"2013-11-14T16:21:10.756688Z\", \n \"description\": null, \n \"events_uri\": \"/v1/credits/CR61MbRIN0QG26HfN20Rbeb0/events\", \n \"id\": \"CR61MbRIN0QG26HfN20Rbeb0\", \n \"meta\": {}, \n \"reversals_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/credits/CR61MbRIN0QG26HfN20Rbeb0/reversals\", \n \"status\": \"paid\", \n \"uri\": \"/v1/credits/CR61MbRIN0QG26HfN20Rbeb0\"\n }, \n {\n \"_type\": \"credit\", \n \"_uris\": {\n \"events_uri\": {\n \"_type\": \"page\", \n \"key\": \"events\"\n }, \n \"reversals_uri\": {\n \"_type\": \"page\", \n \"key\": \"reversals\"\n }\n }, \n \"amount\": 10000, \n \"appears_on_statement_as\": \"example.com\", \n \"bank_account\": {\n \"_type\": \"bank_account\", \n \"_uris\": {}, \n \"account_number\": \"xxxxxx0001\", \n \"bank_name\": \"BANK OF AMERICA, N.A.\", \n \"can_debit\": false, \n \"fingerprint\": \"1eH719hwbYRpEILVKyboPs_pn\", \n \"meta\": {}, \n \"name\": \"Johann Bernoulli\", \n \"routing_number\": \"121000358\", \n \"type\": \"checking\"\n }, \n \"created_at\": \"2013-11-14T16:21:08.065371Z\", \n \"description\": null, \n \"events_uri\": \"/v1/credits/CR5YK26rTyl5vlFK928nhxUI/events\", \n \"id\": \"CR5YK26rTyl5vlFK928nhxUI\", \n \"meta\": {}, \n \"reversals_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/credits/CR5YK26rTyl5vlFK928nhxUI/reversals\", \n \"status\": \"pending\", \n \"uri\": \"/v1/credits/CR5YK26rTyl5vlFK928nhxUI\"\n }\n ], \n \"last_uri\": \"/v1/credits?limit=10&offset=0\", \n \"limit\": 10, \n \"next_uri\": null, \n \"offset\": 0, \n \"previous_uri\": null, \n \"total\": 2, \n \"uri\": \"/v1/credits?limit=10&offset=0\"\n}" - }, - "credit_paid_state": { - "request": { - "payload": { - "amount": 10000, - "bank_account": { - "account_number": "9900000003", - "name": "Johann Bernoulli", - "routing_number": "121000358", - "type": "checking" - } - }, - "uri": "/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/credits" - }, - "response": "{\n \"_type\": \"credit\", \n \"_uris\": {\n \"events_uri\": {\n \"_type\": \"page\", \n \"key\": \"events\"\n }, \n \"reversals_uri\": {\n \"_type\": \"page\", \n \"key\": \"reversals\"\n }\n }, \n \"account\": null, \n \"amount\": 10000, \n \"appears_on_statement_as\": \"example.com\", \n \"available_at\": \"2013-11-14T16:50:54.322108Z\", \n \"bank_account\": {\n \"_type\": \"bank_account\", \n \"_uris\": {}, \n \"account_number\": \"xxxxxx0003\", \n \"bank_name\": \"BANK OF AMERICA, N.A.\", \n \"can_debit\": false, \n \"fingerprint\": \"2voYRuvBfmMa5e098L7Rpd_pd\", \n \"meta\": {}, \n \"name\": \"Johann Bernoulli\", \n \"routing_number\": \"121000358\", \n \"type\": \"checking\"\n }, \n \"created_at\": \"2013-11-14T16:50:53.934354Z\", \n \"customer\": null, \n \"description\": null, \n \"destination\": {\n \"_type\": \"bank_account\", \n \"_uris\": {}, \n \"account_number\": \"xxxxxx0003\", \n \"bank_name\": \"BANK OF AMERICA, N.A.\", \n \"can_debit\": false, \n \"fingerprint\": \"2voYRuvBfmMa5e098L7Rpd_pd\", \n \"meta\": {}, \n \"name\": \"Johann Bernoulli\", \n \"routing_number\": \"121000358\", \n \"type\": \"checking\"\n }, \n \"events_uri\": \"/v1/credits/CR7d6lwEhZXyc0pQPtL1GRTa/events\", \n \"fee\": null, \n \"id\": \"CR7d6lwEhZXyc0pQPtL1GRTa\", \n \"meta\": {}, \n \"reversals_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/credits/CR7d6lwEhZXyc0pQPtL1GRTa/reversals\", \n \"state\": \"cleared\", \n \"status\": \"paid\", \n \"transaction_number\": \"CR454-866-1422\", \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/credits/CR7d6lwEhZXyc0pQPtL1GRTa\"\n}" - }, - "credit_pending_state": { - "request": { - "payload": { - "amount": 10000, - "bank_account": { - "account_number": "9900000000", - "name": "Johann Bernoulli", - "routing_number": "121000358", - "type": "checking" - } - }, - "uri": "/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/credits" - }, - "response": "{\n \"_type\": \"credit\", \n \"_uris\": {\n \"events_uri\": {\n \"_type\": \"page\", \n \"key\": \"events\"\n }, \n \"reversals_uri\": {\n \"_type\": \"page\", \n \"key\": \"reversals\"\n }\n }, \n \"account\": null, \n \"amount\": 10000, \n \"appears_on_statement_as\": \"example.com\", \n \"available_at\": null, \n \"bank_account\": {\n \"_type\": \"bank_account\", \n \"_uris\": {}, \n \"account_number\": \"xxxxxx0000\", \n \"bank_name\": \"BANK OF AMERICA, N.A.\", \n \"can_debit\": false, \n \"fingerprint\": \"1Y1Iq2DIr9MUiY8poVBAlf_pn\", \n \"meta\": {}, \n \"name\": \"Johann Bernoulli\", \n \"routing_number\": \"121000358\", \n \"type\": \"checking\"\n }, \n \"created_at\": \"2013-11-14T16:50:51.375357Z\", \n \"customer\": null, \n \"description\": null, \n \"destination\": {\n \"_type\": \"bank_account\", \n \"_uris\": {}, \n \"account_number\": \"xxxxxx0000\", \n \"bank_name\": \"BANK OF AMERICA, N.A.\", \n \"can_debit\": false, \n \"fingerprint\": \"1Y1Iq2DIr9MUiY8poVBAlf_pn\", \n \"meta\": {}, \n \"name\": \"Johann Bernoulli\", \n \"routing_number\": \"121000358\", \n \"type\": \"checking\"\n }, \n \"events_uri\": \"/v1/credits/CR7acqrh4TCVQPYuNcfvLYHQ/events\", \n \"fee\": null, \n \"id\": \"CR7acqrh4TCVQPYuNcfvLYHQ\", \n \"meta\": {}, \n \"reversals_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/credits/CR7acqrh4TCVQPYuNcfvLYHQ/reversals\", \n \"state\": \"pending\", \n \"status\": \"pending\", \n \"transaction_number\": \"CR399-334-5977\", \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/credits/CR7acqrh4TCVQPYuNcfvLYHQ\"\n}" - }, - "credit_show": { - "request": { - "id": "CR5YK26rTyl5vlFK928nhxUI", - "uri": "/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/credits/CR5YK26rTyl5vlFK928nhxUI" - }, - "response": "{\n \"_type\": \"credit\", \n \"_uris\": {\n \"events_uri\": {\n \"_type\": \"page\", \n \"key\": \"events\"\n }, \n \"reversals_uri\": {\n \"_type\": \"page\", \n \"key\": \"reversals\"\n }\n }, \n \"amount\": 10000, \n \"appears_on_statement_as\": \"example.com\", \n \"bank_account\": {\n \"_type\": \"bank_account\", \n \"_uris\": {}, \n \"account_number\": \"xxxxxx0001\", \n \"bank_name\": \"BANK OF AMERICA, N.A.\", \n \"can_debit\": false, \n \"fingerprint\": \"1eH719hwbYRpEILVKyboPs_pn\", \n \"meta\": {}, \n \"name\": \"Johann Bernoulli\", \n \"routing_number\": \"121000358\", \n \"type\": \"checking\"\n }, \n \"created_at\": \"2013-11-14T16:21:08.065371Z\", \n \"description\": null, \n \"events_uri\": \"/v1/credits/CR5YK26rTyl5vlFK928nhxUI/events\", \n \"id\": \"CR5YK26rTyl5vlFK928nhxUI\", \n \"meta\": {}, \n \"reversals_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/credits/CR5YK26rTyl5vlFK928nhxUI/reversals\", \n \"status\": \"pending\", \n \"uri\": \"/v1/credits/CR5YK26rTyl5vlFK928nhxUI\"\n}" - }, - "customer_add_bank_account": { - "request": { - "bank_account_verifications_uri": "/v1/bank_accounts/BA6oxYWJXxeM63vMorgtSIhI/verifications", - "payload": { - "bank_account_uri": "/v1/bank_accounts/BA6oxYWJXxeM63vMorgtSIhI" - }, - "uri": "/v1/customers/CU6n0viWQoT86ttbkCsPgV0Y" - }, - "response": "{\n \"_type\": \"customer\", \n \"_uris\": {\n \"bank_accounts_uri\": {\n \"_type\": \"page\", \n \"key\": \"bank_accounts\"\n }, \n \"cards_uri\": {\n \"_type\": \"page\", \n \"key\": \"cards\"\n }, \n \"credits_uri\": {\n \"_type\": \"page\", \n \"key\": \"credits\"\n }, \n \"debits_uri\": {\n \"_type\": \"page\", \n \"key\": \"debits\"\n }, \n \"destination_uri\": {\n \"_type\": \"bank_account\", \n \"key\": \"destination\"\n }, \n \"holds_uri\": {\n \"_type\": \"page\", \n \"key\": \"holds\"\n }, \n \"refunds_uri\": {\n \"_type\": \"page\", \n \"key\": \"refunds\"\n }, \n \"reversals_uri\": {\n \"_type\": \"page\", \n \"key\": \"reversals\"\n }, \n \"transactions_uri\": {\n \"_type\": \"page\", \n \"key\": \"transactions\"\n }\n }, \n \"address\": {}, \n \"bank_accounts_uri\": \"/v1/customers/CU6n0viWQoT86ttbkCsPgV0Y/bank_accounts\", \n \"business_name\": null, \n \"cards_uri\": \"/v1/customers/CU6n0viWQoT86ttbkCsPgV0Y/cards\", \n \"created_at\": \"2013-11-14T16:21:29.626033Z\", \n \"credits_uri\": \"/v1/customers/CU6n0viWQoT86ttbkCsPgV0Y/credits\", \n \"debits_uri\": \"/v1/customers/CU6n0viWQoT86ttbkCsPgV0Y/debits\", \n \"destination_uri\": \"/v1/customers/CU6n0viWQoT86ttbkCsPgV0Y/bank_accounts/BA6oxYWJXxeM63vMorgtSIhI\", \n \"dob\": null, \n \"ein\": null, \n \"email\": null, \n \"facebook\": null, \n \"holds_uri\": \"/v1/customers/CU6n0viWQoT86ttbkCsPgV0Y/holds\", \n \"id\": \"CU6n0viWQoT86ttbkCsPgV0Y\", \n \"is_identity_verified\": false, \n \"meta\": {}, \n \"name\": null, \n \"phone\": null, \n \"refunds_uri\": \"/v1/customers/CU6n0viWQoT86ttbkCsPgV0Y/refunds\", \n \"reversals_uri\": \"/v1/customers/CU6n0viWQoT86ttbkCsPgV0Y/reversals\", \n \"source_uri\": null, \n \"ssn_last4\": null, \n \"transactions_uri\": \"/v1/customers/CU6n0viWQoT86ttbkCsPgV0Y/transactions\", \n \"twitter\": null, \n \"uri\": \"/v1/customers/CU6n0viWQoT86ttbkCsPgV0Y\"\n}" - }, - "customer_add_card": { - "request": { - "card_uri": "/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/cards/CC72hXVwWbCJsozvJoRELzIc", - "payload": { - "card_uri": "/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/cards/CC72hXVwWbCJsozvJoRELzIc" - }, - "uri": "/v1/customers/CU70CIWA2NrZwwMQqjBuWFUb" - }, - "response": "{\n \"_type\": \"customer\", \n \"_uris\": {\n \"bank_accounts_uri\": {\n \"_type\": \"page\", \n \"key\": \"bank_accounts\"\n }, \n \"cards_uri\": {\n \"_type\": \"page\", \n \"key\": \"cards\"\n }, \n \"credits_uri\": {\n \"_type\": \"page\", \n \"key\": \"credits\"\n }, \n \"debits_uri\": {\n \"_type\": \"page\", \n \"key\": \"debits\"\n }, \n \"holds_uri\": {\n \"_type\": \"page\", \n \"key\": \"holds\"\n }, \n \"refunds_uri\": {\n \"_type\": \"page\", \n \"key\": \"refunds\"\n }, \n \"reversals_uri\": {\n \"_type\": \"page\", \n \"key\": \"reversals\"\n }, \n \"source_uri\": {\n \"_type\": \"card\", \n \"key\": \"source\"\n }, \n \"transactions_uri\": {\n \"_type\": \"page\", \n \"key\": \"transactions\"\n }\n }, \n \"address\": {}, \n \"bank_accounts_uri\": \"/v1/customers/CU70CIWA2NrZwwMQqjBuWFUb/bank_accounts\", \n \"business_name\": null, \n \"cards_uri\": \"/v1/customers/CU70CIWA2NrZwwMQqjBuWFUb/cards\", \n \"created_at\": \"2013-11-14T16:50:42.841208Z\", \n \"credits_uri\": \"/v1/customers/CU70CIWA2NrZwwMQqjBuWFUb/credits\", \n \"debits_uri\": \"/v1/customers/CU70CIWA2NrZwwMQqjBuWFUb/debits\", \n \"destination_uri\": null, \n \"dob\": null, \n \"ein\": null, \n \"email\": null, \n \"facebook\": null, \n \"holds_uri\": \"/v1/customers/CU70CIWA2NrZwwMQqjBuWFUb/holds\", \n \"id\": \"CU70CIWA2NrZwwMQqjBuWFUb\", \n \"is_identity_verified\": false, \n \"meta\": {}, \n \"name\": null, \n \"phone\": null, \n \"refunds_uri\": \"/v1/customers/CU70CIWA2NrZwwMQqjBuWFUb/refunds\", \n \"reversals_uri\": \"/v1/customers/CU70CIWA2NrZwwMQqjBuWFUb/reversals\", \n \"source_uri\": \"/v1/customers/CU70CIWA2NrZwwMQqjBuWFUb/cards/CC72hXVwWbCJsozvJoRELzIc\", \n \"ssn_last4\": null, \n \"transactions_uri\": \"/v1/customers/CU70CIWA2NrZwwMQqjBuWFUb/transactions\", \n \"twitter\": null, \n \"uri\": \"/v1/customers/CU70CIWA2NrZwwMQqjBuWFUb\"\n}" - }, - "customer_create": { - "request": { - "email": "william@example.com", - "name": "William Henry Cavendish III", - "uri": "/v1/customers" - }, - "response": "{\n \"_type\": \"customer\", \n \"_uris\": {\n \"bank_accounts_uri\": {\n \"_type\": \"page\", \n \"key\": \"bank_accounts\"\n }, \n \"cards_uri\": {\n \"_type\": \"page\", \n \"key\": \"cards\"\n }, \n \"credits_uri\": {\n \"_type\": \"page\", \n \"key\": \"credits\"\n }, \n \"debits_uri\": {\n \"_type\": \"page\", \n \"key\": \"debits\"\n }, \n \"holds_uri\": {\n \"_type\": \"page\", \n \"key\": \"holds\"\n }, \n \"refunds_uri\": {\n \"_type\": \"page\", \n \"key\": \"refunds\"\n }, \n \"reversals_uri\": {\n \"_type\": \"page\", \n \"key\": \"reversals\"\n }, \n \"transactions_uri\": {\n \"_type\": \"page\", \n \"key\": \"transactions\"\n }\n }, \n \"address\": {}, \n \"bank_accounts_uri\": \"/v1/customers/CU70CIWA2NrZwwMQqjBuWFUb/bank_accounts\", \n \"business_name\": null, \n \"cards_uri\": \"/v1/customers/CU70CIWA2NrZwwMQqjBuWFUb/cards\", \n \"created_at\": \"2013-11-14T16:50:42.841208Z\", \n \"credits_uri\": \"/v1/customers/CU70CIWA2NrZwwMQqjBuWFUb/credits\", \n \"debits_uri\": \"/v1/customers/CU70CIWA2NrZwwMQqjBuWFUb/debits\", \n \"destination_uri\": null, \n \"dob\": null, \n \"ein\": null, \n \"email\": null, \n \"facebook\": null, \n \"holds_uri\": \"/v1/customers/CU70CIWA2NrZwwMQqjBuWFUb/holds\", \n \"id\": \"CU70CIWA2NrZwwMQqjBuWFUb\", \n \"is_identity_verified\": false, \n \"meta\": {}, \n \"name\": null, \n \"phone\": null, \n \"refunds_uri\": \"/v1/customers/CU70CIWA2NrZwwMQqjBuWFUb/refunds\", \n \"reversals_uri\": \"/v1/customers/CU70CIWA2NrZwwMQqjBuWFUb/reversals\", \n \"source_uri\": null, \n \"ssn_last4\": null, \n \"transactions_uri\": \"/v1/customers/CU70CIWA2NrZwwMQqjBuWFUb/transactions\", \n \"twitter\": null, \n \"uri\": \"/v1/customers/CU70CIWA2NrZwwMQqjBuWFUb\"\n}" - }, - "customer_create_debit": { - "request": { - "customer_uri": "/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS", - "payload": { - "amount": 5000, - "appears_on_statement_as": "Statement text", - "description": "Some descriptive text for the debit in the dashboard" - }, - "uri": "/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/debits" - }, - "response": "{\n \"_type\": \"debit\", \n \"_uris\": {\n \"events_uri\": {\n \"_type\": \"page\", \n \"key\": \"events\"\n }, \n \"refunds_uri\": {\n \"_type\": \"page\", \n \"key\": \"refunds\"\n }\n }, \n \"amount\": 5000, \n \"appears_on_statement_as\": \"Statement text\", \n \"available_at\": \"2013-11-14T16:21:40.856280Z\", \n \"created_at\": \"2013-11-14T16:21:40.047691Z\", \n \"customer\": {\n \"_type\": \"customer\", \n \"_uris\": {\n \"bank_accounts_uri\": {\n \"_type\": \"page\", \n \"key\": \"bank_accounts\"\n }, \n \"cards_uri\": {\n \"_type\": \"page\", \n \"key\": \"cards\"\n }, \n \"credits_uri\": {\n \"_type\": \"page\", \n \"key\": \"credits\"\n }, \n \"debits_uri\": {\n \"_type\": \"page\", \n \"key\": \"debits\"\n }, \n \"holds_uri\": {\n \"_type\": \"page\", \n \"key\": \"holds\"\n }, \n \"refunds_uri\": {\n \"_type\": \"page\", \n \"key\": \"refunds\"\n }, \n \"reversals_uri\": {\n \"_type\": \"page\", \n \"key\": \"reversals\"\n }, \n \"source_uri\": {\n \"_type\": \"card\", \n \"key\": \"source\"\n }, \n \"transactions_uri\": {\n \"_type\": \"page\", \n \"key\": \"transactions\"\n }\n }, \n \"address\": {}, \n \"bank_accounts_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/bank_accounts\", \n \"business_name\": null, \n \"cards_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/cards\", \n \"created_at\": \"2013-11-14T16:21:37.144218Z\", \n \"credits_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/credits\", \n \"debits_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/debits\", \n \"destination_uri\": null, \n \"dob\": null, \n \"ein\": null, \n \"email\": null, \n \"facebook\": null, \n \"holds_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/holds\", \n \"id\": \"CU6vs1tjxBtifgTuzKjCGtVS\", \n \"is_identity_verified\": false, \n \"meta\": {}, \n \"name\": null, \n \"phone\": null, \n \"refunds_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/refunds\", \n \"reversals_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/reversals\", \n \"source_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/cards/CC6xbFPglEtPRSEA65a5Bd60\", \n \"ssn_last4\": null, \n \"transactions_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/transactions\", \n \"twitter\": null, \n \"uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS\"\n }, \n \"description\": \"Some descriptive text for the debit in the dashboard\", \n \"events_uri\": \"/v1/debits/WD6yIHxqPrzb1apVYERuB72G/events\", \n \"fee\": null, \n \"hold\": {\n \"_type\": \"hold\", \n \"_uris\": {\n \"debit_uri\": {\n \"_type\": \"debit\", \n \"key\": \"debit\"\n }, \n \"events_uri\": {\n \"_type\": \"page\", \n \"key\": \"events\"\n }, \n \"source_uri\": {\n \"_type\": \"card\", \n \"key\": \"source\"\n }\n }, \n \"amount\": 5000, \n \"created_at\": \"2013-11-14T16:21:39.991162Z\", \n \"customer_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS\", \n \"debit_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/debits/WD6yIHxqPrzb1apVYERuB72G\", \n \"description\": \"Some descriptive text for the debit in the dashboard\", \n \"events_uri\": \"/v1/holds/HL6yF80ERpTXcYkszqKCUlHY/events\", \n \"expires_at\": \"2013-11-21T16:21:40.450966Z\", \n \"fee\": null, \n \"id\": \"HL6yF80ERpTXcYkszqKCUlHY\", \n \"is_void\": false, \n \"meta\": {}, \n \"source_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS/cards/CC6xbFPglEtPRSEA65a5Bd60\", \n \"transaction_number\": \"HL560-602-3542\", \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/holds/HL6yF80ERpTXcYkszqKCUlHY\"\n }, \n \"id\": \"WD6yIHxqPrzb1apVYERuB72G\", \n \"meta\": {}, \n \"on_behalf_of\": null, \n \"refunds_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/debits/WD6yIHxqPrzb1apVYERuB72G/refunds\", \n \"source\": {\n \"_type\": \"card\", \n \"_uris\": {}, \n \"brand\": \"MasterCard\", \n \"card_type\": \"mastercard\", \n \"country_code\": null, \n \"created_at\": \"2013-11-14T16:21:38.681465Z\", \n \"customer_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS\", \n \"expiration_month\": 12, \n \"expiration_year\": 2020, \n \"hash\": \"fc4ccd5de54f42a5e75f76fbfde60948440c7a382ee7d21b2bc509ab9cfed788\", \n \"id\": \"CC6xbFPglEtPRSEA65a5Bd60\", \n \"is_valid\": true, \n \"is_verified\": true, \n \"last_four\": \"5100\", \n \"meta\": {}, \n \"name\": null, \n \"postal_code\": null, \n \"postal_code_check\": \"unknown\", \n \"security_code_check\": \"passed\", \n \"street_address\": null, \n \"uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/cards/CC6xbFPglEtPRSEA65a5Bd60\"\n }, \n \"status\": \"succeeded\", \n \"transaction_number\": \"W597-916-7221\", \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/debits/WD6yIHxqPrzb1apVYERuB72G\"\n}" - }, - "customer_credit": { - "request": { - "customer_uri": "/v1/customers/CU5f64LhFMO8cf7N1sQSRVOo", - "payload": { - "amount": 100 - }, - "uri": "/v1/customers/CU5f64LhFMO8cf7N1sQSRVOo/credits" - }, - "response": "{\n \"_type\": \"credit\", \n \"_uris\": {\n \"events_uri\": {\n \"_type\": \"page\", \n \"key\": \"events\"\n }, \n \"reversals_uri\": {\n \"_type\": \"page\", \n \"key\": \"reversals\"\n }\n }, \n \"amount\": 100, \n \"appears_on_statement_as\": \"example.com\", \n \"available_at\": \"2013-11-14T16:21:18.584003Z\", \n \"bank_account\": {\n \"_type\": \"bank_account\", \n \"_uris\": {\n \"credits_uri\": {\n \"_type\": \"page\", \n \"key\": \"credits\"\n }, \n \"debits_uri\": {\n \"_type\": \"page\", \n \"key\": \"debits\"\n }, \n \"verification_uri\": {\n \"_type\": \"bank_account_authentication\", \n \"key\": \"verification\"\n }, \n \"verifications_uri\": {\n \"_type\": \"page\", \n \"key\": \"verifications\"\n }\n }, \n \"account_number\": \"xxxxxx0001\", \n \"bank_code\": \"121000358\", \n \"bank_name\": \"BANK OF AMERICA, N.A.\", \n \"can_debit\": false, \n \"created_at\": \"2013-11-14T16:20:28.771031Z\", \n \"credits_uri\": \"/v1/bank_accounts/BA5gy1b8X8dIGaBWFuoWvkxO/credits\", \n \"customer_uri\": \"/v1/customers/CU5f64LhFMO8cf7N1sQSRVOo\", \n \"debits_uri\": \"/v1/bank_accounts/BA5gy1b8X8dIGaBWFuoWvkxO/debits\", \n \"fingerprint\": \"5f0ba9fa3f1122ef13b944a40abfe44e7eba9e16934e64200913cb4c402ace14\", \n \"id\": \"BA5gy1b8X8dIGaBWFuoWvkxO\", \n \"is_valid\": true, \n \"last_four\": \"0001\", \n \"meta\": {}, \n \"name\": \"Johann Bernoulli\", \n \"routing_number\": \"121000358\", \n \"type\": \"checking\", \n \"uri\": \"/v1/customers/CU5f64LhFMO8cf7N1sQSRVOo/bank_accounts/BA5gy1b8X8dIGaBWFuoWvkxO\", \n \"verification_uri\": \"/v1/bank_accounts/BA5gy1b8X8dIGaBWFuoWvkxO/verifications/BZ5kihRbLIgd64iMWFkWesdw\", \n \"verifications_uri\": \"/v1/bank_accounts/BA5gy1b8X8dIGaBWFuoWvkxO/verifications\"\n }, \n \"created_at\": \"2013-11-14T16:21:18.267102Z\", \n \"customer\": {\n \"_type\": \"customer\", \n \"_uris\": {\n \"bank_accounts_uri\": {\n \"_type\": \"page\", \n \"key\": \"bank_accounts\"\n }, \n \"cards_uri\": {\n \"_type\": \"page\", \n \"key\": \"cards\"\n }, \n \"credits_uri\": {\n \"_type\": \"page\", \n \"key\": \"credits\"\n }, \n \"debits_uri\": {\n \"_type\": \"page\", \n \"key\": \"debits\"\n }, \n \"destination_uri\": {\n \"_type\": \"bank_account\", \n \"key\": \"destination\"\n }, \n \"holds_uri\": {\n \"_type\": \"page\", \n \"key\": \"holds\"\n }, \n \"refunds_uri\": {\n \"_type\": \"page\", \n \"key\": \"refunds\"\n }, \n \"reversals_uri\": {\n \"_type\": \"page\", \n \"key\": \"reversals\"\n }, \n \"transactions_uri\": {\n \"_type\": \"page\", \n \"key\": \"transactions\"\n }\n }, \n \"address\": {}, \n \"bank_accounts_uri\": \"/v1/customers/CU5f64LhFMO8cf7N1sQSRVOo/bank_accounts\", \n \"business_name\": null, \n \"cards_uri\": \"/v1/customers/CU5f64LhFMO8cf7N1sQSRVOo/cards\", \n \"created_at\": \"2013-11-14T16:20:27.468419Z\", \n \"credits_uri\": \"/v1/customers/CU5f64LhFMO8cf7N1sQSRVOo/credits\", \n \"debits_uri\": \"/v1/customers/CU5f64LhFMO8cf7N1sQSRVOo/debits\", \n \"destination_uri\": \"/v1/customers/CU5f64LhFMO8cf7N1sQSRVOo/bank_accounts/BA5gy1b8X8dIGaBWFuoWvkxO\", \n \"dob\": null, \n \"ein\": null, \n \"email\": null, \n \"facebook\": null, \n \"holds_uri\": \"/v1/customers/CU5f64LhFMO8cf7N1sQSRVOo/holds\", \n \"id\": \"CU5f64LhFMO8cf7N1sQSRVOo\", \n \"is_identity_verified\": false, \n \"meta\": {}, \n \"name\": null, \n \"phone\": null, \n \"refunds_uri\": \"/v1/customers/CU5f64LhFMO8cf7N1sQSRVOo/refunds\", \n \"reversals_uri\": \"/v1/customers/CU5f64LhFMO8cf7N1sQSRVOo/reversals\", \n \"source_uri\": null, \n \"ssn_last4\": null, \n \"transactions_uri\": \"/v1/customers/CU5f64LhFMO8cf7N1sQSRVOo/transactions\", \n \"twitter\": null, \n \"uri\": \"/v1/customers/CU5f64LhFMO8cf7N1sQSRVOo\"\n }, \n \"description\": null, \n \"destination\": {\n \"_type\": \"bank_account\", \n \"_uris\": {\n \"credits_uri\": {\n \"_type\": \"page\", \n \"key\": \"credits\"\n }, \n \"debits_uri\": {\n \"_type\": \"page\", \n \"key\": \"debits\"\n }, \n \"verification_uri\": {\n \"_type\": \"bank_account_authentication\", \n \"key\": \"verification\"\n }, \n \"verifications_uri\": {\n \"_type\": \"page\", \n \"key\": \"verifications\"\n }\n }, \n \"account_number\": \"xxxxxx0001\", \n \"bank_code\": \"121000358\", \n \"bank_name\": \"BANK OF AMERICA, N.A.\", \n \"can_debit\": false, \n \"created_at\": \"2013-11-14T16:20:28.771031Z\", \n \"credits_uri\": \"/v1/bank_accounts/BA5gy1b8X8dIGaBWFuoWvkxO/credits\", \n \"customer_uri\": \"/v1/customers/CU5f64LhFMO8cf7N1sQSRVOo\", \n \"debits_uri\": \"/v1/bank_accounts/BA5gy1b8X8dIGaBWFuoWvkxO/debits\", \n \"fingerprint\": \"5f0ba9fa3f1122ef13b944a40abfe44e7eba9e16934e64200913cb4c402ace14\", \n \"id\": \"BA5gy1b8X8dIGaBWFuoWvkxO\", \n \"is_valid\": true, \n \"last_four\": \"0001\", \n \"meta\": {}, \n \"name\": \"Johann Bernoulli\", \n \"routing_number\": \"121000358\", \n \"type\": \"checking\", \n \"uri\": \"/v1/customers/CU5f64LhFMO8cf7N1sQSRVOo/bank_accounts/BA5gy1b8X8dIGaBWFuoWvkxO\", \n \"verification_uri\": \"/v1/bank_accounts/BA5gy1b8X8dIGaBWFuoWvkxO/verifications/BZ5kihRbLIgd64iMWFkWesdw\", \n \"verifications_uri\": \"/v1/bank_accounts/BA5gy1b8X8dIGaBWFuoWvkxO/verifications\"\n }, \n \"events_uri\": \"/v1/credits/CR6admOtZKuECF3I9UlCiWzm/events\", \n \"fee\": null, \n \"id\": \"CR6admOtZKuECF3I9UlCiWzm\", \n \"meta\": {}, \n \"reversals_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/credits/CR6admOtZKuECF3I9UlCiWzm/reversals\", \n \"state\": \"cleared\", \n \"status\": \"paid\", \n \"transaction_number\": \"CR004-468-9882\", \n \"uri\": \"/v1/customers/CU5f64LhFMO8cf7N1sQSRVOo/credits/CR6admOtZKuECF3I9UlCiWzm\"\n}" - }, - "customer_delete": { - "request": { - "uri": "/v1/customers/CU6sqf8CB3M3l6VeSsBqVHhC" - } - }, - "debit_create": { - "request": { - "customer_uri": "/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS", - "debits_uri": "/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/debits", - "payload": { - "amount": 5000, - "appears_on_statement_as": "Statement text", - "description": "Some descriptive text for the debit in the dashboard" - } - }, - "response": "{\n \"_type\": \"debit\", \n \"_uris\": {\n \"events_uri\": {\n \"_type\": \"page\", \n \"key\": \"events\"\n }, \n \"refunds_uri\": {\n \"_type\": \"page\", \n \"key\": \"refunds\"\n }\n }, \n \"amount\": 5000, \n \"appears_on_statement_as\": \"Statement text\", \n \"available_at\": \"2013-11-14T16:22:26.746556Z\", \n \"created_at\": \"2013-11-14T16:22:25.975814Z\", \n \"customer\": {\n \"_type\": \"customer\", \n \"_uris\": {\n \"bank_accounts_uri\": {\n \"_type\": \"page\", \n \"key\": \"bank_accounts\"\n }, \n \"cards_uri\": {\n \"_type\": \"page\", \n \"key\": \"cards\"\n }, \n \"credits_uri\": {\n \"_type\": \"page\", \n \"key\": \"credits\"\n }, \n \"debits_uri\": {\n \"_type\": \"page\", \n \"key\": \"debits\"\n }, \n \"holds_uri\": {\n \"_type\": \"page\", \n \"key\": \"holds\"\n }, \n \"refunds_uri\": {\n \"_type\": \"page\", \n \"key\": \"refunds\"\n }, \n \"reversals_uri\": {\n \"_type\": \"page\", \n \"key\": \"reversals\"\n }, \n \"source_uri\": {\n \"_type\": \"card\", \n \"key\": \"source\"\n }, \n \"transactions_uri\": {\n \"_type\": \"page\", \n \"key\": \"transactions\"\n }\n }, \n \"address\": {}, \n \"bank_accounts_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/bank_accounts\", \n \"business_name\": null, \n \"cards_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/cards\", \n \"created_at\": \"2013-11-14T16:22:19.231687Z\", \n \"credits_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/credits\", \n \"debits_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/debits\", \n \"destination_uri\": null, \n \"dob\": null, \n \"ein\": null, \n \"email\": null, \n \"facebook\": null, \n \"holds_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/holds\", \n \"id\": \"CU7gMTGKh2yGHYn1lUxH9STS\", \n \"is_identity_verified\": false, \n \"meta\": {}, \n \"name\": null, \n \"phone\": null, \n \"refunds_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/refunds\", \n \"reversals_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/reversals\", \n \"source_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/cards/CC7iFRCb5AvLuZ9qzIF0VMmA\", \n \"ssn_last4\": null, \n \"transactions_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/transactions\", \n \"twitter\": null, \n \"uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS\"\n }, \n \"description\": \"Some descriptive text for the debit in the dashboard\", \n \"events_uri\": \"/v1/debits/WD7omMnm45N2JcPZ6fcaRRgY/events\", \n \"fee\": null, \n \"hold\": {\n \"_type\": \"hold\", \n \"_uris\": {\n \"debit_uri\": {\n \"_type\": \"debit\", \n \"key\": \"debit\"\n }, \n \"events_uri\": {\n \"_type\": \"page\", \n \"key\": \"events\"\n }, \n \"source_uri\": {\n \"_type\": \"card\", \n \"key\": \"source\"\n }\n }, \n \"amount\": 5000, \n \"created_at\": \"2013-11-14T16:22:25.945916Z\", \n \"customer_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS\", \n \"debit_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/debits/WD7omMnm45N2JcPZ6fcaRRgY\", \n \"description\": \"Some descriptive text for the debit in the dashboard\", \n \"events_uri\": \"/v1/holds/HL7ol64Qezs7DVaup1KqTHn2/events\", \n \"expires_at\": \"2013-11-21T16:22:26.324832Z\", \n \"fee\": null, \n \"id\": \"HL7ol64Qezs7DVaup1KqTHn2\", \n \"is_void\": false, \n \"meta\": {}, \n \"source_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU7gMTGKh2yGHYn1lUxH9STS/cards/CC7iFRCb5AvLuZ9qzIF0VMmA\", \n \"transaction_number\": \"HL750-344-1146\", \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/holds/HL7ol64Qezs7DVaup1KqTHn2\"\n }, \n \"id\": \"WD7omMnm45N2JcPZ6fcaRRgY\", \n \"meta\": {}, \n \"on_behalf_of\": null, \n \"refunds_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/debits/WD7omMnm45N2JcPZ6fcaRRgY/refunds\", \n \"source\": {\n \"_type\": \"card\", \n \"_uris\": {}, \n \"brand\": \"MasterCard\", \n \"card_type\": \"mastercard\", \n \"country_code\": null, \n \"created_at\": \"2013-11-14T16:22:20.900440Z\", \n \"customer_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS\", \n \"expiration_month\": 12, \n \"expiration_year\": 2020, \n \"hash\": \"fc4ccd5de54f42a5e75f76fbfde60948440c7a382ee7d21b2bc509ab9cfed788\", \n \"id\": \"CC7iFRCb5AvLuZ9qzIF0VMmA\", \n \"is_valid\": true, \n \"is_verified\": true, \n \"last_four\": \"5100\", \n \"meta\": {}, \n \"name\": null, \n \"postal_code\": null, \n \"postal_code_check\": \"unknown\", \n \"security_code_check\": \"passed\", \n \"street_address\": null, \n \"uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/cards/CC7iFRCb5AvLuZ9qzIF0VMmA\"\n }, \n \"status\": \"succeeded\", \n \"transaction_number\": \"W109-369-8530\", \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/debits/WD7omMnm45N2JcPZ6fcaRRgY\"\n}" - }, - "debit_customer_list": { - "request": { - "debits_uri": "/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/debits", - "uri": "/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS" - }, - "response": "{\n \"_type\": \"customer\", \n \"_uris\": {\n \"bank_accounts_uri\": {\n \"_type\": \"page\", \n \"key\": \"bank_accounts\"\n }, \n \"cards_uri\": {\n \"_type\": \"page\", \n \"key\": \"cards\"\n }, \n \"credits_uri\": {\n \"_type\": \"page\", \n \"key\": \"credits\"\n }, \n \"debits_uri\": {\n \"_type\": \"page\", \n \"key\": \"debits\"\n }, \n \"holds_uri\": {\n \"_type\": \"page\", \n \"key\": \"holds\"\n }, \n \"refunds_uri\": {\n \"_type\": \"page\", \n \"key\": \"refunds\"\n }, \n \"reversals_uri\": {\n \"_type\": \"page\", \n \"key\": \"reversals\"\n }, \n \"source_uri\": {\n \"_type\": \"card\", \n \"key\": \"source\"\n }, \n \"transactions_uri\": {\n \"_type\": \"page\", \n \"key\": \"transactions\"\n }\n }, \n \"address\": {}, \n \"bank_accounts_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/bank_accounts\", \n \"business_name\": null, \n \"cards_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/cards\", \n \"created_at\": \"2013-11-14T16:21:37.144218Z\", \n \"credits_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/credits\", \n \"debits_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/debits\", \n \"destination_uri\": null, \n \"dob\": null, \n \"ein\": null, \n \"email\": null, \n \"facebook\": null, \n \"holds_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/holds\", \n \"id\": \"CU6vs1tjxBtifgTuzKjCGtVS\", \n \"is_identity_verified\": false, \n \"meta\": {}, \n \"name\": null, \n \"phone\": null, \n \"refunds_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/refunds\", \n \"reversals_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/reversals\", \n \"source_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/cards/CC6xbFPglEtPRSEA65a5Bd60\", \n \"ssn_last4\": null, \n \"transactions_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/transactions\", \n \"twitter\": null, \n \"uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS\"\n}" - }, - "debit_list": { - "request": { - "uri": "/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/debits" - }, - "response": "{\n \"_type\": \"page\", \n \"_uris\": {\n \"first_uri\": {\n \"_type\": \"page\", \n \"key\": \"first\"\n }, \n \"last_uri\": {\n \"_type\": \"page\", \n \"key\": \"last\"\n }, \n \"next_uri\": {\n \"_type\": \"page\", \n \"key\": \"next\"\n }, \n \"previous_uri\": {\n \"_type\": \"page\", \n \"key\": \"previous\"\n }\n }, \n \"first_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/debits?limit=2&offset=0\", \n \"items\": [\n {\n \"_type\": \"debit\", \n \"_uris\": {\n \"events_uri\": {\n \"_type\": \"page\", \n \"key\": \"events\"\n }, \n \"refunds_uri\": {\n \"_type\": \"page\", \n \"key\": \"refunds\"\n }\n }, \n \"account\": {\n \"_type\": \"account\", \n \"_uris\": {\n \"bank_accounts_uri\": {\n \"_type\": \"page\", \n \"key\": \"bank_accounts\"\n }, \n \"cards_uri\": {\n \"_type\": \"page\", \n \"key\": \"cards\"\n }, \n \"credits_uri\": {\n \"_type\": \"page\", \n \"key\": \"credits\"\n }, \n \"customer_uri\": {\n \"_type\": \"customer\", \n \"key\": \"customer\"\n }, \n \"debits_uri\": {\n \"_type\": \"page\", \n \"key\": \"debits\"\n }, \n \"holds_uri\": {\n \"_type\": \"page\", \n \"key\": \"holds\"\n }, \n \"refunds_uri\": {\n \"_type\": \"page\", \n \"key\": \"refunds\"\n }, \n \"reversals_uri\": {\n \"_type\": \"page\", \n \"key\": \"reversals\"\n }, \n \"transactions_uri\": {\n \"_type\": \"page\", \n \"key\": \"transactions\"\n }\n }, \n \"bank_accounts_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS/bank_accounts\", \n \"cards_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS/cards\", \n \"created_at\": \"2013-11-14T16:21:37.144218Z\", \n \"credits_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS/credits\", \n \"customer_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS\", \n \"debits_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS/debits\", \n \"email_address\": null, \n \"holds_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS/holds\", \n \"id\": \"CU6vs1tjxBtifgTuzKjCGtVS\", \n \"meta\": {}, \n \"name\": null, \n \"refunds_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS/refunds\", \n \"reversals_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS/reversals\", \n \"roles\": [\n \"buyer\"\n ], \n \"transactions_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS/transactions\", \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS\"\n }, \n \"amount\": 5000, \n \"appears_on_statement_as\": \"Statement text\", \n \"available_at\": \"2013-11-14T16:21:43.776719Z\", \n \"created_at\": \"2013-11-14T16:21:43.104998Z\", \n \"customer\": {\n \"_type\": \"customer\", \n \"_uris\": {\n \"bank_accounts_uri\": {\n \"_type\": \"page\", \n \"key\": \"bank_accounts\"\n }, \n \"cards_uri\": {\n \"_type\": \"page\", \n \"key\": \"cards\"\n }, \n \"credits_uri\": {\n \"_type\": \"page\", \n \"key\": \"credits\"\n }, \n \"debits_uri\": {\n \"_type\": \"page\", \n \"key\": \"debits\"\n }, \n \"holds_uri\": {\n \"_type\": \"page\", \n \"key\": \"holds\"\n }, \n \"refunds_uri\": {\n \"_type\": \"page\", \n \"key\": \"refunds\"\n }, \n \"reversals_uri\": {\n \"_type\": \"page\", \n \"key\": \"reversals\"\n }, \n \"source_uri\": {\n \"_type\": \"card\", \n \"key\": \"source\"\n }, \n \"transactions_uri\": {\n \"_type\": \"page\", \n \"key\": \"transactions\"\n }\n }, \n \"address\": {}, \n \"bank_accounts_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/bank_accounts\", \n \"business_name\": null, \n \"cards_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/cards\", \n \"created_at\": \"2013-11-14T16:21:37.144218Z\", \n \"credits_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/credits\", \n \"debits_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/debits\", \n \"destination_uri\": null, \n \"dob\": null, \n \"ein\": null, \n \"email\": null, \n \"facebook\": null, \n \"holds_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/holds\", \n \"id\": \"CU6vs1tjxBtifgTuzKjCGtVS\", \n \"is_identity_verified\": false, \n \"meta\": {}, \n \"name\": null, \n \"phone\": null, \n \"refunds_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/refunds\", \n \"reversals_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/reversals\", \n \"source_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/cards/CC6xbFPglEtPRSEA65a5Bd60\", \n \"ssn_last4\": null, \n \"transactions_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/transactions\", \n \"twitter\": null, \n \"uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS\"\n }, \n \"description\": \"Some descriptive text for the debit in the dashboard\", \n \"events_uri\": \"/v1/debits/WD6Ca1z3nrRRCdiYT1evN19S/events\", \n \"fee\": null, \n \"hold\": {\n \"_type\": \"hold\", \n \"_uris\": {\n \"debit_uri\": {\n \"_type\": \"debit\", \n \"key\": \"debit\"\n }, \n \"events_uri\": {\n \"_type\": \"page\", \n \"key\": \"events\"\n }, \n \"source_uri\": {\n \"_type\": \"card\", \n \"key\": \"source\"\n }\n }, \n \"account_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS\", \n \"amount\": 5000, \n \"created_at\": \"2013-11-14T16:21:43.080028Z\", \n \"customer_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS\", \n \"debit_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/debits/WD6Ca1z3nrRRCdiYT1evN19S\", \n \"description\": \"Some descriptive text for the debit in the dashboard\", \n \"events_uri\": \"/v1/holds/HL6C8GKLqXoEYiAu7LZdXPLa/events\", \n \"expires_at\": \"2013-11-21T16:21:43.420514Z\", \n \"fee\": null, \n \"id\": \"HL6C8GKLqXoEYiAu7LZdXPLa\", \n \"is_void\": false, \n \"meta\": {}, \n \"source_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS/cards/CC6xbFPglEtPRSEA65a5Bd60\", \n \"transaction_number\": \"HL927-455-6133\", \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/holds/HL6C8GKLqXoEYiAu7LZdXPLa\"\n }, \n \"id\": \"WD6Ca1z3nrRRCdiYT1evN19S\", \n \"meta\": {}, \n \"on_behalf_of\": null, \n \"refunds_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/debits/WD6Ca1z3nrRRCdiYT1evN19S/refunds\", \n \"source\": {\n \"_type\": \"card\", \n \"_uris\": {\n \"account_uri\": {\n \"_type\": \"customer\", \n \"key\": \"account\"\n }\n }, \n \"account_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS\", \n \"brand\": \"MasterCard\", \n \"card_type\": \"mastercard\", \n \"country_code\": null, \n \"created_at\": \"2013-11-14T16:21:38.681465Z\", \n \"customer_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS\", \n \"expiration_month\": 12, \n \"expiration_year\": 2020, \n \"hash\": \"fc4ccd5de54f42a5e75f76fbfde60948440c7a382ee7d21b2bc509ab9cfed788\", \n \"id\": \"CC6xbFPglEtPRSEA65a5Bd60\", \n \"is_valid\": true, \n \"is_verified\": true, \n \"last_four\": \"5100\", \n \"meta\": {}, \n \"name\": null, \n \"postal_code\": null, \n \"postal_code_check\": \"unknown\", \n \"security_code_check\": \"passed\", \n \"street_address\": null, \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS/cards/CC6xbFPglEtPRSEA65a5Bd60\"\n }, \n \"status\": \"succeeded\", \n \"transaction_number\": \"W402-648-3361\", \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/debits/WD6Ca1z3nrRRCdiYT1evN19S\"\n }, \n {\n \"_type\": \"debit\", \n \"_uris\": {\n \"events_uri\": {\n \"_type\": \"page\", \n \"key\": \"events\"\n }, \n \"refunds_uri\": {\n \"_type\": \"page\", \n \"key\": \"refunds\"\n }\n }, \n \"account\": {\n \"_type\": \"account\", \n \"_uris\": {\n \"bank_accounts_uri\": {\n \"_type\": \"page\", \n \"key\": \"bank_accounts\"\n }, \n \"cards_uri\": {\n \"_type\": \"page\", \n \"key\": \"cards\"\n }, \n \"credits_uri\": {\n \"_type\": \"page\", \n \"key\": \"credits\"\n }, \n \"customer_uri\": {\n \"_type\": \"customer\", \n \"key\": \"customer\"\n }, \n \"debits_uri\": {\n \"_type\": \"page\", \n \"key\": \"debits\"\n }, \n \"holds_uri\": {\n \"_type\": \"page\", \n \"key\": \"holds\"\n }, \n \"refunds_uri\": {\n \"_type\": \"page\", \n \"key\": \"refunds\"\n }, \n \"reversals_uri\": {\n \"_type\": \"page\", \n \"key\": \"reversals\"\n }, \n \"transactions_uri\": {\n \"_type\": \"page\", \n \"key\": \"transactions\"\n }\n }, \n \"bank_accounts_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS/bank_accounts\", \n \"cards_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS/cards\", \n \"created_at\": \"2013-11-14T16:21:37.144218Z\", \n \"credits_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS/credits\", \n \"customer_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS\", \n \"debits_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS/debits\", \n \"email_address\": null, \n \"holds_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS/holds\", \n \"id\": \"CU6vs1tjxBtifgTuzKjCGtVS\", \n \"meta\": {}, \n \"name\": null, \n \"refunds_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS/refunds\", \n \"reversals_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS/reversals\", \n \"roles\": [\n \"buyer\"\n ], \n \"transactions_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS/transactions\", \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS\"\n }, \n \"amount\": 5000, \n \"appears_on_statement_as\": \"Statement text\", \n \"available_at\": \"2013-11-14T16:21:40.856280Z\", \n \"created_at\": \"2013-11-14T16:21:40.047691Z\", \n \"customer\": {\n \"_type\": \"customer\", \n \"_uris\": {\n \"bank_accounts_uri\": {\n \"_type\": \"page\", \n \"key\": \"bank_accounts\"\n }, \n \"cards_uri\": {\n \"_type\": \"page\", \n \"key\": \"cards\"\n }, \n \"credits_uri\": {\n \"_type\": \"page\", \n \"key\": \"credits\"\n }, \n \"debits_uri\": {\n \"_type\": \"page\", \n \"key\": \"debits\"\n }, \n \"holds_uri\": {\n \"_type\": \"page\", \n \"key\": \"holds\"\n }, \n \"refunds_uri\": {\n \"_type\": \"page\", \n \"key\": \"refunds\"\n }, \n \"reversals_uri\": {\n \"_type\": \"page\", \n \"key\": \"reversals\"\n }, \n \"source_uri\": {\n \"_type\": \"card\", \n \"key\": \"source\"\n }, \n \"transactions_uri\": {\n \"_type\": \"page\", \n \"key\": \"transactions\"\n }\n }, \n \"address\": {}, \n \"bank_accounts_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/bank_accounts\", \n \"business_name\": null, \n \"cards_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/cards\", \n \"created_at\": \"2013-11-14T16:21:37.144218Z\", \n \"credits_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/credits\", \n \"debits_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/debits\", \n \"destination_uri\": null, \n \"dob\": null, \n \"ein\": null, \n \"email\": null, \n \"facebook\": null, \n \"holds_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/holds\", \n \"id\": \"CU6vs1tjxBtifgTuzKjCGtVS\", \n \"is_identity_verified\": false, \n \"meta\": {}, \n \"name\": null, \n \"phone\": null, \n \"refunds_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/refunds\", \n \"reversals_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/reversals\", \n \"source_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/cards/CC6xbFPglEtPRSEA65a5Bd60\", \n \"ssn_last4\": null, \n \"transactions_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/transactions\", \n \"twitter\": null, \n \"uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS\"\n }, \n \"description\": \"Some descriptive text for the debit in the dashboard\", \n \"events_uri\": \"/v1/debits/WD6yIHxqPrzb1apVYERuB72G/events\", \n \"fee\": null, \n \"hold\": {\n \"_type\": \"hold\", \n \"_uris\": {\n \"debit_uri\": {\n \"_type\": \"debit\", \n \"key\": \"debit\"\n }, \n \"events_uri\": {\n \"_type\": \"page\", \n \"key\": \"events\"\n }, \n \"source_uri\": {\n \"_type\": \"card\", \n \"key\": \"source\"\n }\n }, \n \"account_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS\", \n \"amount\": 5000, \n \"created_at\": \"2013-11-14T16:21:39.991162Z\", \n \"customer_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS\", \n \"debit_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/debits/WD6yIHxqPrzb1apVYERuB72G\", \n \"description\": \"Some descriptive text for the debit in the dashboard\", \n \"events_uri\": \"/v1/holds/HL6yF80ERpTXcYkszqKCUlHY/events\", \n \"expires_at\": \"2013-11-21T16:21:40.450966Z\", \n \"fee\": null, \n \"id\": \"HL6yF80ERpTXcYkszqKCUlHY\", \n \"is_void\": false, \n \"meta\": {}, \n \"source_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS/cards/CC6xbFPglEtPRSEA65a5Bd60\", \n \"transaction_number\": \"HL560-602-3542\", \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/holds/HL6yF80ERpTXcYkszqKCUlHY\"\n }, \n \"id\": \"WD6yIHxqPrzb1apVYERuB72G\", \n \"meta\": {}, \n \"on_behalf_of\": null, \n \"refunds_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/debits/WD6yIHxqPrzb1apVYERuB72G/refunds\", \n \"source\": {\n \"_type\": \"card\", \n \"_uris\": {\n \"account_uri\": {\n \"_type\": \"customer\", \n \"key\": \"account\"\n }\n }, \n \"account_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS\", \n \"brand\": \"MasterCard\", \n \"card_type\": \"mastercard\", \n \"country_code\": null, \n \"created_at\": \"2013-11-14T16:21:38.681465Z\", \n \"customer_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS\", \n \"expiration_month\": 12, \n \"expiration_year\": 2020, \n \"hash\": \"fc4ccd5de54f42a5e75f76fbfde60948440c7a382ee7d21b2bc509ab9cfed788\", \n \"id\": \"CC6xbFPglEtPRSEA65a5Bd60\", \n \"is_valid\": true, \n \"is_verified\": true, \n \"last_four\": \"5100\", \n \"meta\": {}, \n \"name\": null, \n \"postal_code\": null, \n \"postal_code_check\": \"unknown\", \n \"security_code_check\": \"passed\", \n \"street_address\": null, \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS/cards/CC6xbFPglEtPRSEA65a5Bd60\"\n }, \n \"status\": \"succeeded\", \n \"transaction_number\": \"W597-916-7221\", \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/debits/WD6yIHxqPrzb1apVYERuB72G\"\n }\n ], \n \"last_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/debits?limit=2&offset=2\", \n \"limit\": 2, \n \"next_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/debits?limit=2&offset=2\", \n \"offset\": 0, \n \"previous_uri\": null, \n \"total\": 3, \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/debits?limit=2&offset=0\"\n}" - }, - "debit_refund": { - "request": { - "debit_uri": "/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/debits/WD6MTAHor9FhO4G2nvZwaXvi", - "refunds_uri": "/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/debits/WD6MTAHor9FhO4G2nvZwaXvi/refunds" - }, - "response": "{\n \"_type\": \"refund\", \n \"_uris\": {}, \n \"account\": {\n \"_type\": \"account\", \n \"_uris\": {\n \"bank_accounts_uri\": {\n \"_type\": \"page\", \n \"key\": \"bank_accounts\"\n }, \n \"cards_uri\": {\n \"_type\": \"page\", \n \"key\": \"cards\"\n }, \n \"credits_uri\": {\n \"_type\": \"page\", \n \"key\": \"credits\"\n }, \n \"customer_uri\": {\n \"_type\": \"customer\", \n \"key\": \"customer\"\n }, \n \"debits_uri\": {\n \"_type\": \"page\", \n \"key\": \"debits\"\n }, \n \"holds_uri\": {\n \"_type\": \"page\", \n \"key\": \"holds\"\n }, \n \"refunds_uri\": {\n \"_type\": \"page\", \n \"key\": \"refunds\"\n }, \n \"reversals_uri\": {\n \"_type\": \"page\", \n \"key\": \"reversals\"\n }, \n \"transactions_uri\": {\n \"_type\": \"page\", \n \"key\": \"transactions\"\n }\n }, \n \"bank_accounts_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS/bank_accounts\", \n \"cards_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS/cards\", \n \"created_at\": \"2013-11-14T16:21:37.144218Z\", \n \"credits_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS/credits\", \n \"customer_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS\", \n \"debits_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS/debits\", \n \"email_address\": null, \n \"holds_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS/holds\", \n \"id\": \"CU6vs1tjxBtifgTuzKjCGtVS\", \n \"meta\": {}, \n \"name\": null, \n \"refunds_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS/refunds\", \n \"reversals_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS/reversals\", \n \"roles\": [\n \"buyer\"\n ], \n \"transactions_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS/transactions\", \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS\"\n }, \n \"amount\": 5000, \n \"appears_on_statement_as\": \"Statement text\", \n \"created_at\": \"2013-11-14T16:21:54.905713Z\", \n \"customer\": {\n \"_type\": \"customer\", \n \"_uris\": {\n \"bank_accounts_uri\": {\n \"_type\": \"page\", \n \"key\": \"bank_accounts\"\n }, \n \"cards_uri\": {\n \"_type\": \"page\", \n \"key\": \"cards\"\n }, \n \"credits_uri\": {\n \"_type\": \"page\", \n \"key\": \"credits\"\n }, \n \"debits_uri\": {\n \"_type\": \"page\", \n \"key\": \"debits\"\n }, \n \"holds_uri\": {\n \"_type\": \"page\", \n \"key\": \"holds\"\n }, \n \"refunds_uri\": {\n \"_type\": \"page\", \n \"key\": \"refunds\"\n }, \n \"reversals_uri\": {\n \"_type\": \"page\", \n \"key\": \"reversals\"\n }, \n \"source_uri\": {\n \"_type\": \"card\", \n \"key\": \"source\"\n }, \n \"transactions_uri\": {\n \"_type\": \"page\", \n \"key\": \"transactions\"\n }\n }, \n \"address\": {}, \n \"bank_accounts_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/bank_accounts\", \n \"business_name\": null, \n \"cards_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/cards\", \n \"created_at\": \"2013-11-14T16:21:37.144218Z\", \n \"credits_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/credits\", \n \"debits_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/debits\", \n \"destination_uri\": null, \n \"dob\": null, \n \"ein\": null, \n \"email\": null, \n \"facebook\": null, \n \"holds_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/holds\", \n \"id\": \"CU6vs1tjxBtifgTuzKjCGtVS\", \n \"is_identity_verified\": false, \n \"meta\": {}, \n \"name\": null, \n \"phone\": null, \n \"refunds_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/refunds\", \n \"reversals_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/reversals\", \n \"source_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/cards/CC6xbFPglEtPRSEA65a5Bd60\", \n \"ssn_last4\": null, \n \"transactions_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/transactions\", \n \"twitter\": null, \n \"uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS\"\n }, \n \"debit\": {\n \"_type\": \"debit\", \n \"_uris\": {\n \"events_uri\": {\n \"_type\": \"page\", \n \"key\": \"events\"\n }, \n \"hold_uri\": {\n \"_type\": \"hold\", \n \"key\": \"hold\"\n }, \n \"refunds_uri\": {\n \"_type\": \"page\", \n \"key\": \"refunds\"\n }\n }, \n \"account_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS\", \n \"amount\": 5000, \n \"appears_on_statement_as\": \"Statement text\", \n \"available_at\": \"2013-11-14T16:21:54.005354Z\", \n \"created_at\": \"2013-11-14T16:21:52.648535Z\", \n \"customer_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS\", \n \"description\": \"Some descriptive text for the debit in the dashboard\", \n \"events_uri\": \"/v1/debits/WD6MTAHor9FhO4G2nvZwaXvi/events\", \n \"fee\": null, \n \"hold_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/holds/HL6MSFloTodCzP9beAgM2IBW\", \n \"id\": \"WD6MTAHor9FhO4G2nvZwaXvi\", \n \"meta\": {}, \n \"on_behalf_of_uri\": null, \n \"refunds_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/debits/WD6MTAHor9FhO4G2nvZwaXvi/refunds\", \n \"source_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS/cards/CC6xbFPglEtPRSEA65a5Bd60\", \n \"status\": \"succeeded\", \n \"transaction_number\": \"W409-412-6948\", \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/debits/WD6MTAHor9FhO4G2nvZwaXvi\"\n }, \n \"description\": \"Some descriptive text for the debit in the dashboard\", \n \"events_uri\": \"/v1/refunds/RF6PpVmJdJsmaBdtMDwtVd4Q/events\", \n \"fee\": null, \n \"id\": \"RF6PpVmJdJsmaBdtMDwtVd4Q\", \n \"meta\": {}, \n \"status\": \"succeeded\", \n \"transaction_number\": \"RF480-493-3185\", \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/refunds/RF6PpVmJdJsmaBdtMDwtVd4Q\"\n}" - }, - "debit_show": { - "request": { - "uri": "/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/debits/WD6Ca1z3nrRRCdiYT1evN19S" - }, - "response": "{\n \"_type\": \"debit\", \n \"_uris\": {\n \"events_uri\": {\n \"_type\": \"page\", \n \"key\": \"events\"\n }, \n \"refunds_uri\": {\n \"_type\": \"page\", \n \"key\": \"refunds\"\n }\n }, \n \"account\": {\n \"_type\": \"account\", \n \"_uris\": {\n \"bank_accounts_uri\": {\n \"_type\": \"page\", \n \"key\": \"bank_accounts\"\n }, \n \"cards_uri\": {\n \"_type\": \"page\", \n \"key\": \"cards\"\n }, \n \"credits_uri\": {\n \"_type\": \"page\", \n \"key\": \"credits\"\n }, \n \"customer_uri\": {\n \"_type\": \"customer\", \n \"key\": \"customer\"\n }, \n \"debits_uri\": {\n \"_type\": \"page\", \n \"key\": \"debits\"\n }, \n \"holds_uri\": {\n \"_type\": \"page\", \n \"key\": \"holds\"\n }, \n \"refunds_uri\": {\n \"_type\": \"page\", \n \"key\": \"refunds\"\n }, \n \"reversals_uri\": {\n \"_type\": \"page\", \n \"key\": \"reversals\"\n }, \n \"transactions_uri\": {\n \"_type\": \"page\", \n \"key\": \"transactions\"\n }\n }, \n \"bank_accounts_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS/bank_accounts\", \n \"cards_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS/cards\", \n \"created_at\": \"2013-11-14T16:21:37.144218Z\", \n \"credits_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS/credits\", \n \"customer_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS\", \n \"debits_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS/debits\", \n \"email_address\": null, \n \"holds_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS/holds\", \n \"id\": \"CU6vs1tjxBtifgTuzKjCGtVS\", \n \"meta\": {}, \n \"name\": null, \n \"refunds_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS/refunds\", \n \"reversals_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS/reversals\", \n \"roles\": [\n \"buyer\"\n ], \n \"transactions_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS/transactions\", \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS\"\n }, \n \"amount\": 5000, \n \"appears_on_statement_as\": \"Statement text\", \n \"available_at\": \"2013-11-14T16:21:43.776719Z\", \n \"created_at\": \"2013-11-14T16:21:43.104998Z\", \n \"customer\": {\n \"_type\": \"customer\", \n \"_uris\": {\n \"bank_accounts_uri\": {\n \"_type\": \"page\", \n \"key\": \"bank_accounts\"\n }, \n \"cards_uri\": {\n \"_type\": \"page\", \n \"key\": \"cards\"\n }, \n \"credits_uri\": {\n \"_type\": \"page\", \n \"key\": \"credits\"\n }, \n \"debits_uri\": {\n \"_type\": \"page\", \n \"key\": \"debits\"\n }, \n \"holds_uri\": {\n \"_type\": \"page\", \n \"key\": \"holds\"\n }, \n \"refunds_uri\": {\n \"_type\": \"page\", \n \"key\": \"refunds\"\n }, \n \"reversals_uri\": {\n \"_type\": \"page\", \n \"key\": \"reversals\"\n }, \n \"source_uri\": {\n \"_type\": \"card\", \n \"key\": \"source\"\n }, \n \"transactions_uri\": {\n \"_type\": \"page\", \n \"key\": \"transactions\"\n }\n }, \n \"address\": {}, \n \"bank_accounts_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/bank_accounts\", \n \"business_name\": null, \n \"cards_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/cards\", \n \"created_at\": \"2013-11-14T16:21:37.144218Z\", \n \"credits_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/credits\", \n \"debits_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/debits\", \n \"destination_uri\": null, \n \"dob\": null, \n \"ein\": null, \n \"email\": null, \n \"facebook\": null, \n \"holds_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/holds\", \n \"id\": \"CU6vs1tjxBtifgTuzKjCGtVS\", \n \"is_identity_verified\": false, \n \"meta\": {}, \n \"name\": null, \n \"phone\": null, \n \"refunds_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/refunds\", \n \"reversals_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/reversals\", \n \"source_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/cards/CC6xbFPglEtPRSEA65a5Bd60\", \n \"ssn_last4\": null, \n \"transactions_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/transactions\", \n \"twitter\": null, \n \"uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS\"\n }, \n \"description\": \"Some descriptive text for the debit in the dashboard\", \n \"events_uri\": \"/v1/debits/WD6Ca1z3nrRRCdiYT1evN19S/events\", \n \"fee\": null, \n \"hold\": {\n \"_type\": \"hold\", \n \"_uris\": {\n \"debit_uri\": {\n \"_type\": \"debit\", \n \"key\": \"debit\"\n }, \n \"events_uri\": {\n \"_type\": \"page\", \n \"key\": \"events\"\n }, \n \"source_uri\": {\n \"_type\": \"card\", \n \"key\": \"source\"\n }\n }, \n \"account_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS\", \n \"amount\": 5000, \n \"created_at\": \"2013-11-14T16:21:43.080028Z\", \n \"customer_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS\", \n \"debit_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/debits/WD6Ca1z3nrRRCdiYT1evN19S\", \n \"description\": \"Some descriptive text for the debit in the dashboard\", \n \"events_uri\": \"/v1/holds/HL6C8GKLqXoEYiAu7LZdXPLa/events\", \n \"expires_at\": \"2013-11-21T16:21:43.420514Z\", \n \"fee\": null, \n \"id\": \"HL6C8GKLqXoEYiAu7LZdXPLa\", \n \"is_void\": false, \n \"meta\": {}, \n \"source_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS/cards/CC6xbFPglEtPRSEA65a5Bd60\", \n \"transaction_number\": \"HL927-455-6133\", \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/holds/HL6C8GKLqXoEYiAu7LZdXPLa\"\n }, \n \"id\": \"WD6Ca1z3nrRRCdiYT1evN19S\", \n \"meta\": {}, \n \"on_behalf_of\": null, \n \"refunds_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/debits/WD6Ca1z3nrRRCdiYT1evN19S/refunds\", \n \"source\": {\n \"_type\": \"card\", \n \"_uris\": {\n \"account_uri\": {\n \"_type\": \"customer\", \n \"key\": \"account\"\n }\n }, \n \"account_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS\", \n \"brand\": \"MasterCard\", \n \"card_type\": \"mastercard\", \n \"country_code\": null, \n \"created_at\": \"2013-11-14T16:21:38.681465Z\", \n \"customer_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS\", \n \"expiration_month\": 12, \n \"expiration_year\": 2020, \n \"hash\": \"fc4ccd5de54f42a5e75f76fbfde60948440c7a382ee7d21b2bc509ab9cfed788\", \n \"id\": \"CC6xbFPglEtPRSEA65a5Bd60\", \n \"is_valid\": true, \n \"is_verified\": true, \n \"last_four\": \"5100\", \n \"meta\": {}, \n \"name\": null, \n \"postal_code\": null, \n \"postal_code_check\": \"unknown\", \n \"security_code_check\": \"passed\", \n \"street_address\": null, \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS/cards/CC6xbFPglEtPRSEA65a5Bd60\"\n }, \n \"status\": \"succeeded\", \n \"transaction_number\": \"W402-648-3361\", \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/debits/WD6Ca1z3nrRRCdiYT1evN19S\"\n}" - }, - "debit_update": { - "request": { - "payload": { - "description": "New description for debit", - "meta": { - "anykey": "valuegoeshere", - "facebook.id": "1234567890" - } - }, - "uri": "/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/debits/WD6Ca1z3nrRRCdiYT1evN19S" - }, - "response": "{\n \"_type\": \"debit\", \n \"_uris\": {\n \"events_uri\": {\n \"_type\": \"page\", \n \"key\": \"events\"\n }, \n \"refunds_uri\": {\n \"_type\": \"page\", \n \"key\": \"refunds\"\n }\n }, \n \"account\": {\n \"_type\": \"account\", \n \"_uris\": {\n \"bank_accounts_uri\": {\n \"_type\": \"page\", \n \"key\": \"bank_accounts\"\n }, \n \"cards_uri\": {\n \"_type\": \"page\", \n \"key\": \"cards\"\n }, \n \"credits_uri\": {\n \"_type\": \"page\", \n \"key\": \"credits\"\n }, \n \"customer_uri\": {\n \"_type\": \"customer\", \n \"key\": \"customer\"\n }, \n \"debits_uri\": {\n \"_type\": \"page\", \n \"key\": \"debits\"\n }, \n \"holds_uri\": {\n \"_type\": \"page\", \n \"key\": \"holds\"\n }, \n \"refunds_uri\": {\n \"_type\": \"page\", \n \"key\": \"refunds\"\n }, \n \"reversals_uri\": {\n \"_type\": \"page\", \n \"key\": \"reversals\"\n }, \n \"transactions_uri\": {\n \"_type\": \"page\", \n \"key\": \"transactions\"\n }\n }, \n \"bank_accounts_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS/bank_accounts\", \n \"cards_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS/cards\", \n \"created_at\": \"2013-11-14T16:21:37.144218Z\", \n \"credits_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS/credits\", \n \"customer_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS\", \n \"debits_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS/debits\", \n \"email_address\": null, \n \"holds_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS/holds\", \n \"id\": \"CU6vs1tjxBtifgTuzKjCGtVS\", \n \"meta\": {}, \n \"name\": null, \n \"refunds_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS/refunds\", \n \"reversals_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS/reversals\", \n \"roles\": [\n \"buyer\"\n ], \n \"transactions_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS/transactions\", \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS\"\n }, \n \"amount\": 5000, \n \"appears_on_statement_as\": \"Statement text\", \n \"available_at\": \"2013-11-14T16:21:43.776719Z\", \n \"created_at\": \"2013-11-14T16:21:43.104998Z\", \n \"customer\": {\n \"_type\": \"customer\", \n \"_uris\": {\n \"bank_accounts_uri\": {\n \"_type\": \"page\", \n \"key\": \"bank_accounts\"\n }, \n \"cards_uri\": {\n \"_type\": \"page\", \n \"key\": \"cards\"\n }, \n \"credits_uri\": {\n \"_type\": \"page\", \n \"key\": \"credits\"\n }, \n \"debits_uri\": {\n \"_type\": \"page\", \n \"key\": \"debits\"\n }, \n \"holds_uri\": {\n \"_type\": \"page\", \n \"key\": \"holds\"\n }, \n \"refunds_uri\": {\n \"_type\": \"page\", \n \"key\": \"refunds\"\n }, \n \"reversals_uri\": {\n \"_type\": \"page\", \n \"key\": \"reversals\"\n }, \n \"source_uri\": {\n \"_type\": \"card\", \n \"key\": \"source\"\n }, \n \"transactions_uri\": {\n \"_type\": \"page\", \n \"key\": \"transactions\"\n }\n }, \n \"address\": {}, \n \"bank_accounts_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/bank_accounts\", \n \"business_name\": null, \n \"cards_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/cards\", \n \"created_at\": \"2013-11-14T16:21:37.144218Z\", \n \"credits_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/credits\", \n \"debits_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/debits\", \n \"destination_uri\": null, \n \"dob\": null, \n \"ein\": null, \n \"email\": null, \n \"facebook\": null, \n \"holds_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/holds\", \n \"id\": \"CU6vs1tjxBtifgTuzKjCGtVS\", \n \"is_identity_verified\": false, \n \"meta\": {}, \n \"name\": null, \n \"phone\": null, \n \"refunds_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/refunds\", \n \"reversals_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/reversals\", \n \"source_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/cards/CC6xbFPglEtPRSEA65a5Bd60\", \n \"ssn_last4\": null, \n \"transactions_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/transactions\", \n \"twitter\": null, \n \"uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS\"\n }, \n \"description\": \"New description for debit\", \n \"events_uri\": \"/v1/debits/WD6Ca1z3nrRRCdiYT1evN19S/events\", \n \"fee\": null, \n \"hold\": {\n \"_type\": \"hold\", \n \"_uris\": {\n \"debit_uri\": {\n \"_type\": \"debit\", \n \"key\": \"debit\"\n }, \n \"events_uri\": {\n \"_type\": \"page\", \n \"key\": \"events\"\n }, \n \"source_uri\": {\n \"_type\": \"card\", \n \"key\": \"source\"\n }\n }, \n \"account_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS\", \n \"amount\": 5000, \n \"created_at\": \"2013-11-14T16:21:43.080028Z\", \n \"customer_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS\", \n \"debit_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/debits/WD6Ca1z3nrRRCdiYT1evN19S\", \n \"description\": \"Some descriptive text for the debit in the dashboard\", \n \"events_uri\": \"/v1/holds/HL6C8GKLqXoEYiAu7LZdXPLa/events\", \n \"expires_at\": \"2013-11-21T16:21:43.420514Z\", \n \"fee\": null, \n \"id\": \"HL6C8GKLqXoEYiAu7LZdXPLa\", \n \"is_void\": false, \n \"meta\": {}, \n \"source_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS/cards/CC6xbFPglEtPRSEA65a5Bd60\", \n \"transaction_number\": \"HL927-455-6133\", \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/holds/HL6C8GKLqXoEYiAu7LZdXPLa\"\n }, \n \"id\": \"WD6Ca1z3nrRRCdiYT1evN19S\", \n \"meta\": {\n \"anykey\": \"valuegoeshere\", \n \"facebook.id\": \"1234567890\"\n }, \n \"on_behalf_of\": null, \n \"refunds_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/debits/WD6Ca1z3nrRRCdiYT1evN19S/refunds\", \n \"source\": {\n \"_type\": \"card\", \n \"_uris\": {\n \"account_uri\": {\n \"_type\": \"customer\", \n \"key\": \"account\"\n }\n }, \n \"account_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS\", \n \"brand\": \"MasterCard\", \n \"card_type\": \"mastercard\", \n \"country_code\": null, \n \"created_at\": \"2013-11-14T16:21:38.681465Z\", \n \"customer_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS\", \n \"expiration_month\": 12, \n \"expiration_year\": 2020, \n \"hash\": \"fc4ccd5de54f42a5e75f76fbfde60948440c7a382ee7d21b2bc509ab9cfed788\", \n \"id\": \"CC6xbFPglEtPRSEA65a5Bd60\", \n \"is_valid\": true, \n \"is_verified\": true, \n \"last_four\": \"5100\", \n \"meta\": {}, \n \"name\": null, \n \"postal_code\": null, \n \"postal_code_check\": \"unknown\", \n \"security_code_check\": \"passed\", \n \"street_address\": null, \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS/cards/CC6xbFPglEtPRSEA65a5Bd60\"\n }, \n \"status\": \"succeeded\", \n \"transaction_number\": \"W402-648-3361\", \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/debits/WD6Ca1z3nrRRCdiYT1evN19S\"\n}" - }, - "event_list": { - "request": { - "uri": "/v1/events" - }, - "response": "{\n \"_type\": \"page\", \n \"_uris\": {\n \"first_uri\": {\n \"_type\": \"page\", \n \"key\": \"first\"\n }, \n \"last_uri\": {\n \"_type\": \"page\", \n \"key\": \"last\"\n }, \n \"next_uri\": {\n \"_type\": \"page\", \n \"key\": \"next\"\n }, \n \"previous_uri\": {\n \"_type\": \"page\", \n \"key\": \"previous\"\n }\n }, \n \"first_uri\": \"/v1/events?limit=2&offset=0\", \n \"items\": [\n {\n \"_type\": \"event\", \n \"_uris\": {\n \"callbacks_uri\": {\n \"_type\": \"page\", \n \"key\": \"callbacks\"\n }\n }, \n \"callback_statuses\": {\n \"failed\": 0, \n \"pending\": 0, \n \"retrying\": 0, \n \"succeeded\": 0\n }, \n \"callbacks_uri\": \"/v1/events/EV9be5771e4d4811e38afd026ba7d31e6f/callbacks\", \n \"entity\": {\n \"_type\": \"account\", \n \"_uris\": {\n \"bank_accounts_uri\": {\n \"_type\": \"page\", \n \"key\": \"bank_accounts\"\n }, \n \"cards_uri\": {\n \"_type\": \"page\", \n \"key\": \"cards\"\n }, \n \"credits_uri\": {\n \"_type\": \"page\", \n \"key\": \"credits\"\n }, \n \"customer_uri\": {\n \"_type\": \"customer\", \n \"key\": \"customer\"\n }, \n \"debits_uri\": {\n \"_type\": \"page\", \n \"key\": \"debits\"\n }, \n \"holds_uri\": {\n \"_type\": \"page\", \n \"key\": \"holds\"\n }, \n \"refunds_uri\": {\n \"_type\": \"page\", \n \"key\": \"refunds\"\n }, \n \"reversals_uri\": {\n \"_type\": \"page\", \n \"key\": \"reversals\"\n }, \n \"transactions_uri\": {\n \"_type\": \"page\", \n \"key\": \"transactions\"\n }\n }, \n \"bank_accounts_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU4K8uglOjNRpZ8JgnSKNCuX/bank_accounts\", \n \"cards_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU4K8uglOjNRpZ8JgnSKNCuX/cards\", \n \"created_at\": \"2013-11-14T16:19:59.943199Z\", \n \"credits_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU4K8uglOjNRpZ8JgnSKNCuX/credits\", \n \"customer_uri\": \"/v1/customers/CU4K8uglOjNRpZ8JgnSKNCuX\", \n \"debits_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU4K8uglOjNRpZ8JgnSKNCuX/debits\", \n \"email_address\": \"whc@example.org\", \n \"holds_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU4K8uglOjNRpZ8JgnSKNCuX/holds\", \n \"id\": \"CU4K8uglOjNRpZ8JgnSKNCuX\", \n \"meta\": {}, \n \"name\": \"William Henry Cavendish III\", \n \"refunds_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU4K8uglOjNRpZ8JgnSKNCuX/refunds\", \n \"reversals_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU4K8uglOjNRpZ8JgnSKNCuX/reversals\", \n \"roles\": [\n \"merchant\", \n \"buyer\"\n ], \n \"transactions_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU4K8uglOjNRpZ8JgnSKNCuX/transactions\", \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU4K8uglOjNRpZ8JgnSKNCuX\"\n }, \n \"id\": \"EV9be5771e4d4811e38afd026ba7d31e6f\", \n \"occurred_at\": \"2013-11-14T16:20:00.110000Z\", \n \"type\": \"account.created\", \n \"uri\": \"/v1/events/EV9be5771e4d4811e38afd026ba7d31e6f\"\n }, \n {\n \"_type\": \"event\", \n \"_uris\": {\n \"callbacks_uri\": {\n \"_type\": \"page\", \n \"key\": \"callbacks\"\n }\n }, \n \"callback_statuses\": {\n \"failed\": 0, \n \"pending\": 0, \n \"retrying\": 0, \n \"succeeded\": 0\n }, \n \"callbacks_uri\": \"/v1/events/EV9c39c6704d4811e38afd026ba7d31e6f/callbacks\", \n \"entity\": {\n \"_type\": \"bank_account\", \n \"_uris\": {\n \"account_uri\": {\n \"_type\": \"customer\", \n \"key\": \"account\"\n }, \n \"credits_uri\": {\n \"_type\": \"page\", \n \"key\": \"credits\"\n }, \n \"debits_uri\": {\n \"_type\": \"page\", \n \"key\": \"debits\"\n }, \n \"verifications_uri\": {\n \"_type\": \"page\", \n \"key\": \"verifications\"\n }\n }, \n \"account_number\": \"xxxxxxxxxxx5555\", \n \"account_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU4K8uglOjNRpZ8JgnSKNCuX\", \n \"bank_code\": \"121042882\", \n \"bank_name\": \"WELLS FARGO BANK NA\", \n \"can_debit\": true, \n \"created_at\": \"2013-11-14T16:20:00.469540Z\", \n \"credits_uri\": \"/v1/bank_accounts/BA4Kmu7splqbtDnER3r9nypx/credits\", \n \"customer_uri\": \"/v1/customers/CU4K8uglOjNRpZ8JgnSKNCuX\", \n \"debits_uri\": \"/v1/bank_accounts/BA4Kmu7splqbtDnER3r9nypx/debits\", \n \"fingerprint\": \"6ybvaLUrJy07phK2EQ7pVk\", \n \"id\": \"BA4Kmu7splqbtDnER3r9nypx\", \n \"is_valid\": true, \n \"last_four\": \"5555\", \n \"meta\": {}, \n \"name\": \"TEST-MERCHANT-BANK-ACCOUNT\", \n \"routing_number\": \"121042882\", \n \"type\": \"CHECKING\", \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU4K8uglOjNRpZ8JgnSKNCuX/bank_accounts/BA4Kmu7splqbtDnER3r9nypx\", \n \"verification_uri\": null, \n \"verifications_uri\": \"/v1/bank_accounts/BA4Kmu7splqbtDnER3r9nypx/verifications\"\n }, \n \"id\": \"EV9c39c6704d4811e38afd026ba7d31e6f\", \n \"occurred_at\": \"2013-11-14T16:20:00.469000Z\", \n \"type\": \"bank_account.created\", \n \"uri\": \"/v1/events/EV9c39c6704d4811e38afd026ba7d31e6f\"\n }\n ], \n \"last_uri\": \"/v1/events?limit=2&offset=86\", \n \"limit\": 2, \n \"next_uri\": \"/v1/events?limit=2&offset=2\", \n \"offset\": 0, \n \"previous_uri\": null, \n \"total\": 87, \n \"uri\": \"/v1/events?limit=2&offset=0\"\n}" - }, - "event_show": { - "request": { - "uri": "/v1/events/EV9be5771e4d4811e38afd026ba7d31e6f" - }, - "response": "{\n \"_type\": \"event\", \n \"_uris\": {\n \"callbacks_uri\": {\n \"_type\": \"page\", \n \"key\": \"callbacks\"\n }\n }, \n \"callback_statuses\": {\n \"failed\": 0, \n \"pending\": 0, \n \"retrying\": 0, \n \"succeeded\": 0\n }, \n \"callbacks_uri\": \"/v1/events/EV9be5771e4d4811e38afd026ba7d31e6f/callbacks\", \n \"entity\": {\n \"_type\": \"account\", \n \"_uris\": {\n \"bank_accounts_uri\": {\n \"_type\": \"page\", \n \"key\": \"bank_accounts\"\n }, \n \"cards_uri\": {\n \"_type\": \"page\", \n \"key\": \"cards\"\n }, \n \"credits_uri\": {\n \"_type\": \"page\", \n \"key\": \"credits\"\n }, \n \"customer_uri\": {\n \"_type\": \"customer\", \n \"key\": \"customer\"\n }, \n \"debits_uri\": {\n \"_type\": \"page\", \n \"key\": \"debits\"\n }, \n \"holds_uri\": {\n \"_type\": \"page\", \n \"key\": \"holds\"\n }, \n \"refunds_uri\": {\n \"_type\": \"page\", \n \"key\": \"refunds\"\n }, \n \"reversals_uri\": {\n \"_type\": \"page\", \n \"key\": \"reversals\"\n }, \n \"transactions_uri\": {\n \"_type\": \"page\", \n \"key\": \"transactions\"\n }\n }, \n \"bank_accounts_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU4K8uglOjNRpZ8JgnSKNCuX/bank_accounts\", \n \"cards_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU4K8uglOjNRpZ8JgnSKNCuX/cards\", \n \"created_at\": \"2013-11-14T16:19:59.943199Z\", \n \"credits_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU4K8uglOjNRpZ8JgnSKNCuX/credits\", \n \"customer_uri\": \"/v1/customers/CU4K8uglOjNRpZ8JgnSKNCuX\", \n \"debits_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU4K8uglOjNRpZ8JgnSKNCuX/debits\", \n \"email_address\": \"whc@example.org\", \n \"holds_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU4K8uglOjNRpZ8JgnSKNCuX/holds\", \n \"id\": \"CU4K8uglOjNRpZ8JgnSKNCuX\", \n \"meta\": {}, \n \"name\": \"William Henry Cavendish III\", \n \"refunds_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU4K8uglOjNRpZ8JgnSKNCuX/refunds\", \n \"reversals_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU4K8uglOjNRpZ8JgnSKNCuX/reversals\", \n \"roles\": [\n \"merchant\", \n \"buyer\"\n ], \n \"transactions_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU4K8uglOjNRpZ8JgnSKNCuX/transactions\", \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU4K8uglOjNRpZ8JgnSKNCuX\"\n }, \n \"id\": \"EV9be5771e4d4811e38afd026ba7d31e6f\", \n \"occurred_at\": \"2013-11-14T16:20:00.110000Z\", \n \"type\": \"account.created\", \n \"uri\": \"/v1/events/EV9be5771e4d4811e38afd026ba7d31e6f\"\n}" - }, - "hold_capture": { - "request": { - "debits_uri": "/v1/customers/CU70CIWA2NrZwwMQqjBuWFUb/debits", - "hold_uri": "/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/holds/HL743q4NqJPc0cxbidCj1WGk", - "payload": { - "appears_on_statement_as": "ShowsUpOnStmt", - "description": "Some descriptive text for the debit in the dashboard" - } - }, - "response": "{\n \"_uris\": {}, \n \"additional\": null, \n \"category_code\": \"request\", \n \"category_type\": \"request\", \n \"description\": \"Missing required field [amount] Your request id is OHMe956b8424d4c11e3b9de026ba7cd33d0.\", \n \"extras\": {\n \"amount\": \"Missing required field [amount]\"\n }, \n \"request_id\": \"OHMe956b8424d4c11e3b9de026ba7cd33d0\", \n \"status\": \"Bad Request\", \n \"status_code\": 400\n}" - }, - "hold_create": { - "request": { - "customer_uri": "/v1/customers/CU70CIWA2NrZwwMQqjBuWFUb", - "debits_uri": "/v1/customers/CU70CIWA2NrZwwMQqjBuWFUb/debits", - "payload": { - "amount": 5000, - "description": "Some descriptive text for the debit in the dashboard", - "source_uri": "/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/cards/CC72hXVwWbCJsozvJoRELzIc" - }, - "uri": "/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/holds" - }, - "response": "{\n \"_type\": \"hold\", \n \"_uris\": {\n \"events_uri\": {\n \"_type\": \"page\", \n \"key\": \"events\"\n }\n }, \n \"account\": {\n \"_type\": \"account\", \n \"_uris\": {\n \"bank_accounts_uri\": {\n \"_type\": \"page\", \n \"key\": \"bank_accounts\"\n }, \n \"cards_uri\": {\n \"_type\": \"page\", \n \"key\": \"cards\"\n }, \n \"credits_uri\": {\n \"_type\": \"page\", \n \"key\": \"credits\"\n }, \n \"customer_uri\": {\n \"_type\": \"customer\", \n \"key\": \"customer\"\n }, \n \"debits_uri\": {\n \"_type\": \"page\", \n \"key\": \"debits\"\n }, \n \"holds_uri\": {\n \"_type\": \"page\", \n \"key\": \"holds\"\n }, \n \"refunds_uri\": {\n \"_type\": \"page\", \n \"key\": \"refunds\"\n }, \n \"reversals_uri\": {\n \"_type\": \"page\", \n \"key\": \"reversals\"\n }, \n \"transactions_uri\": {\n \"_type\": \"page\", \n \"key\": \"transactions\"\n }\n }, \n \"bank_accounts_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU70CIWA2NrZwwMQqjBuWFUb/bank_accounts\", \n \"cards_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU70CIWA2NrZwwMQqjBuWFUb/cards\", \n \"created_at\": \"2013-11-14T16:50:42.841208Z\", \n \"credits_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU70CIWA2NrZwwMQqjBuWFUb/credits\", \n \"customer_uri\": \"/v1/customers/CU70CIWA2NrZwwMQqjBuWFUb\", \n \"debits_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU70CIWA2NrZwwMQqjBuWFUb/debits\", \n \"email_address\": null, \n \"holds_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU70CIWA2NrZwwMQqjBuWFUb/holds\", \n \"id\": \"CU70CIWA2NrZwwMQqjBuWFUb\", \n \"meta\": {}, \n \"name\": null, \n \"refunds_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU70CIWA2NrZwwMQqjBuWFUb/refunds\", \n \"reversals_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU70CIWA2NrZwwMQqjBuWFUb/reversals\", \n \"roles\": [\n \"buyer\"\n ], \n \"transactions_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU70CIWA2NrZwwMQqjBuWFUb/transactions\", \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU70CIWA2NrZwwMQqjBuWFUb\"\n }, \n \"amount\": 5000, \n \"created_at\": \"2013-11-14T16:50:45.885960Z\", \n \"customer\": {\n \"_type\": \"customer\", \n \"_uris\": {\n \"bank_accounts_uri\": {\n \"_type\": \"page\", \n \"key\": \"bank_accounts\"\n }, \n \"cards_uri\": {\n \"_type\": \"page\", \n \"key\": \"cards\"\n }, \n \"credits_uri\": {\n \"_type\": \"page\", \n \"key\": \"credits\"\n }, \n \"debits_uri\": {\n \"_type\": \"page\", \n \"key\": \"debits\"\n }, \n \"holds_uri\": {\n \"_type\": \"page\", \n \"key\": \"holds\"\n }, \n \"refunds_uri\": {\n \"_type\": \"page\", \n \"key\": \"refunds\"\n }, \n \"reversals_uri\": {\n \"_type\": \"page\", \n \"key\": \"reversals\"\n }, \n \"source_uri\": {\n \"_type\": \"card\", \n \"key\": \"source\"\n }, \n \"transactions_uri\": {\n \"_type\": \"page\", \n \"key\": \"transactions\"\n }\n }, \n \"address\": {}, \n \"bank_accounts_uri\": \"/v1/customers/CU70CIWA2NrZwwMQqjBuWFUb/bank_accounts\", \n \"business_name\": null, \n \"cards_uri\": \"/v1/customers/CU70CIWA2NrZwwMQqjBuWFUb/cards\", \n \"created_at\": \"2013-11-14T16:50:42.841208Z\", \n \"credits_uri\": \"/v1/customers/CU70CIWA2NrZwwMQqjBuWFUb/credits\", \n \"debits_uri\": \"/v1/customers/CU70CIWA2NrZwwMQqjBuWFUb/debits\", \n \"destination_uri\": null, \n \"dob\": null, \n \"ein\": null, \n \"email\": null, \n \"facebook\": null, \n \"holds_uri\": \"/v1/customers/CU70CIWA2NrZwwMQqjBuWFUb/holds\", \n \"id\": \"CU70CIWA2NrZwwMQqjBuWFUb\", \n \"is_identity_verified\": false, \n \"meta\": {}, \n \"name\": null, \n \"phone\": null, \n \"refunds_uri\": \"/v1/customers/CU70CIWA2NrZwwMQqjBuWFUb/refunds\", \n \"reversals_uri\": \"/v1/customers/CU70CIWA2NrZwwMQqjBuWFUb/reversals\", \n \"source_uri\": \"/v1/customers/CU70CIWA2NrZwwMQqjBuWFUb/cards/CC72hXVwWbCJsozvJoRELzIc\", \n \"ssn_last4\": null, \n \"transactions_uri\": \"/v1/customers/CU70CIWA2NrZwwMQqjBuWFUb/transactions\", \n \"twitter\": null, \n \"uri\": \"/v1/customers/CU70CIWA2NrZwwMQqjBuWFUb\"\n }, \n \"debit\": null, \n \"description\": \"Some descriptive text for the debit in the dashboard\", \n \"events_uri\": \"/v1/holds/HL743q4NqJPc0cxbidCj1WGk/events\", \n \"expires_at\": \"2013-11-21T16:50:46.060543Z\", \n \"fee\": null, \n \"id\": \"HL743q4NqJPc0cxbidCj1WGk\", \n \"is_void\": false, \n \"meta\": {}, \n \"source\": {\n \"_type\": \"card\", \n \"_uris\": {\n \"account_uri\": {\n \"_type\": \"customer\", \n \"key\": \"account\"\n }\n }, \n \"account_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU70CIWA2NrZwwMQqjBuWFUb\", \n \"brand\": \"MasterCard\", \n \"card_type\": \"mastercard\", \n \"country_code\": null, \n \"created_at\": \"2013-11-14T16:50:44.333724Z\", \n \"customer_uri\": \"/v1/customers/CU70CIWA2NrZwwMQqjBuWFUb\", \n \"expiration_month\": 12, \n \"expiration_year\": 2020, \n \"hash\": \"fc4ccd5de54f42a5e75f76fbfde60948440c7a382ee7d21b2bc509ab9cfed788\", \n \"id\": \"CC72hXVwWbCJsozvJoRELzIc\", \n \"is_valid\": true, \n \"is_verified\": true, \n \"last_four\": \"5100\", \n \"meta\": {}, \n \"name\": null, \n \"postal_code\": null, \n \"postal_code_check\": \"unknown\", \n \"security_code_check\": \"passed\", \n \"street_address\": null, \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU70CIWA2NrZwwMQqjBuWFUb/cards/CC72hXVwWbCJsozvJoRELzIc\"\n }, \n \"transaction_number\": \"HL886-578-0900\", \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/holds/HL743q4NqJPc0cxbidCj1WGk\"\n}" - }, - "hold_customer_list": { - "request": { - "customer_uri": "/v1/customers/CU6ZO6HM8Hf8NMQRMm3ZlCAe", - "uri": "/v1/customers/CU6ZO6HM8Hf8NMQRMm3ZlCAe/holds" - }, - "response": "{\n \"_type\": \"page\", \n \"_uris\": {\n \"first_uri\": {\n \"_type\": \"page\", \n \"key\": \"first\"\n }, \n \"last_uri\": {\n \"_type\": \"page\", \n \"key\": \"last\"\n }, \n \"next_uri\": {\n \"_type\": \"page\", \n \"key\": \"next\"\n }, \n \"previous_uri\": {\n \"_type\": \"page\", \n \"key\": \"previous\"\n }\n }, \n \"first_uri\": \"/v1/customers/CU6ZO6HM8Hf8NMQRMm3ZlCAe/holds?limit=2&offset=0\", \n \"items\": [\n {\n \"_type\": \"hold\", \n \"_uris\": {\n \"events_uri\": {\n \"_type\": \"page\", \n \"key\": \"events\"\n }\n }, \n \"amount\": 5000, \n \"created_at\": \"2013-11-14T16:22:08.051562Z\", \n \"customer\": {\n \"_type\": \"customer\", \n \"_uris\": {\n \"bank_accounts_uri\": {\n \"_type\": \"page\", \n \"key\": \"bank_accounts\"\n }, \n \"cards_uri\": {\n \"_type\": \"page\", \n \"key\": \"cards\"\n }, \n \"credits_uri\": {\n \"_type\": \"page\", \n \"key\": \"credits\"\n }, \n \"debits_uri\": {\n \"_type\": \"page\", \n \"key\": \"debits\"\n }, \n \"holds_uri\": {\n \"_type\": \"page\", \n \"key\": \"holds\"\n }, \n \"refunds_uri\": {\n \"_type\": \"page\", \n \"key\": \"refunds\"\n }, \n \"reversals_uri\": {\n \"_type\": \"page\", \n \"key\": \"reversals\"\n }, \n \"source_uri\": {\n \"_type\": \"card\", \n \"key\": \"source\"\n }, \n \"transactions_uri\": {\n \"_type\": \"page\", \n \"key\": \"transactions\"\n }\n }, \n \"address\": {}, \n \"bank_accounts_uri\": \"/v1/customers/CU6ZO6HM8Hf8NMQRMm3ZlCAe/bank_accounts\", \n \"business_name\": null, \n \"cards_uri\": \"/v1/customers/CU6ZO6HM8Hf8NMQRMm3ZlCAe/cards\", \n \"created_at\": \"2013-11-14T16:22:04.139451Z\", \n \"credits_uri\": \"/v1/customers/CU6ZO6HM8Hf8NMQRMm3ZlCAe/credits\", \n \"debits_uri\": \"/v1/customers/CU6ZO6HM8Hf8NMQRMm3ZlCAe/debits\", \n \"destination_uri\": null, \n \"dob\": null, \n \"ein\": null, \n \"email\": null, \n \"facebook\": null, \n \"holds_uri\": \"/v1/customers/CU6ZO6HM8Hf8NMQRMm3ZlCAe/holds\", \n \"id\": \"CU6ZO6HM8Hf8NMQRMm3ZlCAe\", \n \"is_identity_verified\": false, \n \"meta\": {}, \n \"name\": null, \n \"phone\": null, \n \"refunds_uri\": \"/v1/customers/CU6ZO6HM8Hf8NMQRMm3ZlCAe/refunds\", \n \"reversals_uri\": \"/v1/customers/CU6ZO6HM8Hf8NMQRMm3ZlCAe/reversals\", \n \"source_uri\": \"/v1/customers/CU6ZO6HM8Hf8NMQRMm3ZlCAe/cards/CC720AgbiWsOVlGJ0n9KYp6K\", \n \"ssn_last4\": null, \n \"transactions_uri\": \"/v1/customers/CU6ZO6HM8Hf8NMQRMm3ZlCAe/transactions\", \n \"twitter\": null, \n \"uri\": \"/v1/customers/CU6ZO6HM8Hf8NMQRMm3ZlCAe\"\n }, \n \"debit\": null, \n \"description\": \"Some descriptive text for the debit in the dashboard\", \n \"events_uri\": \"/v1/holds/HL74dRg2HWc5vQwX0kQ9XQfM/events\", \n \"expires_at\": \"2013-11-21T16:22:08.270146Z\", \n \"fee\": null, \n \"id\": \"HL74dRg2HWc5vQwX0kQ9XQfM\", \n \"is_void\": false, \n \"meta\": {}, \n \"source\": {\n \"_type\": \"card\", \n \"_uris\": {}, \n \"brand\": \"MasterCard\", \n \"card_type\": \"mastercard\", \n \"country_code\": null, \n \"created_at\": \"2013-11-14T16:22:06.098768Z\", \n \"customer_uri\": \"/v1/customers/CU6ZO6HM8Hf8NMQRMm3ZlCAe\", \n \"expiration_month\": 12, \n \"expiration_year\": 2020, \n \"hash\": \"fc4ccd5de54f42a5e75f76fbfde60948440c7a382ee7d21b2bc509ab9cfed788\", \n \"id\": \"CC720AgbiWsOVlGJ0n9KYp6K\", \n \"is_valid\": true, \n \"is_verified\": true, \n \"last_four\": \"5100\", \n \"meta\": {}, \n \"name\": null, \n \"postal_code\": null, \n \"postal_code_check\": \"unknown\", \n \"security_code_check\": \"passed\", \n \"street_address\": null, \n \"uri\": \"/v1/customers/CU6ZO6HM8Hf8NMQRMm3ZlCAe/cards/CC720AgbiWsOVlGJ0n9KYp6K\"\n }, \n \"transaction_number\": \"HL274-121-5099\", \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/holds/HL74dRg2HWc5vQwX0kQ9XQfM\"\n }\n ], \n \"last_uri\": \"/v1/customers/CU6ZO6HM8Hf8NMQRMm3ZlCAe/holds?limit=2&offset=0\", \n \"limit\": 2, \n \"next_uri\": null, \n \"offset\": 0, \n \"previous_uri\": null, \n \"total\": 1, \n \"uri\": \"/v1/customers/CU6ZO6HM8Hf8NMQRMm3ZlCAe/holds?limit=2&offset=0\"\n}" - }, - "hold_list": { - "request": { - "uri": "/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/holds" - }, - "response": "{\n \"_type\": \"page\", \n \"_uris\": {\n \"first_uri\": {\n \"_type\": \"page\", \n \"key\": \"first\"\n }, \n \"last_uri\": {\n \"_type\": \"page\", \n \"key\": \"last\"\n }, \n \"next_uri\": {\n \"_type\": \"page\", \n \"key\": \"next\"\n }, \n \"previous_uri\": {\n \"_type\": \"page\", \n \"key\": \"previous\"\n }\n }, \n \"first_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/holds?limit=2&offset=0\", \n \"items\": [\n {\n \"_type\": \"hold\", \n \"_uris\": {\n \"events_uri\": {\n \"_type\": \"page\", \n \"key\": \"events\"\n }\n }, \n \"account\": {\n \"_type\": \"account\", \n \"_uris\": {\n \"bank_accounts_uri\": {\n \"_type\": \"page\", \n \"key\": \"bank_accounts\"\n }, \n \"cards_uri\": {\n \"_type\": \"page\", \n \"key\": \"cards\"\n }, \n \"credits_uri\": {\n \"_type\": \"page\", \n \"key\": \"credits\"\n }, \n \"customer_uri\": {\n \"_type\": \"customer\", \n \"key\": \"customer\"\n }, \n \"debits_uri\": {\n \"_type\": \"page\", \n \"key\": \"debits\"\n }, \n \"holds_uri\": {\n \"_type\": \"page\", \n \"key\": \"holds\"\n }, \n \"refunds_uri\": {\n \"_type\": \"page\", \n \"key\": \"refunds\"\n }, \n \"reversals_uri\": {\n \"_type\": \"page\", \n \"key\": \"reversals\"\n }, \n \"transactions_uri\": {\n \"_type\": \"page\", \n \"key\": \"transactions\"\n }\n }, \n \"bank_accounts_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6ZO6HM8Hf8NMQRMm3ZlCAe/bank_accounts\", \n \"cards_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6ZO6HM8Hf8NMQRMm3ZlCAe/cards\", \n \"created_at\": \"2013-11-14T16:22:04.139451Z\", \n \"credits_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6ZO6HM8Hf8NMQRMm3ZlCAe/credits\", \n \"customer_uri\": \"/v1/customers/CU6ZO6HM8Hf8NMQRMm3ZlCAe\", \n \"debits_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6ZO6HM8Hf8NMQRMm3ZlCAe/debits\", \n \"email_address\": null, \n \"holds_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6ZO6HM8Hf8NMQRMm3ZlCAe/holds\", \n \"id\": \"CU6ZO6HM8Hf8NMQRMm3ZlCAe\", \n \"meta\": {}, \n \"name\": null, \n \"refunds_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6ZO6HM8Hf8NMQRMm3ZlCAe/refunds\", \n \"reversals_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6ZO6HM8Hf8NMQRMm3ZlCAe/reversals\", \n \"roles\": [\n \"buyer\"\n ], \n \"transactions_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6ZO6HM8Hf8NMQRMm3ZlCAe/transactions\", \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6ZO6HM8Hf8NMQRMm3ZlCAe\"\n }, \n \"amount\": 5000, \n \"created_at\": \"2013-11-14T16:22:08.051562Z\", \n \"customer\": {\n \"_type\": \"customer\", \n \"_uris\": {\n \"bank_accounts_uri\": {\n \"_type\": \"page\", \n \"key\": \"bank_accounts\"\n }, \n \"cards_uri\": {\n \"_type\": \"page\", \n \"key\": \"cards\"\n }, \n \"credits_uri\": {\n \"_type\": \"page\", \n \"key\": \"credits\"\n }, \n \"debits_uri\": {\n \"_type\": \"page\", \n \"key\": \"debits\"\n }, \n \"holds_uri\": {\n \"_type\": \"page\", \n \"key\": \"holds\"\n }, \n \"refunds_uri\": {\n \"_type\": \"page\", \n \"key\": \"refunds\"\n }, \n \"reversals_uri\": {\n \"_type\": \"page\", \n \"key\": \"reversals\"\n }, \n \"source_uri\": {\n \"_type\": \"card\", \n \"key\": \"source\"\n }, \n \"transactions_uri\": {\n \"_type\": \"page\", \n \"key\": \"transactions\"\n }\n }, \n \"address\": {}, \n \"bank_accounts_uri\": \"/v1/customers/CU6ZO6HM8Hf8NMQRMm3ZlCAe/bank_accounts\", \n \"business_name\": null, \n \"cards_uri\": \"/v1/customers/CU6ZO6HM8Hf8NMQRMm3ZlCAe/cards\", \n \"created_at\": \"2013-11-14T16:22:04.139451Z\", \n \"credits_uri\": \"/v1/customers/CU6ZO6HM8Hf8NMQRMm3ZlCAe/credits\", \n \"debits_uri\": \"/v1/customers/CU6ZO6HM8Hf8NMQRMm3ZlCAe/debits\", \n \"destination_uri\": null, \n \"dob\": null, \n \"ein\": null, \n \"email\": null, \n \"facebook\": null, \n \"holds_uri\": \"/v1/customers/CU6ZO6HM8Hf8NMQRMm3ZlCAe/holds\", \n \"id\": \"CU6ZO6HM8Hf8NMQRMm3ZlCAe\", \n \"is_identity_verified\": false, \n \"meta\": {}, \n \"name\": null, \n \"phone\": null, \n \"refunds_uri\": \"/v1/customers/CU6ZO6HM8Hf8NMQRMm3ZlCAe/refunds\", \n \"reversals_uri\": \"/v1/customers/CU6ZO6HM8Hf8NMQRMm3ZlCAe/reversals\", \n \"source_uri\": \"/v1/customers/CU6ZO6HM8Hf8NMQRMm3ZlCAe/cards/CC720AgbiWsOVlGJ0n9KYp6K\", \n \"ssn_last4\": null, \n \"transactions_uri\": \"/v1/customers/CU6ZO6HM8Hf8NMQRMm3ZlCAe/transactions\", \n \"twitter\": null, \n \"uri\": \"/v1/customers/CU6ZO6HM8Hf8NMQRMm3ZlCAe\"\n }, \n \"debit\": null, \n \"description\": \"Some descriptive text for the debit in the dashboard\", \n \"events_uri\": \"/v1/holds/HL74dRg2HWc5vQwX0kQ9XQfM/events\", \n \"expires_at\": \"2013-11-21T16:22:08.270146Z\", \n \"fee\": null, \n \"id\": \"HL74dRg2HWc5vQwX0kQ9XQfM\", \n \"is_void\": false, \n \"meta\": {}, \n \"source\": {\n \"_type\": \"card\", \n \"_uris\": {\n \"account_uri\": {\n \"_type\": \"customer\", \n \"key\": \"account\"\n }\n }, \n \"account_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6ZO6HM8Hf8NMQRMm3ZlCAe\", \n \"brand\": \"MasterCard\", \n \"card_type\": \"mastercard\", \n \"country_code\": null, \n \"created_at\": \"2013-11-14T16:22:06.098768Z\", \n \"customer_uri\": \"/v1/customers/CU6ZO6HM8Hf8NMQRMm3ZlCAe\", \n \"expiration_month\": 12, \n \"expiration_year\": 2020, \n \"hash\": \"fc4ccd5de54f42a5e75f76fbfde60948440c7a382ee7d21b2bc509ab9cfed788\", \n \"id\": \"CC720AgbiWsOVlGJ0n9KYp6K\", \n \"is_valid\": true, \n \"is_verified\": true, \n \"last_four\": \"5100\", \n \"meta\": {}, \n \"name\": null, \n \"postal_code\": null, \n \"postal_code_check\": \"unknown\", \n \"security_code_check\": \"passed\", \n \"street_address\": null, \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6ZO6HM8Hf8NMQRMm3ZlCAe/cards/CC720AgbiWsOVlGJ0n9KYp6K\"\n }, \n \"transaction_number\": \"HL274-121-5099\", \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/holds/HL74dRg2HWc5vQwX0kQ9XQfM\"\n }, \n {\n \"_type\": \"hold\", \n \"_uris\": {\n \"events_uri\": {\n \"_type\": \"page\", \n \"key\": \"events\"\n }\n }, \n \"account\": {\n \"_type\": \"account\", \n \"_uris\": {\n \"bank_accounts_uri\": {\n \"_type\": \"page\", \n \"key\": \"bank_accounts\"\n }, \n \"cards_uri\": {\n \"_type\": \"page\", \n \"key\": \"cards\"\n }, \n \"credits_uri\": {\n \"_type\": \"page\", \n \"key\": \"credits\"\n }, \n \"customer_uri\": {\n \"_type\": \"customer\", \n \"key\": \"customer\"\n }, \n \"debits_uri\": {\n \"_type\": \"page\", \n \"key\": \"debits\"\n }, \n \"holds_uri\": {\n \"_type\": \"page\", \n \"key\": \"holds\"\n }, \n \"refunds_uri\": {\n \"_type\": \"page\", \n \"key\": \"refunds\"\n }, \n \"reversals_uri\": {\n \"_type\": \"page\", \n \"key\": \"reversals\"\n }, \n \"transactions_uri\": {\n \"_type\": \"page\", \n \"key\": \"transactions\"\n }\n }, \n \"bank_accounts_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS/bank_accounts\", \n \"cards_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS/cards\", \n \"created_at\": \"2013-11-14T16:21:37.144218Z\", \n \"credits_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS/credits\", \n \"customer_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS\", \n \"debits_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS/debits\", \n \"email_address\": null, \n \"holds_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS/holds\", \n \"id\": \"CU6vs1tjxBtifgTuzKjCGtVS\", \n \"meta\": {}, \n \"name\": null, \n \"refunds_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS/refunds\", \n \"reversals_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS/reversals\", \n \"roles\": [\n \"buyer\"\n ], \n \"transactions_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS/transactions\", \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS\"\n }, \n \"amount\": 5000, \n \"created_at\": \"2013-11-14T16:21:52.630344Z\", \n \"customer\": {\n \"_type\": \"customer\", \n \"_uris\": {\n \"bank_accounts_uri\": {\n \"_type\": \"page\", \n \"key\": \"bank_accounts\"\n }, \n \"cards_uri\": {\n \"_type\": \"page\", \n \"key\": \"cards\"\n }, \n \"credits_uri\": {\n \"_type\": \"page\", \n \"key\": \"credits\"\n }, \n \"debits_uri\": {\n \"_type\": \"page\", \n \"key\": \"debits\"\n }, \n \"holds_uri\": {\n \"_type\": \"page\", \n \"key\": \"holds\"\n }, \n \"refunds_uri\": {\n \"_type\": \"page\", \n \"key\": \"refunds\"\n }, \n \"reversals_uri\": {\n \"_type\": \"page\", \n \"key\": \"reversals\"\n }, \n \"source_uri\": {\n \"_type\": \"card\", \n \"key\": \"source\"\n }, \n \"transactions_uri\": {\n \"_type\": \"page\", \n \"key\": \"transactions\"\n }\n }, \n \"address\": {}, \n \"bank_accounts_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/bank_accounts\", \n \"business_name\": null, \n \"cards_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/cards\", \n \"created_at\": \"2013-11-14T16:21:37.144218Z\", \n \"credits_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/credits\", \n \"debits_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/debits\", \n \"destination_uri\": null, \n \"dob\": null, \n \"ein\": null, \n \"email\": null, \n \"facebook\": null, \n \"holds_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/holds\", \n \"id\": \"CU6vs1tjxBtifgTuzKjCGtVS\", \n \"is_identity_verified\": false, \n \"meta\": {}, \n \"name\": null, \n \"phone\": null, \n \"refunds_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/refunds\", \n \"reversals_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/reversals\", \n \"source_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/cards/CC6xbFPglEtPRSEA65a5Bd60\", \n \"ssn_last4\": null, \n \"transactions_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/transactions\", \n \"twitter\": null, \n \"uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS\"\n }, \n \"debit\": {\n \"_type\": \"debit\", \n \"_uris\": {\n \"events_uri\": {\n \"_type\": \"page\", \n \"key\": \"events\"\n }, \n \"hold_uri\": {\n \"_type\": \"hold\", \n \"key\": \"hold\"\n }, \n \"refunds_uri\": {\n \"_type\": \"page\", \n \"key\": \"refunds\"\n }\n }, \n \"account_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS\", \n \"amount\": 5000, \n \"appears_on_statement_as\": \"Statement text\", \n \"available_at\": \"2013-11-14T16:21:54.005354Z\", \n \"created_at\": \"2013-11-14T16:21:52.648535Z\", \n \"customer_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS\", \n \"description\": \"Some descriptive text for the debit in the dashboard\", \n \"events_uri\": \"/v1/debits/WD6MTAHor9FhO4G2nvZwaXvi/events\", \n \"fee\": null, \n \"hold_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/holds/HL6MSFloTodCzP9beAgM2IBW\", \n \"id\": \"WD6MTAHor9FhO4G2nvZwaXvi\", \n \"meta\": {}, \n \"on_behalf_of_uri\": null, \n \"refunds_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/debits/WD6MTAHor9FhO4G2nvZwaXvi/refunds\", \n \"source_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS/cards/CC6xbFPglEtPRSEA65a5Bd60\", \n \"status\": \"succeeded\", \n \"transaction_number\": \"W409-412-6948\", \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/debits/WD6MTAHor9FhO4G2nvZwaXvi\"\n }, \n \"description\": \"Some descriptive text for the debit in the dashboard\", \n \"events_uri\": \"/v1/holds/HL6MSFloTodCzP9beAgM2IBW/events\", \n \"expires_at\": \"2013-11-21T16:21:52.937144Z\", \n \"fee\": null, \n \"id\": \"HL6MSFloTodCzP9beAgM2IBW\", \n \"is_void\": false, \n \"meta\": {}, \n \"source\": {\n \"_type\": \"card\", \n \"_uris\": {\n \"account_uri\": {\n \"_type\": \"customer\", \n \"key\": \"account\"\n }\n }, \n \"account_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS\", \n \"brand\": \"MasterCard\", \n \"card_type\": \"mastercard\", \n \"country_code\": null, \n \"created_at\": \"2013-11-14T16:21:38.681465Z\", \n \"customer_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS\", \n \"expiration_month\": 12, \n \"expiration_year\": 2020, \n \"hash\": \"fc4ccd5de54f42a5e75f76fbfde60948440c7a382ee7d21b2bc509ab9cfed788\", \n \"id\": \"CC6xbFPglEtPRSEA65a5Bd60\", \n \"is_valid\": true, \n \"is_verified\": true, \n \"last_four\": \"5100\", \n \"meta\": {}, \n \"name\": null, \n \"postal_code\": null, \n \"postal_code_check\": \"unknown\", \n \"security_code_check\": \"passed\", \n \"street_address\": null, \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS/cards/CC6xbFPglEtPRSEA65a5Bd60\"\n }, \n \"transaction_number\": \"HL391-682-9054\", \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/holds/HL6MSFloTodCzP9beAgM2IBW\"\n }\n ], \n \"last_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/holds?limit=2&offset=4\", \n \"limit\": 2, \n \"next_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/holds?limit=2&offset=2\", \n \"offset\": 0, \n \"previous_uri\": null, \n \"total\": 5, \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/holds?limit=2&offset=0\"\n}" - }, - "hold_show": { - "request": { - "uri": "/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/holds/HL74dRg2HWc5vQwX0kQ9XQfM" - }, - "response": "{\n \"_type\": \"hold\", \n \"_uris\": {\n \"events_uri\": {\n \"_type\": \"page\", \n \"key\": \"events\"\n }\n }, \n \"account\": {\n \"_type\": \"account\", \n \"_uris\": {\n \"bank_accounts_uri\": {\n \"_type\": \"page\", \n \"key\": \"bank_accounts\"\n }, \n \"cards_uri\": {\n \"_type\": \"page\", \n \"key\": \"cards\"\n }, \n \"credits_uri\": {\n \"_type\": \"page\", \n \"key\": \"credits\"\n }, \n \"customer_uri\": {\n \"_type\": \"customer\", \n \"key\": \"customer\"\n }, \n \"debits_uri\": {\n \"_type\": \"page\", \n \"key\": \"debits\"\n }, \n \"holds_uri\": {\n \"_type\": \"page\", \n \"key\": \"holds\"\n }, \n \"refunds_uri\": {\n \"_type\": \"page\", \n \"key\": \"refunds\"\n }, \n \"reversals_uri\": {\n \"_type\": \"page\", \n \"key\": \"reversals\"\n }, \n \"transactions_uri\": {\n \"_type\": \"page\", \n \"key\": \"transactions\"\n }\n }, \n \"bank_accounts_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6ZO6HM8Hf8NMQRMm3ZlCAe/bank_accounts\", \n \"cards_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6ZO6HM8Hf8NMQRMm3ZlCAe/cards\", \n \"created_at\": \"2013-11-14T16:22:04.139451Z\", \n \"credits_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6ZO6HM8Hf8NMQRMm3ZlCAe/credits\", \n \"customer_uri\": \"/v1/customers/CU6ZO6HM8Hf8NMQRMm3ZlCAe\", \n \"debits_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6ZO6HM8Hf8NMQRMm3ZlCAe/debits\", \n \"email_address\": null, \n \"holds_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6ZO6HM8Hf8NMQRMm3ZlCAe/holds\", \n \"id\": \"CU6ZO6HM8Hf8NMQRMm3ZlCAe\", \n \"meta\": {}, \n \"name\": null, \n \"refunds_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6ZO6HM8Hf8NMQRMm3ZlCAe/refunds\", \n \"reversals_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6ZO6HM8Hf8NMQRMm3ZlCAe/reversals\", \n \"roles\": [\n \"buyer\"\n ], \n \"transactions_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6ZO6HM8Hf8NMQRMm3ZlCAe/transactions\", \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6ZO6HM8Hf8NMQRMm3ZlCAe\"\n }, \n \"amount\": 5000, \n \"created_at\": \"2013-11-14T16:22:08.051562Z\", \n \"customer\": {\n \"_type\": \"customer\", \n \"_uris\": {\n \"bank_accounts_uri\": {\n \"_type\": \"page\", \n \"key\": \"bank_accounts\"\n }, \n \"cards_uri\": {\n \"_type\": \"page\", \n \"key\": \"cards\"\n }, \n \"credits_uri\": {\n \"_type\": \"page\", \n \"key\": \"credits\"\n }, \n \"debits_uri\": {\n \"_type\": \"page\", \n \"key\": \"debits\"\n }, \n \"holds_uri\": {\n \"_type\": \"page\", \n \"key\": \"holds\"\n }, \n \"refunds_uri\": {\n \"_type\": \"page\", \n \"key\": \"refunds\"\n }, \n \"reversals_uri\": {\n \"_type\": \"page\", \n \"key\": \"reversals\"\n }, \n \"source_uri\": {\n \"_type\": \"card\", \n \"key\": \"source\"\n }, \n \"transactions_uri\": {\n \"_type\": \"page\", \n \"key\": \"transactions\"\n }\n }, \n \"address\": {}, \n \"bank_accounts_uri\": \"/v1/customers/CU6ZO6HM8Hf8NMQRMm3ZlCAe/bank_accounts\", \n \"business_name\": null, \n \"cards_uri\": \"/v1/customers/CU6ZO6HM8Hf8NMQRMm3ZlCAe/cards\", \n \"created_at\": \"2013-11-14T16:22:04.139451Z\", \n \"credits_uri\": \"/v1/customers/CU6ZO6HM8Hf8NMQRMm3ZlCAe/credits\", \n \"debits_uri\": \"/v1/customers/CU6ZO6HM8Hf8NMQRMm3ZlCAe/debits\", \n \"destination_uri\": null, \n \"dob\": null, \n \"ein\": null, \n \"email\": null, \n \"facebook\": null, \n \"holds_uri\": \"/v1/customers/CU6ZO6HM8Hf8NMQRMm3ZlCAe/holds\", \n \"id\": \"CU6ZO6HM8Hf8NMQRMm3ZlCAe\", \n \"is_identity_verified\": false, \n \"meta\": {}, \n \"name\": null, \n \"phone\": null, \n \"refunds_uri\": \"/v1/customers/CU6ZO6HM8Hf8NMQRMm3ZlCAe/refunds\", \n \"reversals_uri\": \"/v1/customers/CU6ZO6HM8Hf8NMQRMm3ZlCAe/reversals\", \n \"source_uri\": \"/v1/customers/CU6ZO6HM8Hf8NMQRMm3ZlCAe/cards/CC720AgbiWsOVlGJ0n9KYp6K\", \n \"ssn_last4\": null, \n \"transactions_uri\": \"/v1/customers/CU6ZO6HM8Hf8NMQRMm3ZlCAe/transactions\", \n \"twitter\": null, \n \"uri\": \"/v1/customers/CU6ZO6HM8Hf8NMQRMm3ZlCAe\"\n }, \n \"debit\": null, \n \"description\": \"Some descriptive text for the debit in the dashboard\", \n \"events_uri\": \"/v1/holds/HL74dRg2HWc5vQwX0kQ9XQfM/events\", \n \"expires_at\": \"2013-11-21T16:22:08.270146Z\", \n \"fee\": null, \n \"id\": \"HL74dRg2HWc5vQwX0kQ9XQfM\", \n \"is_void\": false, \n \"meta\": {}, \n \"source\": {\n \"_type\": \"card\", \n \"_uris\": {\n \"account_uri\": {\n \"_type\": \"customer\", \n \"key\": \"account\"\n }\n }, \n \"account_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6ZO6HM8Hf8NMQRMm3ZlCAe\", \n \"brand\": \"MasterCard\", \n \"card_type\": \"mastercard\", \n \"country_code\": null, \n \"created_at\": \"2013-11-14T16:22:06.098768Z\", \n \"customer_uri\": \"/v1/customers/CU6ZO6HM8Hf8NMQRMm3ZlCAe\", \n \"expiration_month\": 12, \n \"expiration_year\": 2020, \n \"hash\": \"fc4ccd5de54f42a5e75f76fbfde60948440c7a382ee7d21b2bc509ab9cfed788\", \n \"id\": \"CC720AgbiWsOVlGJ0n9KYp6K\", \n \"is_valid\": true, \n \"is_verified\": true, \n \"last_four\": \"5100\", \n \"meta\": {}, \n \"name\": null, \n \"postal_code\": null, \n \"postal_code_check\": \"unknown\", \n \"security_code_check\": \"passed\", \n \"street_address\": null, \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6ZO6HM8Hf8NMQRMm3ZlCAe/cards/CC720AgbiWsOVlGJ0n9KYp6K\"\n }, \n \"transaction_number\": \"HL274-121-5099\", \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/holds/HL74dRg2HWc5vQwX0kQ9XQfM\"\n}" - }, - "hold_update": { - "request": { - "payload": { - "description": "update this description", - "meta": { - "holding.for": "user1", - "meaningful.key": "some.value" - } - }, - "uri": "/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/holds/HL74dRg2HWc5vQwX0kQ9XQfM" - }, - "response": "{\n \"_type\": \"hold\", \n \"_uris\": {\n \"events_uri\": {\n \"_type\": \"page\", \n \"key\": \"events\"\n }\n }, \n \"account\": {\n \"_type\": \"account\", \n \"_uris\": {\n \"bank_accounts_uri\": {\n \"_type\": \"page\", \n \"key\": \"bank_accounts\"\n }, \n \"cards_uri\": {\n \"_type\": \"page\", \n \"key\": \"cards\"\n }, \n \"credits_uri\": {\n \"_type\": \"page\", \n \"key\": \"credits\"\n }, \n \"customer_uri\": {\n \"_type\": \"customer\", \n \"key\": \"customer\"\n }, \n \"debits_uri\": {\n \"_type\": \"page\", \n \"key\": \"debits\"\n }, \n \"holds_uri\": {\n \"_type\": \"page\", \n \"key\": \"holds\"\n }, \n \"refunds_uri\": {\n \"_type\": \"page\", \n \"key\": \"refunds\"\n }, \n \"reversals_uri\": {\n \"_type\": \"page\", \n \"key\": \"reversals\"\n }, \n \"transactions_uri\": {\n \"_type\": \"page\", \n \"key\": \"transactions\"\n }\n }, \n \"bank_accounts_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6ZO6HM8Hf8NMQRMm3ZlCAe/bank_accounts\", \n \"cards_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6ZO6HM8Hf8NMQRMm3ZlCAe/cards\", \n \"created_at\": \"2013-11-14T16:22:04.139451Z\", \n \"credits_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6ZO6HM8Hf8NMQRMm3ZlCAe/credits\", \n \"customer_uri\": \"/v1/customers/CU6ZO6HM8Hf8NMQRMm3ZlCAe\", \n \"debits_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6ZO6HM8Hf8NMQRMm3ZlCAe/debits\", \n \"email_address\": null, \n \"holds_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6ZO6HM8Hf8NMQRMm3ZlCAe/holds\", \n \"id\": \"CU6ZO6HM8Hf8NMQRMm3ZlCAe\", \n \"meta\": {}, \n \"name\": null, \n \"refunds_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6ZO6HM8Hf8NMQRMm3ZlCAe/refunds\", \n \"reversals_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6ZO6HM8Hf8NMQRMm3ZlCAe/reversals\", \n \"roles\": [\n \"buyer\"\n ], \n \"transactions_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6ZO6HM8Hf8NMQRMm3ZlCAe/transactions\", \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6ZO6HM8Hf8NMQRMm3ZlCAe\"\n }, \n \"amount\": 5000, \n \"created_at\": \"2013-11-14T16:22:08.051562Z\", \n \"customer\": {\n \"_type\": \"customer\", \n \"_uris\": {\n \"bank_accounts_uri\": {\n \"_type\": \"page\", \n \"key\": \"bank_accounts\"\n }, \n \"cards_uri\": {\n \"_type\": \"page\", \n \"key\": \"cards\"\n }, \n \"credits_uri\": {\n \"_type\": \"page\", \n \"key\": \"credits\"\n }, \n \"debits_uri\": {\n \"_type\": \"page\", \n \"key\": \"debits\"\n }, \n \"holds_uri\": {\n \"_type\": \"page\", \n \"key\": \"holds\"\n }, \n \"refunds_uri\": {\n \"_type\": \"page\", \n \"key\": \"refunds\"\n }, \n \"reversals_uri\": {\n \"_type\": \"page\", \n \"key\": \"reversals\"\n }, \n \"source_uri\": {\n \"_type\": \"card\", \n \"key\": \"source\"\n }, \n \"transactions_uri\": {\n \"_type\": \"page\", \n \"key\": \"transactions\"\n }\n }, \n \"address\": {}, \n \"bank_accounts_uri\": \"/v1/customers/CU6ZO6HM8Hf8NMQRMm3ZlCAe/bank_accounts\", \n \"business_name\": null, \n \"cards_uri\": \"/v1/customers/CU6ZO6HM8Hf8NMQRMm3ZlCAe/cards\", \n \"created_at\": \"2013-11-14T16:22:04.139451Z\", \n \"credits_uri\": \"/v1/customers/CU6ZO6HM8Hf8NMQRMm3ZlCAe/credits\", \n \"debits_uri\": \"/v1/customers/CU6ZO6HM8Hf8NMQRMm3ZlCAe/debits\", \n \"destination_uri\": null, \n \"dob\": null, \n \"ein\": null, \n \"email\": null, \n \"facebook\": null, \n \"holds_uri\": \"/v1/customers/CU6ZO6HM8Hf8NMQRMm3ZlCAe/holds\", \n \"id\": \"CU6ZO6HM8Hf8NMQRMm3ZlCAe\", \n \"is_identity_verified\": false, \n \"meta\": {}, \n \"name\": null, \n \"phone\": null, \n \"refunds_uri\": \"/v1/customers/CU6ZO6HM8Hf8NMQRMm3ZlCAe/refunds\", \n \"reversals_uri\": \"/v1/customers/CU6ZO6HM8Hf8NMQRMm3ZlCAe/reversals\", \n \"source_uri\": \"/v1/customers/CU6ZO6HM8Hf8NMQRMm3ZlCAe/cards/CC720AgbiWsOVlGJ0n9KYp6K\", \n \"ssn_last4\": null, \n \"transactions_uri\": \"/v1/customers/CU6ZO6HM8Hf8NMQRMm3ZlCAe/transactions\", \n \"twitter\": null, \n \"uri\": \"/v1/customers/CU6ZO6HM8Hf8NMQRMm3ZlCAe\"\n }, \n \"debit\": null, \n \"description\": \"update this description\", \n \"events_uri\": \"/v1/holds/HL74dRg2HWc5vQwX0kQ9XQfM/events\", \n \"expires_at\": \"2013-11-21T16:22:08.270146Z\", \n \"fee\": null, \n \"id\": \"HL74dRg2HWc5vQwX0kQ9XQfM\", \n \"is_void\": false, \n \"meta\": {\n \"holding.for\": \"user1\", \n \"meaningful.key\": \"some.value\"\n }, \n \"source\": {\n \"_type\": \"card\", \n \"_uris\": {\n \"account_uri\": {\n \"_type\": \"customer\", \n \"key\": \"account\"\n }\n }, \n \"account_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6ZO6HM8Hf8NMQRMm3ZlCAe\", \n \"brand\": \"MasterCard\", \n \"card_type\": \"mastercard\", \n \"country_code\": null, \n \"created_at\": \"2013-11-14T16:22:06.098768Z\", \n \"customer_uri\": \"/v1/customers/CU6ZO6HM8Hf8NMQRMm3ZlCAe\", \n \"expiration_month\": 12, \n \"expiration_year\": 2020, \n \"hash\": \"fc4ccd5de54f42a5e75f76fbfde60948440c7a382ee7d21b2bc509ab9cfed788\", \n \"id\": \"CC720AgbiWsOVlGJ0n9KYp6K\", \n \"is_valid\": true, \n \"is_verified\": true, \n \"last_four\": \"5100\", \n \"meta\": {}, \n \"name\": null, \n \"postal_code\": null, \n \"postal_code_check\": \"unknown\", \n \"security_code_check\": \"passed\", \n \"street_address\": null, \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6ZO6HM8Hf8NMQRMm3ZlCAe/cards/CC720AgbiWsOVlGJ0n9KYp6K\"\n }, \n \"transaction_number\": \"HL274-121-5099\", \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/holds/HL74dRg2HWc5vQwX0kQ9XQfM\"\n}" - }, - "hold_void": { - "request": { - "payload": { - "is_void": "true" - }, - "uri": "/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/holds/HL7kzlIJiVvhAmp8xFTMmMPB" - }, - "response": "{\n \"_type\": \"hold\", \n \"_uris\": {\n \"events_uri\": {\n \"_type\": \"page\", \n \"key\": \"events\"\n }\n }, \n \"account\": {\n \"_type\": \"account\", \n \"_uris\": {\n \"bank_accounts_uri\": {\n \"_type\": \"page\", \n \"key\": \"bank_accounts\"\n }, \n \"cards_uri\": {\n \"_type\": \"page\", \n \"key\": \"cards\"\n }, \n \"credits_uri\": {\n \"_type\": \"page\", \n \"key\": \"credits\"\n }, \n \"customer_uri\": {\n \"_type\": \"customer\", \n \"key\": \"customer\"\n }, \n \"debits_uri\": {\n \"_type\": \"page\", \n \"key\": \"debits\"\n }, \n \"holds_uri\": {\n \"_type\": \"page\", \n \"key\": \"holds\"\n }, \n \"refunds_uri\": {\n \"_type\": \"page\", \n \"key\": \"refunds\"\n }, \n \"reversals_uri\": {\n \"_type\": \"page\", \n \"key\": \"reversals\"\n }, \n \"transactions_uri\": {\n \"_type\": \"page\", \n \"key\": \"transactions\"\n }\n }, \n \"bank_accounts_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU7gMTGKh2yGHYn1lUxH9STS/bank_accounts\", \n \"cards_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU7gMTGKh2yGHYn1lUxH9STS/cards\", \n \"created_at\": \"2013-11-14T16:22:19.231687Z\", \n \"credits_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU7gMTGKh2yGHYn1lUxH9STS/credits\", \n \"customer_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS\", \n \"debits_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU7gMTGKh2yGHYn1lUxH9STS/debits\", \n \"email_address\": null, \n \"holds_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU7gMTGKh2yGHYn1lUxH9STS/holds\", \n \"id\": \"CU7gMTGKh2yGHYn1lUxH9STS\", \n \"meta\": {}, \n \"name\": null, \n \"refunds_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU7gMTGKh2yGHYn1lUxH9STS/refunds\", \n \"reversals_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU7gMTGKh2yGHYn1lUxH9STS/reversals\", \n \"roles\": [\n \"buyer\"\n ], \n \"transactions_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU7gMTGKh2yGHYn1lUxH9STS/transactions\", \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU7gMTGKh2yGHYn1lUxH9STS\"\n }, \n \"amount\": 5000, \n \"created_at\": \"2013-11-14T16:22:22.585825Z\", \n \"customer\": {\n \"_type\": \"customer\", \n \"_uris\": {\n \"bank_accounts_uri\": {\n \"_type\": \"page\", \n \"key\": \"bank_accounts\"\n }, \n \"cards_uri\": {\n \"_type\": \"page\", \n \"key\": \"cards\"\n }, \n \"credits_uri\": {\n \"_type\": \"page\", \n \"key\": \"credits\"\n }, \n \"debits_uri\": {\n \"_type\": \"page\", \n \"key\": \"debits\"\n }, \n \"holds_uri\": {\n \"_type\": \"page\", \n \"key\": \"holds\"\n }, \n \"refunds_uri\": {\n \"_type\": \"page\", \n \"key\": \"refunds\"\n }, \n \"reversals_uri\": {\n \"_type\": \"page\", \n \"key\": \"reversals\"\n }, \n \"source_uri\": {\n \"_type\": \"card\", \n \"key\": \"source\"\n }, \n \"transactions_uri\": {\n \"_type\": \"page\", \n \"key\": \"transactions\"\n }\n }, \n \"address\": {}, \n \"bank_accounts_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/bank_accounts\", \n \"business_name\": null, \n \"cards_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/cards\", \n \"created_at\": \"2013-11-14T16:22:19.231687Z\", \n \"credits_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/credits\", \n \"debits_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/debits\", \n \"destination_uri\": null, \n \"dob\": null, \n \"ein\": null, \n \"email\": null, \n \"facebook\": null, \n \"holds_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/holds\", \n \"id\": \"CU7gMTGKh2yGHYn1lUxH9STS\", \n \"is_identity_verified\": false, \n \"meta\": {}, \n \"name\": null, \n \"phone\": null, \n \"refunds_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/refunds\", \n \"reversals_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/reversals\", \n \"source_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/cards/CC7iFRCb5AvLuZ9qzIF0VMmA\", \n \"ssn_last4\": null, \n \"transactions_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/transactions\", \n \"twitter\": null, \n \"uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS\"\n }, \n \"debit\": null, \n \"description\": \"Some descriptive text for the debit in the dashboard\", \n \"events_uri\": \"/v1/holds/HL7kzlIJiVvhAmp8xFTMmMPB/events\", \n \"expires_at\": \"2013-11-21T16:22:22.788253Z\", \n \"fee\": null, \n \"id\": \"HL7kzlIJiVvhAmp8xFTMmMPB\", \n \"is_void\": true, \n \"meta\": {}, \n \"source\": {\n \"_type\": \"card\", \n \"_uris\": {\n \"account_uri\": {\n \"_type\": \"customer\", \n \"key\": \"account\"\n }\n }, \n \"account_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU7gMTGKh2yGHYn1lUxH9STS\", \n \"brand\": \"MasterCard\", \n \"card_type\": \"mastercard\", \n \"country_code\": null, \n \"created_at\": \"2013-11-14T16:22:20.900440Z\", \n \"customer_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS\", \n \"expiration_month\": 12, \n \"expiration_year\": 2020, \n \"hash\": \"fc4ccd5de54f42a5e75f76fbfde60948440c7a382ee7d21b2bc509ab9cfed788\", \n \"id\": \"CC7iFRCb5AvLuZ9qzIF0VMmA\", \n \"is_valid\": true, \n \"is_verified\": true, \n \"last_four\": \"5100\", \n \"meta\": {}, \n \"name\": null, \n \"postal_code\": null, \n \"postal_code_check\": \"unknown\", \n \"security_code_check\": \"passed\", \n \"street_address\": null, \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU7gMTGKh2yGHYn1lUxH9STS/cards/CC7iFRCb5AvLuZ9qzIF0VMmA\"\n }, \n \"transaction_number\": \"HL161-334-3152\", \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/holds/HL7kzlIJiVvhAmp8xFTMmMPB\"\n}" - }, - "marketplace_id": "TEST-MP4K6K0PWGyPtXL4LZ42sQSb", - "marketplace_uri": "/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb", - "refund_create": { - "request": { - "debit_uri": "/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/debits/WD7omMnm45N2JcPZ6fcaRRgY", - "payload": { - "debit_uri": "/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/debits/WD7omMnm45N2JcPZ6fcaRRgY", - "description": "Refund for Order #1111", - "meta": { - "fulfillment.item.condition": "OK", - "merchant.feedback": "positive", - "user.refund_reason": "not happy with product" - } - }, - "uri": "/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/refunds" - }, - "response": "{\n \"_type\": \"refund\", \n \"_uris\": {}, \n \"amount\": 5000, \n \"appears_on_statement_as\": \"Statement text\", \n \"created_at\": \"2013-11-14T16:22:27.894146Z\", \n \"customer\": {\n \"_type\": \"customer\", \n \"_uris\": {\n \"bank_accounts_uri\": {\n \"_type\": \"page\", \n \"key\": \"bank_accounts\"\n }, \n \"cards_uri\": {\n \"_type\": \"page\", \n \"key\": \"cards\"\n }, \n \"credits_uri\": {\n \"_type\": \"page\", \n \"key\": \"credits\"\n }, \n \"debits_uri\": {\n \"_type\": \"page\", \n \"key\": \"debits\"\n }, \n \"holds_uri\": {\n \"_type\": \"page\", \n \"key\": \"holds\"\n }, \n \"refunds_uri\": {\n \"_type\": \"page\", \n \"key\": \"refunds\"\n }, \n \"reversals_uri\": {\n \"_type\": \"page\", \n \"key\": \"reversals\"\n }, \n \"source_uri\": {\n \"_type\": \"card\", \n \"key\": \"source\"\n }, \n \"transactions_uri\": {\n \"_type\": \"page\", \n \"key\": \"transactions\"\n }\n }, \n \"address\": {}, \n \"bank_accounts_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/bank_accounts\", \n \"business_name\": null, \n \"cards_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/cards\", \n \"created_at\": \"2013-11-14T16:22:19.231687Z\", \n \"credits_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/credits\", \n \"debits_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/debits\", \n \"destination_uri\": null, \n \"dob\": null, \n \"ein\": null, \n \"email\": null, \n \"facebook\": null, \n \"holds_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/holds\", \n \"id\": \"CU7gMTGKh2yGHYn1lUxH9STS\", \n \"is_identity_verified\": false, \n \"meta\": {}, \n \"name\": null, \n \"phone\": null, \n \"refunds_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/refunds\", \n \"reversals_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/reversals\", \n \"source_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/cards/CC7iFRCb5AvLuZ9qzIF0VMmA\", \n \"ssn_last4\": null, \n \"transactions_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/transactions\", \n \"twitter\": null, \n \"uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS\"\n }, \n \"debit\": {\n \"_type\": \"debit\", \n \"_uris\": {\n \"events_uri\": {\n \"_type\": \"page\", \n \"key\": \"events\"\n }, \n \"hold_uri\": {\n \"_type\": \"hold\", \n \"key\": \"hold\"\n }, \n \"refunds_uri\": {\n \"_type\": \"page\", \n \"key\": \"refunds\"\n }\n }, \n \"amount\": 5000, \n \"appears_on_statement_as\": \"Statement text\", \n \"available_at\": \"2013-11-14T16:22:26.746556Z\", \n \"created_at\": \"2013-11-14T16:22:25.975814Z\", \n \"customer_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS\", \n \"description\": \"Some descriptive text for the debit in the dashboard\", \n \"events_uri\": \"/v1/debits/WD7omMnm45N2JcPZ6fcaRRgY/events\", \n \"fee\": null, \n \"hold_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/holds/HL7ol64Qezs7DVaup1KqTHn2\", \n \"id\": \"WD7omMnm45N2JcPZ6fcaRRgY\", \n \"meta\": {}, \n \"on_behalf_of_uri\": null, \n \"refunds_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/debits/WD7omMnm45N2JcPZ6fcaRRgY/refunds\", \n \"source_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU7gMTGKh2yGHYn1lUxH9STS/cards/CC7iFRCb5AvLuZ9qzIF0VMmA\", \n \"status\": \"succeeded\", \n \"transaction_number\": \"W109-369-8530\", \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/debits/WD7omMnm45N2JcPZ6fcaRRgY\"\n }, \n \"description\": \"Refund for Order #1111\", \n \"events_uri\": \"/v1/refunds/RF7qwuLxprQJuVGf7sTAdwKc/events\", \n \"fee\": null, \n \"id\": \"RF7qwuLxprQJuVGf7sTAdwKc\", \n \"meta\": {\n \"fulfillment.item.condition\": \"OK\", \n \"merchant.feedback\": \"positive\", \n \"user.refund_reason\": \"not happy with product\"\n }, \n \"status\": \"succeeded\", \n \"transaction_number\": \"RF442-144-9327\", \n \"uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/refunds/RF7qwuLxprQJuVGf7sTAdwKc\"\n}" - }, - "refund_customer_list": { - "request": { - "customer_uri": "/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS", - "uri": "/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/refunds" - }, - "response": "{\n \"_type\": \"page\", \n \"_uris\": {\n \"first_uri\": {\n \"_type\": \"page\", \n \"key\": \"first\"\n }, \n \"last_uri\": {\n \"_type\": \"page\", \n \"key\": \"last\"\n }, \n \"next_uri\": {\n \"_type\": \"page\", \n \"key\": \"next\"\n }, \n \"previous_uri\": {\n \"_type\": \"page\", \n \"key\": \"previous\"\n }\n }, \n \"first_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/refunds?limit=2&offset=0\", \n \"items\": [\n {\n \"_type\": \"refund\", \n \"_uris\": {}, \n \"amount\": 5000, \n \"appears_on_statement_as\": \"Statement text\", \n \"created_at\": \"2013-11-14T16:22:27.894146Z\", \n \"customer\": {\n \"_type\": \"customer\", \n \"_uris\": {\n \"bank_accounts_uri\": {\n \"_type\": \"page\", \n \"key\": \"bank_accounts\"\n }, \n \"cards_uri\": {\n \"_type\": \"page\", \n \"key\": \"cards\"\n }, \n \"credits_uri\": {\n \"_type\": \"page\", \n \"key\": \"credits\"\n }, \n \"debits_uri\": {\n \"_type\": \"page\", \n \"key\": \"debits\"\n }, \n \"holds_uri\": {\n \"_type\": \"page\", \n \"key\": \"holds\"\n }, \n \"refunds_uri\": {\n \"_type\": \"page\", \n \"key\": \"refunds\"\n }, \n \"reversals_uri\": {\n \"_type\": \"page\", \n \"key\": \"reversals\"\n }, \n \"source_uri\": {\n \"_type\": \"card\", \n \"key\": \"source\"\n }, \n \"transactions_uri\": {\n \"_type\": \"page\", \n \"key\": \"transactions\"\n }\n }, \n \"address\": {}, \n \"bank_accounts_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/bank_accounts\", \n \"business_name\": null, \n \"cards_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/cards\", \n \"created_at\": \"2013-11-14T16:22:19.231687Z\", \n \"credits_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/credits\", \n \"debits_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/debits\", \n \"destination_uri\": null, \n \"dob\": null, \n \"ein\": null, \n \"email\": null, \n \"facebook\": null, \n \"holds_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/holds\", \n \"id\": \"CU7gMTGKh2yGHYn1lUxH9STS\", \n \"is_identity_verified\": false, \n \"meta\": {}, \n \"name\": null, \n \"phone\": null, \n \"refunds_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/refunds\", \n \"reversals_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/reversals\", \n \"source_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/cards/CC7iFRCb5AvLuZ9qzIF0VMmA\", \n \"ssn_last4\": null, \n \"transactions_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/transactions\", \n \"twitter\": null, \n \"uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS\"\n }, \n \"debit\": {\n \"_type\": \"debit\", \n \"_uris\": {\n \"events_uri\": {\n \"_type\": \"page\", \n \"key\": \"events\"\n }, \n \"hold_uri\": {\n \"_type\": \"hold\", \n \"key\": \"hold\"\n }, \n \"refunds_uri\": {\n \"_type\": \"page\", \n \"key\": \"refunds\"\n }\n }, \n \"amount\": 5000, \n \"appears_on_statement_as\": \"Statement text\", \n \"available_at\": \"2013-11-14T16:22:26.746556Z\", \n \"created_at\": \"2013-11-14T16:22:25.975814Z\", \n \"customer_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS\", \n \"description\": \"Some descriptive text for the debit in the dashboard\", \n \"events_uri\": \"/v1/debits/WD7omMnm45N2JcPZ6fcaRRgY/events\", \n \"fee\": null, \n \"hold_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/holds/HL7ol64Qezs7DVaup1KqTHn2\", \n \"id\": \"WD7omMnm45N2JcPZ6fcaRRgY\", \n \"meta\": {}, \n \"on_behalf_of_uri\": null, \n \"refunds_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/debits/WD7omMnm45N2JcPZ6fcaRRgY/refunds\", \n \"source_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU7gMTGKh2yGHYn1lUxH9STS/cards/CC7iFRCb5AvLuZ9qzIF0VMmA\", \n \"status\": \"succeeded\", \n \"transaction_number\": \"W109-369-8530\", \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/debits/WD7omMnm45N2JcPZ6fcaRRgY\"\n }, \n \"description\": \"Refund for Order #1111\", \n \"events_uri\": \"/v1/refunds/RF7qwuLxprQJuVGf7sTAdwKc/events\", \n \"fee\": null, \n \"id\": \"RF7qwuLxprQJuVGf7sTAdwKc\", \n \"meta\": {\n \"fulfillment.item.condition\": \"OK\", \n \"merchant.feedback\": \"positive\", \n \"user.refund_reason\": \"not happy with product\"\n }, \n \"status\": \"succeeded\", \n \"transaction_number\": \"RF442-144-9327\", \n \"uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/refunds/RF7qwuLxprQJuVGf7sTAdwKc\"\n }\n ], \n \"last_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/refunds?limit=2&offset=0\", \n \"limit\": 2, \n \"next_uri\": null, \n \"offset\": 0, \n \"previous_uri\": null, \n \"total\": 1, \n \"uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/refunds?limit=2&offset=0\"\n}" - }, - "refund_list": { - "request": { - "uri": "/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/refunds" - }, - "response": "{\n \"_type\": \"page\", \n \"_uris\": {\n \"first_uri\": {\n \"_type\": \"page\", \n \"key\": \"first\"\n }, \n \"last_uri\": {\n \"_type\": \"page\", \n \"key\": \"last\"\n }, \n \"next_uri\": {\n \"_type\": \"page\", \n \"key\": \"next\"\n }, \n \"previous_uri\": {\n \"_type\": \"page\", \n \"key\": \"previous\"\n }\n }, \n \"first_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/refunds?limit=2&offset=0\", \n \"items\": [\n {\n \"_type\": \"refund\", \n \"_uris\": {}, \n \"account\": {\n \"_type\": \"account\", \n \"_uris\": {\n \"bank_accounts_uri\": {\n \"_type\": \"page\", \n \"key\": \"bank_accounts\"\n }, \n \"cards_uri\": {\n \"_type\": \"page\", \n \"key\": \"cards\"\n }, \n \"credits_uri\": {\n \"_type\": \"page\", \n \"key\": \"credits\"\n }, \n \"customer_uri\": {\n \"_type\": \"customer\", \n \"key\": \"customer\"\n }, \n \"debits_uri\": {\n \"_type\": \"page\", \n \"key\": \"debits\"\n }, \n \"holds_uri\": {\n \"_type\": \"page\", \n \"key\": \"holds\"\n }, \n \"refunds_uri\": {\n \"_type\": \"page\", \n \"key\": \"refunds\"\n }, \n \"reversals_uri\": {\n \"_type\": \"page\", \n \"key\": \"reversals\"\n }, \n \"transactions_uri\": {\n \"_type\": \"page\", \n \"key\": \"transactions\"\n }\n }, \n \"bank_accounts_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU7gMTGKh2yGHYn1lUxH9STS/bank_accounts\", \n \"cards_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU7gMTGKh2yGHYn1lUxH9STS/cards\", \n \"created_at\": \"2013-11-14T16:22:19.231687Z\", \n \"credits_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU7gMTGKh2yGHYn1lUxH9STS/credits\", \n \"customer_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS\", \n \"debits_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU7gMTGKh2yGHYn1lUxH9STS/debits\", \n \"email_address\": null, \n \"holds_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU7gMTGKh2yGHYn1lUxH9STS/holds\", \n \"id\": \"CU7gMTGKh2yGHYn1lUxH9STS\", \n \"meta\": {}, \n \"name\": null, \n \"refunds_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU7gMTGKh2yGHYn1lUxH9STS/refunds\", \n \"reversals_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU7gMTGKh2yGHYn1lUxH9STS/reversals\", \n \"roles\": [\n \"buyer\"\n ], \n \"transactions_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU7gMTGKh2yGHYn1lUxH9STS/transactions\", \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU7gMTGKh2yGHYn1lUxH9STS\"\n }, \n \"amount\": 5000, \n \"appears_on_statement_as\": \"Statement text\", \n \"created_at\": \"2013-11-14T16:22:27.894146Z\", \n \"customer\": {\n \"_type\": \"customer\", \n \"_uris\": {\n \"bank_accounts_uri\": {\n \"_type\": \"page\", \n \"key\": \"bank_accounts\"\n }, \n \"cards_uri\": {\n \"_type\": \"page\", \n \"key\": \"cards\"\n }, \n \"credits_uri\": {\n \"_type\": \"page\", \n \"key\": \"credits\"\n }, \n \"debits_uri\": {\n \"_type\": \"page\", \n \"key\": \"debits\"\n }, \n \"holds_uri\": {\n \"_type\": \"page\", \n \"key\": \"holds\"\n }, \n \"refunds_uri\": {\n \"_type\": \"page\", \n \"key\": \"refunds\"\n }, \n \"reversals_uri\": {\n \"_type\": \"page\", \n \"key\": \"reversals\"\n }, \n \"source_uri\": {\n \"_type\": \"card\", \n \"key\": \"source\"\n }, \n \"transactions_uri\": {\n \"_type\": \"page\", \n \"key\": \"transactions\"\n }\n }, \n \"address\": {}, \n \"bank_accounts_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/bank_accounts\", \n \"business_name\": null, \n \"cards_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/cards\", \n \"created_at\": \"2013-11-14T16:22:19.231687Z\", \n \"credits_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/credits\", \n \"debits_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/debits\", \n \"destination_uri\": null, \n \"dob\": null, \n \"ein\": null, \n \"email\": null, \n \"facebook\": null, \n \"holds_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/holds\", \n \"id\": \"CU7gMTGKh2yGHYn1lUxH9STS\", \n \"is_identity_verified\": false, \n \"meta\": {}, \n \"name\": null, \n \"phone\": null, \n \"refunds_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/refunds\", \n \"reversals_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/reversals\", \n \"source_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/cards/CC7iFRCb5AvLuZ9qzIF0VMmA\", \n \"ssn_last4\": null, \n \"transactions_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/transactions\", \n \"twitter\": null, \n \"uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS\"\n }, \n \"debit\": {\n \"_type\": \"debit\", \n \"_uris\": {\n \"events_uri\": {\n \"_type\": \"page\", \n \"key\": \"events\"\n }, \n \"hold_uri\": {\n \"_type\": \"hold\", \n \"key\": \"hold\"\n }, \n \"refunds_uri\": {\n \"_type\": \"page\", \n \"key\": \"refunds\"\n }\n }, \n \"account_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU7gMTGKh2yGHYn1lUxH9STS\", \n \"amount\": 5000, \n \"appears_on_statement_as\": \"Statement text\", \n \"available_at\": \"2013-11-14T16:22:26.746556Z\", \n \"created_at\": \"2013-11-14T16:22:25.975814Z\", \n \"customer_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS\", \n \"description\": \"Some descriptive text for the debit in the dashboard\", \n \"events_uri\": \"/v1/debits/WD7omMnm45N2JcPZ6fcaRRgY/events\", \n \"fee\": null, \n \"hold_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/holds/HL7ol64Qezs7DVaup1KqTHn2\", \n \"id\": \"WD7omMnm45N2JcPZ6fcaRRgY\", \n \"meta\": {}, \n \"on_behalf_of_uri\": null, \n \"refunds_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/debits/WD7omMnm45N2JcPZ6fcaRRgY/refunds\", \n \"source_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU7gMTGKh2yGHYn1lUxH9STS/cards/CC7iFRCb5AvLuZ9qzIF0VMmA\", \n \"status\": \"succeeded\", \n \"transaction_number\": \"W109-369-8530\", \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/debits/WD7omMnm45N2JcPZ6fcaRRgY\"\n }, \n \"description\": \"Refund for Order #1111\", \n \"events_uri\": \"/v1/refunds/RF7qwuLxprQJuVGf7sTAdwKc/events\", \n \"fee\": null, \n \"id\": \"RF7qwuLxprQJuVGf7sTAdwKc\", \n \"meta\": {\n \"fulfillment.item.condition\": \"OK\", \n \"merchant.feedback\": \"positive\", \n \"user.refund_reason\": \"not happy with product\"\n }, \n \"status\": \"succeeded\", \n \"transaction_number\": \"RF442-144-9327\", \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/refunds/RF7qwuLxprQJuVGf7sTAdwKc\"\n }, \n {\n \"_type\": \"refund\", \n \"_uris\": {}, \n \"account\": {\n \"_type\": \"account\", \n \"_uris\": {\n \"bank_accounts_uri\": {\n \"_type\": \"page\", \n \"key\": \"bank_accounts\"\n }, \n \"cards_uri\": {\n \"_type\": \"page\", \n \"key\": \"cards\"\n }, \n \"credits_uri\": {\n \"_type\": \"page\", \n \"key\": \"credits\"\n }, \n \"customer_uri\": {\n \"_type\": \"customer\", \n \"key\": \"customer\"\n }, \n \"debits_uri\": {\n \"_type\": \"page\", \n \"key\": \"debits\"\n }, \n \"holds_uri\": {\n \"_type\": \"page\", \n \"key\": \"holds\"\n }, \n \"refunds_uri\": {\n \"_type\": \"page\", \n \"key\": \"refunds\"\n }, \n \"reversals_uri\": {\n \"_type\": \"page\", \n \"key\": \"reversals\"\n }, \n \"transactions_uri\": {\n \"_type\": \"page\", \n \"key\": \"transactions\"\n }\n }, \n \"bank_accounts_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS/bank_accounts\", \n \"cards_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS/cards\", \n \"created_at\": \"2013-11-14T16:21:37.144218Z\", \n \"credits_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS/credits\", \n \"customer_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS\", \n \"debits_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS/debits\", \n \"email_address\": null, \n \"holds_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS/holds\", \n \"id\": \"CU6vs1tjxBtifgTuzKjCGtVS\", \n \"meta\": {}, \n \"name\": null, \n \"refunds_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS/refunds\", \n \"reversals_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS/reversals\", \n \"roles\": [\n \"buyer\"\n ], \n \"transactions_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS/transactions\", \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS\"\n }, \n \"amount\": 5000, \n \"appears_on_statement_as\": \"Statement text\", \n \"created_at\": \"2013-11-14T16:21:54.905713Z\", \n \"customer\": {\n \"_type\": \"customer\", \n \"_uris\": {\n \"bank_accounts_uri\": {\n \"_type\": \"page\", \n \"key\": \"bank_accounts\"\n }, \n \"cards_uri\": {\n \"_type\": \"page\", \n \"key\": \"cards\"\n }, \n \"credits_uri\": {\n \"_type\": \"page\", \n \"key\": \"credits\"\n }, \n \"debits_uri\": {\n \"_type\": \"page\", \n \"key\": \"debits\"\n }, \n \"holds_uri\": {\n \"_type\": \"page\", \n \"key\": \"holds\"\n }, \n \"refunds_uri\": {\n \"_type\": \"page\", \n \"key\": \"refunds\"\n }, \n \"reversals_uri\": {\n \"_type\": \"page\", \n \"key\": \"reversals\"\n }, \n \"source_uri\": {\n \"_type\": \"card\", \n \"key\": \"source\"\n }, \n \"transactions_uri\": {\n \"_type\": \"page\", \n \"key\": \"transactions\"\n }\n }, \n \"address\": {}, \n \"bank_accounts_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/bank_accounts\", \n \"business_name\": null, \n \"cards_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/cards\", \n \"created_at\": \"2013-11-14T16:21:37.144218Z\", \n \"credits_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/credits\", \n \"debits_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/debits\", \n \"destination_uri\": null, \n \"dob\": null, \n \"ein\": null, \n \"email\": null, \n \"facebook\": null, \n \"holds_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/holds\", \n \"id\": \"CU6vs1tjxBtifgTuzKjCGtVS\", \n \"is_identity_verified\": false, \n \"meta\": {}, \n \"name\": null, \n \"phone\": null, \n \"refunds_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/refunds\", \n \"reversals_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/reversals\", \n \"source_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/cards/CC6xbFPglEtPRSEA65a5Bd60\", \n \"ssn_last4\": null, \n \"transactions_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/transactions\", \n \"twitter\": null, \n \"uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS\"\n }, \n \"debit\": {\n \"_type\": \"debit\", \n \"_uris\": {\n \"events_uri\": {\n \"_type\": \"page\", \n \"key\": \"events\"\n }, \n \"hold_uri\": {\n \"_type\": \"hold\", \n \"key\": \"hold\"\n }, \n \"refunds_uri\": {\n \"_type\": \"page\", \n \"key\": \"refunds\"\n }\n }, \n \"account_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS\", \n \"amount\": 5000, \n \"appears_on_statement_as\": \"Statement text\", \n \"available_at\": \"2013-11-14T16:21:54.005354Z\", \n \"created_at\": \"2013-11-14T16:21:52.648535Z\", \n \"customer_uri\": \"/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS\", \n \"description\": \"Some descriptive text for the debit in the dashboard\", \n \"events_uri\": \"/v1/debits/WD6MTAHor9FhO4G2nvZwaXvi/events\", \n \"fee\": null, \n \"hold_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/holds/HL6MSFloTodCzP9beAgM2IBW\", \n \"id\": \"WD6MTAHor9FhO4G2nvZwaXvi\", \n \"meta\": {}, \n \"on_behalf_of_uri\": null, \n \"refunds_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/debits/WD6MTAHor9FhO4G2nvZwaXvi/refunds\", \n \"source_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU6vs1tjxBtifgTuzKjCGtVS/cards/CC6xbFPglEtPRSEA65a5Bd60\", \n \"status\": \"succeeded\", \n \"transaction_number\": \"W409-412-6948\", \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/debits/WD6MTAHor9FhO4G2nvZwaXvi\"\n }, \n \"description\": \"Some descriptive text for the debit in the dashboard\", \n \"events_uri\": \"/v1/refunds/RF6PpVmJdJsmaBdtMDwtVd4Q/events\", \n \"fee\": null, \n \"id\": \"RF6PpVmJdJsmaBdtMDwtVd4Q\", \n \"meta\": {}, \n \"status\": \"succeeded\", \n \"transaction_number\": \"RF480-493-3185\", \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/refunds/RF6PpVmJdJsmaBdtMDwtVd4Q\"\n }\n ], \n \"last_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/refunds?limit=2&offset=0\", \n \"limit\": 2, \n \"next_uri\": null, \n \"offset\": 0, \n \"previous_uri\": null, \n \"total\": 2, \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/refunds?limit=2&offset=0\"\n}" - }, - "refund_show": { - "request": { - "uri": "/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/refunds/RF7qwuLxprQJuVGf7sTAdwKc" - }, - "response": "{\n \"_type\": \"refund\", \n \"_uris\": {}, \n \"account\": {\n \"_type\": \"account\", \n \"_uris\": {\n \"bank_accounts_uri\": {\n \"_type\": \"page\", \n \"key\": \"bank_accounts\"\n }, \n \"cards_uri\": {\n \"_type\": \"page\", \n \"key\": \"cards\"\n }, \n \"credits_uri\": {\n \"_type\": \"page\", \n \"key\": \"credits\"\n }, \n \"customer_uri\": {\n \"_type\": \"customer\", \n \"key\": \"customer\"\n }, \n \"debits_uri\": {\n \"_type\": \"page\", \n \"key\": \"debits\"\n }, \n \"holds_uri\": {\n \"_type\": \"page\", \n \"key\": \"holds\"\n }, \n \"refunds_uri\": {\n \"_type\": \"page\", \n \"key\": \"refunds\"\n }, \n \"reversals_uri\": {\n \"_type\": \"page\", \n \"key\": \"reversals\"\n }, \n \"transactions_uri\": {\n \"_type\": \"page\", \n \"key\": \"transactions\"\n }\n }, \n \"bank_accounts_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU7gMTGKh2yGHYn1lUxH9STS/bank_accounts\", \n \"cards_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU7gMTGKh2yGHYn1lUxH9STS/cards\", \n \"created_at\": \"2013-11-14T16:22:19.231687Z\", \n \"credits_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU7gMTGKh2yGHYn1lUxH9STS/credits\", \n \"customer_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS\", \n \"debits_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU7gMTGKh2yGHYn1lUxH9STS/debits\", \n \"email_address\": null, \n \"holds_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU7gMTGKh2yGHYn1lUxH9STS/holds\", \n \"id\": \"CU7gMTGKh2yGHYn1lUxH9STS\", \n \"meta\": {}, \n \"name\": null, \n \"refunds_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU7gMTGKh2yGHYn1lUxH9STS/refunds\", \n \"reversals_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU7gMTGKh2yGHYn1lUxH9STS/reversals\", \n \"roles\": [\n \"buyer\"\n ], \n \"transactions_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU7gMTGKh2yGHYn1lUxH9STS/transactions\", \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU7gMTGKh2yGHYn1lUxH9STS\"\n }, \n \"amount\": 5000, \n \"appears_on_statement_as\": \"Statement text\", \n \"created_at\": \"2013-11-14T16:22:27.894146Z\", \n \"customer\": {\n \"_type\": \"customer\", \n \"_uris\": {\n \"bank_accounts_uri\": {\n \"_type\": \"page\", \n \"key\": \"bank_accounts\"\n }, \n \"cards_uri\": {\n \"_type\": \"page\", \n \"key\": \"cards\"\n }, \n \"credits_uri\": {\n \"_type\": \"page\", \n \"key\": \"credits\"\n }, \n \"debits_uri\": {\n \"_type\": \"page\", \n \"key\": \"debits\"\n }, \n \"holds_uri\": {\n \"_type\": \"page\", \n \"key\": \"holds\"\n }, \n \"refunds_uri\": {\n \"_type\": \"page\", \n \"key\": \"refunds\"\n }, \n \"reversals_uri\": {\n \"_type\": \"page\", \n \"key\": \"reversals\"\n }, \n \"source_uri\": {\n \"_type\": \"card\", \n \"key\": \"source\"\n }, \n \"transactions_uri\": {\n \"_type\": \"page\", \n \"key\": \"transactions\"\n }\n }, \n \"address\": {}, \n \"bank_accounts_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/bank_accounts\", \n \"business_name\": null, \n \"cards_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/cards\", \n \"created_at\": \"2013-11-14T16:22:19.231687Z\", \n \"credits_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/credits\", \n \"debits_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/debits\", \n \"destination_uri\": null, \n \"dob\": null, \n \"ein\": null, \n \"email\": null, \n \"facebook\": null, \n \"holds_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/holds\", \n \"id\": \"CU7gMTGKh2yGHYn1lUxH9STS\", \n \"is_identity_verified\": false, \n \"meta\": {}, \n \"name\": null, \n \"phone\": null, \n \"refunds_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/refunds\", \n \"reversals_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/reversals\", \n \"source_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/cards/CC7iFRCb5AvLuZ9qzIF0VMmA\", \n \"ssn_last4\": null, \n \"transactions_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/transactions\", \n \"twitter\": null, \n \"uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS\"\n }, \n \"debit\": {\n \"_type\": \"debit\", \n \"_uris\": {\n \"events_uri\": {\n \"_type\": \"page\", \n \"key\": \"events\"\n }, \n \"hold_uri\": {\n \"_type\": \"hold\", \n \"key\": \"hold\"\n }, \n \"refunds_uri\": {\n \"_type\": \"page\", \n \"key\": \"refunds\"\n }\n }, \n \"account_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU7gMTGKh2yGHYn1lUxH9STS\", \n \"amount\": 5000, \n \"appears_on_statement_as\": \"Statement text\", \n \"available_at\": \"2013-11-14T16:22:26.746556Z\", \n \"created_at\": \"2013-11-14T16:22:25.975814Z\", \n \"customer_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS\", \n \"description\": \"Some descriptive text for the debit in the dashboard\", \n \"events_uri\": \"/v1/debits/WD7omMnm45N2JcPZ6fcaRRgY/events\", \n \"fee\": null, \n \"hold_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/holds/HL7ol64Qezs7DVaup1KqTHn2\", \n \"id\": \"WD7omMnm45N2JcPZ6fcaRRgY\", \n \"meta\": {}, \n \"on_behalf_of_uri\": null, \n \"refunds_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/debits/WD7omMnm45N2JcPZ6fcaRRgY/refunds\", \n \"source_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU7gMTGKh2yGHYn1lUxH9STS/cards/CC7iFRCb5AvLuZ9qzIF0VMmA\", \n \"status\": \"succeeded\", \n \"transaction_number\": \"W109-369-8530\", \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/debits/WD7omMnm45N2JcPZ6fcaRRgY\"\n }, \n \"description\": \"Refund for Order #1111\", \n \"events_uri\": \"/v1/refunds/RF7qwuLxprQJuVGf7sTAdwKc/events\", \n \"fee\": null, \n \"id\": \"RF7qwuLxprQJuVGf7sTAdwKc\", \n \"meta\": {\n \"fulfillment.item.condition\": \"OK\", \n \"merchant.feedback\": \"positive\", \n \"user.refund_reason\": \"not happy with product\"\n }, \n \"status\": \"succeeded\", \n \"transaction_number\": \"RF442-144-9327\", \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/refunds/RF7qwuLxprQJuVGf7sTAdwKc\"\n}" - }, - "refund_update": { - "request": { - "payload": { - "description": "update this description", - "meta": { - "refund.reason": "user not happy with product", - "user.notes": "very polite on the phone", - "user.refund.count": "3" - } - }, - "uri": "/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/refunds/RF7qwuLxprQJuVGf7sTAdwKc" - }, - "response": "{\n \"_type\": \"refund\", \n \"_uris\": {}, \n \"account\": {\n \"_type\": \"account\", \n \"_uris\": {\n \"bank_accounts_uri\": {\n \"_type\": \"page\", \n \"key\": \"bank_accounts\"\n }, \n \"cards_uri\": {\n \"_type\": \"page\", \n \"key\": \"cards\"\n }, \n \"credits_uri\": {\n \"_type\": \"page\", \n \"key\": \"credits\"\n }, \n \"customer_uri\": {\n \"_type\": \"customer\", \n \"key\": \"customer\"\n }, \n \"debits_uri\": {\n \"_type\": \"page\", \n \"key\": \"debits\"\n }, \n \"holds_uri\": {\n \"_type\": \"page\", \n \"key\": \"holds\"\n }, \n \"refunds_uri\": {\n \"_type\": \"page\", \n \"key\": \"refunds\"\n }, \n \"reversals_uri\": {\n \"_type\": \"page\", \n \"key\": \"reversals\"\n }, \n \"transactions_uri\": {\n \"_type\": \"page\", \n \"key\": \"transactions\"\n }\n }, \n \"bank_accounts_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU7gMTGKh2yGHYn1lUxH9STS/bank_accounts\", \n \"cards_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU7gMTGKh2yGHYn1lUxH9STS/cards\", \n \"created_at\": \"2013-11-14T16:22:19.231687Z\", \n \"credits_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU7gMTGKh2yGHYn1lUxH9STS/credits\", \n \"customer_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS\", \n \"debits_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU7gMTGKh2yGHYn1lUxH9STS/debits\", \n \"email_address\": null, \n \"holds_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU7gMTGKh2yGHYn1lUxH9STS/holds\", \n \"id\": \"CU7gMTGKh2yGHYn1lUxH9STS\", \n \"meta\": {}, \n \"name\": null, \n \"refunds_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU7gMTGKh2yGHYn1lUxH9STS/refunds\", \n \"reversals_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU7gMTGKh2yGHYn1lUxH9STS/reversals\", \n \"roles\": [\n \"buyer\"\n ], \n \"transactions_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU7gMTGKh2yGHYn1lUxH9STS/transactions\", \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU7gMTGKh2yGHYn1lUxH9STS\"\n }, \n \"amount\": 5000, \n \"appears_on_statement_as\": \"Statement text\", \n \"created_at\": \"2013-11-14T16:22:27.894146Z\", \n \"customer\": {\n \"_type\": \"customer\", \n \"_uris\": {\n \"bank_accounts_uri\": {\n \"_type\": \"page\", \n \"key\": \"bank_accounts\"\n }, \n \"cards_uri\": {\n \"_type\": \"page\", \n \"key\": \"cards\"\n }, \n \"credits_uri\": {\n \"_type\": \"page\", \n \"key\": \"credits\"\n }, \n \"debits_uri\": {\n \"_type\": \"page\", \n \"key\": \"debits\"\n }, \n \"holds_uri\": {\n \"_type\": \"page\", \n \"key\": \"holds\"\n }, \n \"refunds_uri\": {\n \"_type\": \"page\", \n \"key\": \"refunds\"\n }, \n \"reversals_uri\": {\n \"_type\": \"page\", \n \"key\": \"reversals\"\n }, \n \"source_uri\": {\n \"_type\": \"card\", \n \"key\": \"source\"\n }, \n \"transactions_uri\": {\n \"_type\": \"page\", \n \"key\": \"transactions\"\n }\n }, \n \"address\": {}, \n \"bank_accounts_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/bank_accounts\", \n \"business_name\": null, \n \"cards_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/cards\", \n \"created_at\": \"2013-11-14T16:22:19.231687Z\", \n \"credits_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/credits\", \n \"debits_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/debits\", \n \"destination_uri\": null, \n \"dob\": null, \n \"ein\": null, \n \"email\": null, \n \"facebook\": null, \n \"holds_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/holds\", \n \"id\": \"CU7gMTGKh2yGHYn1lUxH9STS\", \n \"is_identity_verified\": false, \n \"meta\": {}, \n \"name\": null, \n \"phone\": null, \n \"refunds_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/refunds\", \n \"reversals_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/reversals\", \n \"source_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/cards/CC7iFRCb5AvLuZ9qzIF0VMmA\", \n \"ssn_last4\": null, \n \"transactions_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS/transactions\", \n \"twitter\": null, \n \"uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS\"\n }, \n \"debit\": {\n \"_type\": \"debit\", \n \"_uris\": {\n \"events_uri\": {\n \"_type\": \"page\", \n \"key\": \"events\"\n }, \n \"hold_uri\": {\n \"_type\": \"hold\", \n \"key\": \"hold\"\n }, \n \"refunds_uri\": {\n \"_type\": \"page\", \n \"key\": \"refunds\"\n }\n }, \n \"account_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU7gMTGKh2yGHYn1lUxH9STS\", \n \"amount\": 5000, \n \"appears_on_statement_as\": \"Statement text\", \n \"available_at\": \"2013-11-14T16:22:26.746556Z\", \n \"created_at\": \"2013-11-14T16:22:25.975814Z\", \n \"customer_uri\": \"/v1/customers/CU7gMTGKh2yGHYn1lUxH9STS\", \n \"description\": \"Some descriptive text for the debit in the dashboard\", \n \"events_uri\": \"/v1/debits/WD7omMnm45N2JcPZ6fcaRRgY/events\", \n \"fee\": null, \n \"hold_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/holds/HL7ol64Qezs7DVaup1KqTHn2\", \n \"id\": \"WD7omMnm45N2JcPZ6fcaRRgY\", \n \"meta\": {}, \n \"on_behalf_of_uri\": null, \n \"refunds_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/debits/WD7omMnm45N2JcPZ6fcaRRgY/refunds\", \n \"source_uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/accounts/CU7gMTGKh2yGHYn1lUxH9STS/cards/CC7iFRCb5AvLuZ9qzIF0VMmA\", \n \"status\": \"succeeded\", \n \"transaction_number\": \"W109-369-8530\", \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/debits/WD7omMnm45N2JcPZ6fcaRRgY\"\n }, \n \"description\": \"update this description\", \n \"events_uri\": \"/v1/refunds/RF7qwuLxprQJuVGf7sTAdwKc/events\", \n \"fee\": null, \n \"id\": \"RF7qwuLxprQJuVGf7sTAdwKc\", \n \"meta\": {\n \"refund.reason\": \"user not happy with product\", \n \"user.notes\": \"very polite on the phone\", \n \"user.refund.count\": \"3\"\n }, \n \"status\": \"succeeded\", \n \"transaction_number\": \"RF442-144-9327\", \n \"uri\": \"/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/refunds/RF7qwuLxprQJuVGf7sTAdwKc\"\n}" - } -} \ No newline at end of file diff --git a/scenarios/_main.mako b/scenarios/_main.mako index 650f5b8..858a2a3 100644 --- a/scenarios/_main.mako +++ b/scenarios/_main.mako @@ -34,9 +34,10 @@ import balanced %if api_location: -balanced.config.root_uri = ${api_location}' -%endif +balanced.configure('${api_key}', root_url='${api_location}') +%else: balanced.configure('${api_key}') +%endif @@ -60,4 +61,3 @@ balanced.configure('${api_key}') %> ${reindent(formatted_payload, 2)} - diff --git a/scenarios/_mj/_template/_create/definition.mako b/scenarios/_mj/_template/_create/definition.mako new file mode 100644 index 0000000..4e8b7a1 --- /dev/null +++ b/scenarios/_mj/_template/_create/definition.mako @@ -0,0 +1 @@ +balanced.RESOURCE diff --git a/scenarios/credit_account_list/executable.py b/scenarios/_mj/_template/_create/executable.py similarity index 100% rename from scenarios/credit_account_list/executable.py rename to scenarios/_mj/_template/_create/executable.py diff --git a/scenarios/_mj/_template/_create/python.mako b/scenarios/_mj/_template/_create/python.mako new file mode 100644 index 0000000..29e7a14 --- /dev/null +++ b/scenarios/_mj/_template/_create/python.mako @@ -0,0 +1,8 @@ +% if mode == 'definition': +balanced.RESOURCE + +% elif mode == 'request': + +% elif mode == 'response': + +% endif \ No newline at end of file diff --git a/scenarios/hold_void/request.mako b/scenarios/_mj/_template/_create/request.mako similarity index 57% rename from scenarios/hold_void/request.mako rename to scenarios/_mj/_template/_create/request.mako index d9908d5..f7fc6da 100644 --- a/scenarios/hold_void/request.mako +++ b/scenarios/_mj/_template/_create/request.mako @@ -1,5 +1,5 @@ <%namespace file='/_main.mako' name='main'/> <% main.python_boilerplate() %> -hold = balanced.Hold.find('${request['uri']}') -hold.void() \ No newline at end of file +VARIABLE = balanced.RESOURCE() +VARIABLE.save() diff --git a/scenarios/event_replay/definition.mako b/scenarios/_mj/_template/_delete/definition.mako similarity index 100% rename from scenarios/event_replay/definition.mako rename to scenarios/_mj/_template/_delete/definition.mako diff --git a/scenarios/credit_account_merchant_create/executable.py b/scenarios/_mj/_template/_delete/executable.py similarity index 100% rename from scenarios/credit_account_merchant_create/executable.py rename to scenarios/_mj/_template/_delete/executable.py diff --git a/scenarios/_mj/_template/_delete/python.mako b/scenarios/_mj/_template/_delete/python.mako new file mode 100644 index 0000000..d2dd0f8 --- /dev/null +++ b/scenarios/_mj/_template/_delete/python.mako @@ -0,0 +1,7 @@ +% if mode == 'definition': + +% elif mode == 'request': + +% elif mode == 'response': + +% endif \ No newline at end of file diff --git a/scenarios/credit_account_list/request.mako b/scenarios/_mj/_template/_delete/request.mako similarity index 100% rename from scenarios/credit_account_list/request.mako rename to scenarios/_mj/_template/_delete/request.mako diff --git a/scenarios/credit_account_merchant_create/request.mako b/scenarios/_mj/_template/_list/definition.mako similarity index 100% rename from scenarios/credit_account_merchant_create/request.mako rename to scenarios/_mj/_template/_list/definition.mako diff --git a/scenarios/debit_account_list/executable.py b/scenarios/_mj/_template/_list/executable.py similarity index 100% rename from scenarios/debit_account_list/executable.py rename to scenarios/_mj/_template/_list/executable.py diff --git a/scenarios/_mj/_template/_list/python.mako b/scenarios/_mj/_template/_list/python.mako new file mode 100644 index 0000000..d2dd0f8 --- /dev/null +++ b/scenarios/_mj/_template/_list/python.mako @@ -0,0 +1,7 @@ +% if mode == 'definition': + +% elif mode == 'request': + +% elif mode == 'response': + +% endif \ No newline at end of file diff --git a/scenarios/debit_account_list/request.mako b/scenarios/_mj/_template/_list/request.mako similarity index 100% rename from scenarios/debit_account_list/request.mako rename to scenarios/_mj/_template/_list/request.mako diff --git a/scenarios/event_replay/executable.py b/scenarios/_mj/_template/_retrieve/definition.mako similarity index 100% rename from scenarios/event_replay/executable.py rename to scenarios/_mj/_template/_retrieve/definition.mako diff --git a/scenarios/hold_account_list/executable.py b/scenarios/_mj/_template/_retrieve/executable.py similarity index 100% rename from scenarios/hold_account_list/executable.py rename to scenarios/_mj/_template/_retrieve/executable.py diff --git a/scenarios/_mj/_template/_retrieve/python.mako b/scenarios/_mj/_template/_retrieve/python.mako new file mode 100644 index 0000000..d2dd0f8 --- /dev/null +++ b/scenarios/_mj/_template/_retrieve/python.mako @@ -0,0 +1,7 @@ +% if mode == 'definition': + +% elif mode == 'request': + +% elif mode == 'response': + +% endif \ No newline at end of file diff --git a/scenarios/event_replay/request.mako b/scenarios/_mj/_template/_retrieve/request.mako similarity index 100% rename from scenarios/event_replay/request.mako rename to scenarios/_mj/_template/_retrieve/request.mako diff --git a/scenarios/hold_account_list/request.mako b/scenarios/_mj/_template/_update/definition.mako similarity index 100% rename from scenarios/hold_account_list/request.mako rename to scenarios/_mj/_template/_update/definition.mako diff --git a/scenarios/refund_account_list/executable.py b/scenarios/_mj/_template/_update/executable.py similarity index 100% rename from scenarios/refund_account_list/executable.py rename to scenarios/_mj/_template/_update/executable.py diff --git a/scenarios/_mj/_template/_update/python.mako b/scenarios/_mj/_template/_update/python.mako new file mode 100644 index 0000000..d2dd0f8 --- /dev/null +++ b/scenarios/_mj/_template/_update/python.mako @@ -0,0 +1,7 @@ +% if mode == 'definition': + +% elif mode == 'request': + +% elif mode == 'response': + +% endif \ No newline at end of file diff --git a/scenarios/refund_account_list/request.mako b/scenarios/_mj/_template/_update/request.mako similarity index 100% rename from scenarios/refund_account_list/request.mako rename to scenarios/_mj/_template/_update/request.mako diff --git a/scenarios/_mj/api_key_create/definition.mako b/scenarios/_mj/api_key_create/definition.mako new file mode 100644 index 0000000..a66f6d1 --- /dev/null +++ b/scenarios/_mj/api_key_create/definition.mako @@ -0,0 +1 @@ +balanced.APIKey diff --git a/scenarios/_mj/api_key_create/executable.py b/scenarios/_mj/api_key_create/executable.py new file mode 100644 index 0000000..4295a5a --- /dev/null +++ b/scenarios/_mj/api_key_create/executable.py @@ -0,0 +1,6 @@ +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +api_key = balanced.APIKey() +api_key.save() \ No newline at end of file diff --git a/scenarios/_mj/api_key_create/python.mako b/scenarios/_mj/api_key_create/python.mako new file mode 100644 index 0000000..ecd59c2 --- /dev/null +++ b/scenarios/_mj/api_key_create/python.mako @@ -0,0 +1,13 @@ +% if mode == 'definition': +balanced.APIKey + +% elif mode == 'request': +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +api_key = balanced.APIKey() +api_key.save() +% elif mode == 'response': +APIKey(links={}, created_at=u'2015-01-09T03:23:00.061959Z', secret=u'ak-test-2i4j501b699lmRiGiCcIg45CM0bBI0JAQ', href=u'/api_keys/AK3DQGzROuoRYulKXMQdHBxX', meta={}, id=u'AK3DQGzROuoRYulKXMQdHBxX') +% endif \ No newline at end of file diff --git a/scenarios/hold_show/request.mako b/scenarios/_mj/api_key_create/request.mako similarity index 62% rename from scenarios/hold_show/request.mako rename to scenarios/_mj/api_key_create/request.mako index afc7654..014e90c 100644 --- a/scenarios/hold_show/request.mako +++ b/scenarios/_mj/api_key_create/request.mako @@ -1,4 +1,5 @@ <%namespace file='/_main.mako' name='main'/> <% main.python_boilerplate() %> -hold = balanced.Hold.find('${request['uri']}') \ No newline at end of file +api_key = balanced.APIKey() +api_key.save() diff --git a/scenarios/_mj/manage b/scenarios/_mj/manage new file mode 100755 index 0000000..013eaed --- /dev/null +++ b/scenarios/_mj/manage @@ -0,0 +1,74 @@ +#!/usr/bin/env python +from __future__ import unicode_literals +import argparse +import fileinput +import os +import re +import shutil +import sys + + +def convert(name): + s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', name) + return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower() + + +def get_file_paths(directory): + for root, directories, files in os.walk(directory): + + for filename in files: + + # Join the two strings in order to form the full filepath. + filepath = os.path.join(root, filename) + + yield filepath + + +def main(parser): + args = parser.parse_args() + args.command(args) + + +def create(args): + resource = args.resource + try: + exec('from balanced import ' + resource) + except ImportError: + print 'Sorry, we cannot import the resource {} from balanced.'.format( + resource + ) + sys.exit(1) + variable = convert(resource) + print resource, variable + file_root = os.path.dirname(os.path.abspath(__file__)) + for op in ('create', 'delete', 'list', 'retrieve', 'update'): + # copy + + src = os.path.join(file_root, '_template', '_' + op) + dst = os.path.join(file_root, '{}_{}'.format(variable, op)) + try: + shutil.copytree(src, dst) + except OSError: + pass # already exists? + # replace + for file in get_file_paths(dst): + # TODO: write back to file + for line in fileinput.input(file, inplace=True): + line.replace('VARIABLE', variable) + line.replace('RESOURCE', resource) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser(add_help=False) + parents = [parser] + root_parser = argparse.ArgumentParser(parents=parents) + sub_parsers = root_parser.add_subparsers(title='sub-commands') + + sub_parser = sub_parsers.add_parser( + 'create', + description='Create a new set of scenarios', + parents=parents) + sub_parser.add_argument('resource') + sub_parser.set_defaults(command=create) + + main(root_parser) diff --git a/scenarios/account_add_card/definition.mako b/scenarios/account_add_card/definition.mako deleted file mode 100644 index 28e5caf..0000000 --- a/scenarios/account_add_card/definition.mako +++ /dev/null @@ -1 +0,0 @@ -balanced.Account.add_card \ No newline at end of file diff --git a/scenarios/account_add_card/executable.py b/scenarios/account_add_card/executable.py deleted file mode 100644 index e17c97a..0000000 --- a/scenarios/account_add_card/executable.py +++ /dev/null @@ -1,6 +0,0 @@ -import balanced - -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') - -account = balanced.Account.find('/v1/marketplaces/TEST-MP52IlCmywk6hGbgS75QSlN/accounts/CUhWPVv3F9tVZoGd1GPo2zQ') -account.add_card('/v1/marketplaces/TEST-MP52IlCmywk6hGbgS75QSlN/cards/CCjOJKFuXZJlQm9oKtqVZwW') \ No newline at end of file diff --git a/scenarios/account_add_card/python.mako b/scenarios/account_add_card/python.mako deleted file mode 100644 index d0870be..0000000 --- a/scenarios/account_add_card/python.mako +++ /dev/null @@ -1,10 +0,0 @@ -% if mode == 'definition': -balanced.Account.add_card -% else: -import balanced - -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') - -account = balanced.Account.find('/v1/marketplaces/TEST-MP52IlCmywk6hGbgS75QSlN/accounts/CUhWPVv3F9tVZoGd1GPo2zQ') -account.add_card('/v1/marketplaces/TEST-MP52IlCmywk6hGbgS75QSlN/cards/CCjOJKFuXZJlQm9oKtqVZwW') -% endif \ No newline at end of file diff --git a/scenarios/account_add_card/request.mako b/scenarios/account_add_card/request.mako deleted file mode 100644 index 120970d..0000000 --- a/scenarios/account_add_card/request.mako +++ /dev/null @@ -1,5 +0,0 @@ -<%namespace file='/_main.mako' name='main'/> -<% main.python_boilerplate() %> - -account = balanced.Account.find('${request['uri']}') -account.add_card('${request['payload']['card_uri']}') \ No newline at end of file diff --git a/scenarios/account_create/definition.mako b/scenarios/account_create/definition.mako deleted file mode 100644 index 5c073b2..0000000 --- a/scenarios/account_create/definition.mako +++ /dev/null @@ -1 +0,0 @@ -balanced.Account(...).save() \ No newline at end of file diff --git a/scenarios/account_create/executable.py b/scenarios/account_create/executable.py deleted file mode 100644 index 10e51e0..0000000 --- a/scenarios/account_create/executable.py +++ /dev/null @@ -1,5 +0,0 @@ -import balanced - -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') - -account = balanced.Account().save() \ No newline at end of file diff --git a/scenarios/account_create/python.mako b/scenarios/account_create/python.mako deleted file mode 100644 index 5e724a3..0000000 --- a/scenarios/account_create/python.mako +++ /dev/null @@ -1,9 +0,0 @@ -% if mode == 'definition': -balanced.Account(...).save() -% else: -import balanced - -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') - -account = balanced.Account().save() -% endif \ No newline at end of file diff --git a/scenarios/account_create_buyer/definition.mako b/scenarios/account_create_buyer/definition.mako deleted file mode 100644 index 5c073b2..0000000 --- a/scenarios/account_create_buyer/definition.mako +++ /dev/null @@ -1 +0,0 @@ -balanced.Account(...).save() \ No newline at end of file diff --git a/scenarios/account_create_buyer/executable.py b/scenarios/account_create_buyer/executable.py deleted file mode 100644 index 28a265e..0000000 --- a/scenarios/account_create_buyer/executable.py +++ /dev/null @@ -1,7 +0,0 @@ -import balanced - -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') - -buyer = balanced.Marketplace.my_marketplace.create_buyer( - card_uri='/v1/marketplaces/TEST-MP52IlCmywk6hGbgS75QSlN/cards/CChliMH1lqlupiVghuXsWRq' -) \ No newline at end of file diff --git a/scenarios/account_create_buyer/python.mako b/scenarios/account_create_buyer/python.mako deleted file mode 100644 index 6defa82..0000000 --- a/scenarios/account_create_buyer/python.mako +++ /dev/null @@ -1,11 +0,0 @@ -% if mode == 'definition': -balanced.Account(...).save() -% else: -import balanced - -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') - -buyer = balanced.Marketplace.my_marketplace.create_buyer( - card_uri='/v1/marketplaces/TEST-MP52IlCmywk6hGbgS75QSlN/cards/CChliMH1lqlupiVghuXsWRq' -) -% endif \ No newline at end of file diff --git a/scenarios/account_create_merchant/definition.mako b/scenarios/account_create_merchant/definition.mako deleted file mode 100644 index 8ec7951..0000000 --- a/scenarios/account_create_merchant/definition.mako +++ /dev/null @@ -1 +0,0 @@ -balanced.Account.add_bank_account \ No newline at end of file diff --git a/scenarios/account_create_merchant/executable.py b/scenarios/account_create_merchant/executable.py deleted file mode 100644 index 9c46dbf..0000000 --- a/scenarios/account_create_merchant/executable.py +++ /dev/null @@ -1,6 +0,0 @@ -import balanced - -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') - -account = balanced.Account.find('/v1/marketplaces/TEST-MP52IlCmywk6hGbgS75QSlN/accounts/CUhWPVv3F9tVZoGd1GPo2zQ') -account.add_bank_account('/v1/bank_accounts/BAoA1GvbhUuFXyRKiVv76M0') \ No newline at end of file diff --git a/scenarios/account_create_merchant/python.mako b/scenarios/account_create_merchant/python.mako deleted file mode 100644 index 9950538..0000000 --- a/scenarios/account_create_merchant/python.mako +++ /dev/null @@ -1,10 +0,0 @@ -% if mode == 'definition': -balanced.Account.add_bank_account -% else: -import balanced - -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') - -account = balanced.Account.find('/v1/marketplaces/TEST-MP52IlCmywk6hGbgS75QSlN/accounts/CUhWPVv3F9tVZoGd1GPo2zQ') -account.add_bank_account('/v1/bank_accounts/BAoA1GvbhUuFXyRKiVv76M0') -% endif \ No newline at end of file diff --git a/scenarios/account_create_merchant/request.mako b/scenarios/account_create_merchant/request.mako deleted file mode 100644 index 6e05e2f..0000000 --- a/scenarios/account_create_merchant/request.mako +++ /dev/null @@ -1,5 +0,0 @@ -<%namespace file='/_main.mako' name='main'/> -<% main.python_boilerplate() %> - -account = balanced.Account.find('${request['uri']}') -account.add_bank_account('${request['payload']['bank_account_uri']}') \ No newline at end of file diff --git a/scenarios/credit_account_merchant_create/definition.mako b/scenarios/account_credit/definition.mako similarity index 100% rename from scenarios/credit_account_merchant_create/definition.mako rename to scenarios/account_credit/definition.mako diff --git a/scenarios/account_credit/executable.py b/scenarios/account_credit/executable.py new file mode 100644 index 0000000..c832bbd --- /dev/null +++ b/scenarios/account_credit/executable.py @@ -0,0 +1,14 @@ +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +payable_account = balanced.Account.fetch('/accounts/AT3ogJE07IErLJYR510QO6sM') +payable_account.credit( + appears_on_statement_as='ThingsCo', + amount=1000, + description='A simple credit', + order='/orders/OR3vURGwVtqDnnkRS9fgH41G', + meta={ + 'rating': '8' + } +) \ No newline at end of file diff --git a/scenarios/account_credit/python.mako b/scenarios/account_credit/python.mako new file mode 100644 index 0000000..c2d2fa3 --- /dev/null +++ b/scenarios/account_credit/python.mako @@ -0,0 +1,20 @@ +% if mode == 'definition': +balanced.Account.credit() +% elif mode == 'request': +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +payable_account = balanced.Account.fetch('/accounts/AT3ogJE07IErLJYR510QO6sM') +payable_account.credit( + appears_on_statement_as='ThingsCo', + amount=1000, + description='A simple credit', + order='/orders/OR3vURGwVtqDnnkRS9fgH41G', + meta={ + 'rating': '8' + } +) +% elif mode == 'response': +Credit(status=u'succeeded', description=u'A simple credit', links={u'customer': u'CU3o1ZAd8Gtxz6ZTIFK9YmsM', u'destination': u'AT3ogJE07IErLJYR510QO6sM', u'order': u'OR3vURGwVtqDnnkRS9fgH41G'}, amount=1000, created_at=u'2015-01-09T03:22:56.285894Z', updated_at=u'2015-01-09T03:22:56.407717Z', failure_reason=None, currency=u'USD', transaction_number=u'CRMJJ-XQI-MUMX', href=u'/credits/CR3zAL8gnvuDGGTqr1UqehlS', meta={u'rating': u'8'}, failure_reason_code=None, appears_on_statement_as=u'ThingsCo', id=u'CR3zAL8gnvuDGGTqr1UqehlS') +% endif \ No newline at end of file diff --git a/scenarios/account_credit/request.mako b/scenarios/account_credit/request.mako new file mode 100644 index 0000000..e251c32 --- /dev/null +++ b/scenarios/account_credit/request.mako @@ -0,0 +1,13 @@ +<%namespace file='/_main.mako' name='main'/> +<% main.python_boilerplate() %> + +payable_account = balanced.Account.fetch('${request['href']}') +payable_account.credit( + appears_on_statement_as='${request['payload']['appears_on_statement_as']}', + amount=${request['payload']['amount']}, + description='${request['payload']['description']}', + order='${request['payload']['order']}', + meta={ + 'rating': '${request['payload']['meta']['rating']}' + } +) \ No newline at end of file diff --git a/scenarios/account_list/definition.mako b/scenarios/account_list/definition.mako new file mode 100644 index 0000000..19b3dfe --- /dev/null +++ b/scenarios/account_list/definition.mako @@ -0,0 +1 @@ +balanced.Account.query diff --git a/scenarios/account_list/executable.py b/scenarios/account_list/executable.py new file mode 100644 index 0000000..f45e35d --- /dev/null +++ b/scenarios/account_list/executable.py @@ -0,0 +1,5 @@ +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +accounts = balanced.Account.query \ No newline at end of file diff --git a/scenarios/account_list/python.mako b/scenarios/account_list/python.mako new file mode 100644 index 0000000..d042f18 --- /dev/null +++ b/scenarios/account_list/python.mako @@ -0,0 +1,12 @@ +% if mode == 'definition': +balanced.Account.query + +% elif mode == 'request': +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +accounts = balanced.Account.query +% elif mode == 'response': + +% endif \ No newline at end of file diff --git a/scenarios/hold_list/request.mako b/scenarios/account_list/request.mako similarity index 69% rename from scenarios/hold_list/request.mako rename to scenarios/account_list/request.mako index 8049907..41d29a7 100644 --- a/scenarios/hold_list/request.mako +++ b/scenarios/account_list/request.mako @@ -1,4 +1,4 @@ <%namespace file='/_main.mako' name='main'/> <% main.python_boilerplate() %> -holds = balanced.Hold.query.all(); \ No newline at end of file +accounts = balanced.Account.query \ No newline at end of file diff --git a/scenarios/account_list_customer/definition.mako b/scenarios/account_list_customer/definition.mako new file mode 100644 index 0000000..19b3dfe --- /dev/null +++ b/scenarios/account_list_customer/definition.mako @@ -0,0 +1 @@ +balanced.Account.query diff --git a/scenarios/account_list_customer/executable.py b/scenarios/account_list_customer/executable.py new file mode 100644 index 0000000..1bcc290 --- /dev/null +++ b/scenarios/account_list_customer/executable.py @@ -0,0 +1,6 @@ +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +customer = balanced.Customer.fetch('/customers/CU3o1ZAd8Gtxz6ZTIFK9YmsM') +customer.accounts \ No newline at end of file diff --git a/scenarios/account_list_customer/python.mako b/scenarios/account_list_customer/python.mako new file mode 100644 index 0000000..9c6ecbc --- /dev/null +++ b/scenarios/account_list_customer/python.mako @@ -0,0 +1,13 @@ +% if mode == 'definition': +balanced.Account.query + +% elif mode == 'request': +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +customer = balanced.Customer.fetch('/customers/CU3o1ZAd8Gtxz6ZTIFK9YmsM') +customer.accounts +% elif mode == 'response': + +% endif \ No newline at end of file diff --git a/scenarios/account_list_customer/request.mako b/scenarios/account_list_customer/request.mako new file mode 100644 index 0000000..e3e2227 --- /dev/null +++ b/scenarios/account_list_customer/request.mako @@ -0,0 +1,5 @@ +<%namespace file='/_main.mako' name='main'/> +<% main.python_boilerplate() %> + +customer = balanced.Customer.fetch('${request['customer_href']}') +customer.accounts \ No newline at end of file diff --git a/scenarios/account_show/definition.mako b/scenarios/account_show/definition.mako new file mode 100644 index 0000000..ddf0947 --- /dev/null +++ b/scenarios/account_show/definition.mako @@ -0,0 +1 @@ +balanced.Account.fetch() diff --git a/scenarios/account_show/executable.py b/scenarios/account_show/executable.py new file mode 100644 index 0000000..237e2de --- /dev/null +++ b/scenarios/account_show/executable.py @@ -0,0 +1,5 @@ +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +account = balanced.Account.fetch('/accounts/AT2V7l4MoUJH8xDse641Xqog') \ No newline at end of file diff --git a/scenarios/account_show/python.mako b/scenarios/account_show/python.mako new file mode 100644 index 0000000..c0b1833 --- /dev/null +++ b/scenarios/account_show/python.mako @@ -0,0 +1,12 @@ +% if mode == 'definition': +balanced.Account.fetch() + +% elif mode == 'request': +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +account = balanced.Account.fetch('/accounts/AT2V7l4MoUJH8xDse641Xqog') +% elif mode == 'response': +Account(links={u'customer': u'CU2V0zJeFwPUCzJsaK48Ly3S'}, can_credit=True, can_debit=True, created_at=u'2015-01-09T03:22:20.308375Z', updated_at=u'2015-01-09T03:22:20.308376Z', currency=u'USD', href=u'/accounts/AT2V7l4MoUJH8xDse641Xqog', meta={}, balance=0, type=u'payable', id=u'AT2V7l4MoUJH8xDse641Xqog') +% endif \ No newline at end of file diff --git a/scenarios/account_show/request.mako b/scenarios/account_show/request.mako new file mode 100644 index 0000000..ac0e000 --- /dev/null +++ b/scenarios/account_show/request.mako @@ -0,0 +1,4 @@ +<%namespace file='/_main.mako' name='main'/> +<% main.python_boilerplate() %> + +account = balanced.Account.fetch('${request['uri']}') \ No newline at end of file diff --git a/scenarios/account_underwrite_business/definition.mako b/scenarios/account_underwrite_business/definition.mako deleted file mode 100644 index 032aa08..0000000 --- a/scenarios/account_underwrite_business/definition.mako +++ /dev/null @@ -1 +0,0 @@ -balanced.Marketplace.create_merchant() \ No newline at end of file diff --git a/scenarios/account_underwrite_business/executable.py b/scenarios/account_underwrite_business/executable.py deleted file mode 100644 index 322c5ae..0000000 --- a/scenarios/account_underwrite_business/executable.py +++ /dev/null @@ -1,30 +0,0 @@ -import balanced - -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') - -merchant_data = { - "phone_number": "+140899188155", - "name": "Skripts4Kids", - "person": { - "dob": "1989-12", - "phone_number": "+14089999999", - "postal_code": "94110", - "name": "Timmy Q. CopyPasta", - "street_address": "121 Skriptkid Row" - }, - "postal_code": "91111", - "type": "business", - "street_address": "555 VoidMain Road", - "tax_id": "211111111" -} - -account = balanced.Account().save() - -try: - account.add_merchant(merchant_data) -except balanced.exc.MoreInformationRequiredError as ex: - # could not identify this account. - print 'redirect merchant to:', ex.redirect_uri -except balanced.exc.HTTPError as error: - # TODO: handle 400 and 409 exceptions as required - raise \ No newline at end of file diff --git a/scenarios/account_underwrite_business/python.mako b/scenarios/account_underwrite_business/python.mako deleted file mode 100644 index 3136030..0000000 --- a/scenarios/account_underwrite_business/python.mako +++ /dev/null @@ -1,34 +0,0 @@ -% if mode == 'definition': -balanced.Marketplace.create_merchant() -% else: -import balanced - -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') - -merchant_data = { - "phone_number": "+140899188155", - "name": "Skripts4Kids", - "person": { - "dob": "1989-12", - "phone_number": "+14089999999", - "postal_code": "94110", - "name": "Timmy Q. CopyPasta", - "street_address": "121 Skriptkid Row" - }, - "postal_code": "91111", - "type": "business", - "street_address": "555 VoidMain Road", - "tax_id": "211111111" -} - -account = balanced.Account().save() - -try: - account.add_merchant(merchant_data) -except balanced.exc.MoreInformationRequiredError as ex: - # could not identify this account. - print 'redirect merchant to:', ex.redirect_uri -except balanced.exc.HTTPError as error: - # TODO: handle 400 and 409 exceptions as required - raise -% endif \ No newline at end of file diff --git a/scenarios/account_underwrite_business/request.mako b/scenarios/account_underwrite_business/request.mako deleted file mode 100644 index d9fd5c8..0000000 --- a/scenarios/account_underwrite_business/request.mako +++ /dev/null @@ -1,16 +0,0 @@ -<%namespace file='/_main.mako' name='main'/> -<% main.python_boilerplate() %> -<% import json %> -merchant_data = \ -${json.dumps(request['payload']['merchant'], indent=4)} - -account = balanced.Account().save() - -try: - account.add_merchant(merchant_data) -except balanced.exc.MoreInformationRequiredError as ex: - # could not identify this account. - print 'redirect merchant to:', ex.redirect_uri -except balanced.exc.HTTPError as error: - # TODO: handle 400 and 409 exceptions as required - raise \ No newline at end of file diff --git a/scenarios/account_underwrite_person/definition.mako b/scenarios/account_underwrite_person/definition.mako deleted file mode 100644 index 032aa08..0000000 --- a/scenarios/account_underwrite_person/definition.mako +++ /dev/null @@ -1 +0,0 @@ -balanced.Marketplace.create_merchant() \ No newline at end of file diff --git a/scenarios/account_underwrite_person/executable.py b/scenarios/account_underwrite_person/executable.py deleted file mode 100644 index ed83c8b..0000000 --- a/scenarios/account_underwrite_person/executable.py +++ /dev/null @@ -1,23 +0,0 @@ -import balanced - -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') - -merchant_data = { - "phone_number": "+14089999999", - "name": "Timmy Q. CopyPasta", - "dob": "1989-12", - "postal_code": "94110", - "type": "person", - "street_address": "121 Skriptkid Row" -} - -account = balanced.Account().save() - -try: - account.add_merchant(merchant_data) -except balanced.exc.MoreInformationRequiredError as ex: - # could not identify this account. - print 'redirect merchant to:', ex.redirect_uri -except balanced.exc.HTTPError as error: - # TODO: handle 400 and 409 exceptions as required - raise \ No newline at end of file diff --git a/scenarios/account_underwrite_person/python.mako b/scenarios/account_underwrite_person/python.mako deleted file mode 100644 index 921faa7..0000000 --- a/scenarios/account_underwrite_person/python.mako +++ /dev/null @@ -1,27 +0,0 @@ -% if mode == 'definition': -balanced.Marketplace.create_merchant() -% else: -import balanced - -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') - -merchant_data = { - "phone_number": "+14089999999", - "name": "Timmy Q. CopyPasta", - "dob": "1989-12", - "postal_code": "94110", - "type": "person", - "street_address": "121 Skriptkid Row" -} - -account = balanced.Account().save() - -try: - account.add_merchant(merchant_data) -except balanced.exc.MoreInformationRequiredError as ex: - # could not identify this account. - print 'redirect merchant to:', ex.redirect_uri -except balanced.exc.HTTPError as error: - # TODO: handle 400 and 409 exceptions as required - raise -% endif \ No newline at end of file diff --git a/scenarios/account_underwrite_person/request.mako b/scenarios/account_underwrite_person/request.mako deleted file mode 100644 index d9fd5c8..0000000 --- a/scenarios/account_underwrite_person/request.mako +++ /dev/null @@ -1,16 +0,0 @@ -<%namespace file='/_main.mako' name='main'/> -<% main.python_boilerplate() %> -<% import json %> -merchant_data = \ -${json.dumps(request['payload']['merchant'], indent=4)} - -account = balanced.Account().save() - -try: - account.add_merchant(merchant_data) -except balanced.exc.MoreInformationRequiredError as ex: - # could not identify this account. - print 'redirect merchant to:', ex.redirect_uri -except balanced.exc.HTTPError as error: - # TODO: handle 400 and 409 exceptions as required - raise \ No newline at end of file diff --git a/scenarios/api_key_create/definition.mako b/scenarios/api_key_create/definition.mako new file mode 100644 index 0000000..fb01ec3 --- /dev/null +++ b/scenarios/api_key_create/definition.mako @@ -0,0 +1 @@ +balanced.APIKey() \ No newline at end of file diff --git a/scenarios/api_key_create/executable.py b/scenarios/api_key_create/executable.py new file mode 100644 index 0000000..4b934a1 --- /dev/null +++ b/scenarios/api_key_create/executable.py @@ -0,0 +1,5 @@ +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +api_key = balanced.APIKey().save() \ No newline at end of file diff --git a/scenarios/api_key_create/python.mako b/scenarios/api_key_create/python.mako new file mode 100644 index 0000000..d50a576 --- /dev/null +++ b/scenarios/api_key_create/python.mako @@ -0,0 +1,11 @@ +% if mode == 'definition': +balanced.APIKey() +% elif mode == 'request': +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +api_key = balanced.APIKey().save() +% elif mode == 'response': +APIKey(links={}, created_at=u'2015-01-09T03:23:00.061959Z', secret=u'ak-test-2i4j501b699lmRiGiCcIg45CM0bBI0JAQ', href=u'/api_keys/AK3DQGzROuoRYulKXMQdHBxX', meta={}, id=u'AK3DQGzROuoRYulKXMQdHBxX') +% endif \ No newline at end of file diff --git a/scenarios/account_create/request.mako b/scenarios/api_key_create/request.mako similarity index 69% rename from scenarios/account_create/request.mako rename to scenarios/api_key_create/request.mako index cb7388d..18ae28b 100644 --- a/scenarios/account_create/request.mako +++ b/scenarios/api_key_create/request.mako @@ -1,4 +1,4 @@ <%namespace file='/_main.mako' name='main'/> <% main.python_boilerplate() %> -account = balanced.Account().save() \ No newline at end of file +api_key = balanced.APIKey().save() \ No newline at end of file diff --git a/scenarios/api_key_delete/definition.mako b/scenarios/api_key_delete/definition.mako new file mode 100644 index 0000000..02482ff --- /dev/null +++ b/scenarios/api_key_delete/definition.mako @@ -0,0 +1 @@ +balanced.APIKey().delete() \ No newline at end of file diff --git a/scenarios/api_key_delete/executable.py b/scenarios/api_key_delete/executable.py new file mode 100644 index 0000000..f726841 --- /dev/null +++ b/scenarios/api_key_delete/executable.py @@ -0,0 +1,6 @@ +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +key = balanced.APIKey.fetch('/api_keys/AK3DQGzROuoRYulKXMQdHBxX') +key.delete() \ No newline at end of file diff --git a/scenarios/api_key_delete/python.mako b/scenarios/api_key_delete/python.mako new file mode 100644 index 0000000..5bf8c9f --- /dev/null +++ b/scenarios/api_key_delete/python.mako @@ -0,0 +1,12 @@ +% if mode == 'definition': +balanced.APIKey().delete() +% elif mode == 'request': +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +key = balanced.APIKey.fetch('/api_keys/AK3DQGzROuoRYulKXMQdHBxX') +key.delete() +% elif mode == 'response': + +% endif \ No newline at end of file diff --git a/scenarios/api_key_delete/request.mako b/scenarios/api_key_delete/request.mako new file mode 100644 index 0000000..90e410a --- /dev/null +++ b/scenarios/api_key_delete/request.mako @@ -0,0 +1,5 @@ +<%namespace file='/_main.mako' name='main'/> +<% main.python_boilerplate() %> + +key = balanced.APIKey.fetch('${request['uri']}') +key.delete() \ No newline at end of file diff --git a/scenarios/api_key_list/definition.mako b/scenarios/api_key_list/definition.mako new file mode 100644 index 0000000..96c40c8 --- /dev/null +++ b/scenarios/api_key_list/definition.mako @@ -0,0 +1 @@ +balanced.APIKey.query diff --git a/scenarios/api_key_list/executable.py b/scenarios/api_key_list/executable.py new file mode 100644 index 0000000..84c6874 --- /dev/null +++ b/scenarios/api_key_list/executable.py @@ -0,0 +1,5 @@ +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +keys = balanced.APIKey.query \ No newline at end of file diff --git a/scenarios/api_key_list/python.mako b/scenarios/api_key_list/python.mako new file mode 100644 index 0000000..b5c9132 --- /dev/null +++ b/scenarios/api_key_list/python.mako @@ -0,0 +1,12 @@ +% if mode == 'definition': +balanced.APIKey.query + +% elif mode == 'request': +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +keys = balanced.APIKey.query +% elif mode == 'response': + +% endif \ No newline at end of file diff --git a/scenarios/api_key_list/request.mako b/scenarios/api_key_list/request.mako new file mode 100644 index 0000000..8d74d4c --- /dev/null +++ b/scenarios/api_key_list/request.mako @@ -0,0 +1,4 @@ +<%namespace file='/_main.mako' name='main'/> +<% main.python_boilerplate() %> + +keys = balanced.APIKey.query \ No newline at end of file diff --git a/scenarios/api_key_show/definition.mako b/scenarios/api_key_show/definition.mako new file mode 100644 index 0000000..5f4442d --- /dev/null +++ b/scenarios/api_key_show/definition.mako @@ -0,0 +1 @@ +balanced.APIKey.fetch() diff --git a/scenarios/api_key_show/executable.py b/scenarios/api_key_show/executable.py new file mode 100644 index 0000000..50596bf --- /dev/null +++ b/scenarios/api_key_show/executable.py @@ -0,0 +1,5 @@ +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +key = balanced.APIKey.fetch('/api_keys/AK3DQGzROuoRYulKXMQdHBxX') \ No newline at end of file diff --git a/scenarios/api_key_show/python.mako b/scenarios/api_key_show/python.mako new file mode 100644 index 0000000..41a278d --- /dev/null +++ b/scenarios/api_key_show/python.mako @@ -0,0 +1,12 @@ +% if mode == 'definition': +balanced.APIKey.fetch() + +% elif mode == 'request': +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +key = balanced.APIKey.fetch('/api_keys/AK3DQGzROuoRYulKXMQdHBxX') +% elif mode == 'response': +APIKey(created_at=u'2015-01-09T03:23:00.061959Z', href=u'/api_keys/AK3DQGzROuoRYulKXMQdHBxX', meta={}, id=u'AK3DQGzROuoRYulKXMQdHBxX', links={}) +% endif \ No newline at end of file diff --git a/scenarios/api_key_show/request.mako b/scenarios/api_key_show/request.mako new file mode 100644 index 0000000..9c71180 --- /dev/null +++ b/scenarios/api_key_show/request.mako @@ -0,0 +1,4 @@ +<%namespace file='/_main.mako' name='main'/> +<% main.python_boilerplate() %> + +key = balanced.APIKey.fetch('${request['uri']}') \ No newline at end of file diff --git a/scenarios/bank_account_associate_to_customer/definition.mako b/scenarios/bank_account_associate_to_customer/definition.mako new file mode 100644 index 0000000..e04424c --- /dev/null +++ b/scenarios/bank_account_associate_to_customer/definition.mako @@ -0,0 +1 @@ +balanced.BankAccount().associate_to_customer() \ No newline at end of file diff --git a/scenarios/bank_account_associate_to_customer/executable.py b/scenarios/bank_account_associate_to_customer/executable.py new file mode 100644 index 0000000..56ac6eb --- /dev/null +++ b/scenarios/bank_account_associate_to_customer/executable.py @@ -0,0 +1,6 @@ +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +bank_account = balanced.BankAccount.fetch('/bank_accounts/BA45anEaEr8g0lOhzhcE9VAN') +bank_account.associate_to_customer('/customers/CU3o1ZAd8Gtxz6ZTIFK9YmsM') \ No newline at end of file diff --git a/scenarios/bank_account_associate_to_customer/python.mako b/scenarios/bank_account_associate_to_customer/python.mako new file mode 100644 index 0000000..e2ed620 --- /dev/null +++ b/scenarios/bank_account_associate_to_customer/python.mako @@ -0,0 +1,12 @@ +% if mode == 'definition': +balanced.BankAccount().associate_to_customer() +% elif mode == 'request': +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +bank_account = balanced.BankAccount.fetch('/bank_accounts/BA45anEaEr8g0lOhzhcE9VAN') +bank_account.associate_to_customer('/customers/CU3o1ZAd8Gtxz6ZTIFK9YmsM') +% elif mode == 'response': +BankAccount(routing_number=u'121000358', bank_name=u'BANK OF AMERICA, N.A.', account_type=u'checking', name=u'Johann Bernoulli', links={u'customer': u'CU3o1ZAd8Gtxz6ZTIFK9YmsM', u'bank_account_verification': None}, can_credit=True, created_at=u'2015-01-09T03:23:24.352488Z', address={u'city': None, u'line2': None, u'line1': None, u'state': None, u'postal_code': None, u'country_code': None}, updated_at=u'2015-01-09T03:23:25.100561Z', href=u'/bank_accounts/BA45anEaEr8g0lOhzhcE9VAN', meta={}, account_number=u'xxxxxx0001', fingerprint=u'5f0ba9fa3f1122ef13b944a40abfe44e7eba9e16934e64200913cb4c402ace14', can_debit=False, id=u'BA45anEaEr8g0lOhzhcE9VAN') +% endif \ No newline at end of file diff --git a/scenarios/bank_account_associate_to_customer/request.mako b/scenarios/bank_account_associate_to_customer/request.mako new file mode 100644 index 0000000..bafa956 --- /dev/null +++ b/scenarios/bank_account_associate_to_customer/request.mako @@ -0,0 +1,5 @@ +<%namespace file='/_main.mako' name='main'/> +<% main.python_boilerplate() %> + +bank_account = balanced.BankAccount.fetch('${request['uri']}') +bank_account.associate_to_customer('${request['payload']['customer']}') \ No newline at end of file diff --git a/scenarios/bank_account_create/definition.mako b/scenarios/bank_account_create/definition.mako index 3091be6..a843950 100644 --- a/scenarios/bank_account_create/definition.mako +++ b/scenarios/bank_account_create/definition.mako @@ -1 +1 @@ -balanced.BankAccount.save() \ No newline at end of file +balanced.BankAccount().save() \ No newline at end of file diff --git a/scenarios/bank_account_create/executable.py b/scenarios/bank_account_create/executable.py index 648a442..2fd0e6a 100644 --- a/scenarios/bank_account_create/executable.py +++ b/scenarios/bank_account_create/executable.py @@ -1,10 +1,10 @@ import balanced -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') bank_account = balanced.BankAccount( routing_number='121000358', - type='checking', + account_type='checking', account_number='9900000001', name='Johann Bernoulli' ).save() \ No newline at end of file diff --git a/scenarios/bank_account_create/python.mako b/scenarios/bank_account_create/python.mako index 562ab34..383873d 100644 --- a/scenarios/bank_account_create/python.mako +++ b/scenarios/bank_account_create/python.mako @@ -1,14 +1,16 @@ % if mode == 'definition': -balanced.BankAccount.save() -% else: +balanced.BankAccount().save() +% elif mode == 'request': import balanced -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') bank_account = balanced.BankAccount( routing_number='121000358', - type='checking', + account_type='checking', account_number='9900000001', name='Johann Bernoulli' ).save() +% elif mode == 'response': +BankAccount(routing_number=u'121000358', bank_name=u'BANK OF AMERICA, N.A.', account_type=u'checking', name=u'Johann Bernoulli', links={u'customer': None, u'bank_account_verification': None}, can_credit=True, created_at=u'2015-01-09T03:23:24.352488Z', address={u'city': None, u'line2': None, u'line1': None, u'state': None, u'postal_code': None, u'country_code': None}, updated_at=u'2015-01-09T03:23:24.352490Z', href=u'/bank_accounts/BA45anEaEr8g0lOhzhcE9VAN', meta={}, account_number=u'xxxxxx0001', fingerprint=u'5f0ba9fa3f1122ef13b944a40abfe44e7eba9e16934e64200913cb4c402ace14', can_debit=False, id=u'BA45anEaEr8g0lOhzhcE9VAN') % endif \ No newline at end of file diff --git a/scenarios/bank_account_credit/definition.mako b/scenarios/bank_account_credit/definition.mako new file mode 100644 index 0000000..ba5c951 --- /dev/null +++ b/scenarios/bank_account_credit/definition.mako @@ -0,0 +1 @@ +balanced.BankAccount().credit() \ No newline at end of file diff --git a/scenarios/bank_account_credit/executable.py b/scenarios/bank_account_credit/executable.py new file mode 100644 index 0000000..6231551 --- /dev/null +++ b/scenarios/bank_account_credit/executable.py @@ -0,0 +1,8 @@ +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +bank_account = balanced.BankAccount.fetch('/bank_accounts/BA45anEaEr8g0lOhzhcE9VAN') +bank_account.credit( + amount=5000 +) \ No newline at end of file diff --git a/scenarios/bank_account_credit/python.mako b/scenarios/bank_account_credit/python.mako new file mode 100644 index 0000000..c6abea0 --- /dev/null +++ b/scenarios/bank_account_credit/python.mako @@ -0,0 +1,14 @@ +% if mode == 'definition': +balanced.BankAccount().credit() +% elif mode == 'request': +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +bank_account = balanced.BankAccount.fetch('/bank_accounts/BA45anEaEr8g0lOhzhcE9VAN') +bank_account.credit( + amount=5000 +) +% elif mode == 'response': +Credit(status=u'pending', description=None, links={u'customer': u'CU3o1ZAd8Gtxz6ZTIFK9YmsM', u'destination': u'BA45anEaEr8g0lOhzhcE9VAN', u'order': None}, amount=5000, created_at=u'2015-01-09T03:25:41.350099Z', updated_at=u'2015-01-09T03:25:41.727056Z', failure_reason=None, currency=u'USD', transaction_number=u'CR6XX-6KR-7GSZ', href=u'/credits/CR6zeufmfv0u1KHrUBCQtAgU', meta={}, failure_reason_code=None, appears_on_statement_as=u'example.com', id=u'CR6zeufmfv0u1KHrUBCQtAgU') +% endif \ No newline at end of file diff --git a/scenarios/bank_account_credit/request.mako b/scenarios/bank_account_credit/request.mako new file mode 100644 index 0000000..bcbd55a --- /dev/null +++ b/scenarios/bank_account_credit/request.mako @@ -0,0 +1,7 @@ +<%namespace file='/_main.mako' name='main'/> +<% main.python_boilerplate() %> + +bank_account = balanced.BankAccount.fetch('${request['bank_account_href']}') +bank_account.credit( + <% main.payload_expand(request['payload']) %> +) \ No newline at end of file diff --git a/scenarios/bank_account_debit/definition.mako b/scenarios/bank_account_debit/definition.mako new file mode 100644 index 0000000..67d2161 --- /dev/null +++ b/scenarios/bank_account_debit/definition.mako @@ -0,0 +1 @@ +balanced.BankAccount().debit() \ No newline at end of file diff --git a/scenarios/bank_account_debit/executable.py b/scenarios/bank_account_debit/executable.py new file mode 100644 index 0000000..e69de29 diff --git a/scenarios/bank_account_debit/python.mako b/scenarios/bank_account_debit/python.mako new file mode 100644 index 0000000..a0f10b5 --- /dev/null +++ b/scenarios/bank_account_debit/python.mako @@ -0,0 +1,7 @@ +% if mode == 'definition': +balanced.BankAccount().debit() +% elif mode == 'request': + +% elif mode == 'response': + +% endif \ No newline at end of file diff --git a/scenarios/bank_account_debit/request.mako b/scenarios/bank_account_debit/request.mako new file mode 100644 index 0000000..e38c3f0 --- /dev/null +++ b/scenarios/bank_account_debit/request.mako @@ -0,0 +1,7 @@ +<%namespace file='/_main.mako' name='main'/> +<% main.python_boilerplate() %> + +bank_account = balanced.BankAccount.fetch('${request['bank_account_href']}') +bank_account.debit( + <% main.payload_expand(request['payload']) %> +) \ No newline at end of file diff --git a/scenarios/bank_account_debit_order/definition.mako b/scenarios/bank_account_debit_order/definition.mako new file mode 100644 index 0000000..eda6428 --- /dev/null +++ b/scenarios/bank_account_debit_order/definition.mako @@ -0,0 +1 @@ +balanced.Order().debit_from() diff --git a/scenarios/bank_account_debit_order/executable.py b/scenarios/bank_account_debit_order/executable.py new file mode 100644 index 0000000..7fc5acf --- /dev/null +++ b/scenarios/bank_account_debit_order/executable.py @@ -0,0 +1,10 @@ +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +order = balanced.Order.fetch('/orders/OR3vURGwVtqDnnkRS9fgH41G') +bank_account = balanced.BankAccount.fetch('/bank_accounts/BA3LVXVgJLrzkmB3vUntKJ6t') +order.debit_from( + amount=5000, + source=bank_account, +) \ No newline at end of file diff --git a/scenarios/bank_account_debit_order/python.mako b/scenarios/bank_account_debit_order/python.mako new file mode 100644 index 0000000..accb4ae --- /dev/null +++ b/scenarios/bank_account_debit_order/python.mako @@ -0,0 +1,17 @@ +% if mode == 'definition': +balanced.Order().debit_from() + +% elif mode == 'request': +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +order = balanced.Order.fetch('/orders/OR3vURGwVtqDnnkRS9fgH41G') +bank_account = balanced.BankAccount.fetch('/bank_accounts/BA3LVXVgJLrzkmB3vUntKJ6t') +order.debit_from( + amount=5000, + source=bank_account, +) +% elif mode == 'response': +Debit(status=u'pending', description=u'Order #12341234', links={u'customer': None, u'source': u'BA3LVXVgJLrzkmB3vUntKJ6t', u'dispute': None, u'order': u'OR3vURGwVtqDnnkRS9fgH41G', u'card_hold': None}, amount=5000, created_at=u'2015-01-09T03:23:26.676705Z', updated_at=u'2015-01-09T03:23:26.949357Z', failure_reason=None, currency=u'USD', transaction_number=u'WULC-EFN-JTW0', href=u'/debits/WD47MlpITdspMYF3lZSxmGtT', meta={}, failure_reason_code=None, appears_on_statement_as=u'BAL*example.com', id=u'WD47MlpITdspMYF3lZSxmGtT') +% endif \ No newline at end of file diff --git a/scenarios/bank_account_debit_order/request.mako b/scenarios/bank_account_debit_order/request.mako new file mode 100644 index 0000000..11d3115 --- /dev/null +++ b/scenarios/bank_account_debit_order/request.mako @@ -0,0 +1,9 @@ +<%namespace file='/_main.mako' name='main'/> +<% main.python_boilerplate() %> + +order = balanced.Order.fetch('${request['order_href']}') +bank_account = balanced.BankAccount.fetch('${request['bank_account_href']}') +order.debit_from( + amount=${payload['amount']}, + source=bank_account, +) \ No newline at end of file diff --git a/scenarios/bank_account_delete/definition.mako b/scenarios/bank_account_delete/definition.mako index 8923a9b..ecb3e1f 100644 --- a/scenarios/bank_account_delete/definition.mako +++ b/scenarios/bank_account_delete/definition.mako @@ -1 +1 @@ -balanced.BankAccount.delete() \ No newline at end of file +balanced.BankAccount().delete() \ No newline at end of file diff --git a/scenarios/bank_account_delete/executable.py b/scenarios/bank_account_delete/executable.py index 1a18852..919fe06 100644 --- a/scenarios/bank_account_delete/executable.py +++ b/scenarios/bank_account_delete/executable.py @@ -1,6 +1,6 @@ import balanced -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') -bank_account = balanced.BankAccount.find('/v1/bank_accounts/BARHVIjybOf6v3uQsYOnAYE') +bank_account = balanced.BankAccount.fetch('/bank_accounts/BA3Ya2sAlEQE14O1iS17FN0Q') bank_account.delete() \ No newline at end of file diff --git a/scenarios/bank_account_delete/python.mako b/scenarios/bank_account_delete/python.mako index a398980..330cde6 100644 --- a/scenarios/bank_account_delete/python.mako +++ b/scenarios/bank_account_delete/python.mako @@ -1,10 +1,12 @@ % if mode == 'definition': -balanced.BankAccount.delete() -% else: +balanced.BankAccount().delete() +% elif mode == 'request': import balanced -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') -bank_account = balanced.BankAccount.find('/v1/bank_accounts/BARHVIjybOf6v3uQsYOnAYE') +bank_account = balanced.BankAccount.fetch('/bank_accounts/BA3Ya2sAlEQE14O1iS17FN0Q') bank_account.delete() +% elif mode == 'response': + % endif \ No newline at end of file diff --git a/scenarios/bank_account_delete/request.mako b/scenarios/bank_account_delete/request.mako index 3a0a10c..cb00128 100644 --- a/scenarios/bank_account_delete/request.mako +++ b/scenarios/bank_account_delete/request.mako @@ -1,5 +1,5 @@ <%namespace file='/_main.mako' name='main'/> <% main.python_boilerplate() %> -bank_account = balanced.BankAccount.find('${request['uri']}') +bank_account = balanced.BankAccount.fetch('${request['uri']}') bank_account.delete() \ No newline at end of file diff --git a/scenarios/bank_account_invalid_routing_number/definition.mako b/scenarios/bank_account_invalid_routing_number/definition.mako deleted file mode 100644 index 89c684e..0000000 --- a/scenarios/bank_account_invalid_routing_number/definition.mako +++ /dev/null @@ -1 +0,0 @@ -balanced.exc.HTTPError \ No newline at end of file diff --git a/scenarios/bank_account_invalid_routing_number/executable.py b/scenarios/bank_account_invalid_routing_number/executable.py deleted file mode 100644 index f2ac3ca..0000000 --- a/scenarios/bank_account_invalid_routing_number/executable.py +++ /dev/null @@ -1,17 +0,0 @@ -import balanced - -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') - -bank_account = balanced.BankAccount( - routing_number='111111118', - type='checking', - account_number='9900000001', - name='Johann Bernoulli' -) - -try: - bank_account.save() -except balanced.exc.HTTPError, ex: - assert ex.status_code == 400 - assert 'Routing number is invalid' in ex.description - assert ex.request_id is not None \ No newline at end of file diff --git a/scenarios/bank_account_invalid_routing_number/python.mako b/scenarios/bank_account_invalid_routing_number/python.mako deleted file mode 100644 index 6232912..0000000 --- a/scenarios/bank_account_invalid_routing_number/python.mako +++ /dev/null @@ -1,21 +0,0 @@ -% if mode == 'definition': -balanced.exc.HTTPError -% else: -import balanced - -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') - -bank_account = balanced.BankAccount( - routing_number='111111118', - type='checking', - account_number='9900000001', - name='Johann Bernoulli' -) - -try: - bank_account.save() -except balanced.exc.HTTPError, ex: - assert ex.status_code == 400 - assert 'Routing number is invalid' in ex.description - assert ex.request_id is not None -% endif \ No newline at end of file diff --git a/scenarios/bank_account_invalid_routing_number/request.mako b/scenarios/bank_account_invalid_routing_number/request.mako deleted file mode 100644 index f2ebb31..0000000 --- a/scenarios/bank_account_invalid_routing_number/request.mako +++ /dev/null @@ -1,13 +0,0 @@ -<%namespace file='/_main.mako' name='main'/> -<% main.python_boilerplate() %> - -bank_account = balanced.BankAccount( - <% main.payload_expand(request['payload']) %> -) - -try: - bank_account.save() -except balanced.exc.HTTPError, ex: - assert ex.status_code == 400 - assert 'Routing number is invalid' in ex.description - assert ex.request_id is not None \ No newline at end of file diff --git a/scenarios/bank_account_list/definition.mako b/scenarios/bank_account_list/definition.mako index ed40953..6e1d1bb 100644 --- a/scenarios/bank_account_list/definition.mako +++ b/scenarios/bank_account_list/definition.mako @@ -1 +1 @@ -balanced.BankAccount.query() \ No newline at end of file +balanced.BankAccount.query diff --git a/scenarios/bank_account_list/executable.py b/scenarios/bank_account_list/executable.py index 0e45b78..965db18 100644 --- a/scenarios/bank_account_list/executable.py +++ b/scenarios/bank_account_list/executable.py @@ -1,5 +1,5 @@ import balanced -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') -bank_accounts = balanced.BankAccount.query.all() \ No newline at end of file +bank_accounts = balanced.BankAccount.query \ No newline at end of file diff --git a/scenarios/bank_account_list/python.mako b/scenarios/bank_account_list/python.mako index a1f2823..f260642 100644 --- a/scenarios/bank_account_list/python.mako +++ b/scenarios/bank_account_list/python.mako @@ -1,9 +1,12 @@ % if mode == 'definition': -balanced.BankAccount.query() -% else: +balanced.BankAccount.query + +% elif mode == 'request': import balanced -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +bank_accounts = balanced.BankAccount.query +% elif mode == 'response': -bank_accounts = balanced.BankAccount.query.all() % endif \ No newline at end of file diff --git a/scenarios/bank_account_list/request.mako b/scenarios/bank_account_list/request.mako index c5cd06e..eefa756 100644 --- a/scenarios/bank_account_list/request.mako +++ b/scenarios/bank_account_list/request.mako @@ -1,4 +1,4 @@ <%namespace file='/_main.mako' name='main'/> <% main.python_boilerplate() %> -bank_accounts = balanced.BankAccount.query.all() \ No newline at end of file +bank_accounts = balanced.BankAccount.query \ No newline at end of file diff --git a/scenarios/bank_account_show/definition.mako b/scenarios/bank_account_show/definition.mako index d531c20..f47a3bb 100644 --- a/scenarios/bank_account_show/definition.mako +++ b/scenarios/bank_account_show/definition.mako @@ -1 +1 @@ -balanced.BankAccount.find \ No newline at end of file +balanced.BankAccount.fetch() diff --git a/scenarios/bank_account_show/executable.py b/scenarios/bank_account_show/executable.py index 8821c63..d55a090 100644 --- a/scenarios/bank_account_show/executable.py +++ b/scenarios/bank_account_show/executable.py @@ -1,5 +1,5 @@ import balanced -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') -bank_account = balanced.BankAccount.find('/v1/bank_accounts/BAYBae39daGLlFYzJtGPTvw') \ No newline at end of file +bank_account = balanced.BankAccount.fetch('/bank_accounts/BA3Ya2sAlEQE14O1iS17FN0Q') \ No newline at end of file diff --git a/scenarios/bank_account_show/python.mako b/scenarios/bank_account_show/python.mako index 921bda9..9b2f347 100644 --- a/scenarios/bank_account_show/python.mako +++ b/scenarios/bank_account_show/python.mako @@ -1,9 +1,12 @@ % if mode == 'definition': -balanced.BankAccount.find -% else: +balanced.BankAccount.fetch() + +% elif mode == 'request': import balanced -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') -bank_account = balanced.BankAccount.find('/v1/bank_accounts/BAYBae39daGLlFYzJtGPTvw') +bank_account = balanced.BankAccount.fetch('/bank_accounts/BA3Ya2sAlEQE14O1iS17FN0Q') +% elif mode == 'response': +BankAccount(routing_number=u'121000358', bank_name=u'BANK OF AMERICA, N.A.', account_type=u'checking', name=u'Johann Bernoulli', links={u'customer': None, u'bank_account_verification': None}, can_credit=True, created_at=u'2015-01-09T03:23:18.120531Z', address={u'city': None, u'line2': None, u'line1': None, u'state': None, u'postal_code': None, u'country_code': None}, updated_at=u'2015-01-09T03:23:18.120532Z', href=u'/bank_accounts/BA3Ya2sAlEQE14O1iS17FN0Q', meta={}, account_number=u'xxxxxx0001', fingerprint=u'5f0ba9fa3f1122ef13b944a40abfe44e7eba9e16934e64200913cb4c402ace14', can_debit=False, id=u'BA3Ya2sAlEQE14O1iS17FN0Q') % endif \ No newline at end of file diff --git a/scenarios/bank_account_show/request.mako b/scenarios/bank_account_show/request.mako index 24daabe..2047ceb 100644 --- a/scenarios/bank_account_show/request.mako +++ b/scenarios/bank_account_show/request.mako @@ -1,4 +1,4 @@ <%namespace file='/_main.mako' name='main'/> <% main.python_boilerplate() %> -bank_account = balanced.BankAccount.find('${request['uri']}') \ No newline at end of file +bank_account = balanced.BankAccount.fetch('${request['uri']}') \ No newline at end of file diff --git a/scenarios/bank_account_update/definition.mako b/scenarios/bank_account_update/definition.mako new file mode 100644 index 0000000..67d2161 --- /dev/null +++ b/scenarios/bank_account_update/definition.mako @@ -0,0 +1 @@ +balanced.BankAccount().debit() \ No newline at end of file diff --git a/scenarios/bank_account_update/executable.py b/scenarios/bank_account_update/executable.py new file mode 100644 index 0000000..bce9e1a --- /dev/null +++ b/scenarios/bank_account_update/executable.py @@ -0,0 +1,11 @@ +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +bank_account = balanced.BankAccount.fetch('/bank_accounts/BA3Ya2sAlEQE14O1iS17FN0Q') +bank_account.meta = { + 'twitter.id'='1234987650', + 'facebook.user_id'='0192837465', + 'my-own-customer-id'='12345' +} +bank_account.save() \ No newline at end of file diff --git a/scenarios/bank_account_update/python.mako b/scenarios/bank_account_update/python.mako new file mode 100644 index 0000000..af118a7 --- /dev/null +++ b/scenarios/bank_account_update/python.mako @@ -0,0 +1,17 @@ +% if mode == 'definition': +balanced.BankAccount().debit() +% elif mode == 'request': +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +bank_account = balanced.BankAccount.fetch('/bank_accounts/BA3Ya2sAlEQE14O1iS17FN0Q') +bank_account.meta = { + 'twitter.id'='1234987650', + 'facebook.user_id'='0192837465', + 'my-own-customer-id'='12345' +} +bank_account.save() +% elif mode == 'response': +BankAccount(routing_number=u'121000358', bank_name=u'BANK OF AMERICA, N.A.', account_type=u'checking', name=u'Johann Bernoulli', links={u'customer': None, u'bank_account_verification': None}, can_credit=True, created_at=u'2015-01-09T03:23:18.120531Z', address={u'city': None, u'line2': None, u'line1': None, u'state': None, u'postal_code': None, u'country_code': None}, updated_at=u'2015-01-09T03:23:22.310587Z', href=u'/bank_accounts/BA3Ya2sAlEQE14O1iS17FN0Q', meta={u'twitter.id': u'1234987650', u'facebook.user_id': u'0192837465', u'my-own-customer-id': u'12345'}, account_number=u'xxxxxx0001', fingerprint=u'5f0ba9fa3f1122ef13b944a40abfe44e7eba9e16934e64200913cb4c402ace14', can_debit=False, id=u'BA3Ya2sAlEQE14O1iS17FN0Q') +% endif \ No newline at end of file diff --git a/scenarios/bank_account_update/request.mako b/scenarios/bank_account_update/request.mako new file mode 100644 index 0000000..5ab3526 --- /dev/null +++ b/scenarios/bank_account_update/request.mako @@ -0,0 +1,10 @@ +<%namespace file='/_main.mako' name='main'/> +<% main.python_boilerplate() %> + +bank_account = balanced.BankAccount.fetch('${request['uri']}') +bank_account.meta = { + 'twitter.id'='1234987650', + 'facebook.user_id'='0192837465', + 'my-own-customer-id'='12345' +} +bank_account.save() \ No newline at end of file diff --git a/scenarios/bank_account_verification_create/definition.mako b/scenarios/bank_account_verification_create/definition.mako index 93abd48..864f40a 100644 --- a/scenarios/bank_account_verification_create/definition.mako +++ b/scenarios/bank_account_verification_create/definition.mako @@ -1 +1 @@ -balanced.Verification().save() \ No newline at end of file +balanced.BankAccountVerification().save() \ No newline at end of file diff --git a/scenarios/bank_account_verification_create/executable.py b/scenarios/bank_account_verification_create/executable.py index b4f11cd..6f99a8d 100644 --- a/scenarios/bank_account_verification_create/executable.py +++ b/scenarios/bank_account_verification_create/executable.py @@ -1,6 +1,6 @@ import balanced -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') -bank_account = balanced.BankAccount.find('/v1/bank_accounts/BAA31STlZw3eRtjJHyyr0aC') +bank_account = balanced.BankAccount.fetch('/bank_accounts/BA3LVXVgJLrzkmB3vUntKJ6t') verification = bank_account.verify() \ No newline at end of file diff --git a/scenarios/bank_account_verification_create/python.mako b/scenarios/bank_account_verification_create/python.mako index fb055c3..6b25b0f 100644 --- a/scenarios/bank_account_verification_create/python.mako +++ b/scenarios/bank_account_verification_create/python.mako @@ -1,10 +1,12 @@ % if mode == 'definition': -balanced.Verification().save() -% else: +balanced.BankAccountVerification().save() +% elif mode == 'request': import balanced -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') -bank_account = balanced.BankAccount.find('/v1/bank_accounts/BAA31STlZw3eRtjJHyyr0aC') +bank_account = balanced.BankAccount.fetch('/bank_accounts/BA3LVXVgJLrzkmB3vUntKJ6t') verification = bank_account.verify() +% elif mode == 'response': +BankAccountVerification(verification_status=u'pending', links={u'bank_account': u'BA3LVXVgJLrzkmB3vUntKJ6t'}, created_at=u'2015-01-09T03:23:13.465191Z', attempts_remaining=3, updated_at=u'2015-01-09T03:23:13.465192Z', deposit_status=u'pending', attempts=0, href=u'/verifications/BZ3SVvXTx85CrYo8045tr2cU', meta={}, id=u'BZ3SVvXTx85CrYo8045tr2cU') % endif \ No newline at end of file diff --git a/scenarios/bank_account_verification_create/request.mako b/scenarios/bank_account_verification_create/request.mako index 6df8918..17ae4f4 100644 --- a/scenarios/bank_account_verification_create/request.mako +++ b/scenarios/bank_account_verification_create/request.mako @@ -1,5 +1,5 @@ <%namespace file='/_main.mako' name='main'/> <% main.python_boilerplate() %> -bank_account = balanced.BankAccount.find('${request['bank_account_uri']}') +bank_account = balanced.BankAccount.fetch('${request['bank_account_uri']}') verification = bank_account.verify() \ No newline at end of file diff --git a/scenarios/bank_account_verification_show/definition.mako b/scenarios/bank_account_verification_show/definition.mako index 97e1efb..7dd75ca 100644 --- a/scenarios/bank_account_verification_show/definition.mako +++ b/scenarios/bank_account_verification_show/definition.mako @@ -1 +1 @@ -balanced.Verification.find \ No newline at end of file +balanced.BankAccountVerification.fetch() diff --git a/scenarios/bank_account_verification_show/executable.py b/scenarios/bank_account_verification_show/executable.py index 6aae174..1004d0b 100644 --- a/scenarios/bank_account_verification_show/executable.py +++ b/scenarios/bank_account_verification_show/executable.py @@ -1,4 +1,4 @@ import balanced -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') -verification = balanced.BankAccountVerification.find('/v1/bank_accounts/BAH8CyjUCJzGtnlG7jvGDHy/verifications/BZJPjdW217PPcBBBy1g3RBk') \ No newline at end of file +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') +verification = balanced.BankAccountVerification.fetch('/verifications/BZ3SVvXTx85CrYo8045tr2cU') \ No newline at end of file diff --git a/scenarios/bank_account_verification_show/python.mako b/scenarios/bank_account_verification_show/python.mako index cfb5d69..49b5b9d 100644 --- a/scenarios/bank_account_verification_show/python.mako +++ b/scenarios/bank_account_verification_show/python.mako @@ -1,8 +1,11 @@ % if mode == 'definition': -balanced.Verification.find -% else: +balanced.BankAccountVerification.fetch() + +% elif mode == 'request': import balanced -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') -verification = balanced.BankAccountVerification.find('/v1/bank_accounts/BAH8CyjUCJzGtnlG7jvGDHy/verifications/BZJPjdW217PPcBBBy1g3RBk') +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') +verification = balanced.BankAccountVerification.fetch('/verifications/BZ3SVvXTx85CrYo8045tr2cU') +% elif mode == 'response': +BankAccountVerification(verification_status=u'pending', links={u'bank_account': u'BA3LVXVgJLrzkmB3vUntKJ6t'}, created_at=u'2015-01-09T03:23:13.465191Z', attempts_remaining=3, updated_at=u'2015-01-09T03:23:13.465192Z', deposit_status=u'pending', attempts=0, href=u'/verifications/BZ3SVvXTx85CrYo8045tr2cU', meta={}, id=u'BZ3SVvXTx85CrYo8045tr2cU') % endif \ No newline at end of file diff --git a/scenarios/bank_account_verification_show/request.mako b/scenarios/bank_account_verification_show/request.mako index a358fe7..f8ac54d 100644 --- a/scenarios/bank_account_verification_show/request.mako +++ b/scenarios/bank_account_verification_show/request.mako @@ -1,3 +1,3 @@ <%namespace file='/_main.mako' name='main'/> <% main.python_boilerplate() %> -verification = balanced.BankAccountVerification.find('${request['uri']}') \ No newline at end of file +verification = balanced.BankAccountVerification.fetch('${request['uri']}') \ No newline at end of file diff --git a/scenarios/bank_account_verification_update/definition.mako b/scenarios/bank_account_verification_update/definition.mako index 985e18f..e012862 100644 --- a/scenarios/bank_account_verification_update/definition.mako +++ b/scenarios/bank_account_verification_update/definition.mako @@ -1 +1 @@ -balanced.Verification.save \ No newline at end of file +balanced.BankAccountVerification().confirm() \ No newline at end of file diff --git a/scenarios/bank_account_verification_update/executable.py b/scenarios/bank_account_verification_update/executable.py index 7c2b0ca..1e3c80a 100644 --- a/scenarios/bank_account_verification_update/executable.py +++ b/scenarios/bank_account_verification_update/executable.py @@ -1,7 +1,6 @@ import balanced -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') -verification = balanced.BankAccountVerification.find('/v1/bank_accounts/BARHVIjybOf6v3uQsYOnAYE/verifications/BZTEkn24x0fcao764SiSGTC') -verification.amount_1 = 1 -verification.amount_2 = 1 -verification.save \ No newline at end of file +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +verification = balanced.BankAccountVerification.fetch('/verifications/BZ3SVvXTx85CrYo8045tr2cU') +verification.confirm(amount_1=1, amount_2=1) \ No newline at end of file diff --git a/scenarios/bank_account_verification_update/python.mako b/scenarios/bank_account_verification_update/python.mako index e191733..afaefe0 100644 --- a/scenarios/bank_account_verification_update/python.mako +++ b/scenarios/bank_account_verification_update/python.mako @@ -1,11 +1,12 @@ % if mode == 'definition': -balanced.Verification.save -% else: +balanced.BankAccountVerification().confirm() +% elif mode == 'request': import balanced -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') -verification = balanced.BankAccountVerification.find('/v1/bank_accounts/BARHVIjybOf6v3uQsYOnAYE/verifications/BZTEkn24x0fcao764SiSGTC') -verification.amount_1 = 1 -verification.amount_2 = 1 -verification.save +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +verification = balanced.BankAccountVerification.fetch('/verifications/BZ3SVvXTx85CrYo8045tr2cU') +verification.confirm(amount_1=1, amount_2=1) +% elif mode == 'response': +BankAccountVerification(verification_status=u'succeeded', links={u'bank_account': u'BA3LVXVgJLrzkmB3vUntKJ6t'}, created_at=u'2015-01-09T03:23:13.465191Z', attempts_remaining=2, updated_at=u'2015-01-09T03:23:16.381292Z', deposit_status=u'succeeded', attempts=1, href=u'/verifications/BZ3SVvXTx85CrYo8045tr2cU', meta={}, id=u'BZ3SVvXTx85CrYo8045tr2cU') % endif \ No newline at end of file diff --git a/scenarios/bank_account_verification_update/request.mako b/scenarios/bank_account_verification_update/request.mako index 4834e6e..382d135 100644 --- a/scenarios/bank_account_verification_update/request.mako +++ b/scenarios/bank_account_verification_update/request.mako @@ -1,6 +1,5 @@ <%namespace file='/_main.mako' name='main'/> <% main.python_boilerplate() %> -verification = balanced.BankAccountVerification.find('${request['uri']}') -verification.amount_1 = 1 -verification.amount_2 = 1 -verification.save \ No newline at end of file + +verification = balanced.BankAccountVerification.fetch('${request['uri']}') +verification.confirm(amount_1=1, amount_2=1) diff --git a/scenarios/callback_create/definition.mako b/scenarios/callback_create/definition.mako index b00979e..ab352d3 100644 --- a/scenarios/callback_create/definition.mako +++ b/scenarios/callback_create/definition.mako @@ -1 +1 @@ -balanced.Callback \ No newline at end of file +balanced.Callback() \ No newline at end of file diff --git a/scenarios/callback_create/executable.py b/scenarios/callback_create/executable.py index 1041103..050574b 100644 --- a/scenarios/callback_create/executable.py +++ b/scenarios/callback_create/executable.py @@ -1,7 +1,8 @@ import balanced -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') callback = balanced.Callback( - url='http://www.example.com/callback' + url='http://www.example.com/callback_test', + method='post' ).save() \ No newline at end of file diff --git a/scenarios/callback_create/python.mako b/scenarios/callback_create/python.mako index 2c9f789..6be8c1a 100644 --- a/scenarios/callback_create/python.mako +++ b/scenarios/callback_create/python.mako @@ -1,11 +1,14 @@ % if mode == 'definition': -balanced.Callback -% else: +balanced.Callback() +% elif mode == 'request': import balanced -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') callback = balanced.Callback( - url='http://www.example.com/callback' + url='http://www.example.com/callback_test', + method='post' ).save() +% elif mode == 'response': +Callback(links={}, url=u'http://www.example.com/callback_test', id=u'CB4a7Q7HSdJJgMVHwPsarIw8', href=u'/callbacks/CB4a7Q7HSdJJgMVHwPsarIw8', method=u'post', revision=u'1.1') % endif \ No newline at end of file diff --git a/scenarios/callback_delete/definition.mako b/scenarios/callback_delete/definition.mako index a1ab3b4..a60e731 100644 --- a/scenarios/callback_delete/definition.mako +++ b/scenarios/callback_delete/definition.mako @@ -1 +1 @@ -Callback.unstore \ No newline at end of file +balanced.Callback().unstore() \ No newline at end of file diff --git a/scenarios/callback_delete/executable.py b/scenarios/callback_delete/executable.py index 647205c..927a678 100644 --- a/scenarios/callback_delete/executable.py +++ b/scenarios/callback_delete/executable.py @@ -1,6 +1,6 @@ import balanced -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') -callback = balanced.Callback.find('/v1/callbacks/CB18dXR1zGLZeawfMBIOPVYs') +callback = balanced.Callback.fetch('/callbacks/CB4a7Q7HSdJJgMVHwPsarIw8') callback.unstore() \ No newline at end of file diff --git a/scenarios/callback_delete/python.mako b/scenarios/callback_delete/python.mako index f705cde..359fbca 100644 --- a/scenarios/callback_delete/python.mako +++ b/scenarios/callback_delete/python.mako @@ -1,10 +1,12 @@ % if mode == 'definition': -Callback.unstore -% else: +balanced.Callback().unstore() +% elif mode == 'request': import balanced -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') -callback = balanced.Callback.find('/v1/callbacks/CB18dXR1zGLZeawfMBIOPVYs') +callback = balanced.Callback.fetch('/callbacks/CB4a7Q7HSdJJgMVHwPsarIw8') callback.unstore() +% elif mode == 'response': + % endif \ No newline at end of file diff --git a/scenarios/callback_delete/request.mako b/scenarios/callback_delete/request.mako index 3000856..a427748 100644 --- a/scenarios/callback_delete/request.mako +++ b/scenarios/callback_delete/request.mako @@ -1,5 +1,5 @@ <%namespace file='/_main.mako' name='main'/> <% main.python_boilerplate() %> -callback = balanced.Callback.find('${request['uri']}') +callback = balanced.Callback.fetch('${request['uri']}') callback.unstore() \ No newline at end of file diff --git a/scenarios/callback_list/definition.mako b/scenarios/callback_list/definition.mako index f8ea1c2..b6d0a3b 100644 --- a/scenarios/callback_list/definition.mako +++ b/scenarios/callback_list/definition.mako @@ -1 +1 @@ -balanced.Callback.query.all \ No newline at end of file +balanced.Callback.query diff --git a/scenarios/callback_list/executable.py b/scenarios/callback_list/executable.py index dd3ff25..986e0da 100644 --- a/scenarios/callback_list/executable.py +++ b/scenarios/callback_list/executable.py @@ -1,5 +1,5 @@ import balanced -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') -callback = balanced.Callback.query.all() \ No newline at end of file +callbacks = balanced.Callback.query \ No newline at end of file diff --git a/scenarios/callback_list/python.mako b/scenarios/callback_list/python.mako index ee9e3e6..24fa6e3 100644 --- a/scenarios/callback_list/python.mako +++ b/scenarios/callback_list/python.mako @@ -1,9 +1,12 @@ % if mode == 'definition': -balanced.Callback.query.all -% else: +balanced.Callback.query + +% elif mode == 'request': import balanced -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +callbacks = balanced.Callback.query +% elif mode == 'response': -callback = balanced.Callback.query.all() % endif \ No newline at end of file diff --git a/scenarios/callback_list/request.mako b/scenarios/callback_list/request.mako index 3ada641..f04f7b2 100644 --- a/scenarios/callback_list/request.mako +++ b/scenarios/callback_list/request.mako @@ -1,4 +1,4 @@ <%namespace file='/_main.mako' name='main'/> <% main.python_boilerplate() %> -callback = balanced.Callback.query.all() \ No newline at end of file +callbacks = balanced.Callback.query \ No newline at end of file diff --git a/scenarios/callback_show/definition.mako b/scenarios/callback_show/definition.mako index 6f75e8f..e14fb92 100644 --- a/scenarios/callback_show/definition.mako +++ b/scenarios/callback_show/definition.mako @@ -1 +1 @@ -balanced.Callback.find \ No newline at end of file +balanced.Callback.fetch() diff --git a/scenarios/callback_show/executable.py b/scenarios/callback_show/executable.py index f00f411..b267af9 100644 --- a/scenarios/callback_show/executable.py +++ b/scenarios/callback_show/executable.py @@ -1,5 +1,5 @@ import balanced -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') -callback = balanced.Callback.find('/v1/callbacks/CB18dXR1zGLZeawfMBIOPVYs') \ No newline at end of file +callback = balanced.Callback.fetch('/callbacks/CB4a7Q7HSdJJgMVHwPsarIw8') \ No newline at end of file diff --git a/scenarios/callback_show/python.mako b/scenarios/callback_show/python.mako index b625f9e..2513875 100644 --- a/scenarios/callback_show/python.mako +++ b/scenarios/callback_show/python.mako @@ -1,9 +1,12 @@ % if mode == 'definition': -balanced.Callback.find -% else: +balanced.Callback.fetch() + +% elif mode == 'request': import balanced -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') -callback = balanced.Callback.find('/v1/callbacks/CB18dXR1zGLZeawfMBIOPVYs') +callback = balanced.Callback.fetch('/callbacks/CB4a7Q7HSdJJgMVHwPsarIw8') +% elif mode == 'response': +Callback(links={}, url=u'http://www.example.com/callback_test', id=u'CB4a7Q7HSdJJgMVHwPsarIw8', href=u'/callbacks/CB4a7Q7HSdJJgMVHwPsarIw8', method=u'post', revision=u'1.1') % endif \ No newline at end of file diff --git a/scenarios/callback_show/request.mako b/scenarios/callback_show/request.mako index 77f5c5e..b296241 100644 --- a/scenarios/callback_show/request.mako +++ b/scenarios/callback_show/request.mako @@ -1,4 +1,4 @@ <%namespace file='/_main.mako' name='main'/> <% main.python_boilerplate() %> -callback = balanced.Callback.find('${request['uri']}') \ No newline at end of file +callback = balanced.Callback.fetch('${request['uri']}') \ No newline at end of file diff --git a/scenarios/card_associate_to_customer/definition.mako b/scenarios/card_associate_to_customer/definition.mako new file mode 100644 index 0000000..2090176 --- /dev/null +++ b/scenarios/card_associate_to_customer/definition.mako @@ -0,0 +1 @@ +balanced.Card().associate_to_customer() \ No newline at end of file diff --git a/scenarios/card_associate_to_customer/executable.py b/scenarios/card_associate_to_customer/executable.py new file mode 100644 index 0000000..b2f4245 --- /dev/null +++ b/scenarios/card_associate_to_customer/executable.py @@ -0,0 +1,6 @@ +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +card = balanced.Card.fetch('/cards/CC4HDcgvzIltvwv6GSjBVbji') +card.associate_to_customer('/customers/CU3o1ZAd8Gtxz6ZTIFK9YmsM') \ No newline at end of file diff --git a/scenarios/card_associate_to_customer/python.mako b/scenarios/card_associate_to_customer/python.mako new file mode 100644 index 0000000..465a99e --- /dev/null +++ b/scenarios/card_associate_to_customer/python.mako @@ -0,0 +1,12 @@ +% if mode == 'definition': +balanced.Card().associate_to_customer() +% elif mode == 'request': +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +card = balanced.Card.fetch('/cards/CC4HDcgvzIltvwv6GSjBVbji') +card.associate_to_customer('/customers/CU3o1ZAd8Gtxz6ZTIFK9YmsM') +% elif mode == 'response': +Card(links={u'customer': u'CU3o1ZAd8Gtxz6ZTIFK9YmsM'}, cvv_result=None, number=u'xxxxxxxxxxxx1118', expiration_month=5, href=u'/cards/CC4HDcgvzIltvwv6GSjBVbji', type=u'debit', id=u'CC4HDcgvzIltvwv6GSjBVbji', category=u'other', is_verified=True, cvv_match=None, bank_name=u'WELLS FARGO BANK, N.A.', avs_street_match=None, brand=u'Visa', updated_at=u'2015-01-09T03:23:59.133903Z', fingerprint=u'7dc93d35b59078a1da8e0ebd2cbec65a6ca205760a1be1b90a143d7f2b00e355', can_debit=True, name=u'Johannes Bach', expiration_year=2020, cvv=None, avs_postal_match=None, avs_result=None, can_credit=True, meta={}, created_at=u'2015-01-09T03:23:58.549644Z', address={u'city': None, u'line2': None, u'line1': None, u'state': None, u'postal_code': None, u'country_code': None}) +% endif \ No newline at end of file diff --git a/scenarios/card_associate_to_customer/request.mako b/scenarios/card_associate_to_customer/request.mako new file mode 100644 index 0000000..71ec07b --- /dev/null +++ b/scenarios/card_associate_to_customer/request.mako @@ -0,0 +1,5 @@ +<%namespace file='/_main.mako' name='main'/> +<% main.python_boilerplate() %> + +card = balanced.Card.fetch('${request['uri']}') +card.associate_to_customer('${request['payload']['customer']}') \ No newline at end of file diff --git a/scenarios/card_create/definition.mako b/scenarios/card_create/definition.mako index 638c1d2..1235831 100644 --- a/scenarios/card_create/definition.mako +++ b/scenarios/card_create/definition.mako @@ -1 +1 @@ -balanced.Card.save() \ No newline at end of file +balanced.Card().save() \ No newline at end of file diff --git a/scenarios/card_create/executable.py b/scenarios/card_create/executable.py index 32ba2e0..84e7b87 100644 --- a/scenarios/card_create/executable.py +++ b/scenarios/card_create/executable.py @@ -1,10 +1,10 @@ import balanced -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') card = balanced.Card( + cvv='123', expiration_month='12', - security_code='123', - card_number='5105105105105100', + number='5105105105105100', expiration_year='2020' ).save() \ No newline at end of file diff --git a/scenarios/card_create/python.mako b/scenarios/card_create/python.mako index 3a8fd95..98c9693 100644 --- a/scenarios/card_create/python.mako +++ b/scenarios/card_create/python.mako @@ -1,14 +1,16 @@ % if mode == 'definition': -balanced.Card.save() -% else: +balanced.Card().save() +% elif mode == 'request': import balanced -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') card = balanced.Card( + cvv='123', expiration_month='12', - security_code='123', - card_number='5105105105105100', + number='5105105105105100', expiration_year='2020' ).save() +% elif mode == 'response': +Card(links={u'customer': None}, cvv_result=u'Match', number=u'xxxxxxxxxxxx5100', expiration_month=12, href=u'/cards/CC4zyuNpxY0A0eAf87SeULCR', type=u'credit', id=u'CC4zyuNpxY0A0eAf87SeULCR', category=u'other', is_verified=True, cvv_match=u'yes', bank_name=u'BANK OF HAWAII', avs_street_match=None, brand=u'MasterCard', updated_at=u'2015-01-09T03:23:51.373359Z', fingerprint=u'fc4ccd5de54f42a5e75f76fbfde60948440c7a382ee7d21b2bc509ab9cfed788', can_debit=True, name=None, expiration_year=2020, cvv=u'xxx', avs_postal_match=None, avs_result=None, can_credit=False, meta={}, created_at=u'2015-01-09T03:23:51.373358Z', address={u'city': None, u'line2': None, u'line1': None, u'state': None, u'postal_code': None, u'country_code': None}) % endif \ No newline at end of file diff --git a/scenarios/card_create_creditable/definition.mako b/scenarios/card_create_creditable/definition.mako new file mode 100644 index 0000000..1235831 --- /dev/null +++ b/scenarios/card_create_creditable/definition.mako @@ -0,0 +1 @@ +balanced.Card().save() \ No newline at end of file diff --git a/scenarios/card_create_creditable/executable.py b/scenarios/card_create_creditable/executable.py new file mode 100644 index 0000000..11d1569 --- /dev/null +++ b/scenarios/card_create_creditable/executable.py @@ -0,0 +1,10 @@ +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +card = balanced.Card( + expiration_month='05', + name='Johannes Bach', + expiration_year='2020', + number='4342561111111118' +).save() \ No newline at end of file diff --git a/scenarios/card_create_creditable/python.mako b/scenarios/card_create_creditable/python.mako new file mode 100644 index 0000000..5b74317 --- /dev/null +++ b/scenarios/card_create_creditable/python.mako @@ -0,0 +1,16 @@ +% if mode == 'definition': +balanced.Card().save() +% elif mode == 'request': +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +card = balanced.Card( + expiration_month='05', + name='Johannes Bach', + expiration_year='2020', + number='4342561111111118' +).save() +% elif mode == 'response': +Card(links={u'customer': None}, cvv_result=None, number=u'xxxxxxxxxxxx1118', expiration_month=5, href=u'/cards/CC4HDcgvzIltvwv6GSjBVbji', type=u'debit', id=u'CC4HDcgvzIltvwv6GSjBVbji', category=u'other', is_verified=True, cvv_match=None, bank_name=u'WELLS FARGO BANK, N.A.', avs_street_match=None, brand=u'Visa', updated_at=u'2015-01-09T03:23:58.549645Z', fingerprint=u'7dc93d35b59078a1da8e0ebd2cbec65a6ca205760a1be1b90a143d7f2b00e355', can_debit=True, name=u'Johannes Bach', expiration_year=2020, cvv=None, avs_postal_match=None, avs_result=None, can_credit=True, meta={}, created_at=u'2015-01-09T03:23:58.549644Z', address={u'city': None, u'line2': None, u'line1': None, u'state': None, u'postal_code': None, u'country_code': None}) +% endif \ No newline at end of file diff --git a/scenarios/hold_create/request.mako b/scenarios/card_create_creditable/request.mako similarity index 77% rename from scenarios/hold_create/request.mako rename to scenarios/card_create_creditable/request.mako index 8c1b6c8..bae039b 100644 --- a/scenarios/hold_create/request.mako +++ b/scenarios/card_create_creditable/request.mako @@ -1,7 +1,6 @@ <%namespace file='/_main.mako' name='main'/> <% main.python_boilerplate() %> -hold = balanced.Hold( +card = balanced.Card( <% main.payload_expand(request['payload']) %> -) -hold.save() +).save() \ No newline at end of file diff --git a/scenarios/card_create_dispute/definition.mako b/scenarios/card_create_dispute/definition.mako new file mode 100644 index 0000000..1235831 --- /dev/null +++ b/scenarios/card_create_dispute/definition.mako @@ -0,0 +1 @@ +balanced.Card().save() \ No newline at end of file diff --git a/scenarios/card_create_dispute/executable.py b/scenarios/card_create_dispute/executable.py new file mode 100644 index 0000000..068e3fd --- /dev/null +++ b/scenarios/card_create_dispute/executable.py @@ -0,0 +1,10 @@ +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +card = balanced.Card( + cvv='123', + expiration_month='12', + number='6500000000000002', + expiration_year='3000' +).save() \ No newline at end of file diff --git a/scenarios/card_create_dispute/python.mako b/scenarios/card_create_dispute/python.mako new file mode 100644 index 0000000..3b4099f --- /dev/null +++ b/scenarios/card_create_dispute/python.mako @@ -0,0 +1,16 @@ +% if mode == 'definition': +balanced.Card().save() +% elif mode == 'request': +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +card = balanced.Card( + cvv='123', + expiration_month='12', + number='6500000000000002', + expiration_year='3000' +).save() +% elif mode == 'response': +Card(links={u'customer': None}, cvv_result=u'Match', number=u'xxxxxxxxxxxx0002', expiration_month=12, href=u'/cards/CC5RRvpnZIg0PWdSphR8xxPa', type=u'debit', id=u'CC5RRvpnZIg0PWdSphR8xxPa', category=u'other', is_verified=True, cvv_match=u'yes', bank_name=u'BANK OF AMERICA', avs_street_match=None, brand=u'Discover', updated_at=u'2015-01-09T03:25:02.773172Z', fingerprint=u'3c667a62653e187f29b5781eeb0703f26e99558080de0c0f9490b5f9c4ac2871', can_debit=True, name=None, expiration_year=3000, cvv=u'xxx', avs_postal_match=None, avs_result=None, can_credit=True, meta={}, created_at=u'2015-01-09T03:25:02.773170Z', address={u'city': None, u'line2': None, u'line1': None, u'state': None, u'postal_code': None, u'country_code': None}) +% endif \ No newline at end of file diff --git a/scenarios/account_create_buyer/request.mako b/scenarios/card_create_dispute/request.mako similarity index 68% rename from scenarios/account_create_buyer/request.mako rename to scenarios/card_create_dispute/request.mako index 2ff4127..bae039b 100644 --- a/scenarios/account_create_buyer/request.mako +++ b/scenarios/card_create_dispute/request.mako @@ -1,6 +1,6 @@ <%namespace file='/_main.mako' name='main'/> <% main.python_boilerplate() %> -buyer = balanced.Marketplace.my_marketplace.create_buyer( +card = balanced.Card( <% main.payload_expand(request['payload']) %> -) \ No newline at end of file +).save() \ No newline at end of file diff --git a/scenarios/card_credit/definition.mako b/scenarios/card_credit/definition.mako new file mode 100644 index 0000000..d97ded5 --- /dev/null +++ b/scenarios/card_credit/definition.mako @@ -0,0 +1 @@ +balanced.Card().credit() \ No newline at end of file diff --git a/scenarios/card_credit/executable.py b/scenarios/card_credit/executable.py new file mode 100644 index 0000000..e69de29 diff --git a/scenarios/card_credit/python.mako b/scenarios/card_credit/python.mako new file mode 100644 index 0000000..b8a2fa8 --- /dev/null +++ b/scenarios/card_credit/python.mako @@ -0,0 +1,7 @@ +% if mode == 'definition': +balanced.Card().credit() +% elif mode == 'request': + +% elif mode == 'response': + +% endif \ No newline at end of file diff --git a/scenarios/hold_capture/request.mako b/scenarios/card_credit/request.mako similarity index 62% rename from scenarios/hold_capture/request.mako rename to scenarios/card_credit/request.mako index 5590711..b4350ce 100644 --- a/scenarios/hold_capture/request.mako +++ b/scenarios/card_credit/request.mako @@ -1,7 +1,8 @@ <%namespace file='/_main.mako' name='main'/> <% main.python_boilerplate() %> -hold = balanced.Hold.find('${request['hold_uri']}') -debit = hold.capture( +card = balanced.Card.fetch('${request['card_href']}') +card.credit( <% main.payload_expand(request['payload']) %> -) \ No newline at end of file +) + diff --git a/scenarios/card_credit_order/definition.mako b/scenarios/card_credit_order/definition.mako new file mode 100644 index 0000000..a389100 --- /dev/null +++ b/scenarios/card_credit_order/definition.mako @@ -0,0 +1 @@ +balanced.Order().credit_to() diff --git a/scenarios/card_credit_order/executable.py b/scenarios/card_credit_order/executable.py new file mode 100644 index 0000000..ca620d5 --- /dev/null +++ b/scenarios/card_credit_order/executable.py @@ -0,0 +1,10 @@ +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +order = balanced.Order.fetch('/orders/OR3vURGwVtqDnnkRS9fgH41G') +card = balanced.Card.fetch('/cards/CC4HDcgvzIltvwv6GSjBVbji') +order.credit_to( + amount=5000, + source=card, +) \ No newline at end of file diff --git a/scenarios/card_credit_order/python.mako b/scenarios/card_credit_order/python.mako new file mode 100644 index 0000000..5ee0022 --- /dev/null +++ b/scenarios/card_credit_order/python.mako @@ -0,0 +1,17 @@ +% if mode == 'definition': +balanced.Order().credit_to() + +% elif mode == 'request': +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +order = balanced.Order.fetch('/orders/OR3vURGwVtqDnnkRS9fgH41G') +card = balanced.Card.fetch('/cards/CC4HDcgvzIltvwv6GSjBVbji') +order.credit_to( + amount=5000, + source=card, +) +% elif mode == 'response': +Credit(status=u'succeeded', description=u'Order #12341234', links={u'customer': u'CU3o1ZAd8Gtxz6ZTIFK9YmsM', u'destination': u'CC4HDcgvzIltvwv6GSjBVbji', u'order': u'OR3vURGwVtqDnnkRS9fgH41G'}, amount=5000, created_at=u'2015-01-09T03:24:02.493888Z', updated_at=u'2015-01-09T03:24:02.893852Z', failure_reason=None, currency=u'USD', transaction_number=u'CROCY-7EY-ZRI2', href=u'/credits/CR4M2HpYdKDcG8nh4d5HrKJL', meta={}, failure_reason_code=None, appears_on_statement_as=u'example.com', id=u'CR4M2HpYdKDcG8nh4d5HrKJL') +% endif \ No newline at end of file diff --git a/scenarios/card_credit_order/request.mako b/scenarios/card_credit_order/request.mako new file mode 100644 index 0000000..2d14cdd --- /dev/null +++ b/scenarios/card_credit_order/request.mako @@ -0,0 +1,9 @@ +<%namespace file='/_main.mako' name='main'/> +<% main.python_boilerplate() %> + +order = balanced.Order.fetch('${request['order_href']}') +card = balanced.Card.fetch('${request['card_href']}') +order.credit_to( + amount=${payload['amount']}, + source=card, +) \ No newline at end of file diff --git a/scenarios/card_debit/definition.mako b/scenarios/card_debit/definition.mako new file mode 100644 index 0000000..91d7e5b --- /dev/null +++ b/scenarios/card_debit/definition.mako @@ -0,0 +1 @@ +balanced.Card().debit() \ No newline at end of file diff --git a/scenarios/card_debit/executable.py b/scenarios/card_debit/executable.py new file mode 100644 index 0000000..7ee7acc --- /dev/null +++ b/scenarios/card_debit/executable.py @@ -0,0 +1,10 @@ +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +card = balanced.Card.fetch('/cards/CC4zyuNpxY0A0eAf87SeULCR') +card.debit( + appears_on_statement_as='Statement text', + amount=5000, + description='Some descriptive text for the debit in the dashboard' +) \ No newline at end of file diff --git a/scenarios/card_debit/python.mako b/scenarios/card_debit/python.mako new file mode 100644 index 0000000..9dccea6 --- /dev/null +++ b/scenarios/card_debit/python.mako @@ -0,0 +1,16 @@ +% if mode == 'definition': +balanced.Card().debit() +% elif mode == 'request': +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +card = balanced.Card.fetch('/cards/CC4zyuNpxY0A0eAf87SeULCR') +card.debit( + appears_on_statement_as='Statement text', + amount=5000, + description='Some descriptive text for the debit in the dashboard' +) +% elif mode == 'response': +Debit(status=u'succeeded', description=u'Some descriptive text for the debit in the dashboard', links={u'customer': None, u'source': u'CC4zyuNpxY0A0eAf87SeULCR', u'dispute': None, u'order': None, u'card_hold': u'HL5NbQRZSxbr0o64QWu7szni'}, amount=5000, created_at=u'2015-01-09T03:24:58.643499Z', updated_at=u'2015-01-09T03:24:59.368094Z', failure_reason=None, currency=u'USD', transaction_number=u'WS4G-1FI-AT4Z', href=u'/debits/WD5Nd61WpdlRk6D39YVNFAEo', meta={}, failure_reason_code=None, appears_on_statement_as=u'BAL*Statement text', id=u'WD5Nd61WpdlRk6D39YVNFAEo') +% endif \ No newline at end of file diff --git a/scenarios/card_debit/request.mako b/scenarios/card_debit/request.mako new file mode 100644 index 0000000..ed62839 --- /dev/null +++ b/scenarios/card_debit/request.mako @@ -0,0 +1,8 @@ +<%namespace file='/_main.mako' name='main'/> +<% main.python_boilerplate() %> + +card = balanced.Card.fetch('${request['card_href']}') +card.debit( + <% main.payload_expand(request['payload']) %> +) + diff --git a/scenarios/card_debit_dispute/definition.mako b/scenarios/card_debit_dispute/definition.mako new file mode 100644 index 0000000..91d7e5b --- /dev/null +++ b/scenarios/card_debit_dispute/definition.mako @@ -0,0 +1 @@ +balanced.Card().debit() \ No newline at end of file diff --git a/scenarios/card_debit_dispute/executable.py b/scenarios/card_debit_dispute/executable.py new file mode 100644 index 0000000..eb7fee8 --- /dev/null +++ b/scenarios/card_debit_dispute/executable.py @@ -0,0 +1,10 @@ +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +card = balanced.Card.fetch('/cards/CC5RRvpnZIg0PWdSphR8xxPa') +card.debit( + appears_on_statement_as='Statement text', + amount=5000, + description='Some descriptive text for the debit in the dashboard' +) \ No newline at end of file diff --git a/scenarios/card_debit_dispute/python.mako b/scenarios/card_debit_dispute/python.mako new file mode 100644 index 0000000..a2c95d4 --- /dev/null +++ b/scenarios/card_debit_dispute/python.mako @@ -0,0 +1,16 @@ +% if mode == 'definition': +balanced.Card().debit() +% elif mode == 'request': +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +card = balanced.Card.fetch('/cards/CC5RRvpnZIg0PWdSphR8xxPa') +card.debit( + appears_on_statement_as='Statement text', + amount=5000, + description='Some descriptive text for the debit in the dashboard' +) +% elif mode == 'response': +Debit(status=u'succeeded', description=u'Some descriptive text for the debit in the dashboard', links={u'customer': None, u'source': u'CC5RRvpnZIg0PWdSphR8xxPa', u'dispute': None, u'order': None, u'card_hold': u'HL5Svbmw6nDDP5HO2RblsBCJ'}, amount=5000, created_at=u'2015-01-09T03:25:03.383375Z', updated_at=u'2015-01-09T03:25:04.090381Z', failure_reason=None, currency=u'USD', transaction_number=u'WA4K-D44-O5DR', href=u'/debits/WD5SwXr9jcCfCmmjTH5MCMFD', meta={}, failure_reason_code=None, appears_on_statement_as=u'BAL*Statement text', id=u'WD5SwXr9jcCfCmmjTH5MCMFD') +% endif \ No newline at end of file diff --git a/scenarios/card_debit_dispute/request.mako b/scenarios/card_debit_dispute/request.mako new file mode 100644 index 0000000..ed62839 --- /dev/null +++ b/scenarios/card_debit_dispute/request.mako @@ -0,0 +1,8 @@ +<%namespace file='/_main.mako' name='main'/> +<% main.python_boilerplate() %> + +card = balanced.Card.fetch('${request['card_href']}') +card.debit( + <% main.payload_expand(request['payload']) %> +) + diff --git a/scenarios/card_delete/definition.mako b/scenarios/card_delete/definition.mako index 52e2dee..489ff5d 100644 --- a/scenarios/card_delete/definition.mako +++ b/scenarios/card_delete/definition.mako @@ -1 +1 @@ -balanced.Card.unstore() \ No newline at end of file +balanced.Card().unstore() \ No newline at end of file diff --git a/scenarios/card_delete/executable.py b/scenarios/card_delete/executable.py index 423b7a8..4c1bb19 100644 --- a/scenarios/card_delete/executable.py +++ b/scenarios/card_delete/executable.py @@ -1,6 +1,6 @@ import balanced -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') -card = balanced.Card.find('/v1/marketplaces/TEST-MP52IlCmywk6hGbgS75QSlN/cards/CC1i5vMNFo69BmOfBWcx5iZM') +card = balanced.Card.fetch('/cards/CC4zyuNpxY0A0eAf87SeULCR') card.unstore() \ No newline at end of file diff --git a/scenarios/card_delete/python.mako b/scenarios/card_delete/python.mako index 52c9205..24f9f5e 100644 --- a/scenarios/card_delete/python.mako +++ b/scenarios/card_delete/python.mako @@ -1,10 +1,12 @@ % if mode == 'definition': -balanced.Card.unstore() -% else: +balanced.Card().unstore() +% elif mode == 'request': import balanced -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') -card = balanced.Card.find('/v1/marketplaces/TEST-MP52IlCmywk6hGbgS75QSlN/cards/CC1i5vMNFo69BmOfBWcx5iZM') +card = balanced.Card.fetch('/cards/CC4zyuNpxY0A0eAf87SeULCR') card.unstore() +% elif mode == 'response': + % endif \ No newline at end of file diff --git a/scenarios/card_delete/request.mako b/scenarios/card_delete/request.mako index 19db77d..43cdd7e 100644 --- a/scenarios/card_delete/request.mako +++ b/scenarios/card_delete/request.mako @@ -1,5 +1,5 @@ <%namespace file='/_main.mako' name='main'/> <% main.python_boilerplate() %> -card = balanced.Card.find('${request['uri']}') +card = balanced.Card.fetch('${request['uri']}') card.unstore() \ No newline at end of file diff --git a/scenarios/card_hold_capture/definition.mako b/scenarios/card_hold_capture/definition.mako new file mode 100644 index 0000000..b4fbac6 --- /dev/null +++ b/scenarios/card_hold_capture/definition.mako @@ -0,0 +1 @@ +balanced.CardHold().capture() \ No newline at end of file diff --git a/scenarios/card_hold_capture/executable.py b/scenarios/card_hold_capture/executable.py new file mode 100644 index 0000000..190b743 --- /dev/null +++ b/scenarios/card_hold_capture/executable.py @@ -0,0 +1,9 @@ +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +card_hold = balanced.CardHold.fetch('/card_holds/HL4iHX8OBNW7nVsu6MqyjnQ9') +debit = card_hold.capture( + appears_on_statement_as='ShowsUpOnStmt', + description='Some descriptive text for the debit in the dashboard' +) \ No newline at end of file diff --git a/scenarios/card_hold_capture/python.mako b/scenarios/card_hold_capture/python.mako new file mode 100644 index 0000000..22e5dd4 --- /dev/null +++ b/scenarios/card_hold_capture/python.mako @@ -0,0 +1,15 @@ +% if mode == 'definition': +balanced.CardHold().capture() +% elif mode == 'request': +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +card_hold = balanced.CardHold.fetch('/card_holds/HL4iHX8OBNW7nVsu6MqyjnQ9') +debit = card_hold.capture( + appears_on_statement_as='ShowsUpOnStmt', + description='Some descriptive text for the debit in the dashboard' +) +% elif mode == 'response': +Debit(status=u'succeeded', description=u'Some descriptive text for the debit in the dashboard', links={u'customer': None, u'source': u'CC3vhL91rWtwtHcOBl0ITshG', u'dispute': None, u'order': None, u'card_hold': u'HL4iHX8OBNW7nVsu6MqyjnQ9'}, amount=5000, created_at=u'2015-01-09T03:23:43.969240Z', updated_at=u'2015-01-09T03:23:44.454341Z', failure_reason=None, currency=u'USD', transaction_number=u'W456-5GN-9ECN', href=u'/debits/WD4relmrBWDQmtlKKKmKLi7z', meta={u'holding.for': u'user1', u'meaningful.key': u'some.value'}, failure_reason_code=None, appears_on_statement_as=u'BAL*ShowsUpOnStmt', id=u'WD4relmrBWDQmtlKKKmKLi7z') +% endif \ No newline at end of file diff --git a/scenarios/card_hold_capture/request.mako b/scenarios/card_hold_capture/request.mako new file mode 100644 index 0000000..d41ce8c --- /dev/null +++ b/scenarios/card_hold_capture/request.mako @@ -0,0 +1,7 @@ +<%namespace file='/_main.mako' name='main'/> +<% main.python_boilerplate() %> + +card_hold = balanced.CardHold.fetch('${request['card_hold_href']}') +debit = card_hold.capture( + <% main.payload_expand(request['payload']) %> +) \ No newline at end of file diff --git a/scenarios/card_hold_create/definition.mako b/scenarios/card_hold_create/definition.mako new file mode 100644 index 0000000..01df58f --- /dev/null +++ b/scenarios/card_hold_create/definition.mako @@ -0,0 +1 @@ +balanced.Card().hold() \ No newline at end of file diff --git a/scenarios/card_hold_create/executable.py b/scenarios/card_hold_create/executable.py new file mode 100644 index 0000000..a2b2fce --- /dev/null +++ b/scenarios/card_hold_create/executable.py @@ -0,0 +1,9 @@ +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +card = balanced.Card.fetch('/cards/CC3vhL91rWtwtHcOBl0ITshG') +card_hold = card.hold( + amount=5000, + description='Some descriptive text for the debit in the dashboard' +) \ No newline at end of file diff --git a/scenarios/card_hold_create/python.mako b/scenarios/card_hold_create/python.mako new file mode 100644 index 0000000..b48c2e4 --- /dev/null +++ b/scenarios/card_hold_create/python.mako @@ -0,0 +1,15 @@ +% if mode == 'definition': +balanced.Card().hold() +% elif mode == 'request': +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +card = balanced.Card.fetch('/cards/CC3vhL91rWtwtHcOBl0ITshG') +card_hold = card.hold( + amount=5000, + description='Some descriptive text for the debit in the dashboard' +) +% elif mode == 'response': +CardHold(status=u'succeeded', description=u'Some descriptive text for the debit in the dashboard', links={u'order': None, u'card': u'CC3vhL91rWtwtHcOBl0ITshG', u'debit': None}, amount=5000, created_at=u'2015-01-09T03:23:46.500278Z', updated_at=u'2015-01-09T03:23:46.803224Z', expires_at=u'2015-01-16T03:23:46.699907Z', failure_reason=None, currency=u'USD', transaction_number=u'HL07I-F9N-OVPO', href=u'/card_holds/HL4u4T2877PfgYwnbhD2XweV', meta={}, failure_reason_code=None, voided_at=None, id=u'HL4u4T2877PfgYwnbhD2XweV') +% endif \ No newline at end of file diff --git a/scenarios/debit_create/request.mako b/scenarios/card_hold_create/request.mako similarity index 61% rename from scenarios/debit_create/request.mako rename to scenarios/card_hold_create/request.mako index a659d1c..6c2a820 100644 --- a/scenarios/debit_create/request.mako +++ b/scenarios/card_hold_create/request.mako @@ -1,7 +1,7 @@ <%namespace file='/_main.mako' name='main'/> <% main.python_boilerplate() %> -customer = balanced.Customer.find('${request['customer_uri']}') -customer.debit( +card = balanced.Card.fetch('${request['card_href']}') +card_hold = card.hold( <% main.payload_expand(request['payload']) %> ) \ No newline at end of file diff --git a/scenarios/card_hold_list/definition.mako b/scenarios/card_hold_list/definition.mako new file mode 100644 index 0000000..0acf33a --- /dev/null +++ b/scenarios/card_hold_list/definition.mako @@ -0,0 +1 @@ +balanced.CardHold.query diff --git a/scenarios/card_hold_list/executable.py b/scenarios/card_hold_list/executable.py new file mode 100644 index 0000000..8fc7d17 --- /dev/null +++ b/scenarios/card_hold_list/executable.py @@ -0,0 +1,5 @@ +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +card_holds = balanced.CardHold.query \ No newline at end of file diff --git a/scenarios/card_hold_list/python.mako b/scenarios/card_hold_list/python.mako new file mode 100644 index 0000000..5dc8559 --- /dev/null +++ b/scenarios/card_hold_list/python.mako @@ -0,0 +1,12 @@ +% if mode == 'definition': +balanced.CardHold.query + +% elif mode == 'request': +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +card_holds = balanced.CardHold.query +% elif mode == 'response': + +% endif \ No newline at end of file diff --git a/scenarios/card_hold_list/request.mako b/scenarios/card_hold_list/request.mako new file mode 100644 index 0000000..a5eef2c --- /dev/null +++ b/scenarios/card_hold_list/request.mako @@ -0,0 +1,4 @@ +<%namespace file='/_main.mako' name='main'/> +<% main.python_boilerplate() %> + +card_holds = balanced.CardHold.query \ No newline at end of file diff --git a/scenarios/card_hold_order/definition.mako b/scenarios/card_hold_order/definition.mako new file mode 100644 index 0000000..01df58f --- /dev/null +++ b/scenarios/card_hold_order/definition.mako @@ -0,0 +1 @@ +balanced.Card().hold() \ No newline at end of file diff --git a/scenarios/card_hold_order/executable.py b/scenarios/card_hold_order/executable.py new file mode 100644 index 0000000..4218600 --- /dev/null +++ b/scenarios/card_hold_order/executable.py @@ -0,0 +1,11 @@ +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +order = balanced.Order.fetch('/orders/OR3vURGwVtqDnnkRS9fgH41G') +card = balanced.Card.fetch('/cards/CC3vhL91rWtwtHcOBl0ITshG') +card_hold = card.hold( +amount=5000, + description='Some descriptive text for the debit in the dashboard', + order='/orders/OR3vURGwVtqDnnkRS9fgH41G' +) \ No newline at end of file diff --git a/scenarios/card_hold_order/python.mako b/scenarios/card_hold_order/python.mako new file mode 100644 index 0000000..fbb6bc7 --- /dev/null +++ b/scenarios/card_hold_order/python.mako @@ -0,0 +1,17 @@ +% if mode == 'definition': +balanced.Card().hold() +% elif mode == 'request': +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +order = balanced.Order.fetch('/orders/OR3vURGwVtqDnnkRS9fgH41G') +card = balanced.Card.fetch('/cards/CC3vhL91rWtwtHcOBl0ITshG') +card_hold = card.hold( +amount=5000, + description='Some descriptive text for the debit in the dashboard', + order='/orders/OR3vURGwVtqDnnkRS9fgH41G' +) +% elif mode == 'response': +CardHold(status=u'succeeded', description=u'Some descriptive text for the debit in the dashboard', links={u'order': u'OR3vURGwVtqDnnkRS9fgH41G', u'card': u'CC3vhL91rWtwtHcOBl0ITshG', u'debit': None}, amount=5000, created_at=u'2015-01-09T03:23:34.413652Z', updated_at=u'2015-01-09T03:23:34.713108Z', expires_at=u'2015-01-16T03:23:34.647009Z', failure_reason=None, currency=u'USD', transaction_number=u'HLVKB-4MF-JL5N', href=u'/card_holds/HL4gu3SX4Z5LEPYtYhg6HOOp', meta={}, failure_reason_code=None, voided_at=None, id=u'HL4gu3SX4Z5LEPYtYhg6HOOp') +% endif \ No newline at end of file diff --git a/scenarios/card_hold_order/request.mako b/scenarios/card_hold_order/request.mako new file mode 100644 index 0000000..9541409 --- /dev/null +++ b/scenarios/card_hold_order/request.mako @@ -0,0 +1,8 @@ +<%namespace file='/_main.mako' name='main'/> +<% main.python_boilerplate() %> + +order = balanced.Order.fetch('${request['order_href']}') +card = balanced.Card.fetch('${request['card_href']}') +card_hold = card.hold( +<% main.payload_expand(request['payload']) %> +) \ No newline at end of file diff --git a/scenarios/card_hold_show/definition.mako b/scenarios/card_hold_show/definition.mako new file mode 100644 index 0000000..53d51dd --- /dev/null +++ b/scenarios/card_hold_show/definition.mako @@ -0,0 +1 @@ +balanced.CardHold.fetch() diff --git a/scenarios/card_hold_show/executable.py b/scenarios/card_hold_show/executable.py new file mode 100644 index 0000000..9f58fcd --- /dev/null +++ b/scenarios/card_hold_show/executable.py @@ -0,0 +1,5 @@ +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +card_hold = balanced.CardHold.fetch('/card_holds/HL4iHX8OBNW7nVsu6MqyjnQ9') \ No newline at end of file diff --git a/scenarios/card_hold_show/python.mako b/scenarios/card_hold_show/python.mako new file mode 100644 index 0000000..0f45e0c --- /dev/null +++ b/scenarios/card_hold_show/python.mako @@ -0,0 +1,12 @@ +% if mode == 'definition': +balanced.CardHold.fetch() + +% elif mode == 'request': +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +card_hold = balanced.CardHold.fetch('/card_holds/HL4iHX8OBNW7nVsu6MqyjnQ9') +% elif mode == 'response': +CardHold(status=u'succeeded', description=u'Some descriptive text for the debit in the dashboard', links={u'order': None, u'card': u'CC3vhL91rWtwtHcOBl0ITshG', u'debit': None}, amount=5000, created_at=u'2015-01-09T03:23:36.391121Z', updated_at=u'2015-01-09T03:23:36.674542Z', expires_at=u'2015-01-16T03:23:36.585031Z', failure_reason=None, currency=u'USD', transaction_number=u'HLI6T-T0A-HGZI', href=u'/card_holds/HL4iHX8OBNW7nVsu6MqyjnQ9', meta={}, failure_reason_code=None, voided_at=None, id=u'HL4iHX8OBNW7nVsu6MqyjnQ9') +% endif \ No newline at end of file diff --git a/scenarios/card_hold_show/request.mako b/scenarios/card_hold_show/request.mako new file mode 100644 index 0000000..91394e6 --- /dev/null +++ b/scenarios/card_hold_show/request.mako @@ -0,0 +1,4 @@ +<%namespace file='/_main.mako' name='main'/> +<% main.python_boilerplate() %> + +card_hold = balanced.CardHold.fetch('${request['uri']}') \ No newline at end of file diff --git a/scenarios/card_hold_update/definition.mako b/scenarios/card_hold_update/definition.mako new file mode 100644 index 0000000..9dfe4f8 --- /dev/null +++ b/scenarios/card_hold_update/definition.mako @@ -0,0 +1 @@ +balanced.CardHold().save() \ No newline at end of file diff --git a/scenarios/card_hold_update/executable.py b/scenarios/card_hold_update/executable.py new file mode 100644 index 0000000..3979709 --- /dev/null +++ b/scenarios/card_hold_update/executable.py @@ -0,0 +1,11 @@ +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +card_hold = balanced.CardHold.fetch('/card_holds/HL4iHX8OBNW7nVsu6MqyjnQ9') +card_hold.description = 'update this description' +card_hold.meta = { + 'holding.for': 'user1', + 'meaningful.key': 'some.value', +} +card_hold.save() \ No newline at end of file diff --git a/scenarios/card_hold_update/python.mako b/scenarios/card_hold_update/python.mako new file mode 100644 index 0000000..eb74e48 --- /dev/null +++ b/scenarios/card_hold_update/python.mako @@ -0,0 +1,17 @@ +% if mode == 'definition': +balanced.CardHold().save() +% elif mode == 'request': +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +card_hold = balanced.CardHold.fetch('/card_holds/HL4iHX8OBNW7nVsu6MqyjnQ9') +card_hold.description = 'update this description' +card_hold.meta = { + 'holding.for': 'user1', + 'meaningful.key': 'some.value', +} +card_hold.save() +% elif mode == 'response': +CardHold(status=u'succeeded', description=u'update this description', links={u'order': None, u'card': u'CC3vhL91rWtwtHcOBl0ITshG', u'debit': None}, amount=5000, created_at=u'2015-01-09T03:23:36.391121Z', updated_at=u'2015-01-09T03:23:42.106452Z', expires_at=u'2015-01-16T03:23:36.585031Z', failure_reason=None, currency=u'USD', transaction_number=u'HLI6T-T0A-HGZI', href=u'/card_holds/HL4iHX8OBNW7nVsu6MqyjnQ9', meta={u'holding.for': u'user1', u'meaningful.key': u'some.value'}, failure_reason_code=None, voided_at=None, id=u'HL4iHX8OBNW7nVsu6MqyjnQ9') +% endif \ No newline at end of file diff --git a/scenarios/card_hold_update/request.mako b/scenarios/card_hold_update/request.mako new file mode 100644 index 0000000..248fc91 --- /dev/null +++ b/scenarios/card_hold_update/request.mako @@ -0,0 +1,10 @@ +<%namespace file='/_main.mako' name='main'/> +<% main.python_boilerplate() %> + +card_hold = balanced.CardHold.fetch('${request['uri']}') +card_hold.description = '${request['payload']['description']}' +card_hold.meta = { + 'holding.for': 'user1', + 'meaningful.key': 'some.value', +} +card_hold.save() \ No newline at end of file diff --git a/scenarios/card_hold_void/definition.mako b/scenarios/card_hold_void/definition.mako new file mode 100644 index 0000000..725336e --- /dev/null +++ b/scenarios/card_hold_void/definition.mako @@ -0,0 +1 @@ +balanced.CardHold().cancel() \ No newline at end of file diff --git a/scenarios/card_hold_void/executable.py b/scenarios/card_hold_void/executable.py new file mode 100644 index 0000000..6e1f701 --- /dev/null +++ b/scenarios/card_hold_void/executable.py @@ -0,0 +1,6 @@ +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +card_hold = balanced.CardHold.fetch('/card_holds/HL4u4T2877PfgYwnbhD2XweV') +card_hold.cancel() \ No newline at end of file diff --git a/scenarios/card_hold_void/python.mako b/scenarios/card_hold_void/python.mako new file mode 100644 index 0000000..7a730b3 --- /dev/null +++ b/scenarios/card_hold_void/python.mako @@ -0,0 +1,12 @@ +% if mode == 'definition': +balanced.CardHold().cancel() +% elif mode == 'request': +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +card_hold = balanced.CardHold.fetch('/card_holds/HL4u4T2877PfgYwnbhD2XweV') +card_hold.cancel() +% elif mode == 'response': +CardHold(status=u'succeeded', description=u'Some descriptive text for the debit in the dashboard', links={u'order': None, u'card': u'CC3vhL91rWtwtHcOBl0ITshG', u'debit': None}, amount=5000, created_at=u'2015-01-09T03:23:46.500278Z', updated_at=u'2015-01-09T03:23:47.578727Z', expires_at=u'2015-01-16T03:23:46.699907Z', failure_reason=None, currency=u'USD', transaction_number=u'HL07I-F9N-OVPO', href=u'/card_holds/HL4u4T2877PfgYwnbhD2XweV', meta={}, failure_reason_code=None, voided_at=u'2015-01-09T03:23:47.257558Z', id=u'HL4u4T2877PfgYwnbhD2XweV') +% endif \ No newline at end of file diff --git a/scenarios/card_hold_void/request.mako b/scenarios/card_hold_void/request.mako new file mode 100644 index 0000000..3f09752 --- /dev/null +++ b/scenarios/card_hold_void/request.mako @@ -0,0 +1,5 @@ +<%namespace file='/_main.mako' name='main'/> +<% main.python_boilerplate() %> + +card_hold = balanced.CardHold.fetch('${request['uri']}') +card_hold.cancel() \ No newline at end of file diff --git a/scenarios/card_invalidate/definition.mako b/scenarios/card_invalidate/definition.mako deleted file mode 100644 index 638c1d2..0000000 --- a/scenarios/card_invalidate/definition.mako +++ /dev/null @@ -1 +0,0 @@ -balanced.Card.save() \ No newline at end of file diff --git a/scenarios/card_invalidate/executable.py b/scenarios/card_invalidate/executable.py deleted file mode 100644 index 00c430d..0000000 --- a/scenarios/card_invalidate/executable.py +++ /dev/null @@ -1,7 +0,0 @@ -import balanced - -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') - -card = balanced.Card.find('/v1/marketplaces/TEST-MP52IlCmywk6hGbgS75QSlN/cards/CC1i5vMNFo69BmOfBWcx5iZM') -card.is_valid = False -card.save() \ No newline at end of file diff --git a/scenarios/card_invalidate/python.mako b/scenarios/card_invalidate/python.mako deleted file mode 100644 index dadd61e..0000000 --- a/scenarios/card_invalidate/python.mako +++ /dev/null @@ -1,11 +0,0 @@ -% if mode == 'definition': -balanced.Card.save() -% else: -import balanced - -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') - -card = balanced.Card.find('/v1/marketplaces/TEST-MP52IlCmywk6hGbgS75QSlN/cards/CC1i5vMNFo69BmOfBWcx5iZM') -card.is_valid = False -card.save() -% endif \ No newline at end of file diff --git a/scenarios/card_invalidate/request.mako b/scenarios/card_invalidate/request.mako deleted file mode 100644 index df63314..0000000 --- a/scenarios/card_invalidate/request.mako +++ /dev/null @@ -1,6 +0,0 @@ -<%namespace file='/_main.mako' name='main'/> -<% main.python_boilerplate() %> - -card = balanced.Card.find('${request['uri']}') -card.is_valid = False -card.save() \ No newline at end of file diff --git a/scenarios/card_list/definition.mako b/scenarios/card_list/definition.mako index 967ae52..d5c620b 100644 --- a/scenarios/card_list/definition.mako +++ b/scenarios/card_list/definition.mako @@ -1 +1 @@ -balanced.Card.query() \ No newline at end of file +balanced.Card.query diff --git a/scenarios/card_list/executable.py b/scenarios/card_list/executable.py index a43f83f..abc2c37 100644 --- a/scenarios/card_list/executable.py +++ b/scenarios/card_list/executable.py @@ -1,5 +1,5 @@ import balanced -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') -cards = balanced.Card.query.all(); \ No newline at end of file +cards = balanced.Card.query \ No newline at end of file diff --git a/scenarios/card_list/python.mako b/scenarios/card_list/python.mako index 31d72e0..a0411a3 100644 --- a/scenarios/card_list/python.mako +++ b/scenarios/card_list/python.mako @@ -1,9 +1,12 @@ % if mode == 'definition': -balanced.Card.query() -% else: +balanced.Card.query + +% elif mode == 'request': import balanced -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +cards = balanced.Card.query +% elif mode == 'response': -cards = balanced.Card.query.all(); % endif \ No newline at end of file diff --git a/scenarios/card_list/request.mako b/scenarios/card_list/request.mako index f8fea8d..2d54dd7 100644 --- a/scenarios/card_list/request.mako +++ b/scenarios/card_list/request.mako @@ -1,4 +1,4 @@ <%namespace file='/_main.mako' name='main'/> <% main.python_boilerplate() %> -cards = balanced.Card.query.all(); \ No newline at end of file +cards = balanced.Card.query \ No newline at end of file diff --git a/scenarios/card_show/definition.mako b/scenarios/card_show/definition.mako index e761ee6..42577f2 100644 --- a/scenarios/card_show/definition.mako +++ b/scenarios/card_show/definition.mako @@ -1 +1 @@ -balanced.Card.find \ No newline at end of file +balanced.Card.fetch() \ No newline at end of file diff --git a/scenarios/card_show/executable.py b/scenarios/card_show/executable.py index 1f8d162..5e6f1cc 100644 --- a/scenarios/card_show/executable.py +++ b/scenarios/card_show/executable.py @@ -1,5 +1,5 @@ import balanced -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') -card = balanced.Card.find('/v1/marketplaces/TEST-MP52IlCmywk6hGbgS75QSlN/cards/CC1i5vMNFo69BmOfBWcx5iZM') \ No newline at end of file +card = balanced.Card.fetch('/cards/CC4zyuNpxY0A0eAf87SeULCR') \ No newline at end of file diff --git a/scenarios/card_show/python.mako b/scenarios/card_show/python.mako index e86f3b9..24fede7 100644 --- a/scenarios/card_show/python.mako +++ b/scenarios/card_show/python.mako @@ -1,9 +1,11 @@ % if mode == 'definition': -balanced.Card.find -% else: +balanced.Card.fetch() +% elif mode == 'request': import balanced -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') -card = balanced.Card.find('/v1/marketplaces/TEST-MP52IlCmywk6hGbgS75QSlN/cards/CC1i5vMNFo69BmOfBWcx5iZM') +card = balanced.Card.fetch('/cards/CC4zyuNpxY0A0eAf87SeULCR') +% elif mode == 'response': +Card(links={u'customer': None}, cvv_result=u'Match', number=u'xxxxxxxxxxxx5100', expiration_month=12, href=u'/cards/CC4zyuNpxY0A0eAf87SeULCR', type=u'credit', id=u'CC4zyuNpxY0A0eAf87SeULCR', category=u'other', is_verified=True, cvv_match=u'yes', bank_name=u'BANK OF HAWAII', avs_street_match=None, brand=u'MasterCard', updated_at=u'2015-01-09T03:23:51.373359Z', fingerprint=u'fc4ccd5de54f42a5e75f76fbfde60948440c7a382ee7d21b2bc509ab9cfed788', can_debit=True, name=None, expiration_year=2020, cvv=u'xxx', avs_postal_match=None, avs_result=None, can_credit=False, meta={}, created_at=u'2015-01-09T03:23:51.373358Z', address={u'city': None, u'line2': None, u'line1': None, u'state': None, u'postal_code': None, u'country_code': None}) % endif \ No newline at end of file diff --git a/scenarios/card_show/request.mako b/scenarios/card_show/request.mako index 3821f1f..0871aec 100644 --- a/scenarios/card_show/request.mako +++ b/scenarios/card_show/request.mako @@ -1,4 +1,4 @@ <%namespace file='/_main.mako' name='main'/> <% main.python_boilerplate() %> -card = balanced.Card.find('${request['uri']}') \ No newline at end of file +card = balanced.Card.fetch('${request['uri']}') diff --git a/scenarios/card_update/definition.mako b/scenarios/card_update/definition.mako index 638c1d2..1235831 100644 --- a/scenarios/card_update/definition.mako +++ b/scenarios/card_update/definition.mako @@ -1 +1 @@ -balanced.Card.save() \ No newline at end of file +balanced.Card().save() \ No newline at end of file diff --git a/scenarios/card_update/executable.py b/scenarios/card_update/executable.py index 0908992..be60c95 100644 --- a/scenarios/card_update/executable.py +++ b/scenarios/card_update/executable.py @@ -1,11 +1,11 @@ import balanced -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') -card = balanced.Card.find('/v1/marketplaces/TEST-MP52IlCmywk6hGbgS75QSlN/cards/CC1i5vMNFo69BmOfBWcx5iZM') +card = balanced.Card.fetch('/cards/CC4zyuNpxY0A0eAf87SeULCR') card.meta = { 'twitter.id': '1234987650', 'facebook.user_id': '0192837465', - 'my-own-customer-id': '12345', + 'my-own-customer-id': '12345' } card.save() \ No newline at end of file diff --git a/scenarios/card_update/python.mako b/scenarios/card_update/python.mako index 1f6e2c8..bbd6122 100644 --- a/scenarios/card_update/python.mako +++ b/scenarios/card_update/python.mako @@ -1,15 +1,17 @@ % if mode == 'definition': -balanced.Card.save() -% else: +balanced.Card().save() +% elif mode == 'request': import balanced -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') -card = balanced.Card.find('/v1/marketplaces/TEST-MP52IlCmywk6hGbgS75QSlN/cards/CC1i5vMNFo69BmOfBWcx5iZM') +card = balanced.Card.fetch('/cards/CC4zyuNpxY0A0eAf87SeULCR') card.meta = { 'twitter.id': '1234987650', 'facebook.user_id': '0192837465', - 'my-own-customer-id': '12345', + 'my-own-customer-id': '12345' } card.save() +% elif mode == 'response': +Card(links={u'customer': None}, cvv_result=u'Match', number=u'xxxxxxxxxxxx5100', expiration_month=12, href=u'/cards/CC4zyuNpxY0A0eAf87SeULCR', type=u'credit', id=u'CC4zyuNpxY0A0eAf87SeULCR', category=u'other', is_verified=True, cvv_match=u'yes', bank_name=u'BANK OF HAWAII', avs_street_match=None, brand=u'MasterCard', updated_at=u'2015-01-09T03:23:56.070888Z', fingerprint=u'fc4ccd5de54f42a5e75f76fbfde60948440c7a382ee7d21b2bc509ab9cfed788', can_debit=True, name=None, expiration_year=2020, cvv=u'xxx', avs_postal_match=None, avs_result=None, can_credit=False, meta={u'twitter.id': u'1234987650', u'facebook.user_id': u'0192837465', u'my-own-customer-id': u'12345'}, created_at=u'2015-01-09T03:23:51.373358Z', address={u'city': None, u'line2': None, u'line1': None, u'state': None, u'postal_code': None, u'country_code': None}) % endif \ No newline at end of file diff --git a/scenarios/card_update/request.mako b/scenarios/card_update/request.mako index 788f839..2478ff1 100644 --- a/scenarios/card_update/request.mako +++ b/scenarios/card_update/request.mako @@ -1,10 +1,10 @@ <%namespace file='/_main.mako' name='main'/> <% main.python_boilerplate() %> -card = balanced.Card.find('${request['uri']}') +card = balanced.Card.fetch('${request['uri']}') card.meta = { 'twitter.id': '1234987650', 'facebook.user_id': '0192837465', - 'my-own-customer-id': '12345', + 'my-own-customer-id': '12345' } card.save() \ No newline at end of file diff --git a/scenarios/credit_account_list/definition.mako b/scenarios/credit_account_list/definition.mako deleted file mode 100644 index ff01458..0000000 --- a/scenarios/credit_account_list/definition.mako +++ /dev/null @@ -1 +0,0 @@ -balanced.Account.credits \ No newline at end of file diff --git a/scenarios/credit_account_list/python.mako b/scenarios/credit_account_list/python.mako deleted file mode 100644 index c80e1b6..0000000 --- a/scenarios/credit_account_list/python.mako +++ /dev/null @@ -1,5 +0,0 @@ -% if mode == 'definition': -balanced.Account.credits -% else: - -% endif \ No newline at end of file diff --git a/scenarios/credit_account_merchant_create/python.mako b/scenarios/credit_account_merchant_create/python.mako deleted file mode 100644 index faed00d..0000000 --- a/scenarios/credit_account_merchant_create/python.mako +++ /dev/null @@ -1,5 +0,0 @@ -% if mode == 'definition': -balanced.Account.credit() -% else: - -% endif \ No newline at end of file diff --git a/scenarios/credit_bank_account_list/definition.mako b/scenarios/credit_bank_account_list/definition.mako deleted file mode 100644 index 9ea8870..0000000 --- a/scenarios/credit_bank_account_list/definition.mako +++ /dev/null @@ -1 +0,0 @@ -balanced.BankAccount.credits \ No newline at end of file diff --git a/scenarios/credit_bank_account_list/executable.py b/scenarios/credit_bank_account_list/executable.py deleted file mode 100644 index 727abfb..0000000 --- a/scenarios/credit_bank_account_list/executable.py +++ /dev/null @@ -1,6 +0,0 @@ -import balanced - -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') - -bank_account = balanced.BankAccount.find('/v1/bank_accounts/BAYBae39daGLlFYzJtGPTvw') -credits = bank_account.credits.all() \ No newline at end of file diff --git a/scenarios/credit_bank_account_list/python.mako b/scenarios/credit_bank_account_list/python.mako deleted file mode 100644 index 889e0c1..0000000 --- a/scenarios/credit_bank_account_list/python.mako +++ /dev/null @@ -1,10 +0,0 @@ -% if mode == 'definition': -balanced.BankAccount.credits -% else: -import balanced - -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') - -bank_account = balanced.BankAccount.find('/v1/bank_accounts/BAYBae39daGLlFYzJtGPTvw') -credits = bank_account.credits.all() -% endif \ No newline at end of file diff --git a/scenarios/credit_bank_account_list/request.mako b/scenarios/credit_bank_account_list/request.mako deleted file mode 100644 index b2a213f..0000000 --- a/scenarios/credit_bank_account_list/request.mako +++ /dev/null @@ -1,5 +0,0 @@ -<%namespace file='/_main.mako' name='main'/> -<% main.python_boilerplate() %> - -bank_account = balanced.BankAccount.find('${request['uri']}') -credits = bank_account.credits.all() \ No newline at end of file diff --git a/scenarios/credit_create_existing_bank_account/definition.mako b/scenarios/credit_create_existing_bank_account/definition.mako deleted file mode 100644 index ee4199a..0000000 --- a/scenarios/credit_create_existing_bank_account/definition.mako +++ /dev/null @@ -1 +0,0 @@ -balanced.BankAccount.credit() \ No newline at end of file diff --git a/scenarios/credit_create_existing_bank_account/executable.py b/scenarios/credit_create_existing_bank_account/executable.py deleted file mode 100644 index c117eb1..0000000 --- a/scenarios/credit_create_existing_bank_account/executable.py +++ /dev/null @@ -1,6 +0,0 @@ -import balanced - -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') - -bank_account = balanced.BankAccount.find('/v1/bank_accounts/BAYBae39daGLlFYzJtGPTvw') -credit = bank_account.credit(amount=10000) \ No newline at end of file diff --git a/scenarios/credit_create_existing_bank_account/python.mako b/scenarios/credit_create_existing_bank_account/python.mako deleted file mode 100644 index 2b161c9..0000000 --- a/scenarios/credit_create_existing_bank_account/python.mako +++ /dev/null @@ -1,10 +0,0 @@ -% if mode == 'definition': -balanced.BankAccount.credit() -% else: -import balanced - -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') - -bank_account = balanced.BankAccount.find('/v1/bank_accounts/BAYBae39daGLlFYzJtGPTvw') -credit = bank_account.credit(amount=10000) -% endif \ No newline at end of file diff --git a/scenarios/credit_create_existing_bank_account/request.mako b/scenarios/credit_create_existing_bank_account/request.mako deleted file mode 100644 index 8968dc8..0000000 --- a/scenarios/credit_create_existing_bank_account/request.mako +++ /dev/null @@ -1,5 +0,0 @@ -<%namespace file='/_main.mako' name='main'/> -<% main.python_boilerplate() %> - -bank_account = balanced.BankAccount.find('${request['uri']}') -credit = bank_account.credit(amount=${request['payload']['amount']}) \ No newline at end of file diff --git a/scenarios/credit_create_new_bank_account/definition.mako b/scenarios/credit_create_new_bank_account/definition.mako deleted file mode 100644 index 67abe6c..0000000 --- a/scenarios/credit_create_new_bank_account/definition.mako +++ /dev/null @@ -1 +0,0 @@ -balanced.Credit.save() \ No newline at end of file diff --git a/scenarios/credit_create_new_bank_account/executable.py b/scenarios/credit_create_new_bank_account/executable.py deleted file mode 100644 index 51507e8..0000000 --- a/scenarios/credit_create_new_bank_account/executable.py +++ /dev/null @@ -1,15 +0,0 @@ -import balanced - -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') - -bank_account_info = { - "routing_number": "121000358", - "type": "checking", - "account_number": "9900000001", - "name": "Johann Bernoulli" -} - -credit = balanced.Credit( - amount=10000, - bank_account=bank_account_info -).save() \ No newline at end of file diff --git a/scenarios/credit_create_new_bank_account/python.mako b/scenarios/credit_create_new_bank_account/python.mako deleted file mode 100644 index 0a73abb..0000000 --- a/scenarios/credit_create_new_bank_account/python.mako +++ /dev/null @@ -1,19 +0,0 @@ -% if mode == 'definition': -balanced.Credit.save() -% else: -import balanced - -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') - -bank_account_info = { - "routing_number": "121000358", - "type": "checking", - "account_number": "9900000001", - "name": "Johann Bernoulli" -} - -credit = balanced.Credit( - amount=10000, - bank_account=bank_account_info -).save() -% endif \ No newline at end of file diff --git a/scenarios/credit_create_new_bank_account/request.mako b/scenarios/credit_create_new_bank_account/request.mako deleted file mode 100644 index 2b4ee0e..0000000 --- a/scenarios/credit_create_new_bank_account/request.mako +++ /dev/null @@ -1,10 +0,0 @@ -<%namespace file='/_main.mako' name='main'/> -<% main.python_boilerplate() %> -<% import json %> -bank_account_info = \ -${json.dumps(request['payload']['bank_account'], indent=4)} - -credit = balanced.Credit( - amount=${request['payload']['amount']}, - bank_account=bank_account_info -).save() \ No newline at end of file diff --git a/scenarios/credit_customer_list/definition.mako b/scenarios/credit_customer_list/definition.mako deleted file mode 100644 index ea1513c..0000000 --- a/scenarios/credit_customer_list/definition.mako +++ /dev/null @@ -1 +0,0 @@ -balanced.Customer.credits \ No newline at end of file diff --git a/scenarios/credit_customer_list/executable.py b/scenarios/credit_customer_list/executable.py deleted file mode 100644 index bbe2655..0000000 --- a/scenarios/credit_customer_list/executable.py +++ /dev/null @@ -1,6 +0,0 @@ -import balanced - -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') - -customer = balanced.Customer.find('/v1/customers/CUyABeNYx8vHAaP4KRsd1j4') -credits = customer.credits.all() \ No newline at end of file diff --git a/scenarios/credit_customer_list/python.mako b/scenarios/credit_customer_list/python.mako deleted file mode 100644 index e5b046c..0000000 --- a/scenarios/credit_customer_list/python.mako +++ /dev/null @@ -1,10 +0,0 @@ -% if mode == 'definition': -balanced.Customer.credits -% else: -import balanced - -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') - -customer = balanced.Customer.find('/v1/customers/CUyABeNYx8vHAaP4KRsd1j4') -credits = customer.credits.all() -% endif \ No newline at end of file diff --git a/scenarios/credit_customer_list/request.mako b/scenarios/credit_customer_list/request.mako deleted file mode 100644 index d4f50d9..0000000 --- a/scenarios/credit_customer_list/request.mako +++ /dev/null @@ -1,5 +0,0 @@ -<%namespace file='/_main.mako' name='main'/> -<% main.python_boilerplate() %> - -customer = balanced.Customer.find('${request['customer_uri']}') -credits = customer.credits.all() \ No newline at end of file diff --git a/scenarios/credit_failed_state/definition.mako b/scenarios/credit_failed_state/definition.mako deleted file mode 100644 index 67abe6c..0000000 --- a/scenarios/credit_failed_state/definition.mako +++ /dev/null @@ -1 +0,0 @@ -balanced.Credit.save() \ No newline at end of file diff --git a/scenarios/credit_failed_state/executable.py b/scenarios/credit_failed_state/executable.py deleted file mode 100644 index 1a8ba56..0000000 --- a/scenarios/credit_failed_state/executable.py +++ /dev/null @@ -1,15 +0,0 @@ -import balanced - -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') - -bank_account_info = { - "routing_number": "121000358", - "type": "checking", - "account_number": "9900000004", - "name": "Johann Bernoulli" -} - -credit = balanced.Credit( - amount=10000, - bank_account=bank_account_info -).save() \ No newline at end of file diff --git a/scenarios/credit_failed_state/python.mako b/scenarios/credit_failed_state/python.mako deleted file mode 100644 index f78f364..0000000 --- a/scenarios/credit_failed_state/python.mako +++ /dev/null @@ -1,19 +0,0 @@ -% if mode == 'definition': -balanced.Credit.save() -% else: -import balanced - -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') - -bank_account_info = { - "routing_number": "121000358", - "type": "checking", - "account_number": "9900000004", - "name": "Johann Bernoulli" -} - -credit = balanced.Credit( - amount=10000, - bank_account=bank_account_info -).save() -% endif \ No newline at end of file diff --git a/scenarios/credit_failed_state/request.mako b/scenarios/credit_failed_state/request.mako deleted file mode 100644 index 2b4ee0e..0000000 --- a/scenarios/credit_failed_state/request.mako +++ /dev/null @@ -1,10 +0,0 @@ -<%namespace file='/_main.mako' name='main'/> -<% main.python_boilerplate() %> -<% import json %> -bank_account_info = \ -${json.dumps(request['payload']['bank_account'], indent=4)} - -credit = balanced.Credit( - amount=${request['payload']['amount']}, - bank_account=bank_account_info -).save() \ No newline at end of file diff --git a/scenarios/credit_list/definition.mako b/scenarios/credit_list/definition.mako index 25d1921..c04e473 100644 --- a/scenarios/credit_list/definition.mako +++ b/scenarios/credit_list/definition.mako @@ -1 +1 @@ -balanced.Credit.query \ No newline at end of file +balanced.Credit.query diff --git a/scenarios/credit_list/executable.py b/scenarios/credit_list/executable.py index 66318fe..673ce94 100644 --- a/scenarios/credit_list/executable.py +++ b/scenarios/credit_list/executable.py @@ -1,5 +1,5 @@ import balanced -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') -credits = balanced.Credit.query.all() \ No newline at end of file +credits = balanced.Credit.query \ No newline at end of file diff --git a/scenarios/credit_list/python.mako b/scenarios/credit_list/python.mako index d75dc7f..c58eafd 100644 --- a/scenarios/credit_list/python.mako +++ b/scenarios/credit_list/python.mako @@ -1,9 +1,12 @@ % if mode == 'definition': balanced.Credit.query -% else: + +% elif mode == 'request': import balanced -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +credits = balanced.Credit.query +% elif mode == 'response': -credits = balanced.Credit.query.all() % endif \ No newline at end of file diff --git a/scenarios/credit_list/request.mako b/scenarios/credit_list/request.mako index 55eb938..d980ca6 100644 --- a/scenarios/credit_list/request.mako +++ b/scenarios/credit_list/request.mako @@ -1,4 +1,4 @@ <%namespace file='/_main.mako' name='main'/> <% main.python_boilerplate() %> -credits = balanced.Credit.query.all() \ No newline at end of file +credits = balanced.Credit.query \ No newline at end of file diff --git a/scenarios/credit_list_bank_account/definition.mako b/scenarios/credit_list_bank_account/definition.mako new file mode 100644 index 0000000..8dd38f7 --- /dev/null +++ b/scenarios/credit_list_bank_account/definition.mako @@ -0,0 +1 @@ +balanced.BankAccount.credits() \ No newline at end of file diff --git a/scenarios/credit_list_bank_account/executable.py b/scenarios/credit_list_bank_account/executable.py new file mode 100644 index 0000000..e57530c --- /dev/null +++ b/scenarios/credit_list_bank_account/executable.py @@ -0,0 +1,6 @@ +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +bank_account = balanced.BankAccount.fetch('/bank_accounts/BA45anEaEr8g0lOhzhcE9VAN') +credits = bank_account.credits \ No newline at end of file diff --git a/scenarios/credit_list_bank_account/python.mako b/scenarios/credit_list_bank_account/python.mako new file mode 100644 index 0000000..df7dafa --- /dev/null +++ b/scenarios/credit_list_bank_account/python.mako @@ -0,0 +1,12 @@ +% if mode == 'definition': +balanced.BankAccount.credits() +% elif mode == 'request': +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +bank_account = balanced.BankAccount.fetch('/bank_accounts/BA45anEaEr8g0lOhzhcE9VAN') +credits = bank_account.credits +% elif mode == 'response': + +% endif \ No newline at end of file diff --git a/scenarios/credit_list_bank_account/request.mako b/scenarios/credit_list_bank_account/request.mako new file mode 100644 index 0000000..53542ea --- /dev/null +++ b/scenarios/credit_list_bank_account/request.mako @@ -0,0 +1,5 @@ +<%namespace file='/_main.mako' name='main'/> +<% main.python_boilerplate() %> + +bank_account = balanced.BankAccount.fetch('${request['bank_account_href']}') +credits = bank_account.credits \ No newline at end of file diff --git a/scenarios/credit_order/definition.mako b/scenarios/credit_order/definition.mako new file mode 100644 index 0000000..0f57856 --- /dev/null +++ b/scenarios/credit_order/definition.mako @@ -0,0 +1 @@ +balanced.Order().credit_to() \ No newline at end of file diff --git a/scenarios/credit_order/executable.py b/scenarios/credit_order/executable.py new file mode 100644 index 0000000..eb07a69 --- /dev/null +++ b/scenarios/credit_order/executable.py @@ -0,0 +1,10 @@ +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +order = balanced.Order.fetch('/orders/OR3vURGwVtqDnnkRS9fgH41G') +bank_account = balanced.BankAccount.fetch('/bank_accounts/BA45anEaEr8g0lOhzhcE9VAN/credits') +order.credit_to( + amount=5000, + destination=bank_account +) \ No newline at end of file diff --git a/scenarios/credit_order/python.mako b/scenarios/credit_order/python.mako new file mode 100644 index 0000000..bf5dc4c --- /dev/null +++ b/scenarios/credit_order/python.mako @@ -0,0 +1,16 @@ +% if mode == 'definition': +balanced.Order().credit_to() +% elif mode == 'request': +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +order = balanced.Order.fetch('/orders/OR3vURGwVtqDnnkRS9fgH41G') +bank_account = balanced.BankAccount.fetch('/bank_accounts/BA45anEaEr8g0lOhzhcE9VAN/credits') +order.credit_to( + amount=5000, + destination=bank_account +) +% elif mode == 'response': + +% endif \ No newline at end of file diff --git a/scenarios/credit_order/request.mako b/scenarios/credit_order/request.mako new file mode 100644 index 0000000..c35079c --- /dev/null +++ b/scenarios/credit_order/request.mako @@ -0,0 +1,9 @@ +<%namespace file='/_main.mako' name='main'/> +<% main.python_boilerplate() %> + +order = balanced.Order.fetch('${request['order_href']}') +bank_account = balanced.BankAccount.fetch('${request['bank_account_href']}') +order.credit_to( + amount=${payload['amount']}, + destination=bank_account +) \ No newline at end of file diff --git a/scenarios/credit_paid_state/definition.mako b/scenarios/credit_paid_state/definition.mako deleted file mode 100644 index 67abe6c..0000000 --- a/scenarios/credit_paid_state/definition.mako +++ /dev/null @@ -1 +0,0 @@ -balanced.Credit.save() \ No newline at end of file diff --git a/scenarios/credit_paid_state/executable.py b/scenarios/credit_paid_state/executable.py deleted file mode 100644 index ab888d6..0000000 --- a/scenarios/credit_paid_state/executable.py +++ /dev/null @@ -1,15 +0,0 @@ -import balanced - -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') - -bank_account_info = { - "routing_number": "121000358", - "type": "checking", - "account_number": "9900000003", - "name": "Johann Bernoulli" -} - -credit = balanced.Credit( - amount=10000, - bank_account=bank_account_info -).save() \ No newline at end of file diff --git a/scenarios/credit_paid_state/python.mako b/scenarios/credit_paid_state/python.mako deleted file mode 100644 index 71fb35a..0000000 --- a/scenarios/credit_paid_state/python.mako +++ /dev/null @@ -1,19 +0,0 @@ -% if mode == 'definition': -balanced.Credit.save() -% else: -import balanced - -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') - -bank_account_info = { - "routing_number": "121000358", - "type": "checking", - "account_number": "9900000003", - "name": "Johann Bernoulli" -} - -credit = balanced.Credit( - amount=10000, - bank_account=bank_account_info -).save() -% endif \ No newline at end of file diff --git a/scenarios/credit_paid_state/request.mako b/scenarios/credit_paid_state/request.mako deleted file mode 100644 index 0344b43..0000000 --- a/scenarios/credit_paid_state/request.mako +++ /dev/null @@ -1,10 +0,0 @@ -<%namespace file='/_main.mako' name='main'/> -<% main.python_boilerplate() %> -<% import json %> -bank_account_info = \ -${json.dumps(request['payload']['bank_account'], indent=4)} - -credit = balanced.Credit( - amount=${request['payload']['amount']}, - bank_account=bank_account_info -).save() diff --git a/scenarios/credit_pending_state/definition.mako b/scenarios/credit_pending_state/definition.mako deleted file mode 100644 index 67abe6c..0000000 --- a/scenarios/credit_pending_state/definition.mako +++ /dev/null @@ -1 +0,0 @@ -balanced.Credit.save() \ No newline at end of file diff --git a/scenarios/credit_pending_state/executable.py b/scenarios/credit_pending_state/executable.py deleted file mode 100644 index e74a41c..0000000 --- a/scenarios/credit_pending_state/executable.py +++ /dev/null @@ -1,15 +0,0 @@ -import balanced - -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') - -bank_account_info = { - "routing_number": "121000358", - "type": "checking", - "account_number": "9900000000", - "name": "Johann Bernoulli" -} - -credit = balanced.Credit( - amount=10000, - bank_account=bank_account_info -).save() \ No newline at end of file diff --git a/scenarios/credit_pending_state/python.mako b/scenarios/credit_pending_state/python.mako deleted file mode 100644 index 797ddb7..0000000 --- a/scenarios/credit_pending_state/python.mako +++ /dev/null @@ -1,19 +0,0 @@ -% if mode == 'definition': -balanced.Credit.save() -% else: -import balanced - -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') - -bank_account_info = { - "routing_number": "121000358", - "type": "checking", - "account_number": "9900000000", - "name": "Johann Bernoulli" -} - -credit = balanced.Credit( - amount=10000, - bank_account=bank_account_info -).save() -% endif \ No newline at end of file diff --git a/scenarios/credit_pending_state/request.mako b/scenarios/credit_pending_state/request.mako deleted file mode 100644 index 2b4ee0e..0000000 --- a/scenarios/credit_pending_state/request.mako +++ /dev/null @@ -1,10 +0,0 @@ -<%namespace file='/_main.mako' name='main'/> -<% main.python_boilerplate() %> -<% import json %> -bank_account_info = \ -${json.dumps(request['payload']['bank_account'], indent=4)} - -credit = balanced.Credit( - amount=${request['payload']['amount']}, - bank_account=bank_account_info -).save() \ No newline at end of file diff --git a/scenarios/credit_show/definition.mako b/scenarios/credit_show/definition.mako index 816c212..9a3d2e7 100644 --- a/scenarios/credit_show/definition.mako +++ b/scenarios/credit_show/definition.mako @@ -1 +1 @@ -balanced.Credit.find() \ No newline at end of file +balanced.Credit.fetch() diff --git a/scenarios/credit_show/executable.py b/scenarios/credit_show/executable.py index 73d37e0..0a7f6af 100644 --- a/scenarios/credit_show/executable.py +++ b/scenarios/credit_show/executable.py @@ -1,5 +1,5 @@ import balanced -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') -credit = balanced.Credit.find('/v1/marketplaces/TEST-MP52IlCmywk6hGbgS75QSlN/credits/CR1xunmvDnFBo3fynM1KnuUm') \ No newline at end of file +credit = balanced.Credit.fetch('/credits/CR4RdgCoOqYhr4sjPdcDjf3T') \ No newline at end of file diff --git a/scenarios/credit_show/python.mako b/scenarios/credit_show/python.mako index 4b033ca..e3ee829 100644 --- a/scenarios/credit_show/python.mako +++ b/scenarios/credit_show/python.mako @@ -1,9 +1,12 @@ % if mode == 'definition': -balanced.Credit.find() -% else: +balanced.Credit.fetch() + +% elif mode == 'request': import balanced -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') -credit = balanced.Credit.find('/v1/marketplaces/TEST-MP52IlCmywk6hGbgS75QSlN/credits/CR1xunmvDnFBo3fynM1KnuUm') +credit = balanced.Credit.fetch('/credits/CR4RdgCoOqYhr4sjPdcDjf3T') +% elif mode == 'response': +Credit(status=u'pending', description=None, links={u'customer': u'CU3o1ZAd8Gtxz6ZTIFK9YmsM', u'destination': u'BA45anEaEr8g0lOhzhcE9VAN', u'order': None}, amount=5000, created_at=u'2015-01-09T03:24:07.078171Z', updated_at=u'2015-01-09T03:24:07.425391Z', failure_reason=None, currency=u'USD', transaction_number=u'CRGY7-P5M-OXHO', href=u'/credits/CR4RdgCoOqYhr4sjPdcDjf3T', meta={}, failure_reason_code=None, appears_on_statement_as=u'example.com', id=u'CR4RdgCoOqYhr4sjPdcDjf3T') % endif \ No newline at end of file diff --git a/scenarios/credit_show/request.mako b/scenarios/credit_show/request.mako index aeb0587..609801a 100644 --- a/scenarios/credit_show/request.mako +++ b/scenarios/credit_show/request.mako @@ -1,4 +1,4 @@ <%namespace file='/_main.mako' name='main'/> <% main.python_boilerplate() %> -credit = balanced.Credit.find('${request['uri']}') \ No newline at end of file +credit = balanced.Credit.fetch('${request['uri']}') \ No newline at end of file diff --git a/scenarios/credit_update/definition.mako b/scenarios/credit_update/definition.mako new file mode 100644 index 0000000..34fa36d --- /dev/null +++ b/scenarios/credit_update/definition.mako @@ -0,0 +1 @@ +balanced.Credit().save() \ No newline at end of file diff --git a/scenarios/credit_update/executable.py b/scenarios/credit_update/executable.py new file mode 100644 index 0000000..b51240c --- /dev/null +++ b/scenarios/credit_update/executable.py @@ -0,0 +1,11 @@ +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +credit = balanced.Credit.fetch('/credits/CR4RdgCoOqYhr4sjPdcDjf3T') +credit.meta = { + 'twitter.id': '1234987650', + 'facebook.user_id': '0192837465', + 'my-own-customer-id': '12345' +} +credit.save() \ No newline at end of file diff --git a/scenarios/credit_update/python.mako b/scenarios/credit_update/python.mako new file mode 100644 index 0000000..465064c --- /dev/null +++ b/scenarios/credit_update/python.mako @@ -0,0 +1,17 @@ +% if mode == 'definition': +balanced.Credit().save() +% elif mode == 'request': +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +credit = balanced.Credit.fetch('/credits/CR4RdgCoOqYhr4sjPdcDjf3T') +credit.meta = { + 'twitter.id': '1234987650', + 'facebook.user_id': '0192837465', + 'my-own-customer-id': '12345' +} +credit.save() +% elif mode == 'response': +Credit(status=u'pending', description=u'New description for credit', links={u'customer': u'CU3o1ZAd8Gtxz6ZTIFK9YmsM', u'destination': u'BA45anEaEr8g0lOhzhcE9VAN', u'order': None}, amount=5000, created_at=u'2015-01-09T03:24:07.078171Z', updated_at=u'2015-01-09T03:24:15.880088Z', failure_reason=None, currency=u'USD', transaction_number=u'CRGY7-P5M-OXHO', href=u'/credits/CR4RdgCoOqYhr4sjPdcDjf3T', meta={u'facebook.id': u'1234567890', u'anykey': u'valuegoeshere'}, failure_reason_code=None, appears_on_statement_as=u'example.com', id=u'CR4RdgCoOqYhr4sjPdcDjf3T') +% endif \ No newline at end of file diff --git a/scenarios/credit_update/request.mako b/scenarios/credit_update/request.mako new file mode 100644 index 0000000..c4de179 --- /dev/null +++ b/scenarios/credit_update/request.mako @@ -0,0 +1,10 @@ +<%namespace file='/_main.mako' name='main'/> +<% main.python_boilerplate() %> + +credit = balanced.Credit.fetch('${request['uri']}') +credit.meta = { + 'twitter.id': '1234987650', + 'facebook.user_id': '0192837465', + 'my-own-customer-id': '12345' +} +credit.save() \ No newline at end of file diff --git a/scenarios/customer_add_bank_account/definition.mako b/scenarios/customer_add_bank_account/definition.mako deleted file mode 100644 index fbba3a2..0000000 --- a/scenarios/customer_add_bank_account/definition.mako +++ /dev/null @@ -1 +0,0 @@ -balanced.Customer.add_bank_account \ No newline at end of file diff --git a/scenarios/customer_add_bank_account/executable.py b/scenarios/customer_add_bank_account/executable.py deleted file mode 100644 index b078188..0000000 --- a/scenarios/customer_add_bank_account/executable.py +++ /dev/null @@ -1,6 +0,0 @@ -import balanced - -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') - -customer = balanced.Customer.find('/v1/customers/CU22xHvLbgGKfzamLW8IZJsr') -customer.add_bank_account('/v1/bank_accounts/BA24Zc2jo1moflunJDxKrCrB') \ No newline at end of file diff --git a/scenarios/customer_add_bank_account/python.mako b/scenarios/customer_add_bank_account/python.mako deleted file mode 100644 index 8aaa3e1..0000000 --- a/scenarios/customer_add_bank_account/python.mako +++ /dev/null @@ -1,10 +0,0 @@ -% if mode == 'definition': -balanced.Customer.add_bank_account -% else: -import balanced - -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') - -customer = balanced.Customer.find('/v1/customers/CU22xHvLbgGKfzamLW8IZJsr') -customer.add_bank_account('/v1/bank_accounts/BA24Zc2jo1moflunJDxKrCrB') -% endif \ No newline at end of file diff --git a/scenarios/customer_add_bank_account/request.mako b/scenarios/customer_add_bank_account/request.mako deleted file mode 100644 index 4069b5b..0000000 --- a/scenarios/customer_add_bank_account/request.mako +++ /dev/null @@ -1,5 +0,0 @@ -<%namespace file='/_main.mako' name='main'/> -<% main.python_boilerplate() %> - -customer = balanced.Customer.find('${request['uri']}') -customer.add_bank_account('${request['payload']['bank_account_uri']}') \ No newline at end of file diff --git a/scenarios/customer_add_card/definition.mako b/scenarios/customer_add_card/definition.mako deleted file mode 100644 index 69aafcb..0000000 --- a/scenarios/customer_add_card/definition.mako +++ /dev/null @@ -1 +0,0 @@ -balanced.Customer.add_card \ No newline at end of file diff --git a/scenarios/customer_add_card/executable.py b/scenarios/customer_add_card/executable.py deleted file mode 100644 index 3605af4..0000000 --- a/scenarios/customer_add_card/executable.py +++ /dev/null @@ -1,6 +0,0 @@ -import balanced - -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') - -customer = balanced.Customer.find('/v1/customers/CU3yqhHviPZ4ZbpHMcaa3SKH') -customer.add_card('/v1/marketplaces/TEST-MP52IlCmywk6hGbgS75QSlN/cards/CC3AiMy0KEP1PhwnffMk32RF') \ No newline at end of file diff --git a/scenarios/customer_add_card/python.mako b/scenarios/customer_add_card/python.mako deleted file mode 100644 index a57dd38..0000000 --- a/scenarios/customer_add_card/python.mako +++ /dev/null @@ -1,10 +0,0 @@ -% if mode == 'definition': -balanced.Customer.add_card -% else: -import balanced - -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') - -customer = balanced.Customer.find('/v1/customers/CU3yqhHviPZ4ZbpHMcaa3SKH') -customer.add_card('/v1/marketplaces/TEST-MP52IlCmywk6hGbgS75QSlN/cards/CC3AiMy0KEP1PhwnffMk32RF') -% endif \ No newline at end of file diff --git a/scenarios/customer_add_card/request.mako b/scenarios/customer_add_card/request.mako deleted file mode 100644 index 6578636..0000000 --- a/scenarios/customer_add_card/request.mako +++ /dev/null @@ -1,5 +0,0 @@ -<%namespace file='/_main.mako' name='main'/> -<% main.python_boilerplate() %> - -customer = balanced.Customer.find('${request['uri']}') -customer.add_card('${request['payload']['card_uri']}') \ No newline at end of file diff --git a/scenarios/customer_create/definition.mako b/scenarios/customer_create/definition.mako index cd27a6f..5e58f65 100644 --- a/scenarios/customer_create/definition.mako +++ b/scenarios/customer_create/definition.mako @@ -1 +1 @@ -balanced.Customer(...).save() \ No newline at end of file +balanced.Customer().save() \ No newline at end of file diff --git a/scenarios/customer_create/executable.py b/scenarios/customer_create/executable.py index c53e345..d67d79e 100644 --- a/scenarios/customer_create/executable.py +++ b/scenarios/customer_create/executable.py @@ -1,5 +1,12 @@ import balanced -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') -customer = balanced.Customer().save() \ No newline at end of file +customer = balanced.Customer( + dob_year=1963, + dob_month=7, + name='Henry Ford', + address={ + 'postal_code': '48120' + } +).save() \ No newline at end of file diff --git a/scenarios/customer_create/python.mako b/scenarios/customer_create/python.mako index 6f66262..55ac777 100644 --- a/scenarios/customer_create/python.mako +++ b/scenarios/customer_create/python.mako @@ -1,9 +1,18 @@ % if mode == 'definition': -balanced.Customer(...).save() -% else: +balanced.Customer().save() +% elif mode == 'request': import balanced -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') -customer = balanced.Customer().save() +customer = balanced.Customer( + dob_year=1963, + dob_month=7, + name='Henry Ford', + address={ + 'postal_code': '48120' + } +).save() +% elif mode == 'response': +Customer(name=u'Henry Ford', links={u'source': None, u'destination': None}, created_at=u'2015-01-09T03:24:47.364051Z', dob_month=7, updated_at=u'2015-01-09T03:24:47.598887Z', phone=None, href=u'/customers/CU5AxbQrjAcjsbquafnvwaas', meta={}, dob_year=1963, email=None, address={u'city': None, u'line2': None, u'line1': None, u'state': None, u'postal_code': u'48120', u'country_code': None}, id=u'CU5AxbQrjAcjsbquafnvwaas', business_name=None, ssn_last4=None, merchant_status=u'underwritten', ein=None) % endif \ No newline at end of file diff --git a/scenarios/customer_create/request.mako b/scenarios/customer_create/request.mako index 7ac8c2d..b480892 100644 --- a/scenarios/customer_create/request.mako +++ b/scenarios/customer_create/request.mako @@ -1,4 +1,11 @@ <%namespace file='/_main.mako' name='main'/> <% main.python_boilerplate() %> -customer = balanced.Customer().save() \ No newline at end of file +customer = balanced.Customer( + dob_year=1963, + dob_month=7, + name='Henry Ford', + address={ + 'postal_code': '48120' + } +).save() \ No newline at end of file diff --git a/scenarios/customer_create_debit/definition.mako b/scenarios/customer_create_debit/definition.mako deleted file mode 100644 index a75cd4c..0000000 --- a/scenarios/customer_create_debit/definition.mako +++ /dev/null @@ -1 +0,0 @@ -balanced.Customer.debit() \ No newline at end of file diff --git a/scenarios/customer_create_debit/executable.py b/scenarios/customer_create_debit/executable.py deleted file mode 100644 index 997d154..0000000 --- a/scenarios/customer_create_debit/executable.py +++ /dev/null @@ -1,6 +0,0 @@ -import balanced - -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') - -customer = balanced.Customer.find('/v1/customers/CU2dUh4jpUihIQsHFbTwuDAc') -customer.debit(amount=5000) \ No newline at end of file diff --git a/scenarios/customer_create_debit/python.mako b/scenarios/customer_create_debit/python.mako deleted file mode 100644 index a9c9d92..0000000 --- a/scenarios/customer_create_debit/python.mako +++ /dev/null @@ -1,10 +0,0 @@ -% if mode == 'definition': -balanced.Customer.debit() -% else: -import balanced - -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') - -customer = balanced.Customer.find('/v1/customers/CU2dUh4jpUihIQsHFbTwuDAc') -customer.debit(amount=5000) -% endif \ No newline at end of file diff --git a/scenarios/customer_create_debit/request.mako b/scenarios/customer_create_debit/request.mako deleted file mode 100644 index a6038e4..0000000 --- a/scenarios/customer_create_debit/request.mako +++ /dev/null @@ -1,5 +0,0 @@ -<%namespace file='/_main.mako' name='main'/> -<% main.python_boilerplate() %> - -customer = balanced.Customer.find('${request['customer_uri']}') -customer.debit(amount=${request['payload']['amount']}) \ No newline at end of file diff --git a/scenarios/customer_credit/definition.mako b/scenarios/customer_credit/definition.mako deleted file mode 100644 index 3dac8ae..0000000 --- a/scenarios/customer_credit/definition.mako +++ /dev/null @@ -1 +0,0 @@ -balanced.Customer.credit() \ No newline at end of file diff --git a/scenarios/customer_credit/executable.py b/scenarios/customer_credit/executable.py deleted file mode 100644 index 040e4b8..0000000 --- a/scenarios/customer_credit/executable.py +++ /dev/null @@ -1,6 +0,0 @@ -import balanced - -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') - -customer = balanced.Customer.find('/v1/customers/CUyABeNYx8vHAaP4KRsd1j4/credits') -customer.credit(amount=100) \ No newline at end of file diff --git a/scenarios/customer_credit/python.mako b/scenarios/customer_credit/python.mako deleted file mode 100644 index d6f97f9..0000000 --- a/scenarios/customer_credit/python.mako +++ /dev/null @@ -1,10 +0,0 @@ -% if mode == 'definition': -balanced.Customer.credit() -% else: -import balanced - -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') - -customer = balanced.Customer.find('/v1/customers/CUyABeNYx8vHAaP4KRsd1j4/credits') -customer.credit(amount=100) -% endif \ No newline at end of file diff --git a/scenarios/customer_credit/request.mako b/scenarios/customer_credit/request.mako deleted file mode 100644 index 5f4d2e2..0000000 --- a/scenarios/customer_credit/request.mako +++ /dev/null @@ -1,5 +0,0 @@ -<%namespace file='/_main.mako' name='main'/> -<% main.python_boilerplate() %> - -customer = balanced.Customer.find('${request['uri']}') -customer.credit(amount=${request['payload']['amount']}) \ No newline at end of file diff --git a/scenarios/customer_delete/definition.mako b/scenarios/customer_delete/definition.mako index c19541c..63219d0 100644 --- a/scenarios/customer_delete/definition.mako +++ b/scenarios/customer_delete/definition.mako @@ -1 +1 @@ -balanced.Customer(...).unstore() \ No newline at end of file +balanced.Customer().unstore() \ No newline at end of file diff --git a/scenarios/customer_delete/executable.py b/scenarios/customer_delete/executable.py index 8c89db8..0418f8b 100644 --- a/scenarios/customer_delete/executable.py +++ b/scenarios/customer_delete/executable.py @@ -1,6 +1,6 @@ import balanced -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') -customer = balanced.Customer.find('/v1/customers/CU29FAMV807phGkX4wGIuymW') +customer = balanced.Customer.fetch('/customers/CU5AxbQrjAcjsbquafnvwaas') customer.unstore() \ No newline at end of file diff --git a/scenarios/customer_delete/python.mako b/scenarios/customer_delete/python.mako index f8c07ae..05dde83 100644 --- a/scenarios/customer_delete/python.mako +++ b/scenarios/customer_delete/python.mako @@ -1,10 +1,12 @@ % if mode == 'definition': -balanced.Customer(...).unstore() -% else: +balanced.Customer().unstore() +% elif mode == 'request': import balanced -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') -customer = balanced.Customer.find('/v1/customers/CU29FAMV807phGkX4wGIuymW') +customer = balanced.Customer.fetch('/customers/CU5AxbQrjAcjsbquafnvwaas') customer.unstore() +% elif mode == 'response': + % endif \ No newline at end of file diff --git a/scenarios/customer_delete/request.mako b/scenarios/customer_delete/request.mako index 801c438..d23457d 100644 --- a/scenarios/customer_delete/request.mako +++ b/scenarios/customer_delete/request.mako @@ -1,5 +1,5 @@ <%namespace file='/_main.mako' name='main'/> <% main.python_boilerplate() %> -customer = balanced.Customer.find('${request['uri']}') +customer = balanced.Customer.fetch('${request['uri']}') customer.unstore() \ No newline at end of file diff --git a/scenarios/customer_list/definition.mako b/scenarios/customer_list/definition.mako new file mode 100644 index 0000000..c27241d --- /dev/null +++ b/scenarios/customer_list/definition.mako @@ -0,0 +1 @@ +balanced.Customer.query diff --git a/scenarios/customer_list/executable.py b/scenarios/customer_list/executable.py new file mode 100644 index 0000000..d347509 --- /dev/null +++ b/scenarios/customer_list/executable.py @@ -0,0 +1,5 @@ +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +customers = balanced.Customer.query \ No newline at end of file diff --git a/scenarios/customer_list/python.mako b/scenarios/customer_list/python.mako new file mode 100644 index 0000000..70572e1 --- /dev/null +++ b/scenarios/customer_list/python.mako @@ -0,0 +1,12 @@ +% if mode == 'definition': +balanced.Customer.query + +% elif mode == 'request': +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +customers = balanced.Customer.query +% elif mode == 'response': + +% endif \ No newline at end of file diff --git a/scenarios/customer_list/request.mako b/scenarios/customer_list/request.mako new file mode 100644 index 0000000..b6ab4f2 --- /dev/null +++ b/scenarios/customer_list/request.mako @@ -0,0 +1,4 @@ +<%namespace file='/_main.mako' name='main'/> +<% main.python_boilerplate() %> + +customers = balanced.Customer.query \ No newline at end of file diff --git a/scenarios/customer_show/definition.mako b/scenarios/customer_show/definition.mako new file mode 100644 index 0000000..8db9ee3 --- /dev/null +++ b/scenarios/customer_show/definition.mako @@ -0,0 +1 @@ +balanced.Customer.fetch() diff --git a/scenarios/customer_show/executable.py b/scenarios/customer_show/executable.py new file mode 100644 index 0000000..caa72fe --- /dev/null +++ b/scenarios/customer_show/executable.py @@ -0,0 +1,5 @@ +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +customer = balanced.Customer.fetch('/customers/CU5aACCvYYfV6mcWJL4TEcK1') \ No newline at end of file diff --git a/scenarios/customer_show/python.mako b/scenarios/customer_show/python.mako new file mode 100644 index 0000000..d37dd56 --- /dev/null +++ b/scenarios/customer_show/python.mako @@ -0,0 +1,12 @@ +% if mode == 'definition': +balanced.Customer.fetch() + +% elif mode == 'request': +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +customer = balanced.Customer.fetch('/customers/CU5aACCvYYfV6mcWJL4TEcK1') +% elif mode == 'response': +Customer(name=u'Henry Ford', links={u'source': None, u'destination': None}, created_at=u'2015-01-09T03:24:24.298841Z', dob_month=7, updated_at=u'2015-01-09T03:24:24.504781Z', phone=None, href=u'/customers/CU5aACCvYYfV6mcWJL4TEcK1', meta={}, dob_year=1963, email=None, address={u'city': None, u'line2': None, u'line1': None, u'state': None, u'postal_code': u'48120', u'country_code': None}, id=u'CU5aACCvYYfV6mcWJL4TEcK1', business_name=None, ssn_last4=None, merchant_status=u'underwritten', ein=None) +% endif \ No newline at end of file diff --git a/scenarios/customer_show/request.mako b/scenarios/customer_show/request.mako new file mode 100644 index 0000000..d3f8f70 --- /dev/null +++ b/scenarios/customer_show/request.mako @@ -0,0 +1,4 @@ +<%namespace file='/_main.mako' name='main'/> +<% main.python_boilerplate() %> + +customer = balanced.Customer.fetch('${request['uri']}') \ No newline at end of file diff --git a/scenarios/customer_update/definition.mako b/scenarios/customer_update/definition.mako new file mode 100644 index 0000000..5e58f65 --- /dev/null +++ b/scenarios/customer_update/definition.mako @@ -0,0 +1 @@ +balanced.Customer().save() \ No newline at end of file diff --git a/scenarios/customer_update/executable.py b/scenarios/customer_update/executable.py new file mode 100644 index 0000000..118e5af --- /dev/null +++ b/scenarios/customer_update/executable.py @@ -0,0 +1,10 @@ +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +customer = balanced.Debit.fetch('/customers/CU5aACCvYYfV6mcWJL4TEcK1') +customer.email = 'email@newdomain.com' +customer.meta = { + 'shipping-preference': 'ground' +} +customer.save() \ No newline at end of file diff --git a/scenarios/customer_update/python.mako b/scenarios/customer_update/python.mako new file mode 100644 index 0000000..9739721 --- /dev/null +++ b/scenarios/customer_update/python.mako @@ -0,0 +1,16 @@ +% if mode == 'definition': +balanced.Customer().save() +% elif mode == 'request': +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +customer = balanced.Debit.fetch('/customers/CU5aACCvYYfV6mcWJL4TEcK1') +customer.email = 'email@newdomain.com' +customer.meta = { + 'shipping-preference': 'ground' +} +customer.save() +% elif mode == 'response': +Customer(name=u'Henry Ford', links={u'source': None, u'destination': None}, created_at=u'2015-01-09T03:24:24.298841Z', dob_month=7, updated_at=u'2015-01-09T03:24:42.621096Z', phone=None, href=u'/customers/CU5aACCvYYfV6mcWJL4TEcK1', meta={u'shipping-preference': u'ground'}, dob_year=1963, email=u'email@newdomain.com', address={u'city': None, u'line2': None, u'line1': None, u'state': None, u'postal_code': u'48120', u'country_code': None}, id=u'CU5aACCvYYfV6mcWJL4TEcK1', business_name=None, ssn_last4=None, merchant_status=u'underwritten', ein=None) +% endif \ No newline at end of file diff --git a/scenarios/customer_update/request.mako b/scenarios/customer_update/request.mako new file mode 100644 index 0000000..8ab3f58 --- /dev/null +++ b/scenarios/customer_update/request.mako @@ -0,0 +1,9 @@ +<%namespace file='/_main.mako' name='main'/> +<% main.python_boilerplate() %> + +customer = balanced.Debit.fetch('${request['uri']}') +customer.email = '${request['payload']['email']}' +customer.meta = { + 'shipping-preference': 'ground' +} +customer.save() \ No newline at end of file diff --git a/scenarios/debit_account_list/definition.mako b/scenarios/debit_account_list/definition.mako deleted file mode 100644 index 9f18600..0000000 --- a/scenarios/debit_account_list/definition.mako +++ /dev/null @@ -1 +0,0 @@ -balanced.Account.debits \ No newline at end of file diff --git a/scenarios/debit_account_list/python.mako b/scenarios/debit_account_list/python.mako deleted file mode 100644 index b4c0cb0..0000000 --- a/scenarios/debit_account_list/python.mako +++ /dev/null @@ -1,5 +0,0 @@ -% if mode == 'definition': -balanced.Account.debits -% else: - -% endif \ No newline at end of file diff --git a/scenarios/debit_create/definition.mako b/scenarios/debit_create/definition.mako deleted file mode 100644 index b1c724b..0000000 --- a/scenarios/debit_create/definition.mako +++ /dev/null @@ -1 +0,0 @@ -balanced.Customer.debit(...) \ No newline at end of file diff --git a/scenarios/debit_create/executable.py b/scenarios/debit_create/executable.py deleted file mode 100644 index 778d27a..0000000 --- a/scenarios/debit_create/executable.py +++ /dev/null @@ -1,10 +0,0 @@ -import balanced - -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') - -customer = balanced.Customer.find('/v1/customers/CU35rlJBXqlvD9LC26PWu0cy') -customer.debit( - appears_on_statement_as='Statement text', - amount=5000, - description='Some descriptive text for the debit in the dashboard' -) \ No newline at end of file diff --git a/scenarios/debit_create/python.mako b/scenarios/debit_create/python.mako deleted file mode 100644 index 3ef246c..0000000 --- a/scenarios/debit_create/python.mako +++ /dev/null @@ -1,14 +0,0 @@ -% if mode == 'definition': -balanced.Customer.debit(...) -% else: -import balanced - -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') - -customer = balanced.Customer.find('/v1/customers/CU35rlJBXqlvD9LC26PWu0cy') -customer.debit( - appears_on_statement_as='Statement text', - amount=5000, - description='Some descriptive text for the debit in the dashboard' -) -% endif \ No newline at end of file diff --git a/scenarios/debit_customer_list/definition.mako b/scenarios/debit_customer_list/definition.mako deleted file mode 100644 index fee5ae3..0000000 --- a/scenarios/debit_customer_list/definition.mako +++ /dev/null @@ -1 +0,0 @@ -balanced.Customer.debits \ No newline at end of file diff --git a/scenarios/debit_customer_list/executable.py b/scenarios/debit_customer_list/executable.py deleted file mode 100644 index b1ba6bf..0000000 --- a/scenarios/debit_customer_list/executable.py +++ /dev/null @@ -1,6 +0,0 @@ -import balanced - -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') - -customer = balanced.Customer.find('/v1/customers/CU2dUh4jpUihIQsHFbTwuDAc') -debits = customer.debits.all() \ No newline at end of file diff --git a/scenarios/debit_customer_list/python.mako b/scenarios/debit_customer_list/python.mako deleted file mode 100644 index e18ce55..0000000 --- a/scenarios/debit_customer_list/python.mako +++ /dev/null @@ -1,10 +0,0 @@ -% if mode == 'definition': -balanced.Customer.debits -% else: -import balanced - -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') - -customer = balanced.Customer.find('/v1/customers/CU2dUh4jpUihIQsHFbTwuDAc') -debits = customer.debits.all() -% endif \ No newline at end of file diff --git a/scenarios/debit_customer_list/request.mako b/scenarios/debit_customer_list/request.mako deleted file mode 100644 index c262455..0000000 --- a/scenarios/debit_customer_list/request.mako +++ /dev/null @@ -1,5 +0,0 @@ -<%namespace file='/_main.mako' name='main'/> -<% main.python_boilerplate() %> - -customer = balanced.Customer.find('${request['uri']}') -debits = customer.debits.all() \ No newline at end of file diff --git a/scenarios/debit_dispute_show/definition.mako b/scenarios/debit_dispute_show/definition.mako new file mode 100644 index 0000000..ce8c692 --- /dev/null +++ b/scenarios/debit_dispute_show/definition.mako @@ -0,0 +1 @@ +balanced.Debit().dispute diff --git a/scenarios/debit_dispute_show/executable.py b/scenarios/debit_dispute_show/executable.py new file mode 100644 index 0000000..5a01719 --- /dev/null +++ b/scenarios/debit_dispute_show/executable.py @@ -0,0 +1,6 @@ +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +debit = balanced.Debit.fetch('/debits/WD5SwXr9jcCfCmmjTH5MCMFD') +dispute = debit.dispute \ No newline at end of file diff --git a/scenarios/debit_dispute_show/python.mako b/scenarios/debit_dispute_show/python.mako new file mode 100644 index 0000000..6be7f8f --- /dev/null +++ b/scenarios/debit_dispute_show/python.mako @@ -0,0 +1,13 @@ +% if mode == 'definition': +balanced.Debit().dispute + +% elif mode == 'request': +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +debit = balanced.Debit.fetch('/debits/WD5SwXr9jcCfCmmjTH5MCMFD') +dispute = debit.dispute +% elif mode == 'response': +Dispute(status=u'pending', links={u'transaction': u'WD5SwXr9jcCfCmmjTH5MCMFD'}, respond_by=u'2015-02-08T03:22:35.440841Z', amount=5000, created_at=u'2015-01-09T03:25:14.170586Z', updated_at=u'2015-01-09T03:25:14.170588Z', initiated_at=u'2015-01-09T03:22:35.440838Z', currency=u'USD', reason=u'fraud', href=u'/disputes/DT64FIXm5agnVqfCMHZVe8dR', meta={}, id=u'DT64FIXm5agnVqfCMHZVe8dR') +% endif \ No newline at end of file diff --git a/scenarios/debit_dispute_show/request.mako b/scenarios/debit_dispute_show/request.mako new file mode 100644 index 0000000..1406a28 --- /dev/null +++ b/scenarios/debit_dispute_show/request.mako @@ -0,0 +1,5 @@ +<%namespace file='/_main.mako' name='main'/> +<% main.python_boilerplate() %> + +debit = balanced.Debit.fetch('${request['debit_href']}') +dispute = debit.dispute \ No newline at end of file diff --git a/scenarios/debit_list/definition.mako b/scenarios/debit_list/definition.mako index debf1ff..389fecf 100644 --- a/scenarios/debit_list/definition.mako +++ b/scenarios/debit_list/definition.mako @@ -1 +1 @@ -balanced.Debit.query() \ No newline at end of file +balanced.Debit.query diff --git a/scenarios/debit_list/executable.py b/scenarios/debit_list/executable.py index 16c21b3..e2c9191 100644 --- a/scenarios/debit_list/executable.py +++ b/scenarios/debit_list/executable.py @@ -1,5 +1,5 @@ import balanced -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') -debits = balanced.Debit.query.all(); \ No newline at end of file +debits = balanced.Debit.query \ No newline at end of file diff --git a/scenarios/debit_list/python.mako b/scenarios/debit_list/python.mako index 68d62a1..f62fb57 100644 --- a/scenarios/debit_list/python.mako +++ b/scenarios/debit_list/python.mako @@ -1,9 +1,12 @@ % if mode == 'definition': -balanced.Debit.query() -% else: +balanced.Debit.query + +% elif mode == 'request': import balanced -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +debits = balanced.Debit.query +% elif mode == 'response': -debits = balanced.Debit.query.all(); % endif \ No newline at end of file diff --git a/scenarios/debit_list/request.mako b/scenarios/debit_list/request.mako index a10d29b..5ff7d93 100644 --- a/scenarios/debit_list/request.mako +++ b/scenarios/debit_list/request.mako @@ -1,4 +1,4 @@ <%namespace file='/_main.mako' name='main'/> <% main.python_boilerplate() %> -debits = balanced.Debit.query.all(); \ No newline at end of file +debits = balanced.Debit.query \ No newline at end of file diff --git a/scenarios/debit_order/definition.mako b/scenarios/debit_order/definition.mako new file mode 100644 index 0000000..eda6428 --- /dev/null +++ b/scenarios/debit_order/definition.mako @@ -0,0 +1 @@ +balanced.Order().debit_from() diff --git a/scenarios/debit_order/executable.py b/scenarios/debit_order/executable.py new file mode 100644 index 0000000..7f34819 --- /dev/null +++ b/scenarios/debit_order/executable.py @@ -0,0 +1,10 @@ +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +order = balanced.Order.fetch('/orders/OR3vURGwVtqDnnkRS9fgH41G') +card = balanced.Card.fetch('/cards/CC4zyuNpxY0A0eAf87SeULCR') +order.debit_from( + amount=5000, + source=card, +) \ No newline at end of file diff --git a/scenarios/debit_order/python.mako b/scenarios/debit_order/python.mako new file mode 100644 index 0000000..90b478a --- /dev/null +++ b/scenarios/debit_order/python.mako @@ -0,0 +1,17 @@ +% if mode == 'definition': +balanced.Order().debit_from() + +% elif mode == 'request': +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +order = balanced.Order.fetch('/orders/OR3vURGwVtqDnnkRS9fgH41G') +card = balanced.Card.fetch('/cards/CC4zyuNpxY0A0eAf87SeULCR') +order.debit_from( + amount=5000, + source=card, +) +% elif mode == 'response': +Debit(status=u'succeeded', description=u'Order #12341234', links={u'customer': None, u'source': u'CC4zyuNpxY0A0eAf87SeULCR', u'dispute': None, u'order': u'OR3vURGwVtqDnnkRS9fgH41G', u'card_hold': u'HL4JLr6FnToEyeoEdOCOTpC5'}, amount=5000, created_at=u'2015-01-09T03:24:00.472796Z', updated_at=u'2015-01-09T03:24:01.120118Z', failure_reason=None, currency=u'USD', transaction_number=u'W2W2-G3K-YCMU', href=u'/debits/WD4JMhEQTuXpqzpBvpgDo633', meta={}, failure_reason_code=None, appears_on_statement_as=u'BAL*example.com', id=u'WD4JMhEQTuXpqzpBvpgDo633') +% endif \ No newline at end of file diff --git a/scenarios/debit_order/request.mako b/scenarios/debit_order/request.mako new file mode 100644 index 0000000..699e0a5 --- /dev/null +++ b/scenarios/debit_order/request.mako @@ -0,0 +1,9 @@ +<%namespace file='/_main.mako' name='main'/> +<% main.python_boilerplate() %> + +order = balanced.Order.fetch('${request['order_href']}') +card = balanced.Card.fetch('${request['card_href']}') +order.debit_from( + amount=${payload['amount']}, + source=card, +) diff --git a/scenarios/debit_refund/definition.mako b/scenarios/debit_refund/definition.mako deleted file mode 100644 index a5321df..0000000 --- a/scenarios/debit_refund/definition.mako +++ /dev/null @@ -1 +0,0 @@ -balanced.Debit.refund() \ No newline at end of file diff --git a/scenarios/debit_refund/executable.py b/scenarios/debit_refund/executable.py deleted file mode 100644 index ea27048..0000000 --- a/scenarios/debit_refund/executable.py +++ /dev/null @@ -1,6 +0,0 @@ -import balanced - -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') - -debit = balanced.Debit.find('/v1/marketplaces/TEST-MP52IlCmywk6hGbgS75QSlN/debits/WD2za3rLGBUpINViqUGbY5XW') -debit.refund() \ No newline at end of file diff --git a/scenarios/debit_refund/python.mako b/scenarios/debit_refund/python.mako deleted file mode 100644 index 38ddc01..0000000 --- a/scenarios/debit_refund/python.mako +++ /dev/null @@ -1,10 +0,0 @@ -% if mode == 'definition': -balanced.Debit.refund() -% else: -import balanced - -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') - -debit = balanced.Debit.find('/v1/marketplaces/TEST-MP52IlCmywk6hGbgS75QSlN/debits/WD2za3rLGBUpINViqUGbY5XW') -debit.refund() -% endif \ No newline at end of file diff --git a/scenarios/debit_show/definition.mako b/scenarios/debit_show/definition.mako index 1fc6ab5..ae0f43c 100644 --- a/scenarios/debit_show/definition.mako +++ b/scenarios/debit_show/definition.mako @@ -1 +1 @@ -balanced.Debit.find \ No newline at end of file +balanced.Debit.fetch() diff --git a/scenarios/debit_show/executable.py b/scenarios/debit_show/executable.py index 0ee5c59..213731c 100644 --- a/scenarios/debit_show/executable.py +++ b/scenarios/debit_show/executable.py @@ -1,5 +1,5 @@ import balanced -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') -debit = balanced.Debit.find('/v1/marketplaces/TEST-MP52IlCmywk6hGbgS75QSlN/debits/WD2lQO6cFyxyTWj6mLQ6zFDO') \ No newline at end of file +debit = balanced.Debit.fetch('/debits/WD5EW7vbyXlTsudIGF5AkrEA') \ No newline at end of file diff --git a/scenarios/debit_show/python.mako b/scenarios/debit_show/python.mako index 796ea08..0c27f46 100644 --- a/scenarios/debit_show/python.mako +++ b/scenarios/debit_show/python.mako @@ -1,9 +1,12 @@ % if mode == 'definition': -balanced.Debit.find -% else: +balanced.Debit.fetch() + +% elif mode == 'request': import balanced -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') -debit = balanced.Debit.find('/v1/marketplaces/TEST-MP52IlCmywk6hGbgS75QSlN/debits/WD2lQO6cFyxyTWj6mLQ6zFDO') +debit = balanced.Debit.fetch('/debits/WD5EW7vbyXlTsudIGF5AkrEA') +% elif mode == 'response': +Debit(status=u'succeeded', description=u'Some descriptive text for the debit in the dashboard', links={u'customer': None, u'source': u'CC4zyuNpxY0A0eAf87SeULCR', u'dispute': None, u'order': None, u'card_hold': u'HL5EUR5M3MniPMPUQM0hDdeg'}, amount=5000, created_at=u'2015-01-09T03:24:51.290112Z', updated_at=u'2015-01-09T03:24:52.004949Z', failure_reason=None, currency=u'USD', transaction_number=u'WMBW-XBR-0C9N', href=u'/debits/WD5EW7vbyXlTsudIGF5AkrEA', meta={}, failure_reason_code=None, appears_on_statement_as=u'BAL*Statement text', id=u'WD5EW7vbyXlTsudIGF5AkrEA') % endif \ No newline at end of file diff --git a/scenarios/debit_show/request.mako b/scenarios/debit_show/request.mako index bf2c349..ea00307 100644 --- a/scenarios/debit_show/request.mako +++ b/scenarios/debit_show/request.mako @@ -1,4 +1,4 @@ <%namespace file='/_main.mako' name='main'/> <% main.python_boilerplate() %> -debit = balanced.Debit.find('${request['uri']}') \ No newline at end of file +debit = balanced.Debit.fetch('${request['uri']}') \ No newline at end of file diff --git a/scenarios/debit_update/definition.mako b/scenarios/debit_update/definition.mako index 01fec2c..7c5d008 100644 --- a/scenarios/debit_update/definition.mako +++ b/scenarios/debit_update/definition.mako @@ -1 +1 @@ -balanced.Debit.save() \ No newline at end of file +balanced.Debit().save() \ No newline at end of file diff --git a/scenarios/debit_update/executable.py b/scenarios/debit_update/executable.py index 162ed97..685698a 100644 --- a/scenarios/debit_update/executable.py +++ b/scenarios/debit_update/executable.py @@ -1,8 +1,8 @@ import balanced -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') -debit = balanced.Debit.find('/v1/marketplaces/TEST-MP52IlCmywk6hGbgS75QSlN/debits/WD2lQO6cFyxyTWj6mLQ6zFDO') +debit = balanced.Debit.fetch('/debits/WD5EW7vbyXlTsudIGF5AkrEA') debit.description = 'New description for debit' debit.meta = { 'facebook.id': '1234567890', diff --git a/scenarios/debit_update/python.mako b/scenarios/debit_update/python.mako index 60a3d4e..c026387 100644 --- a/scenarios/debit_update/python.mako +++ b/scenarios/debit_update/python.mako @@ -1,15 +1,17 @@ % if mode == 'definition': -balanced.Debit.save() -% else: +balanced.Debit().save() +% elif mode == 'request': import balanced -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') -debit = balanced.Debit.find('/v1/marketplaces/TEST-MP52IlCmywk6hGbgS75QSlN/debits/WD2lQO6cFyxyTWj6mLQ6zFDO') +debit = balanced.Debit.fetch('/debits/WD5EW7vbyXlTsudIGF5AkrEA') debit.description = 'New description for debit' debit.meta = { 'facebook.id': '1234567890', 'anykey': 'valuegoeshere', } debit.save() +% elif mode == 'response': +Debit(status=u'succeeded', description=u'New description for debit', links={u'customer': None, u'source': u'CC4zyuNpxY0A0eAf87SeULCR', u'dispute': None, u'order': None, u'card_hold': u'HL5EUR5M3MniPMPUQM0hDdeg'}, amount=5000, created_at=u'2015-01-09T03:24:51.290112Z', updated_at=u'2015-01-09T03:24:56.837641Z', failure_reason=None, currency=u'USD', transaction_number=u'WMBW-XBR-0C9N', href=u'/debits/WD5EW7vbyXlTsudIGF5AkrEA', meta={u'facebook.id': u'1234567890', u'anykey': u'valuegoeshere'}, failure_reason_code=None, appears_on_statement_as=u'BAL*Statement text', id=u'WD5EW7vbyXlTsudIGF5AkrEA') % endif \ No newline at end of file diff --git a/scenarios/debit_update/request.mako b/scenarios/debit_update/request.mako index d33bc4a..987414c 100644 --- a/scenarios/debit_update/request.mako +++ b/scenarios/debit_update/request.mako @@ -1,7 +1,7 @@ <%namespace file='/_main.mako' name='main'/> <% main.python_boilerplate() %> -debit = balanced.Debit.find('${request['uri']}') +debit = balanced.Debit.fetch('${request['uri']}') debit.description = '${request['payload']['description']}' debit.meta = { 'facebook.id': '1234567890', diff --git a/scenarios/dispute_list/definition.mako b/scenarios/dispute_list/definition.mako new file mode 100644 index 0000000..e3b1ab2 --- /dev/null +++ b/scenarios/dispute_list/definition.mako @@ -0,0 +1 @@ +balanced.Dispute.query \ No newline at end of file diff --git a/scenarios/dispute_list/executable.py b/scenarios/dispute_list/executable.py new file mode 100644 index 0000000..5a9ca78 --- /dev/null +++ b/scenarios/dispute_list/executable.py @@ -0,0 +1,5 @@ +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +disputes = balanced.Dispute.query \ No newline at end of file diff --git a/scenarios/dispute_list/python.mako b/scenarios/dispute_list/python.mako new file mode 100644 index 0000000..cb5ece1 --- /dev/null +++ b/scenarios/dispute_list/python.mako @@ -0,0 +1,11 @@ +% if mode == 'definition': +balanced.Dispute.query +% elif mode == 'request': +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +disputes = balanced.Dispute.query +% elif mode == 'response': + +% endif \ No newline at end of file diff --git a/scenarios/dispute_list/request.mako b/scenarios/dispute_list/request.mako new file mode 100644 index 0000000..cbd6885 --- /dev/null +++ b/scenarios/dispute_list/request.mako @@ -0,0 +1,4 @@ +<%namespace file='/_main.mako' name='main'/> +<% main.python_boilerplate() %> + +disputes = balanced.Dispute.query \ No newline at end of file diff --git a/scenarios/dispute_show/definition.mako b/scenarios/dispute_show/definition.mako new file mode 100644 index 0000000..6fb713f --- /dev/null +++ b/scenarios/dispute_show/definition.mako @@ -0,0 +1 @@ +balanced.Dispute.fetch() diff --git a/scenarios/dispute_show/executable.py b/scenarios/dispute_show/executable.py new file mode 100644 index 0000000..3987715 --- /dev/null +++ b/scenarios/dispute_show/executable.py @@ -0,0 +1,5 @@ +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +dispute = balanced.Dispute.fetch('/disputes/DT64FIXm5agnVqfCMHZVe8dR') \ No newline at end of file diff --git a/scenarios/dispute_show/python.mako b/scenarios/dispute_show/python.mako new file mode 100644 index 0000000..a2e607f --- /dev/null +++ b/scenarios/dispute_show/python.mako @@ -0,0 +1,12 @@ +% if mode == 'definition': +balanced.Dispute.fetch() + +% elif mode == 'request': +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +dispute = balanced.Dispute.fetch('/disputes/DT64FIXm5agnVqfCMHZVe8dR') +% elif mode == 'response': +Dispute(status=u'pending', links={u'transaction': u'WD5SwXr9jcCfCmmjTH5MCMFD'}, respond_by=u'2015-02-08T03:22:35.440841Z', amount=5000, created_at=u'2015-01-09T03:25:14.170586Z', updated_at=u'2015-01-09T03:25:14.170588Z', initiated_at=u'2015-01-09T03:22:35.440838Z', currency=u'USD', reason=u'fraud', href=u'/disputes/DT64FIXm5agnVqfCMHZVe8dR', meta={}, id=u'DT64FIXm5agnVqfCMHZVe8dR') +% endif \ No newline at end of file diff --git a/scenarios/dispute_show/request.mako b/scenarios/dispute_show/request.mako new file mode 100644 index 0000000..c9e302e --- /dev/null +++ b/scenarios/dispute_show/request.mako @@ -0,0 +1,4 @@ +<%namespace file='/_main.mako' name='main'/> +<% main.python_boilerplate() %> + +dispute = balanced.Dispute.fetch('${request['uri']}') \ No newline at end of file diff --git a/scenarios/event_list/definition.mako b/scenarios/event_list/definition.mako index 9bb7484..4b78ca8 100644 --- a/scenarios/event_list/definition.mako +++ b/scenarios/event_list/definition.mako @@ -1 +1 @@ -balanced.Event.query \ No newline at end of file +balanced.Event.query diff --git a/scenarios/event_list/executable.py b/scenarios/event_list/executable.py index 731312e..a5be556 100644 --- a/scenarios/event_list/executable.py +++ b/scenarios/event_list/executable.py @@ -1,5 +1,5 @@ import balanced -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') -events = balanced.Event.query.all(); \ No newline at end of file +events = balanced.Event.query \ No newline at end of file diff --git a/scenarios/event_list/python.mako b/scenarios/event_list/python.mako index c5924e3..2704919 100644 --- a/scenarios/event_list/python.mako +++ b/scenarios/event_list/python.mako @@ -1,9 +1,12 @@ % if mode == 'definition': balanced.Event.query -% else: + +% elif mode == 'request': import balanced -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +events = balanced.Event.query +% elif mode == 'response': -events = balanced.Event.query.all(); % endif \ No newline at end of file diff --git a/scenarios/event_list/request.mako b/scenarios/event_list/request.mako index 135a735..a471a52 100644 --- a/scenarios/event_list/request.mako +++ b/scenarios/event_list/request.mako @@ -1,4 +1,4 @@ <%namespace file='/_main.mako' name='main'/> <% main.python_boilerplate() %> -events = balanced.Event.query.all(); \ No newline at end of file +events = balanced.Event.query \ No newline at end of file diff --git a/scenarios/event_replay/python.mako b/scenarios/event_replay/python.mako deleted file mode 100644 index b3d0a94..0000000 --- a/scenarios/event_replay/python.mako +++ /dev/null @@ -1,5 +0,0 @@ -% if mode == 'definition': - -% else: - -% endif \ No newline at end of file diff --git a/scenarios/event_show/definition.mako b/scenarios/event_show/definition.mako index 05086e3..c0f29dd 100644 --- a/scenarios/event_show/definition.mako +++ b/scenarios/event_show/definition.mako @@ -1 +1 @@ -balanced.Event.find \ No newline at end of file +balanced.Event.fetch() diff --git a/scenarios/event_show/executable.py b/scenarios/event_show/executable.py index b3afc8f..8c898bb 100644 --- a/scenarios/event_show/executable.py +++ b/scenarios/event_show/executable.py @@ -1,5 +1,5 @@ import balanced -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') -event = balanced.Event.find('/v1/events/EV02f1fad84d4711e384a9026ba7d31e6f') \ No newline at end of file +event = balanced.Event.fetch('/events/EVc7cbc12497ae11e48e4606debca797bb') \ No newline at end of file diff --git a/scenarios/event_show/python.mako b/scenarios/event_show/python.mako index 445682b..1ed1bc6 100644 --- a/scenarios/event_show/python.mako +++ b/scenarios/event_show/python.mako @@ -1,9 +1,12 @@ % if mode == 'definition': -balanced.Event.find -% else: +balanced.Event.fetch() + +% elif mode == 'request': import balanced -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') -event = balanced.Event.find('/v1/events/EV02f1fad84d4711e384a9026ba7d31e6f') +event = balanced.Event.fetch('/events/EVc7cbc12497ae11e48e4606debca797bb') +% elif mode == 'response': +Event(links={}, occurred_at=u'2015-01-09T03:25:04.090381Z', entity={u'debits': [{u'status': u'succeeded', u'description': u'Some descriptive text for the debit in the dashboard', u'links': {u'customer': None, u'source': u'CC5RRvpnZIg0PWdSphR8xxPa', u'dispute': u'DT64FIXm5agnVqfCMHZVe8dR', u'order': None, u'card_hold': u'HL5Svbmw6nDDP5HO2RblsBCJ'}, u'href': u'/debits/WD5SwXr9jcCfCmmjTH5MCMFD', u'created_at': u'2015-01-09T03:25:03.383375Z', u'transaction_number': u'WA4K-D44-O5DR', u'failure_reason': None, u'updated_at': u'2015-01-09T03:25:04.090381Z', u'currency': u'USD', u'amount': 5000, u'failure_reason_code': None, u'meta': {}, u'appears_on_statement_as': u'BAL*Statement text', u'id': u'WD5SwXr9jcCfCmmjTH5MCMFD'}], u'links': {u'debits.customer': u'/customers/{debits.customer}', u'debits.dispute': u'/disputes/{debits.dispute}', u'debits.card_hold': u'/holds/{debits.card_hold}', u'debits.source': u'/resources/{debits.source}', u'debits.order': u'/orders/{debits.order}', u'debits.refunds': u'/debits/{debits.id}/refunds', u'debits.events': u'/debits/{debits.id}/events'}}, href=u'/events/EVc7cbc12497ae11e48e4606debca797bb', callback_statuses={u'failed': 0, u'retrying': 0, u'succeeded': 0, u'pending': 1}, type=u'debit.succeeded', id=u'EVc7cbc12497ae11e48e4606debca797bb') % endif \ No newline at end of file diff --git a/scenarios/event_show/request.mako b/scenarios/event_show/request.mako index 9a20ccd..09f63e5 100644 --- a/scenarios/event_show/request.mako +++ b/scenarios/event_show/request.mako @@ -1,4 +1,4 @@ <%namespace file='/_main.mako' name='main'/> <% main.python_boilerplate() %> -event = balanced.Event.find('${request['uri']}') \ No newline at end of file +event = balanced.Event.fetch('${request['uri']}') \ No newline at end of file diff --git a/scenarios/hold_account_list/definition.mako b/scenarios/hold_account_list/definition.mako deleted file mode 100644 index 696f9d2..0000000 --- a/scenarios/hold_account_list/definition.mako +++ /dev/null @@ -1 +0,0 @@ -balanced.Account.holds \ No newline at end of file diff --git a/scenarios/hold_account_list/python.mako b/scenarios/hold_account_list/python.mako deleted file mode 100644 index 6c147bd..0000000 --- a/scenarios/hold_account_list/python.mako +++ /dev/null @@ -1,5 +0,0 @@ -% if mode == 'definition': -balanced.Account.holds -% else: - -% endif \ No newline at end of file diff --git a/scenarios/hold_capture/definition.mako b/scenarios/hold_capture/definition.mako deleted file mode 100644 index 57957cd..0000000 --- a/scenarios/hold_capture/definition.mako +++ /dev/null @@ -1 +0,0 @@ -balanced.Hold.capture(...) \ No newline at end of file diff --git a/scenarios/hold_capture/executable.py b/scenarios/hold_capture/executable.py deleted file mode 100644 index 739f5d7..0000000 --- a/scenarios/hold_capture/executable.py +++ /dev/null @@ -1,9 +0,0 @@ -import balanced - -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') - -hold = balanced.Hold.find('/v1/marketplaces/TEST-MP52IlCmywk6hGbgS75QSlN/holds/HL3CgDhSRS2YOwbR7Uj0eXtU') -debit = hold.capture( - appears_on_statement_as='ShowsUpOnStmt', - description='Some descriptive text for the debit in the dashboard' -) \ No newline at end of file diff --git a/scenarios/hold_capture/python.mako b/scenarios/hold_capture/python.mako deleted file mode 100644 index 4251df2..0000000 --- a/scenarios/hold_capture/python.mako +++ /dev/null @@ -1,13 +0,0 @@ -% if mode == 'definition': -balanced.Hold.capture(...) -% else: -import balanced - -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') - -hold = balanced.Hold.find('/v1/marketplaces/TEST-MP52IlCmywk6hGbgS75QSlN/holds/HL3CgDhSRS2YOwbR7Uj0eXtU') -debit = hold.capture( - appears_on_statement_as='ShowsUpOnStmt', - description='Some descriptive text for the debit in the dashboard' -) -% endif \ No newline at end of file diff --git a/scenarios/hold_create/definition.mako b/scenarios/hold_create/definition.mako deleted file mode 100644 index 6af1b0f..0000000 --- a/scenarios/hold_create/definition.mako +++ /dev/null @@ -1 +0,0 @@ -balanced.Hold(...) \ No newline at end of file diff --git a/scenarios/hold_create/executable.py b/scenarios/hold_create/executable.py deleted file mode 100644 index 2d22020..0000000 --- a/scenarios/hold_create/executable.py +++ /dev/null @@ -1,10 +0,0 @@ -import balanced - -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') - -hold = balanced.Hold( - source_uri='/v1/marketplaces/TEST-MP52IlCmywk6hGbgS75QSlN/cards/CC3AiMy0KEP1PhwnffMk32RF', - amount=5000, - description='Some descriptive text for the debit in the dashboard' -) -hold.save() diff --git a/scenarios/hold_create/python.mako b/scenarios/hold_create/python.mako deleted file mode 100644 index 0140cfd..0000000 --- a/scenarios/hold_create/python.mako +++ /dev/null @@ -1,14 +0,0 @@ -% if mode == 'definition': -balanced.Hold(...) -% else: -import balanced - -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') - -hold = balanced.Hold( - source_uri='/v1/marketplaces/TEST-MP52IlCmywk6hGbgS75QSlN/cards/CC3AiMy0KEP1PhwnffMk32RF', - amount=5000, - description='Some descriptive text for the debit in the dashboard' -) -hold.save() -% endif \ No newline at end of file diff --git a/scenarios/hold_customer_list/definition.mako b/scenarios/hold_customer_list/definition.mako deleted file mode 100644 index 194ed53..0000000 --- a/scenarios/hold_customer_list/definition.mako +++ /dev/null @@ -1 +0,0 @@ -balanced.Customer.holds \ No newline at end of file diff --git a/scenarios/hold_customer_list/executable.py b/scenarios/hold_customer_list/executable.py deleted file mode 100644 index c318afe..0000000 --- a/scenarios/hold_customer_list/executable.py +++ /dev/null @@ -1,6 +0,0 @@ -import balanced - -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') - -customer = balanced.Customer.find('/v1/customers/CU2L1UERNEH5anL0rl1gAgW4/holds') -holds = customer.holds.all() \ No newline at end of file diff --git a/scenarios/hold_customer_list/python.mako b/scenarios/hold_customer_list/python.mako deleted file mode 100644 index bc3aa33..0000000 --- a/scenarios/hold_customer_list/python.mako +++ /dev/null @@ -1,10 +0,0 @@ -% if mode == 'definition': -balanced.Customer.holds -% else: -import balanced - -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') - -customer = balanced.Customer.find('/v1/customers/CU2L1UERNEH5anL0rl1gAgW4/holds') -holds = customer.holds.all() -% endif \ No newline at end of file diff --git a/scenarios/hold_customer_list/request.mako b/scenarios/hold_customer_list/request.mako deleted file mode 100644 index aafe91e..0000000 --- a/scenarios/hold_customer_list/request.mako +++ /dev/null @@ -1,5 +0,0 @@ -<%namespace file='/_main.mako' name='main'/> -<% main.python_boilerplate() %> - -customer = balanced.Customer.find('${request['uri']}') -holds = customer.holds.all() \ No newline at end of file diff --git a/scenarios/hold_list/definition.mako b/scenarios/hold_list/definition.mako deleted file mode 100644 index 2becc11..0000000 --- a/scenarios/hold_list/definition.mako +++ /dev/null @@ -1 +0,0 @@ -balanced.Hold.query() \ No newline at end of file diff --git a/scenarios/hold_list/executable.py b/scenarios/hold_list/executable.py deleted file mode 100644 index 2b8d57a..0000000 --- a/scenarios/hold_list/executable.py +++ /dev/null @@ -1,5 +0,0 @@ -import balanced - -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') - -holds = balanced.Hold.query.all(); \ No newline at end of file diff --git a/scenarios/hold_list/python.mako b/scenarios/hold_list/python.mako deleted file mode 100644 index 19a67af..0000000 --- a/scenarios/hold_list/python.mako +++ /dev/null @@ -1,9 +0,0 @@ -% if mode == 'definition': -balanced.Hold.query() -% else: -import balanced - -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') - -holds = balanced.Hold.query.all(); -% endif \ No newline at end of file diff --git a/scenarios/hold_show/definition.mako b/scenarios/hold_show/definition.mako deleted file mode 100644 index 063f416..0000000 --- a/scenarios/hold_show/definition.mako +++ /dev/null @@ -1 +0,0 @@ -balanced.Hold.find \ No newline at end of file diff --git a/scenarios/hold_show/executable.py b/scenarios/hold_show/executable.py deleted file mode 100644 index 0b5e9d1..0000000 --- a/scenarios/hold_show/executable.py +++ /dev/null @@ -1,5 +0,0 @@ -import balanced - -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') - -hold = balanced.Hold.find('/v1/marketplaces/TEST-MP52IlCmywk6hGbgS75QSlN/holds/HL2PtUrw5zStavbcn933ZsmW') \ No newline at end of file diff --git a/scenarios/hold_show/python.mako b/scenarios/hold_show/python.mako deleted file mode 100644 index 9eed585..0000000 --- a/scenarios/hold_show/python.mako +++ /dev/null @@ -1,9 +0,0 @@ -% if mode == 'definition': -balanced.Hold.find -% else: -import balanced - -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') - -hold = balanced.Hold.find('/v1/marketplaces/TEST-MP52IlCmywk6hGbgS75QSlN/holds/HL2PtUrw5zStavbcn933ZsmW') -% endif \ No newline at end of file diff --git a/scenarios/hold_update/definition.mako b/scenarios/hold_update/definition.mako deleted file mode 100644 index 74eeb28..0000000 --- a/scenarios/hold_update/definition.mako +++ /dev/null @@ -1 +0,0 @@ -balanced.Hold.save() \ No newline at end of file diff --git a/scenarios/hold_update/executable.py b/scenarios/hold_update/executable.py deleted file mode 100644 index 43a7839..0000000 --- a/scenarios/hold_update/executable.py +++ /dev/null @@ -1,11 +0,0 @@ -import balanced - -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') - -hold = balanced.Hold.find('/v1/marketplaces/TEST-MP52IlCmywk6hGbgS75QSlN/holds/HL2PtUrw5zStavbcn933ZsmW') -hold.description = 'update this description' -hold.meta = { - 'holding.for': 'user1', - 'meaningful.key': 'some.value', -} -hold.save() \ No newline at end of file diff --git a/scenarios/hold_update/python.mako b/scenarios/hold_update/python.mako deleted file mode 100644 index 0ebe446..0000000 --- a/scenarios/hold_update/python.mako +++ /dev/null @@ -1,15 +0,0 @@ -% if mode == 'definition': -balanced.Hold.save() -% else: -import balanced - -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') - -hold = balanced.Hold.find('/v1/marketplaces/TEST-MP52IlCmywk6hGbgS75QSlN/holds/HL2PtUrw5zStavbcn933ZsmW') -hold.description = 'update this description' -hold.meta = { - 'holding.for': 'user1', - 'meaningful.key': 'some.value', -} -hold.save() -% endif \ No newline at end of file diff --git a/scenarios/hold_update/request.mako b/scenarios/hold_update/request.mako deleted file mode 100644 index f06f5b2..0000000 --- a/scenarios/hold_update/request.mako +++ /dev/null @@ -1,10 +0,0 @@ -<%namespace file='/_main.mako' name='main'/> -<% main.python_boilerplate() %> - -hold = balanced.Hold.find('${request['uri']}') -hold.description = '${request['payload']['description']}' -hold.meta = { - 'holding.for': 'user1', - 'meaningful.key': 'some.value', -} -hold.save() \ No newline at end of file diff --git a/scenarios/hold_void/definition.mako b/scenarios/hold_void/definition.mako deleted file mode 100644 index 8292a5c..0000000 --- a/scenarios/hold_void/definition.mako +++ /dev/null @@ -1 +0,0 @@ -balanced.Hold.void() \ No newline at end of file diff --git a/scenarios/hold_void/executable.py b/scenarios/hold_void/executable.py deleted file mode 100644 index 6dcf5d7..0000000 --- a/scenarios/hold_void/executable.py +++ /dev/null @@ -1,6 +0,0 @@ -import balanced - -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') - -hold = balanced.Hold.find('/v1/marketplaces/TEST-MP52IlCmywk6hGbgS75QSlN/holds/HL39pZ8ec317eN4fi57TpmUU') -hold.void() \ No newline at end of file diff --git a/scenarios/hold_void/python.mako b/scenarios/hold_void/python.mako deleted file mode 100644 index fddc7d7..0000000 --- a/scenarios/hold_void/python.mako +++ /dev/null @@ -1,10 +0,0 @@ -% if mode == 'definition': -balanced.Hold.void() -% else: -import balanced - -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') - -hold = balanced.Hold.find('/v1/marketplaces/TEST-MP52IlCmywk6hGbgS75QSlN/holds/HL39pZ8ec317eN4fi57TpmUU') -hold.void() -% endif \ No newline at end of file diff --git a/scenarios/order_create/definition.mako b/scenarios/order_create/definition.mako new file mode 100644 index 0000000..f91c106 --- /dev/null +++ b/scenarios/order_create/definition.mako @@ -0,0 +1 @@ +balanced.Order() \ No newline at end of file diff --git a/scenarios/order_create/executable.py b/scenarios/order_create/executable.py new file mode 100644 index 0000000..ec309db --- /dev/null +++ b/scenarios/order_create/executable.py @@ -0,0 +1,8 @@ +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +merchant_customer = balanced.Customer.fetch('/customers/CU5AxbQrjAcjsbquafnvwaas') +merchant_customer.create_order( + description='Order #12341234' +).save() \ No newline at end of file diff --git a/scenarios/order_create/python.mako b/scenarios/order_create/python.mako new file mode 100644 index 0000000..0a2d64b --- /dev/null +++ b/scenarios/order_create/python.mako @@ -0,0 +1,14 @@ +% if mode == 'definition': +balanced.Order() +% elif mode == 'request': +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +merchant_customer = balanced.Customer.fetch('/customers/CU5AxbQrjAcjsbquafnvwaas') +merchant_customer.create_order( + description='Order #12341234' +).save() +% elif mode == 'response': +Order(delivery_address={u'city': None, u'line2': None, u'line1': None, u'state': None, u'postal_code': None, u'country_code': None}, description=u'Order #12341234', links={u'merchant': u'CU5AxbQrjAcjsbquafnvwaas'}, created_at=u'2015-01-09T03:25:31.087736Z', updated_at=u'2015-01-09T03:25:31.087737Z', currency=u'USD', amount=0, href=u'/orders/OR6nHTLOYehaSU5SoxqQE5WB', meta={}, id=u'OR6nHTLOYehaSU5SoxqQE5WB', amount_escrowed=0) +% endif \ No newline at end of file diff --git a/scenarios/order_create/request.mako b/scenarios/order_create/request.mako new file mode 100644 index 0000000..5fa1a74 --- /dev/null +++ b/scenarios/order_create/request.mako @@ -0,0 +1,7 @@ +<%namespace file='/_main.mako' name='main'/> +<% main.python_boilerplate() %> + +merchant_customer = balanced.Customer.fetch('${request['customer_href']}') +merchant_customer.create_order( + <% main.payload_expand(request['payload']) %> +).save() \ No newline at end of file diff --git a/scenarios/order_list/definition.mako b/scenarios/order_list/definition.mako new file mode 100644 index 0000000..5121d41 --- /dev/null +++ b/scenarios/order_list/definition.mako @@ -0,0 +1 @@ +balanced.Order.query diff --git a/scenarios/order_list/executable.py b/scenarios/order_list/executable.py new file mode 100644 index 0000000..92d5d98 --- /dev/null +++ b/scenarios/order_list/executable.py @@ -0,0 +1,5 @@ +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +orders = balanced.Order.query \ No newline at end of file diff --git a/scenarios/order_list/python.mako b/scenarios/order_list/python.mako new file mode 100644 index 0000000..8379c57 --- /dev/null +++ b/scenarios/order_list/python.mako @@ -0,0 +1,12 @@ +% if mode == 'definition': +balanced.Order.query + +% elif mode == 'request': +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +orders = balanced.Order.query +% elif mode == 'response': + +% endif \ No newline at end of file diff --git a/scenarios/order_list/request.mako b/scenarios/order_list/request.mako new file mode 100644 index 0000000..45c59b2 --- /dev/null +++ b/scenarios/order_list/request.mako @@ -0,0 +1,4 @@ +<%namespace file='/_main.mako' name='main'/> +<% main.python_boilerplate() %> + +orders = balanced.Order.query \ No newline at end of file diff --git a/scenarios/order_show/definition.mako b/scenarios/order_show/definition.mako new file mode 100644 index 0000000..cd568b8 --- /dev/null +++ b/scenarios/order_show/definition.mako @@ -0,0 +1 @@ +balanced.Order.fetch() diff --git a/scenarios/order_show/executable.py b/scenarios/order_show/executable.py new file mode 100644 index 0000000..b3ac814 --- /dev/null +++ b/scenarios/order_show/executable.py @@ -0,0 +1,5 @@ +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +order = balanced.Order.fetch('/orders/OR6nHTLOYehaSU5SoxqQE5WB') \ No newline at end of file diff --git a/scenarios/order_show/python.mako b/scenarios/order_show/python.mako new file mode 100644 index 0000000..36436db --- /dev/null +++ b/scenarios/order_show/python.mako @@ -0,0 +1,12 @@ +% if mode == 'definition': +balanced.Order.fetch() + +% elif mode == 'request': +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +order = balanced.Order.fetch('/orders/OR6nHTLOYehaSU5SoxqQE5WB') +% elif mode == 'response': +Order(delivery_address={u'city': None, u'line2': None, u'line1': None, u'state': None, u'postal_code': None, u'country_code': None}, description=u'Order #12341234', links={u'merchant': u'CU5AxbQrjAcjsbquafnvwaas'}, created_at=u'2015-01-09T03:25:31.087736Z', updated_at=u'2015-01-09T03:25:31.087737Z', currency=u'USD', amount=0, href=u'/orders/OR6nHTLOYehaSU5SoxqQE5WB', meta={}, id=u'OR6nHTLOYehaSU5SoxqQE5WB', amount_escrowed=0) +% endif \ No newline at end of file diff --git a/scenarios/order_show/request.mako b/scenarios/order_show/request.mako new file mode 100644 index 0000000..c48f518 --- /dev/null +++ b/scenarios/order_show/request.mako @@ -0,0 +1,4 @@ +<%namespace file='/_main.mako' name='main'/> +<% main.python_boilerplate() %> + +order = balanced.Order.fetch('${request['uri']}') \ No newline at end of file diff --git a/scenarios/order_update/definition.mako b/scenarios/order_update/definition.mako new file mode 100644 index 0000000..ed8a494 --- /dev/null +++ b/scenarios/order_update/definition.mako @@ -0,0 +1 @@ +balanced.Order().save() \ No newline at end of file diff --git a/scenarios/order_update/executable.py b/scenarios/order_update/executable.py new file mode 100644 index 0000000..90b2372 --- /dev/null +++ b/scenarios/order_update/executable.py @@ -0,0 +1,11 @@ +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +order = balanced.Order.fetch('/orders/OR6nHTLOYehaSU5SoxqQE5WB') +order.description = 'New description for order' +order.meta = { + 'anykey': 'valuegoeshere', + 'product.id': '1234567890' +} +order.save() \ No newline at end of file diff --git a/scenarios/order_update/python.mako b/scenarios/order_update/python.mako new file mode 100644 index 0000000..67be965 --- /dev/null +++ b/scenarios/order_update/python.mako @@ -0,0 +1,17 @@ +% if mode == 'definition': +balanced.Order().save() +% elif mode == 'request': +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +order = balanced.Order.fetch('/orders/OR6nHTLOYehaSU5SoxqQE5WB') +order.description = 'New description for order' +order.meta = { + 'anykey': 'valuegoeshere', + 'product.id': '1234567890' +} +order.save() +% elif mode == 'response': +Order(delivery_address={u'city': None, u'line2': None, u'line1': None, u'state': None, u'postal_code': None, u'country_code': None}, description=u'New description for order', links={u'merchant': u'CU5AxbQrjAcjsbquafnvwaas'}, created_at=u'2015-01-09T03:25:31.087736Z', updated_at=u'2015-01-09T03:25:34.898356Z', currency=u'USD', amount=0, href=u'/orders/OR6nHTLOYehaSU5SoxqQE5WB', meta={u'product.id': u'1234567890', u'anykey': u'valuegoeshere'}, id=u'OR6nHTLOYehaSU5SoxqQE5WB', amount_escrowed=0) +% endif \ No newline at end of file diff --git a/scenarios/order_update/request.mako b/scenarios/order_update/request.mako new file mode 100644 index 0000000..ba1759d --- /dev/null +++ b/scenarios/order_update/request.mako @@ -0,0 +1,10 @@ +<%namespace file='/_main.mako' name='main'/> +<% main.python_boilerplate() %> + +order = balanced.Order.fetch('${request['uri']}') +order.description = '${request['payload']['description']}' +order.meta = { + 'anykey': 'valuegoeshere', + 'product.id': '1234567890' +} +order.save() \ No newline at end of file diff --git a/scenarios/refund_account_list/definition.mako b/scenarios/refund_account_list/definition.mako deleted file mode 100644 index 8549ea4..0000000 --- a/scenarios/refund_account_list/definition.mako +++ /dev/null @@ -1 +0,0 @@ -balanced.Account.refunds \ No newline at end of file diff --git a/scenarios/refund_account_list/python.mako b/scenarios/refund_account_list/python.mako deleted file mode 100644 index dc0f653..0000000 --- a/scenarios/refund_account_list/python.mako +++ /dev/null @@ -1,5 +0,0 @@ -% if mode == 'definition': -balanced.Account.refunds -% else: - -% endif \ No newline at end of file diff --git a/scenarios/refund_create/definition.mako b/scenarios/refund_create/definition.mako index a5321df..991e687 100644 --- a/scenarios/refund_create/definition.mako +++ b/scenarios/refund_create/definition.mako @@ -1 +1 @@ -balanced.Debit.refund() \ No newline at end of file +balanced.Debit().refund() \ No newline at end of file diff --git a/scenarios/refund_create/executable.py b/scenarios/refund_create/executable.py index 4634e3e..545c010 100644 --- a/scenarios/refund_create/executable.py +++ b/scenarios/refund_create/executable.py @@ -1,13 +1,14 @@ import balanced -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') -debit = balanced.Debit.find('/v1/marketplaces/TEST-MP52IlCmywk6hGbgS75QSlN/debits/WD3dI1cfIvXo7p2f9tNMNSc2') -debit.refund( - description='Refund for Order #1111', +debit = balanced.Debit.fetch('/debits/WD5Nd61WpdlRk6D39YVNFAEo') +refund = debit.refund( + amount=3000, + description="Refund for Order #1111", meta={ - 'fulfillment.item.condition': 'OK', - 'user.refund_reason': 'not happy with product', - 'merchant.feedback': 'positive', - }, + "merchant.feedback": "positive", + "user.refund_reason": "not happy with product", + "fulfillment.item.condition": "OK", + } ) \ No newline at end of file diff --git a/scenarios/refund_create/python.mako b/scenarios/refund_create/python.mako index 9eb1146..3965138 100644 --- a/scenarios/refund_create/python.mako +++ b/scenarios/refund_create/python.mako @@ -1,17 +1,20 @@ % if mode == 'definition': -balanced.Debit.refund() -% else: +balanced.Debit().refund() +% elif mode == 'request': import balanced -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') -debit = balanced.Debit.find('/v1/marketplaces/TEST-MP52IlCmywk6hGbgS75QSlN/debits/WD3dI1cfIvXo7p2f9tNMNSc2') -debit.refund( - description='Refund for Order #1111', +debit = balanced.Debit.fetch('/debits/WD5Nd61WpdlRk6D39YVNFAEo') +refund = debit.refund( + amount=3000, + description="Refund for Order #1111", meta={ - 'fulfillment.item.condition': 'OK', - 'user.refund_reason': 'not happy with product', - 'merchant.feedback': 'positive', - }, + "merchant.feedback": "positive", + "user.refund_reason": "not happy with product", + "fulfillment.item.condition": "OK", + } ) +% elif mode == 'response': +Refund(status=u'succeeded', description=u'Refund for Order #1111', links={u'dispute': None, u'order': None, u'debit': u'WD5Nd61WpdlRk6D39YVNFAEo'}, amount=3000, created_at=u'2015-01-09T03:25:00.202596Z', updated_at=u'2015-01-09T03:25:00.686907Z', currency=u'USD', transaction_number=u'RFN4R-7JB-96UV', href=u'/refunds/RF5OXw4w1a9g2GsPqQ2Hg9hj', meta={u'fulfillment.item.condition': u'OK', u'user.refund_reason': u'not happy with product', u'merchant.feedback': u'positive'}, id=u'RF5OXw4w1a9g2GsPqQ2Hg9hj') % endif \ No newline at end of file diff --git a/scenarios/refund_create/request.mako b/scenarios/refund_create/request.mako index b52ac6f..1dc7289 100644 --- a/scenarios/refund_create/request.mako +++ b/scenarios/refund_create/request.mako @@ -1,12 +1,13 @@ <%namespace file='/_main.mako' name='main'/> <% main.python_boilerplate() %> -debit = balanced.Debit.find('${request['debit_uri']}') -debit.refund( - description='${request['payload']['description']}', +debit = balanced.Debit.fetch('${request['debit_href']}') +refund = debit.refund( + amount=3000, + description="Refund for Order #1111", meta={ - 'fulfillment.item.condition': 'OK', - 'user.refund_reason': 'not happy with product', - 'merchant.feedback': 'positive', - }, -) \ No newline at end of file + "merchant.feedback": "positive", + "user.refund_reason": "not happy with product", + "fulfillment.item.condition": "OK", + } +) diff --git a/scenarios/refund_customer_list/definition.mako b/scenarios/refund_customer_list/definition.mako deleted file mode 100644 index 2d52a91..0000000 --- a/scenarios/refund_customer_list/definition.mako +++ /dev/null @@ -1 +0,0 @@ -balanced.Customer.refunds \ No newline at end of file diff --git a/scenarios/refund_customer_list/executable.py b/scenarios/refund_customer_list/executable.py deleted file mode 100644 index 020e492..0000000 --- a/scenarios/refund_customer_list/executable.py +++ /dev/null @@ -1,6 +0,0 @@ -import balanced - -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') - -customer = balanced.Customer.find('/v1/customers/CU35rlJBXqlvD9LC26PWu0cy') -refunds = customer.refunds.all() \ No newline at end of file diff --git a/scenarios/refund_customer_list/python.mako b/scenarios/refund_customer_list/python.mako deleted file mode 100644 index dc46965..0000000 --- a/scenarios/refund_customer_list/python.mako +++ /dev/null @@ -1,10 +0,0 @@ -% if mode == 'definition': -balanced.Customer.refunds -% else: -import balanced - -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') - -customer = balanced.Customer.find('/v1/customers/CU35rlJBXqlvD9LC26PWu0cy') -refunds = customer.refunds.all() -% endif \ No newline at end of file diff --git a/scenarios/refund_customer_list/request.mako b/scenarios/refund_customer_list/request.mako deleted file mode 100644 index 590bed0..0000000 --- a/scenarios/refund_customer_list/request.mako +++ /dev/null @@ -1,5 +0,0 @@ -<%namespace file='/_main.mako' name='main'/> -<% main.python_boilerplate() %> - -customer = balanced.Customer.find('${request['customer_uri']}') -refunds = customer.refunds.all() \ No newline at end of file diff --git a/scenarios/refund_list/definition.mako b/scenarios/refund_list/definition.mako index cd0fc3c..30e82b5 100644 --- a/scenarios/refund_list/definition.mako +++ b/scenarios/refund_list/definition.mako @@ -1 +1 @@ -balanced.Refund.query() \ No newline at end of file +balanced.Refund.query diff --git a/scenarios/refund_list/executable.py b/scenarios/refund_list/executable.py index d836829..cff31bf 100644 --- a/scenarios/refund_list/executable.py +++ b/scenarios/refund_list/executable.py @@ -1,5 +1,5 @@ import balanced -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') -refunds = balanced.Refund.query.all(); \ No newline at end of file +refunds = balanced.Refund.query \ No newline at end of file diff --git a/scenarios/refund_list/python.mako b/scenarios/refund_list/python.mako index e23df58..002da20 100644 --- a/scenarios/refund_list/python.mako +++ b/scenarios/refund_list/python.mako @@ -1,9 +1,12 @@ % if mode == 'definition': -balanced.Refund.query() -% else: +balanced.Refund.query + +% elif mode == 'request': import balanced -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +refunds = balanced.Refund.query +% elif mode == 'response': -refunds = balanced.Refund.query.all(); % endif \ No newline at end of file diff --git a/scenarios/refund_list/request.mako b/scenarios/refund_list/request.mako index ef7a16f..02bf364 100644 --- a/scenarios/refund_list/request.mako +++ b/scenarios/refund_list/request.mako @@ -1,4 +1,4 @@ <%namespace file='/_main.mako' name='main'/> <% main.python_boilerplate() %> -refunds = balanced.Refund.query.all(); \ No newline at end of file +refunds = balanced.Refund.query \ No newline at end of file diff --git a/scenarios/refund_show/definition.mako b/scenarios/refund_show/definition.mako index 29a6b61..bcf8615 100644 --- a/scenarios/refund_show/definition.mako +++ b/scenarios/refund_show/definition.mako @@ -1 +1 @@ -balanced.Refund.find \ No newline at end of file +balanced.Refund.fetch() diff --git a/scenarios/refund_show/executable.py b/scenarios/refund_show/executable.py index 916875b..43e47b1 100644 --- a/scenarios/refund_show/executable.py +++ b/scenarios/refund_show/executable.py @@ -1,5 +1,5 @@ import balanced -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') -refund = balanced.Refund.find('/v1/customers/CU35rlJBXqlvD9LC26PWu0cy/refunds/RF3fVPCag0ppfvvWLSc2oQ4O') \ No newline at end of file +refund = balanced.Refund.fetch('/refunds/RF5OXw4w1a9g2GsPqQ2Hg9hj') \ No newline at end of file diff --git a/scenarios/refund_show/python.mako b/scenarios/refund_show/python.mako index 925dae3..29bd36a 100644 --- a/scenarios/refund_show/python.mako +++ b/scenarios/refund_show/python.mako @@ -1,9 +1,12 @@ % if mode == 'definition': -balanced.Refund.find -% else: +balanced.Refund.fetch() + +% elif mode == 'request': import balanced -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') -refund = balanced.Refund.find('/v1/customers/CU35rlJBXqlvD9LC26PWu0cy/refunds/RF3fVPCag0ppfvvWLSc2oQ4O') +refund = balanced.Refund.fetch('/refunds/RF5OXw4w1a9g2GsPqQ2Hg9hj') +% elif mode == 'response': +Refund(status=u'succeeded', description=u'Refund for Order #1111', links={u'dispute': None, u'order': None, u'debit': u'WD5Nd61WpdlRk6D39YVNFAEo'}, amount=3000, created_at=u'2015-01-09T03:25:00.202596Z', updated_at=u'2015-01-09T03:25:00.686907Z', currency=u'USD', transaction_number=u'RFN4R-7JB-96UV', href=u'/refunds/RF5OXw4w1a9g2GsPqQ2Hg9hj', meta={u'fulfillment.item.condition': u'OK', u'user.refund_reason': u'not happy with product', u'merchant.feedback': u'positive'}, id=u'RF5OXw4w1a9g2GsPqQ2Hg9hj') % endif \ No newline at end of file diff --git a/scenarios/refund_show/request.mako b/scenarios/refund_show/request.mako index f0b89cc..c351064 100644 --- a/scenarios/refund_show/request.mako +++ b/scenarios/refund_show/request.mako @@ -1,4 +1,4 @@ <%namespace file='/_main.mako' name='main'/> <% main.python_boilerplate() %> -refund = balanced.Refund.find('${request['uri']}') \ No newline at end of file +refund = balanced.Refund.fetch('${request['uri']}') \ No newline at end of file diff --git a/scenarios/refund_update/definition.mako b/scenarios/refund_update/definition.mako index 18cd86d..a0f7693 100644 --- a/scenarios/refund_update/definition.mako +++ b/scenarios/refund_update/definition.mako @@ -1 +1 @@ -balanced.Refund.save() \ No newline at end of file +balanced.Refund().save() \ No newline at end of file diff --git a/scenarios/refund_update/executable.py b/scenarios/refund_update/executable.py index 08479c1..113fbde 100644 --- a/scenarios/refund_update/executable.py +++ b/scenarios/refund_update/executable.py @@ -1,8 +1,8 @@ import balanced -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') -refund = balanced.Refund.find('/v1/customers/CU35rlJBXqlvD9LC26PWu0cy/refunds/RF3fVPCag0ppfvvWLSc2oQ4O') +refund = balanced.Refund.fetch('/refunds/RF5OXw4w1a9g2GsPqQ2Hg9hj') refund.description = 'update this description' refund.meta = { 'user.refund.count': '3', diff --git a/scenarios/refund_update/python.mako b/scenarios/refund_update/python.mako index 2dae174..35912a7 100644 --- a/scenarios/refund_update/python.mako +++ b/scenarios/refund_update/python.mako @@ -1,11 +1,11 @@ % if mode == 'definition': -balanced.Refund.save() -% else: +balanced.Refund().save() +% elif mode == 'request': import balanced -balanced.configure('ak-test-14W5azoiV99O1XiPwZ3faH10MaUdZ1kCA') +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') -refund = balanced.Refund.find('/v1/customers/CU35rlJBXqlvD9LC26PWu0cy/refunds/RF3fVPCag0ppfvvWLSc2oQ4O') +refund = balanced.Refund.fetch('/refunds/RF5OXw4w1a9g2GsPqQ2Hg9hj') refund.description = 'update this description' refund.meta = { 'user.refund.count': '3', @@ -13,4 +13,6 @@ refund.meta = { 'user.notes': 'very polite on the phone', } refund.save() +% elif mode == 'response': +Refund(status=u'succeeded', description=u'update this description', links={u'dispute': None, u'order': None, u'debit': u'WD5Nd61WpdlRk6D39YVNFAEo'}, amount=3000, created_at=u'2015-01-09T03:25:00.202596Z', updated_at=u'2015-01-09T03:25:39.570204Z', currency=u'USD', transaction_number=u'RFN4R-7JB-96UV', href=u'/refunds/RF5OXw4w1a9g2GsPqQ2Hg9hj', meta={u'user.refund.count': u'3', u'refund.reason': u'user not happy with product', u'user.notes': u'very polite on the phone'}, id=u'RF5OXw4w1a9g2GsPqQ2Hg9hj') % endif \ No newline at end of file diff --git a/scenarios/refund_update/request.mako b/scenarios/refund_update/request.mako index e45ac6c..575eaf4 100644 --- a/scenarios/refund_update/request.mako +++ b/scenarios/refund_update/request.mako @@ -1,7 +1,7 @@ <%namespace file='/_main.mako' name='main'/> <% main.python_boilerplate() %> -refund = balanced.Refund.find('${request['uri']}') +refund = balanced.Refund.fetch('${request['uri']}') refund.description = '${request['payload']['description']}' refund.meta = { 'user.refund.count': '3', diff --git a/scenarios/reversal_create/definition.mako b/scenarios/reversal_create/definition.mako new file mode 100644 index 0000000..41e8774 --- /dev/null +++ b/scenarios/reversal_create/definition.mako @@ -0,0 +1 @@ +balanced.Credit().reverse() \ No newline at end of file diff --git a/scenarios/reversal_create/executable.py b/scenarios/reversal_create/executable.py new file mode 100644 index 0000000..ea10993 --- /dev/null +++ b/scenarios/reversal_create/executable.py @@ -0,0 +1,14 @@ +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +credit = balanced.Credit.fetch('/credits/CR6zeufmfv0u1KHrUBCQtAgU') +reversal = credit.reverse( + amount=3000, + description="Reversal for Order #1111", + meta={ + "merchant.feedback": "positive", + "user.refund_reason": "not happy with product", + "fulfillment.item.condition": "OK", + } +) \ No newline at end of file diff --git a/scenarios/reversal_create/python.mako b/scenarios/reversal_create/python.mako new file mode 100644 index 0000000..cd11f05 --- /dev/null +++ b/scenarios/reversal_create/python.mako @@ -0,0 +1,20 @@ +% if mode == 'definition': +balanced.Credit().reverse() +% elif mode == 'request': +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +credit = balanced.Credit.fetch('/credits/CR6zeufmfv0u1KHrUBCQtAgU') +reversal = credit.reverse( + amount=3000, + description="Reversal for Order #1111", + meta={ + "merchant.feedback": "positive", + "user.refund_reason": "not happy with product", + "fulfillment.item.condition": "OK", + } +) +% elif mode == 'response': +Reversal(status=u'pending', description=u'Reversal for Order #1111', links={u'credit': u'CR6zeufmfv0u1KHrUBCQtAgU', u'order': None}, amount=3000, created_at=u'2015-01-09T03:25:42.331343Z', updated_at=u'2015-01-09T03:25:42.672661Z', failure_reason=None, currency=u'USD', transaction_number=u'RVYWS-BLM-PY8J', href=u'/reversals/RV6AleFrrhNHBDpr9W9ozGmY', meta={u'fulfillment.item.condition': u'OK', u'user.refund_reason': u'not happy with product', u'merchant.feedback': u'positive'}, failure_reason_code=None, id=u'RV6AleFrrhNHBDpr9W9ozGmY') +% endif \ No newline at end of file diff --git a/scenarios/reversal_create/request.mako b/scenarios/reversal_create/request.mako new file mode 100644 index 0000000..624b86a --- /dev/null +++ b/scenarios/reversal_create/request.mako @@ -0,0 +1,13 @@ +<%namespace file='/_main.mako' name='main'/> +<% main.python_boilerplate() %> + +credit = balanced.Credit.fetch('${request['credit_href']}') +reversal = credit.reverse( + amount=3000, + description="Reversal for Order #1111", + meta={ + "merchant.feedback": "positive", + "user.refund_reason": "not happy with product", + "fulfillment.item.condition": "OK", + } +) diff --git a/scenarios/reversal_list/definition.mako b/scenarios/reversal_list/definition.mako new file mode 100644 index 0000000..afb3218 --- /dev/null +++ b/scenarios/reversal_list/definition.mako @@ -0,0 +1 @@ +balanced.Reversal.query() diff --git a/scenarios/reversal_list/executable.py b/scenarios/reversal_list/executable.py new file mode 100644 index 0000000..66c2a9e --- /dev/null +++ b/scenarios/reversal_list/executable.py @@ -0,0 +1,5 @@ +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +reversals = balanced.Reversal.query \ No newline at end of file diff --git a/scenarios/reversal_list/python.mako b/scenarios/reversal_list/python.mako new file mode 100644 index 0000000..fe33c78 --- /dev/null +++ b/scenarios/reversal_list/python.mako @@ -0,0 +1,12 @@ +% if mode == 'definition': +balanced.Reversal.query() + +% elif mode == 'request': +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +reversals = balanced.Reversal.query +% elif mode == 'response': + +% endif \ No newline at end of file diff --git a/scenarios/reversal_list/request.mako b/scenarios/reversal_list/request.mako new file mode 100644 index 0000000..1b30130 --- /dev/null +++ b/scenarios/reversal_list/request.mako @@ -0,0 +1,4 @@ +<%namespace file='/_main.mako' name='main'/> +<% main.python_boilerplate() %> + +reversals = balanced.Reversal.query \ No newline at end of file diff --git a/scenarios/reversal_show/definition.mako b/scenarios/reversal_show/definition.mako new file mode 100644 index 0000000..78df43c --- /dev/null +++ b/scenarios/reversal_show/definition.mako @@ -0,0 +1 @@ +balanced.Reversal.fetch() diff --git a/scenarios/reversal_show/executable.py b/scenarios/reversal_show/executable.py new file mode 100644 index 0000000..4ae5290 --- /dev/null +++ b/scenarios/reversal_show/executable.py @@ -0,0 +1,5 @@ +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +refund = balanced.Reversal.fetch('/reversals/RV6AleFrrhNHBDpr9W9ozGmY') \ No newline at end of file diff --git a/scenarios/reversal_show/python.mako b/scenarios/reversal_show/python.mako new file mode 100644 index 0000000..9fea217 --- /dev/null +++ b/scenarios/reversal_show/python.mako @@ -0,0 +1,12 @@ +% if mode == 'definition': +balanced.Reversal.fetch() + +% elif mode == 'request': +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +refund = balanced.Reversal.fetch('/reversals/RV6AleFrrhNHBDpr9W9ozGmY') +% elif mode == 'response': +Reversal(status=u'pending', description=u'Reversal for Order #1111', links={u'credit': u'CR6zeufmfv0u1KHrUBCQtAgU', u'order': None}, amount=3000, created_at=u'2015-01-09T03:25:42.331343Z', updated_at=u'2015-01-09T03:25:42.672661Z', failure_reason=None, currency=u'USD', transaction_number=u'RVYWS-BLM-PY8J', href=u'/reversals/RV6AleFrrhNHBDpr9W9ozGmY', meta={u'fulfillment.item.condition': u'OK', u'user.refund_reason': u'not happy with product', u'merchant.feedback': u'positive'}, failure_reason_code=None, id=u'RV6AleFrrhNHBDpr9W9ozGmY') +% endif \ No newline at end of file diff --git a/scenarios/reversal_show/request.mako b/scenarios/reversal_show/request.mako new file mode 100644 index 0000000..1dfac86 --- /dev/null +++ b/scenarios/reversal_show/request.mako @@ -0,0 +1,4 @@ +<%namespace file='/_main.mako' name='main'/> +<% main.python_boilerplate() %> + +refund = balanced.Reversal.fetch('${request['uri']}') \ No newline at end of file diff --git a/scenarios/reversal_update/definition.mako b/scenarios/reversal_update/definition.mako new file mode 100644 index 0000000..26bc384 --- /dev/null +++ b/scenarios/reversal_update/definition.mako @@ -0,0 +1 @@ +balanced.Reversal().save() \ No newline at end of file diff --git a/scenarios/reversal_update/executable.py b/scenarios/reversal_update/executable.py new file mode 100644 index 0000000..134927a --- /dev/null +++ b/scenarios/reversal_update/executable.py @@ -0,0 +1,12 @@ +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +reversal = balanced.Reversal.fetch('/reversals/RV6AleFrrhNHBDpr9W9ozGmY') +reversal.description = 'update this description' +reversal.meta = { + 'user.refund.count': '3', + 'refund.reason': 'user not happy with product', + 'user.notes': 'very polite on the phone', +} +reversal.save() \ No newline at end of file diff --git a/scenarios/reversal_update/python.mako b/scenarios/reversal_update/python.mako new file mode 100644 index 0000000..c2147c8 --- /dev/null +++ b/scenarios/reversal_update/python.mako @@ -0,0 +1,18 @@ +% if mode == 'definition': +balanced.Reversal().save() +% elif mode == 'request': +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +reversal = balanced.Reversal.fetch('/reversals/RV6AleFrrhNHBDpr9W9ozGmY') +reversal.description = 'update this description' +reversal.meta = { + 'user.refund.count': '3', + 'refund.reason': 'user not happy with product', + 'user.notes': 'very polite on the phone', +} +reversal.save() +% elif mode == 'response': +Reversal(status=u'pending', description=u'update this description', links={u'credit': u'CR6zeufmfv0u1KHrUBCQtAgU', u'order': None}, amount=3000, created_at=u'2015-01-09T03:25:42.331343Z', updated_at=u'2015-01-09T03:25:46.424201Z', failure_reason=None, currency=u'USD', transaction_number=u'RVYWS-BLM-PY8J', href=u'/reversals/RV6AleFrrhNHBDpr9W9ozGmY', meta={u'user.satisfaction': u'6', u'refund.reason': u'user not happy with product', u'user.notes': u'very polite on the phone'}, failure_reason_code=None, id=u'RV6AleFrrhNHBDpr9W9ozGmY') +% endif \ No newline at end of file diff --git a/scenarios/reversal_update/request.mako b/scenarios/reversal_update/request.mako new file mode 100644 index 0000000..8a4f508 --- /dev/null +++ b/scenarios/reversal_update/request.mako @@ -0,0 +1,11 @@ +<%namespace file='/_main.mako' name='main'/> +<% main.python_boilerplate() %> + +reversal = balanced.Reversal.fetch('${request['uri']}') +reversal.description = '${request['payload']['description']}' +reversal.meta = { + 'user.refund.count': '3', + 'refund.reason': 'user not happy with product', + 'user.notes': 'very polite on the phone', +} +reversal.save() \ No newline at end of file diff --git a/scenarios/settlement_create/definition.mako b/scenarios/settlement_create/definition.mako new file mode 100644 index 0000000..29abd05 --- /dev/null +++ b/scenarios/settlement_create/definition.mako @@ -0,0 +1 @@ +balanced.Account.settle() \ No newline at end of file diff --git a/scenarios/settlement_create/executable.py b/scenarios/settlement_create/executable.py new file mode 100644 index 0000000..267ee37 --- /dev/null +++ b/scenarios/settlement_create/executable.py @@ -0,0 +1,14 @@ +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +payable_account = balanced.Account.fetch('/accounts/AT3ogJE07IErLJYR510QO6sM') +payable_account.settle( + appears_on_statement_as='ThingsCo', + funding_instrument='/bank_accounts/BA45anEaEr8g0lOhzhcE9VAN', + description='Payout A', + meta={ + 'group': 'alpha' + } +) +) \ No newline at end of file diff --git a/scenarios/settlement_create/python.mako b/scenarios/settlement_create/python.mako new file mode 100644 index 0000000..c659e2e --- /dev/null +++ b/scenarios/settlement_create/python.mako @@ -0,0 +1,20 @@ +% if mode == 'definition': +balanced.Account.settle() +% elif mode == 'request': +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +payable_account = balanced.Account.fetch('/accounts/AT3ogJE07IErLJYR510QO6sM') +payable_account.settle( + appears_on_statement_as='ThingsCo', + funding_instrument='/bank_accounts/BA45anEaEr8g0lOhzhcE9VAN', + description='Payout A', + meta={ + 'group': 'alpha' + } +) +) +% elif mode == 'response': +Settlement(status=u'pending', description=u'Payout A', links={u'source': u'AT3ogJE07IErLJYR510QO6sM', u'destination': u'BA45anEaEr8g0lOhzhcE9VAN'}, amount=1000, created_at=u'2015-01-09T03:25:48.587751Z', updated_at=u'2015-01-09T03:25:48.946792Z', failure_reason=None, currency=u'USD', transaction_number=u'SCRGN-RWP-FFSL', href=u'/settlements/ST6HmBuLJSEa82oUwId1AShW', meta={u'group': u'alpha'}, failure_reason_code=None, appears_on_statement_as=u'BAL*ThingsCo', id=u'ST6HmBuLJSEa82oUwId1AShW') +% endif \ No newline at end of file diff --git a/scenarios/settlement_create/request.mako b/scenarios/settlement_create/request.mako new file mode 100644 index 0000000..2cee79d --- /dev/null +++ b/scenarios/settlement_create/request.mako @@ -0,0 +1,13 @@ +<%namespace file='/_main.mako' name='main'/> +<% main.python_boilerplate() %> + +payable_account = balanced.Account.fetch('${request['href']}') +payable_account.settle( + appears_on_statement_as='${request['payload']['appears_on_statement_as']}', + funding_instrument='${request['payload']['funding_instrument']}', + description='${request['payload']['description']}', + meta={ + 'group': '${request['payload']['meta']['group']}' + } +) +) \ No newline at end of file diff --git a/scenarios/settlement_list/definition.mako b/scenarios/settlement_list/definition.mako new file mode 100644 index 0000000..03d6fd8 --- /dev/null +++ b/scenarios/settlement_list/definition.mako @@ -0,0 +1 @@ +balanced.Settlement.query diff --git a/scenarios/settlement_list/executable.py b/scenarios/settlement_list/executable.py new file mode 100644 index 0000000..7d9c1b4 --- /dev/null +++ b/scenarios/settlement_list/executable.py @@ -0,0 +1,5 @@ +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +settlements = balanced.Settlement.query \ No newline at end of file diff --git a/scenarios/settlement_list/python.mako b/scenarios/settlement_list/python.mako new file mode 100644 index 0000000..113ba98 --- /dev/null +++ b/scenarios/settlement_list/python.mako @@ -0,0 +1,12 @@ +% if mode == 'definition': +balanced.Settlement.query + +% elif mode == 'request': +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +settlements = balanced.Settlement.query +% elif mode == 'response': + +% endif \ No newline at end of file diff --git a/scenarios/settlement_list/request.mako b/scenarios/settlement_list/request.mako new file mode 100644 index 0000000..257a2d8 --- /dev/null +++ b/scenarios/settlement_list/request.mako @@ -0,0 +1,4 @@ +<%namespace file='/_main.mako' name='main'/> +<% main.python_boilerplate() %> + +settlements = balanced.Settlement.query \ No newline at end of file diff --git a/scenarios/settlement_list_account/definition.mako b/scenarios/settlement_list_account/definition.mako new file mode 100644 index 0000000..03d6fd8 --- /dev/null +++ b/scenarios/settlement_list_account/definition.mako @@ -0,0 +1 @@ +balanced.Settlement.query diff --git a/scenarios/settlement_list_account/executable.py b/scenarios/settlement_list_account/executable.py new file mode 100644 index 0000000..91bac2a --- /dev/null +++ b/scenarios/settlement_list_account/executable.py @@ -0,0 +1,6 @@ +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +account = balanced.Account.fetch('/accounts/AT3ogJE07IErLJYR510QO6sM') +account.settlements \ No newline at end of file diff --git a/scenarios/settlement_list_account/python.mako b/scenarios/settlement_list_account/python.mako new file mode 100644 index 0000000..ca953e1 --- /dev/null +++ b/scenarios/settlement_list_account/python.mako @@ -0,0 +1,13 @@ +% if mode == 'definition': +balanced.Settlement.query + +% elif mode == 'request': +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +account = balanced.Account.fetch('/accounts/AT3ogJE07IErLJYR510QO6sM') +account.settlements +% elif mode == 'response': + +% endif \ No newline at end of file diff --git a/scenarios/debit_refund/request.mako b/scenarios/settlement_list_account/request.mako similarity index 51% rename from scenarios/debit_refund/request.mako rename to scenarios/settlement_list_account/request.mako index 565e9cd..3e696f4 100644 --- a/scenarios/debit_refund/request.mako +++ b/scenarios/settlement_list_account/request.mako @@ -1,5 +1,5 @@ <%namespace file='/_main.mako' name='main'/> <% main.python_boilerplate() %> -debit = balanced.Debit.find('${request['debit_uri']}') -debit.refund() \ No newline at end of file +account = balanced.Account.fetch('${request['href']}') +account.settlements \ No newline at end of file diff --git a/scenarios/settlement_show/definition.mako b/scenarios/settlement_show/definition.mako new file mode 100644 index 0000000..633208d --- /dev/null +++ b/scenarios/settlement_show/definition.mako @@ -0,0 +1 @@ +balanced.Settlement.fetch() diff --git a/scenarios/settlement_show/executable.py b/scenarios/settlement_show/executable.py new file mode 100644 index 0000000..b0a772e --- /dev/null +++ b/scenarios/settlement_show/executable.py @@ -0,0 +1,5 @@ +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +settlement = balanced.Settlement.fetch('/settlements/ST6HmBuLJSEa82oUwId1AShW') \ No newline at end of file diff --git a/scenarios/settlement_show/python.mako b/scenarios/settlement_show/python.mako new file mode 100644 index 0000000..4c1b287 --- /dev/null +++ b/scenarios/settlement_show/python.mako @@ -0,0 +1,12 @@ +% if mode == 'definition': +balanced.Settlement.fetch() + +% elif mode == 'request': +import balanced + +balanced.configure('ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY') + +settlement = balanced.Settlement.fetch('/settlements/ST6HmBuLJSEa82oUwId1AShW') +% elif mode == 'response': +Settlement(status=u'pending', description=u'Payout A', links={u'source': u'AT3ogJE07IErLJYR510QO6sM', u'destination': u'BA45anEaEr8g0lOhzhcE9VAN'}, amount=1000, created_at=u'2015-01-09T03:25:48.587751Z', updated_at=u'2015-01-09T03:25:48.946792Z', failure_reason=None, currency=u'USD', transaction_number=u'SCRGN-RWP-FFSL', href=u'/settlements/ST6HmBuLJSEa82oUwId1AShW', meta={u'group': u'alpha'}, failure_reason_code=None, appears_on_statement_as=u'BAL*ThingsCo', id=u'ST6HmBuLJSEa82oUwId1AShW') +% endif \ No newline at end of file diff --git a/scenarios/settlement_show/request.mako b/scenarios/settlement_show/request.mako new file mode 100644 index 0000000..69a0d4c --- /dev/null +++ b/scenarios/settlement_show/request.mako @@ -0,0 +1,4 @@ +<%namespace file='/_main.mako' name='main'/> +<% main.python_boilerplate() %> + +settlement = balanced.Settlement.fetch('${request['uri']}') \ No newline at end of file diff --git a/setup.py b/setup.py index 635a0e5..2215162 100644 --- a/setup.py +++ b/setup.py @@ -4,10 +4,7 @@ See ``README.md`` for usage advice. """ import os -import pickle import re -import subprocess -from distutils.core import Command try: import setuptools @@ -19,48 +16,6 @@ setup = setuptools.setup -class DocumentationCommand(Command): - description = 'build documentation and upload to s3' - path_to_pickled_file = 'docs/build/pickle/api_reference.fpickle' - destination_file = 'docs/build/python_api_reference.html' - user_options = [] - - def initialize_options(self): - pass - - def finalize_options(self): - pass - - def run(self): - self._build_docs() - self._upload_to_s3(self._unpickle(), - 'justice.web', - 'docs/python_api_reference.html') - - def _build_docs(self): - p = subprocess.Popen('make clean'.split(), cwd='docs') - p.wait() - p = subprocess.Popen('make pickle'.split(), cwd='docs') - p.wait() - - def _unpickle(self): - with open(self.path_to_pickled_file) as f: - pickled = f.read() - unpickled = pickle.loads(pickled) - return unpickled['body'] - - def _upload_to_s3(self, data, bucket, key_name): - from boto.s3.connection import S3Connection - from boto.s3.key import Key - - conn = S3Connection() - bucket = conn.get_bucket(bucket) - - key = Key(bucket) - key.key = key_name - key.set_contents_from_string(data) - key.set_acl('public-read') - def _get_version(): path = os.path.join(PATH_TO_FILE, 'balanced', '__init__.py') @@ -112,9 +67,9 @@ def parse_dependency_links(file_name): name='balanced', version=VERSION, url='https://balancedpayments.com/', - license='BSD', - author='Mahmoud Abdelkader', - author_email='support@balancedpayments.com', + license='MIT License', + author='Balanced', + author_email='dev@balancedpayments.com', description='Payments platform for marketplaces', long_description=LONG_DESCRIPTION, packages=['balanced'], @@ -123,11 +78,8 @@ def parse_dependency_links(file_name): dependency_links=parse_dependency_links('requirements.txt'), classifiers=[ 'Intended Audience :: Developers', - 'License :: OSI Approved :: BSD License', + 'License :: OSI Approved :: MIT License', 'Programming Language :: Python', 'Topic :: Software Development :: Libraries :: Python Modules', ], - cmdclass={ - 'docs': DocumentationCommand, - } ) diff --git a/snippets/account-balance.py b/snippets/account-balance.py new file mode 100644 index 0000000..059adb9 --- /dev/null +++ b/snippets/account-balance.py @@ -0,0 +1 @@ +account.balance \ No newline at end of file diff --git a/snippets/bank-account-create.py b/snippets/bank-account-create.py new file mode 100644 index 0000000..5c67d51 --- /dev/null +++ b/snippets/bank-account-create.py @@ -0,0 +1,6 @@ +bank_account = balanced.BankAccount( + routing_number='121000358', + type='checking', + account_number='9900000001', + name='Johann Bernoulli' +).save() \ No newline at end of file diff --git a/snippets/bank-account-debit.py b/snippets/bank-account-debit.py new file mode 100644 index 0000000..4948ff7 --- /dev/null +++ b/snippets/bank-account-debit.py @@ -0,0 +1,9 @@ +# bank_account_href is the stored href for the BankAccount +# order_href is the stored href for the Order +bank_account = balanced.BankAccount.fetch(bank_account_href) +bank_account.debit( + appears_on_statement_as='Statement text', + amount=5000, + description='Some descriptive text for the debit in the dashboard', + order=order_href +) \ No newline at end of file diff --git a/snippets/bank-account-verification-confirm.py b/snippets/bank-account-verification-confirm.py new file mode 100644 index 0000000..09f2f24 --- /dev/null +++ b/snippets/bank-account-verification-confirm.py @@ -0,0 +1,3 @@ +# time has elapsed, so find the BankAccountVerification +verification = balanced.BankAccountVerification.find('/verifications/BZ2Sy2Z4Bp2mARnCLztiu2VG') +verification.confirm(amount_1=1, amount_2=1) \ No newline at end of file diff --git a/snippets/bank-account-verification-create.py b/snippets/bank-account-verification-create.py new file mode 100644 index 0000000..f1cc90f --- /dev/null +++ b/snippets/bank-account-verification-create.py @@ -0,0 +1 @@ +verification = bank_account.verify \ No newline at end of file diff --git a/snippets/callback-create.py b/snippets/callback-create.py new file mode 100644 index 0000000..acb3ee8 --- /dev/null +++ b/snippets/callback-create.py @@ -0,0 +1,4 @@ +callback = balanced.Callback( + url='http://www.example.com/callback', + method='post' +).save() \ No newline at end of file diff --git a/snippets/card-associate-to-customer.py b/snippets/card-associate-to-customer.py new file mode 100644 index 0000000..634ae43 --- /dev/null +++ b/snippets/card-associate-to-customer.py @@ -0,0 +1,2 @@ +card = balanced.Card.fetch(card_href) +card.associate_to_customer(customer_href) \ No newline at end of file diff --git a/snippets/card-create-dispute.py b/snippets/card-create-dispute.py new file mode 100644 index 0000000..1291923 --- /dev/null +++ b/snippets/card-create-dispute.py @@ -0,0 +1,6 @@ +card = balanced.Card( + cvv='123', + expiration_month='12', + number='6500000000000002', + expiration_year='2020' +).save() \ No newline at end of file diff --git a/snippets/card-create.py b/snippets/card-create.py new file mode 100644 index 0000000..b02f975 --- /dev/null +++ b/snippets/card-create.py @@ -0,0 +1,6 @@ +card = balanced.Card( + expiration_month='12', + security_code='123', + number='5105105105105100', + expiration_year='2020' +).save() \ No newline at end of file diff --git a/snippets/card-credit.py b/snippets/card-credit.py new file mode 100644 index 0000000..185a1cd --- /dev/null +++ b/snippets/card-credit.py @@ -0,0 +1,9 @@ +# card_href is the stored href for the Card +# order_href is the stored href for the Order +card = balanced.Card.fetch(card_href) +card.credit( + appears_on_statement_as='Some text', + amount=5000, + description='Some descriptive text for the debit in the dashboard', + order=order_href +) \ No newline at end of file diff --git a/snippets/card-debit.py b/snippets/card-debit.py new file mode 100644 index 0000000..58ad26c --- /dev/null +++ b/snippets/card-debit.py @@ -0,0 +1,9 @@ +# card_href is the stored href for the Card +# order_href is the stored href for the Order +card = balanced.Card.fetch(card_href) +card.debit( + appears_on_statement_as='Statement text', + amount=5000, + description='Some descriptive text for the debit in the dashboard', + order=order_href +) \ No newline at end of file diff --git a/snippets/card-hold-capture.py b/snippets/card-hold-capture.py new file mode 100644 index 0000000..545048a --- /dev/null +++ b/snippets/card-hold-capture.py @@ -0,0 +1,6 @@ +# card_hold_href is the stored href for the CardHold +card_hold = balanced.CardHold.fetch(card_hold_href) +debit = card_hold.capture( + appears_on_statement_as='ShowsUpOnStmt', + description='Some descriptive text for the debit in the dashboard' +) \ No newline at end of file diff --git a/snippets/card-hold-create.py b/snippets/card-hold-create.py new file mode 100644 index 0000000..5d833e8 --- /dev/null +++ b/snippets/card-hold-create.py @@ -0,0 +1,6 @@ +# card_href is the stored href for the Card +card = balanced.Card.fetch(card_href) +card_hold = card.hold( + amount=5000, + description='Some descriptive text for the debit in the dashboard' +) \ No newline at end of file diff --git a/snippets/card-hold-void.py b/snippets/card-hold-void.py new file mode 100644 index 0000000..0cd8dc9 --- /dev/null +++ b/snippets/card-hold-void.py @@ -0,0 +1,3 @@ +# card_hold_href is the stored href for the CardHold +card_hold = balanced.CardHold.fetch(card_hold_href) +card_hold.cancel() \ No newline at end of file diff --git a/snippets/create-buyer-and-card.py b/snippets/create-buyer-and-card.py new file mode 100644 index 0000000..8414e0c --- /dev/null +++ b/snippets/create-buyer-and-card.py @@ -0,0 +1,13 @@ +buyer = balanced.Customer( + name='John Buyer' +).save() + +card = balanced.Card( + expiration_month='12', + security_code='123', + number='5105105105105100', + expiration_year='2020', + name='John Buyer' +).save() + +card.associate_to(buyer) \ No newline at end of file diff --git a/snippets/credit-create.py b/snippets/credit-create.py new file mode 100644 index 0000000..6e1887e --- /dev/null +++ b/snippets/credit-create.py @@ -0,0 +1,8 @@ +# bank_account_href is the stored href for the BankAccount +# order_href is the stored href for the Order +bank_account = balanced.BankAccount.fetch(bank_account_href) +credit = bank_account.credit( + amount=100000, + description='Payout for order #1111', + order=order_href +) \ No newline at end of file diff --git a/snippets/credit-fetch.py b/snippets/credit-fetch.py new file mode 100644 index 0000000..3f404e7 --- /dev/null +++ b/snippets/credit-fetch.py @@ -0,0 +1 @@ +credit = balanced.Credit.fetch(credit_href) \ No newline at end of file diff --git a/snippets/credit-marketplace-escrow.py b/snippets/credit-marketplace-escrow.py new file mode 100644 index 0000000..f1e522c --- /dev/null +++ b/snippets/credit-marketplace-escrow.py @@ -0,0 +1,4 @@ +balanced.Marketplace.mine.owner_customer.bank_accounts[0].credit( + amount=2000000, + description='Credit from Balanced escrow' +) \ No newline at end of file diff --git a/snippets/credit-reverse.py b/snippets/credit-reverse.py new file mode 100644 index 0000000..1c28d61 --- /dev/null +++ b/snippets/credit-reverse.py @@ -0,0 +1 @@ +reversal = credit.reverse() \ No newline at end of file diff --git a/snippets/credit-soft-descriptor.py b/snippets/credit-soft-descriptor.py new file mode 100644 index 0000000..abd2f79 --- /dev/null +++ b/snippets/credit-soft-descriptor.py @@ -0,0 +1,9 @@ +# bank_account_href is the stored href for the BankAccount +# order_href is the stored href for the Order +bank_account = balanced.BankAccount.fetch(bank_account_href) +credit = bank_account.credit( + amount=100000, + description='Payout for order #1111', + appears_on_statement_as='GoodCo #1111', + order=order_href +) \ No newline at end of file diff --git a/snippets/credit-split.py b/snippets/credit-split.py new file mode 100644 index 0000000..685dda4 --- /dev/null +++ b/snippets/credit-split.py @@ -0,0 +1,13 @@ +# bank_account_href_a is the stored href for the BankAccount for Person A +bank_account_person_a = balanced.BankAccount.fetch(bank_account_href_a) +credit = bank_account_person_a.credit( + amount=50000, + description='Payout for order #1111' +) + +# bank_account_href_b is the stored href for the BankAccount for Person B +bank_account_person_b = balanced.BankAccount.fetch(bank_account_href_b) +credit = bank_account_person_b.credit( + amount=50000, + description='Payout for order #1111' +) \ No newline at end of file diff --git a/snippets/customer-create.py b/snippets/customer-create.py new file mode 100644 index 0000000..ca1d179 --- /dev/null +++ b/snippets/customer-create.py @@ -0,0 +1,8 @@ +merchant = balanced.Customer( + dob_year=1963, + dob_month=7, + name='Henry Ford', + address={ + 'postal_code': '48120' + } +).save() \ No newline at end of file diff --git a/snippets/debit-dispute-show.py b/snippets/debit-dispute-show.py new file mode 100644 index 0000000..538169d --- /dev/null +++ b/snippets/debit-dispute-show.py @@ -0,0 +1,3 @@ +# debit_href is the stored href of the debit +debit = balanced.Debit.fetch(debit_href) +dispute = debit.dispute \ No newline at end of file diff --git a/snippets/debit-fetch.py b/snippets/debit-fetch.py new file mode 100644 index 0000000..3d1450b --- /dev/null +++ b/snippets/debit-fetch.py @@ -0,0 +1 @@ +debit = balanced.Debit.fetch(debit_href) \ No newline at end of file diff --git a/snippets/debit-marketplace-escrow.py b/snippets/debit-marketplace-escrow.py new file mode 100644 index 0000000..f612b65 --- /dev/null +++ b/snippets/debit-marketplace-escrow.py @@ -0,0 +1,4 @@ +balanced.Marketplace.mine.owner_customer.bank_accounts[0].debit( + amount=2000000, + description='Pre-fund Balanced escrow' +) \ No newline at end of file diff --git a/snippets/debit-refund.py b/snippets/debit-refund.py new file mode 100644 index 0000000..f5eb7fb --- /dev/null +++ b/snippets/debit-refund.py @@ -0,0 +1 @@ +debit.refund() \ No newline at end of file diff --git a/snippets/dispute-list.py b/snippets/dispute-list.py new file mode 100644 index 0000000..753e764 --- /dev/null +++ b/snippets/dispute-list.py @@ -0,0 +1 @@ +disputes = balanced.Dispute.query \ No newline at end of file diff --git a/snippets/dispute-show.py b/snippets/dispute-show.py new file mode 100644 index 0000000..7f66314 --- /dev/null +++ b/snippets/dispute-show.py @@ -0,0 +1,2 @@ +# dispute_href is the stored href of the dispute +dispute = balanced.Dispute.fetch(dispute_href) \ No newline at end of file diff --git a/snippets/examine-order-after-refund.py b/snippets/examine-order-after-refund.py new file mode 100644 index 0000000..03e46f5 --- /dev/null +++ b/snippets/examine-order-after-refund.py @@ -0,0 +1,3 @@ +order = balanced.Order.fetch(order_href) +order.amount # original order amount +order.amount_escrowed # will decrease by amount of reversed credit \ No newline at end of file diff --git a/snippets/examine-order-after-reversal.py b/snippets/examine-order-after-reversal.py new file mode 100644 index 0000000..9c0d264 --- /dev/null +++ b/snippets/examine-order-after-reversal.py @@ -0,0 +1,3 @@ +order = balanced.Order.fetch(order_href) +order.amount # original order amount +order.amount_escrowed # will increase by amount of reversed credit \ No newline at end of file diff --git a/snippets/marketplace-in-escrow.py b/snippets/marketplace-in-escrow.py new file mode 100644 index 0000000..401a4b3 --- /dev/null +++ b/snippets/marketplace-in-escrow.py @@ -0,0 +1 @@ +balanced.Marketplace.my_marketplace.in_escrow \ No newline at end of file diff --git a/snippets/merchant-payable-account-fetch.py b/snippets/merchant-payable-account-fetch.py new file mode 100644 index 0000000..07f461f --- /dev/null +++ b/snippets/merchant-payable-account-fetch.py @@ -0,0 +1,2 @@ +# merchant is a Customer instance +merchant.payable_account \ No newline at end of file diff --git a/snippets/order-amount-escrowed.py b/snippets/order-amount-escrowed.py new file mode 100644 index 0000000..9cb3b33 --- /dev/null +++ b/snippets/order-amount-escrowed.py @@ -0,0 +1,3 @@ +order.reload # reload the order to get recent changes +order.amount +order.amount_escrowed \ No newline at end of file diff --git a/snippets/order-bank-account-create.py b/snippets/order-bank-account-create.py new file mode 100644 index 0000000..350cc21 --- /dev/null +++ b/snippets/order-bank-account-create.py @@ -0,0 +1,8 @@ +bank_account = balanced.BankAccount( + routing_number='121000358', + type='checking', + account_number='9900000001', + name='Henry Ford' +).save() + +bank_account.associate_to(merchant) \ No newline at end of file diff --git a/snippets/order-create.py b/snippets/order-create.py new file mode 100644 index 0000000..a888a46 --- /dev/null +++ b/snippets/order-create.py @@ -0,0 +1 @@ +order = merchant.create_order() \ No newline at end of file diff --git a/snippets/order-credit-marketplace.py b/snippets/order-credit-marketplace.py new file mode 100644 index 0000000..2a7b714 --- /dev/null +++ b/snippets/order-credit-marketplace.py @@ -0,0 +1,6 @@ +marketplace_bank_account = balanced.Marketplace.mine.owner_customer.bank_accounts[0] +order.credit_to( + amount=2000, + description="Credit from order escrow to marketplace bank account", + destination=marketplace_bank_account +) \ No newline at end of file diff --git a/snippets/order-credit-merchant-payable-account.py b/snippets/order-credit-merchant-payable-account.py new file mode 100644 index 0000000..6264dfb --- /dev/null +++ b/snippets/order-credit-merchant-payable-account.py @@ -0,0 +1,4 @@ +order.credit_to( + destination=account_href, + amount=8000 +) \ No newline at end of file diff --git a/snippets/order-credit.py b/snippets/order-credit.py new file mode 100644 index 0000000..19a6dba --- /dev/null +++ b/snippets/order-credit.py @@ -0,0 +1,4 @@ +order.credit_to( + destination=bank_account_href, + amount=8000 +) \ No newline at end of file diff --git a/snippets/order-credits-fetch.py b/snippets/order-credits-fetch.py new file mode 100644 index 0000000..1b76eef --- /dev/null +++ b/snippets/order-credits-fetch.py @@ -0,0 +1 @@ +order.credits \ No newline at end of file diff --git a/snippets/order-debit.py b/snippets/order-debit.py new file mode 100644 index 0000000..d5a76bd --- /dev/null +++ b/snippets/order-debit.py @@ -0,0 +1,4 @@ +debit = order.debit_from( + source=card, + amount=10000 +) \ No newline at end of file diff --git a/snippets/order-debits-fetch.py b/snippets/order-debits-fetch.py new file mode 100644 index 0000000..ef19236 --- /dev/null +++ b/snippets/order-debits-fetch.py @@ -0,0 +1 @@ +order.debits \ No newline at end of file diff --git a/snippets/order-fetch.py b/snippets/order-fetch.py new file mode 100644 index 0000000..809edb8 --- /dev/null +++ b/snippets/order-fetch.py @@ -0,0 +1 @@ +order = balanced.Order.fetch(order_href) \ No newline at end of file diff --git a/snippets/order-update.py b/snippets/order-update.py new file mode 100644 index 0000000..aa543ca --- /dev/null +++ b/snippets/order-update.py @@ -0,0 +1,5 @@ +order.description = 'Item description' +order.meta = { + 'item_url': 'https://neatitems.com/12342134123' +} +order.save() \ No newline at end of file diff --git a/snippets/refund-create.py b/snippets/refund-create.py new file mode 100644 index 0000000..95bad17 --- /dev/null +++ b/snippets/refund-create.py @@ -0,0 +1,13 @@ +# debit_href is the stored href for the Debit +# order_href is the stored href for the Order +debit = balanced.Debit.fetch(debit_href) +refund = debit.refund( + amount=3000, + description="Refund for Order #1111", + meta={ + "merchant.feedback": "positive", + "user.refund_reason": "not happy with product", + "fulfillment.item.condition": "OK", + }, + order=order_href +) \ No newline at end of file diff --git a/snippets/reversal-create.py b/snippets/reversal-create.py new file mode 100644 index 0000000..bc175d3 --- /dev/null +++ b/snippets/reversal-create.py @@ -0,0 +1,13 @@ +# credit_href is the stored href for the Credit +# order_href is the stored href for the Order +credit = balanced.Credit.fetch(credit_href) +reversal = credit.reverse( + amount=100000, + description="Reversal for order #1111", + meta={ + "merchant.feedback": "positive", + "user.refund_reason": "not happy with product", + "fulfillment.item.condition": "OK" + }, + order=order_href +) \ No newline at end of file diff --git a/snippets/settlement-create.py b/snippets/settlement-create.py new file mode 100644 index 0000000..e3d5294 --- /dev/null +++ b/snippets/settlement-create.py @@ -0,0 +1,5 @@ +account.settle( + appears_on_statement_as='ThingsCo', + description='A simple description', + funding_instrument=bank_account_href +) \ No newline at end of file diff --git a/test-requirements.txt b/test-requirements.txt index ac41c4b..e824df9 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,5 +1,4 @@ -nose==1.1.2 -bottle==0.10.9 +nose nose-setenv -mock==0.8.0 +mock unittest2 diff --git a/tests/_responses/__init__.py b/tests/_responses/__init__.py deleted file mode 100644 index 433f6ca..0000000 --- a/tests/_responses/__init__.py +++ /dev/null @@ -1,12 +0,0 @@ -import marketplaces -import merchants -import transactions -import accounts - - -__all__ = [ - marketplaces.__name__, - merchants.__name__, - transactions.__name__, - accounts.__name__, - ] diff --git a/tests/_responses/accounts.py b/tests/_responses/accounts.py deleted file mode 100644 index e7a16fc..0000000 --- a/tests/_responses/accounts.py +++ /dev/null @@ -1,21 +0,0 @@ - - -def show(marketplace_eid, account_eid): - mp_uri = '/v1/marketplaces/' + marketplace_eid - ac_uri = mp_uri + '/accounts/' + account_eid - - return { - 'transactions_uri': ac_uri + '/transactions', - 'name': 'Nicolaas Bloembergen', - 'roles': [ - 'buyer' - ], - 'created_at': '2012-03-27T11:11:34.104277Z', - 'holds_uri': ac_uri + '/holds', - 'uri': ac_uri, - 'refunds_uri': ac_uri + '/refunds', - 'meta': {}, - 'debits_uri': ac_uri + '/debits', - 'email_address': 'nicolaas.bloembergen214@hotmail.web', - 'credits_uri': ac_uri + '/credits' - } diff --git a/tests/_responses/marketplaces.py b/tests/_responses/marketplaces.py deleted file mode 100644 index 9472f12..0000000 --- a/tests/_responses/marketplaces.py +++ /dev/null @@ -1,92 +0,0 @@ -import random -import urllib - - -def anonymous_create(): - return { - 'uri': '/v1/marketplaces/TEST-M123-456-7890', - 'name': 'Test Marketplace', - 'support_email_address': 'support@example.com', - 'support_phone_number': '+16505551234', - 'domain_url': 'example.com', - 'in_escrow': 0, - 'account': { - 'uri': ('/v1/marketplaces/TEST-M123-456-7890' - '/accounts/A123-456-7890'), - 'api_key': 'd8e7d4406a1e11e193bee4ce8f4a4f46', - }, - 'debits_uri': '/v1/marketplaces/M123-456-7890/debits', - 'credits_uri': '/v1/marketplaces/M123-456-7890/credits', - 'refunds_uri': '/v1/marketplaces/M123-456-7890/refunds', - 'accounts_uri': '/v1/marketplaces/M123-456-7890/accounts', - 'holds_uri': '/v1/marketplaces/M123-456-7890/holds', - 'api_keys_uri': '/v1/marketplaces/TEST-M123-456-7890/api_keys', - 'meta': {} - } - - -def index(limit=10, offset=0, num=1, pages=1): - params = { - 'limit': limit, - 'offset': offset, - 'num': num, - } - - pages -= 1 - qs = urllib.urlencode(params.copy()) - params.update({ - 'offset': params['limit'] + params['offset'], - 'pages': pages, - }) - - response = { - 'total': num, - 'offset': offset, - 'limit': limit, - 'first_uri': '/v1/marketplaces?' + qs, - 'last_uri': '/v1/marketplaces?' + qs, - 'next_uri': None, - 'previous_uri': None, - 'uri': '/v1/marketplaces?' + qs, - } - - if pages: - qs_next = urllib.urlencode(params) - response['next_uri'] = '/v1/marketplaces?' + qs_next - - items = [] - for _ in xrange(num): - rand = int(random.random() * 10000) - mp_uri = '/v1/marketplaces/TEST-MP-123-456-{0}'.format(rand) - rand = int(random.random() * 10000) - ac_uri = mp_uri + '/accounts/AC123-456-{0}'.format(rand) - - items.append({ - 'uri': mp_uri, - 'name': 'Test Marketplace', - 'support_email_address': 'support@example.com', - 'support_phone_number': '+16505551234', - 'domain_url': 'example.com', - 'in_escrow': 0, - 'account': { - 'uri': ac_uri, - 'name': 'Test Business', - 'email_address': 'owner@example.com', - 'roles': ['merchant'], - 'balance': 0, - 'debits_uri': ac_uri + '/debits', - 'credits_uri': ac_uri + '/credits', - 'holds_uri': 'ac_uri' + '/holds', - 'meta': {} - }, - 'debits_uri': mp_uri + '/debits', - 'credits_uri': mp_uri + '/credits', - 'refunds_uri': mp_uri + '/refunds', - 'accounts_uri': mp_uri + '/accounts', - 'holds_uri': mp_uri + '/holds', - 'api_keys_uri': mp_uri + '/api_keys', - 'meta': {} - }) - - response['items'] = items - return response diff --git a/tests/_responses/merchants.py b/tests/_responses/merchants.py deleted file mode 100644 index eb0576c..0000000 --- a/tests/_responses/merchants.py +++ /dev/null @@ -1,9 +0,0 @@ -import os -import json - -FILE_PATH = os.path.dirname(__file__) - - -def index(): - path = os.path.join(FILE_PATH, 'merchants1.json') - return json.loads(open(path).read()) diff --git a/tests/_responses/merchants1.json b/tests/_responses/merchants1.json deleted file mode 100644 index 87bbbbb..0000000 --- a/tests/_responses/merchants1.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "first_uri": "/v1/merchants?limit=10&offset=0", - "items": [ - { - "phone_number": "+16505551212", - "city": null, - "marketplace": { - "domain_url": "http://www.balancedpayments.com", - "name": "Planet Profit", - "owner_account_uri": "/v1/marketplaces/TEST-MP318-823-1966/accounts/AC360-823-8847", - "holds_uri": "/v1/marketplaces/TEST-MP318-823-1966/holds", - "support_email_address": "marshall@poundpay.com", - "uri": "/v1/marketplaces/TEST-MP318-823-1966", - "in_escrow": -743778, - "accounts_uri": "/v1/marketplaces/TEST-MP318-823-1966/accounts", - "support_phone_number": "+16505551234", - "refunds_uri": "/v1/marketplaces/TEST-MP318-823-1966/refunds", - "meta": {}, - "debits_uri": "/v1/marketplaces/TEST-MP318-823-1966/debits", - "transactions_uri": "/v1/marketplaces/TEST-MP318-823-1966/transactions", - "credits_uri": "/v1/marketplaces/TEST-MP318-823-1966/credits" - }, - "name": "William Henry Cavendish III", - "email_address": "whc@example.org", - "created_at": "2012-03-27T12:27:01.972216Z", - "uri": "/v1/merchants/TEST-MR733-635-0109", - "accounts_uri": "/v1/merchants/TEST-MR733-635-0109/accounts", - "meta": { - "meta data": "goes here" - }, - "postal_code": "90210", - "country_code": "USA", - "type": "PERSON", - "balance": -2518, - "api_keys_uri": "/v1/merchants/TEST-MR733-635-0109/api_keys", - "street_address": "123 Fake St" - } - ], - "previous_uri": null, - "uri": "/v1/merchants?limit=10&offset=0", - "limit": 10, - "offset": 0, - "total": 1, - "next_uri": null, - "last_uri": "/v1/merchants?limit=10&offset=0" -} diff --git a/tests/_responses/transactions.py b/tests/_responses/transactions.py deleted file mode 100644 index 1986a61..0000000 --- a/tests/_responses/transactions.py +++ /dev/null @@ -1,13 +0,0 @@ -import os -import json - -FILE_PATH = os.path.dirname(__file__) - - -def index(limit=10, offset=0): - if not offset: - path = os.path.join(FILE_PATH, 'transactions1.json') - return json.loads(open(path).read()) - else: - path = os.path.join(FILE_PATH, 'transactions2.json') - return json.loads(open(path).read()) diff --git a/tests/_responses/transactions1.json b/tests/_responses/transactions1.json deleted file mode 100644 index 27fd4d7..0000000 --- a/tests/_responses/transactions1.json +++ /dev/null @@ -1,248 +0,0 @@ -{ - "first_uri": "/v1/marketplaces/TEST-MP778-071-6386/transactions?limit=10&offset=0", - "items": [ - { - "account": { - "transactions_uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC435-398-8011/transactions", - "name": "Nicolaas Bloembergen", - "roles": [ - "buyer" - ], - "created_at": "2012-03-27T11:11:34.104277Z", - "holds_uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC435-398-8011/holds", - "uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC435-398-8011", - "refunds_uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC435-398-8011/refunds", - "meta": {}, - "debits_uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC435-398-8011/debits", - "email_address": "nicolaas.bloembergen214@hotmail.web", - "credits_uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC435-398-8011/credits" - }, - "fee": 163, - "description": null, - "created_at": "2012-03-27T11:11:34.297546Z", - "uri": "/v1/marketplaces/TEST-MP778-071-6386/debits/W563-141-3004", - "refunds_uri": "/v1/marketplaces/TEST-MP778-071-6386/debits/W563-141-3004/refunds", - "amount": 4674, - "meta": {}, - "appears_on_statement_as": "http://www.balancedpay", - "hold": { - "fee": 35, - "description": null, - "created_at": "2012-03-27T11:11:34.236943Z", - "is_void": false, - "expires_at": "2012-04-03T18:11:34.232401Z", - "uri": "/v1/marketplaces/TEST-MP778-071-6386/debits/W563-141-3004/holds/HL195-571-1604", - "amount": 4674, - "meta": {}, - "debits_uri": "/v1/marketplaces/TEST-MP778-071-6386/holds/HL195-571-1604/debits", - "account_uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC435-398-8011" - } - }, - { - "account": { - "transactions_uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC758-484-9314/transactions", - "name": "Cherry Jul", - "roles": [ - "merchant", - "buyer" - ], - "created_at": "2012-03-27T11:11:35.171392Z", - "holds_uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC758-484-9314/holds", - "uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC758-484-9314", - "refunds_uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC758-484-9314/refunds", - "meta": {}, - "debits_uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC758-484-9314/debits", - "email_address": "cherry.jul76@gmail.web", - "credits_uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC758-484-9314/credits" - }, - "description": "", - "created_at": "2012-03-27T11:11:35.272886Z", - "uri": "/v1/marketplaces/TEST-MP778-071-6386/credits/CR438-257-9455", - "amount": 6904, - "meta": {} - }, - { - "account": { - "transactions_uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC038-775-8140/transactions", - "name": "Heather Gables", - "roles": [ - "merchant", - "buyer" - ], - "created_at": "2012-03-27T11:11:35.444929Z", - "holds_uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC038-775-8140/holds", - "uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC038-775-8140", - "refunds_uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC038-775-8140/refunds", - "meta": {}, - "debits_uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC038-775-8140/debits", - "email_address": "heather.gables986@yahoo.web", - "credits_uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC038-775-8140/credits" - }, - "description": "", - "created_at": "2012-03-27T11:11:35.489474Z", - "uri": "/v1/marketplaces/TEST-MP778-071-6386/credits/CR797-952-5783", - "amount": 7533, - "meta": {} - }, - { - "account": { - "transactions_uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC435-398-8011/transactions", - "name": "Nicolaas Bloembergen", - "roles": [ - "buyer" - ], - "created_at": "2012-03-27T11:11:34.104277Z", - "holds_uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC435-398-8011/holds", - "uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC435-398-8011", - "refunds_uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC435-398-8011/refunds", - "meta": {}, - "debits_uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC435-398-8011/debits", - "email_address": "nicolaas.bloembergen214@hotmail.web", - "credits_uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC435-398-8011/credits" - }, - "fee": 11, - "description": "", - "created_at": "2012-03-27T11:11:34.162925Z", - "uri": "/v1/marketplaces/TEST-MP778-071-6386/debits/W366-099-0509", - "refunds_uri": "/v1/marketplaces/TEST-MP778-071-6386/debits/W366-099-0509/refunds", - "amount": 330, - "meta": {}, - "appears_on_statement_as": "http://www.balancedpay", - "hold": { - "fee": 35, - "description": null, - "created_at": "2012-03-27T11:11:34.151807Z", - "is_void": false, - "expires_at": "2012-04-03T18:11:34.145562Z", - "uri": "/v1/marketplaces/TEST-MP778-071-6386/debits/W366-099-0509/holds/HL995-212-1155", - "amount": 330, - "meta": {}, - "debits_uri": "/v1/marketplaces/TEST-MP778-071-6386/holds/HL995-212-1155/debits", - "account_uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC435-398-8011" - } - }, - { - "account": { - "transactions_uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC767-701-1063/transactions", - "name": "Ashlynn Brooke", - "roles": [ - "merchant", - "buyer" - ], - "created_at": "2012-03-27T11:11:34.909828Z", - "holds_uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC767-701-1063/holds", - "uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC767-701-1063", - "refunds_uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC767-701-1063/refunds", - "meta": {}, - "debits_uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC767-701-1063/debits", - "email_address": "ashlynn.brooke627@example.com", - "credits_uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC767-701-1063/credits" - }, - "description": "", - "created_at": "2012-03-27T11:11:35.008982Z", - "uri": "/v1/marketplaces/TEST-MP778-071-6386/credits/CR518-800-6309", - "amount": 761, - "meta": {} - }, - { - "account": { - "transactions_uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC796-303-9468/transactions", - "name": "Specific Appraisals", - "roles": [ - "merchant", - "buyer" - ], - "created_at": "2012-03-27T11:11:35.336394Z", - "holds_uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC796-303-9468/holds", - "uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC796-303-9468", - "refunds_uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC796-303-9468/refunds", - "meta": {}, - "debits_uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC796-303-9468/debits", - "email_address": "eve.angel899@example.org", - "credits_uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC796-303-9468/credits" - }, - "description": "", - "created_at": "2012-03-27T11:11:35.386199Z", - "uri": "/v1/marketplaces/TEST-MP778-071-6386/credits/CR909-215-5732", - "amount": 6625, - "meta": {} - }, - { - "fee": 35, - "description": null, - "created_at": "2012-03-27T11:11:34.617509Z", - "is_void": false, - "expires_at": "2012-04-03T18:11:34.613124Z", - "uri": "/v1/marketplaces/TEST-MP778-071-6386/debits/W985-622-9570/holds/HL299-190-9129", - "amount": 2930, - "meta": {}, - "debits_uri": "/v1/marketplaces/TEST-MP778-071-6386/holds/HL299-190-9129/debits", - "account_uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC737-627-5712" - }, - { - "account": { - "transactions_uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC038-775-8140/transactions", - "name": "Heather Gables", - "roles": [ - "merchant", - "buyer" - ], - "created_at": "2012-03-27T11:11:35.444929Z", - "holds_uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC038-775-8140/holds", - "uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC038-775-8140", - "refunds_uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC038-775-8140/refunds", - "meta": {}, - "debits_uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC038-775-8140/debits", - "email_address": "heather.gables986@yahoo.web", - "credits_uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC038-775-8140/credits" - }, - "description": "", - "created_at": "2012-03-27T11:11:35.543397Z", - "uri": "/v1/marketplaces/TEST-MP778-071-6386/credits/CR431-061-7325", - "amount": 7982, - "meta": {} - }, - { - "fee": 35, - "description": null, - "created_at": "2012-03-27T11:11:34.413653Z", - "is_void": false, - "expires_at": "2012-04-03T18:11:34.409482Z", - "uri": "/v1/marketplaces/TEST-MP778-071-6386/debits/W181-120-0761/holds/HL352-452-3508", - "amount": 5868, - "meta": {}, - "debits_uri": "/v1/marketplaces/TEST-MP778-071-6386/holds/HL352-452-3508/debits", - "account_uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC988-845-0622" - }, - { - "account": { - "transactions_uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC758-484-9314/transactions", - "name": "Cherry Jul", - "roles": [ - "merchant", - "buyer" - ], - "created_at": "2012-03-27T11:11:35.171392Z", - "holds_uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC758-484-9314/holds", - "uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC758-484-9314", - "refunds_uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC758-484-9314/refunds", - "meta": {}, - "debits_uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC758-484-9314/debits", - "email_address": "cherry.jul76@gmail.web", - "credits_uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC758-484-9314/credits" - }, - "description": "", - "created_at": "2012-03-27T11:11:35.215111Z", - "uri": "/v1/marketplaces/TEST-MP778-071-6386/credits/CR297-614-9921", - "amount": 7873, - "meta": {} - } - ], - "previous_uri": null, - "uri": "/v1/marketplaces/TEST-MP778-071-6386/transactions?limit=10&offset=0", - "limit": 10, - "offset": 0, - "total": 17, - "next_uri": "/v1/marketplaces/TEST-MP778-071-6386/transactions?limit=10&offset=10", - "last_uri": "/v1/marketplaces/TEST-MP778-071-6386/transactions?limit=10&offset=10" -} diff --git a/tests/_responses/transactions2.json b/tests/_responses/transactions2.json deleted file mode 100644 index 571ce27..0000000 --- a/tests/_responses/transactions2.json +++ /dev/null @@ -1,179 +0,0 @@ -{ - "first_uri": "/v1/marketplaces/TEST-MP778-071-6386/transactions?limit=10&offset=0", - "items": [ - { - "account": { - "transactions_uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC988-845-0622/transactions", - "name": "Samuel King Allison", - "roles": [ - "buyer" - ], - "created_at": "2012-03-27T11:11:34.368584Z", - "holds_uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC988-845-0622/holds", - "uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC988-845-0622", - "refunds_uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC988-845-0622/refunds", - "meta": {}, - "debits_uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC988-845-0622/debits", - "email_address": "samuel.king.allison461@gmail.web", - "credits_uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC988-845-0622/credits" - }, - "fee": 205, - "description": "", - "created_at": "2012-03-27T11:11:34.421526Z", - "uri": "/v1/marketplaces/TEST-MP778-071-6386/debits/W181-120-0761", - "refunds_uri": "/v1/marketplaces/TEST-MP778-071-6386/debits/W181-120-0761/refunds", - "amount": 5868, - "meta": {}, - "appears_on_statement_as": "http://www.balancedpay", - "hold": { - "fee": 35, - "description": null, - "created_at": "2012-03-27T11:11:34.413653Z", - "is_void": false, - "expires_at": "2012-04-03T18:11:34.409482Z", - "uri": "/v1/marketplaces/TEST-MP778-071-6386/debits/W181-120-0761/holds/HL352-452-3508", - "amount": 5868, - "meta": {}, - "debits_uri": "/v1/marketplaces/TEST-MP778-071-6386/holds/HL352-452-3508/debits", - "account_uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC988-845-0622" - } - }, - { - "account": { - "transactions_uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC812-716-3408/transactions", - "name": "Chargepal", - "roles": [ - "merchant", - "buyer" - ], - "created_at": "2012-03-27T11:11:34.751693Z", - "holds_uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC812-716-3408/holds", - "uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC812-716-3408", - "refunds_uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC812-716-3408/refunds", - "meta": {}, - "debits_uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC812-716-3408/debits", - "email_address": "ava.devine219@hotmail.web", - "credits_uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC812-716-3408/credits" - }, - "description": "", - "created_at": "2012-03-27T11:11:34.796144Z", - "uri": "/v1/marketplaces/TEST-MP778-071-6386/credits/CR929-148-2468", - "amount": 6831, - "meta": {} - }, - { - "account": { - "transactions_uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC737-627-5712/transactions", - "name": "Aleksandr Mikhailovich Lyapunov", - "roles": [ - "buyer" - ], - "created_at": "2012-03-27T11:11:34.574993Z", - "holds_uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC737-627-5712/holds", - "uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC737-627-5712", - "refunds_uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC737-627-5712/refunds", - "meta": {}, - "debits_uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC737-627-5712/debits", - "email_address": "aleksandr.mikhailovich.lyapunov847@msn.web", - "credits_uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC737-627-5712/credits" - }, - "fee": 102, - "description": "", - "created_at": "2012-03-27T11:11:34.626011Z", - "uri": "/v1/marketplaces/TEST-MP778-071-6386/debits/W985-622-9570", - "refunds_uri": "/v1/marketplaces/TEST-MP778-071-6386/debits/W985-622-9570/refunds", - "amount": 2930, - "meta": {}, - "appears_on_statement_as": "http://www.balancedpay", - "hold": { - "fee": 35, - "description": null, - "created_at": "2012-03-27T11:11:34.617509Z", - "is_void": false, - "expires_at": "2012-04-03T18:11:34.613124Z", - "uri": "/v1/marketplaces/TEST-MP778-071-6386/debits/W985-622-9570/holds/HL299-190-9129", - "amount": 2930, - "meta": {}, - "debits_uri": "/v1/marketplaces/TEST-MP778-071-6386/holds/HL299-190-9129/debits", - "account_uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC737-627-5712" - } - }, - { - "fee": 35, - "description": null, - "created_at": "2012-03-27T11:11:34.151807Z", - "is_void": false, - "expires_at": "2012-04-03T18:11:34.145562Z", - "uri": "/v1/marketplaces/TEST-MP778-071-6386/debits/W366-099-0509/holds/HL995-212-1155", - "amount": 330, - "meta": {}, - "debits_uri": "/v1/marketplaces/TEST-MP778-071-6386/holds/HL995-212-1155/debits", - "account_uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC435-398-8011" - }, - { - "account": { - "transactions_uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC767-701-1063/transactions", - "name": "Ashlynn Brooke", - "roles": [ - "merchant", - "buyer" - ], - "created_at": "2012-03-27T11:11:34.909828Z", - "holds_uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC767-701-1063/holds", - "uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC767-701-1063", - "refunds_uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC767-701-1063/refunds", - "meta": {}, - "debits_uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC767-701-1063/debits", - "email_address": "ashlynn.brooke627@example.com", - "credits_uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC767-701-1063/credits" - }, - "description": "", - "created_at": "2012-03-27T11:11:34.955274Z", - "uri": "/v1/marketplaces/TEST-MP778-071-6386/credits/CR881-320-0396", - "amount": 8928, - "meta": {} - }, - { - "fee": 35, - "description": null, - "created_at": "2012-03-27T11:11:34.236943Z", - "is_void": false, - "expires_at": "2012-04-03T18:11:34.232401Z", - "uri": "/v1/marketplaces/TEST-MP778-071-6386/debits/W563-141-3004/holds/HL195-571-1604", - "amount": 4674, - "meta": {}, - "debits_uri": "/v1/marketplaces/TEST-MP778-071-6386/holds/HL195-571-1604/debits", - "account_uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC435-398-8011" - }, - { - "account": { - "transactions_uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC360-287-8313/transactions", - "name": "Aki Tomosaki", - "roles": [ - "merchant", - "buyer" - ], - "created_at": "2012-03-27T11:11:35.067431Z", - "holds_uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC360-287-8313/holds", - "uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC360-287-8313", - "refunds_uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC360-287-8313/refunds", - "meta": {}, - "debits_uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC360-287-8313/debits", - "email_address": "aki.tomosaki643@msn.web", - "credits_uri": "/v1/marketplaces/TEST-MP778-071-6386/accounts/AC360-287-8313/credits" - }, - "description": "", - "created_at": "2012-03-27T11:11:35.111038Z", - "uri": "/v1/marketplaces/TEST-MP778-071-6386/credits/CR088-182-3641", - "amount": 5787, - "meta": {} - } - ], - "previous_uri": "/v1/marketplaces/TEST-MP778-071-6386/transactions?limit=10&offset=0", - "uri": "/v1/marketplaces/TEST-MP778-071-6386/transactions?limit=10&offset=10", - "limit": 10, - "offset": 10, - "total": 17, - "next_uri": null, - "last_uri": "/v1/marketplaces/TEST-MP778-071-6386/transactions?limit=10&offset=10" -} diff --git a/tests/application.py b/tests/application.py deleted file mode 100644 index 767ab99..0000000 --- a/tests/application.py +++ /dev/null @@ -1,92 +0,0 @@ -import json - -import bottle - -import _responses - - -SERIALIZERS = { - 'application/json': json.dumps, - } - - -app = bottle.Bottle() - - -@app.get('/marketplaces//accounts/') -def marketplace_accounts(mp_eid, ac_eid): - bottle.response.content_type = ( - bottle.request.headers.get('Accept', 'application/json')) - serializer = SERIALIZERS[bottle.response.content_type] - the_response = _responses.accounts.show(mp_eid, ac_eid) - bottle.response.body = serializer(the_response) - return bottle.response - - -@app.get('/merchants') -def merchants_index(): - bottle.response.content_type = ( - bottle.request.headers.get('Accept', 'application/json')) - serializer = SERIALIZERS[bottle.response.content_type] - the_response = _responses.merchants.index() - bottle.response.body = serializer(the_response) - return bottle.response - - -@app.get('/marketplaces') -def marketplaces_index(): - bottle.response.content_type = ( - bottle.request.headers.get('Accept', 'application/json')) - serializer = SERIALIZERS[bottle.response.content_type] - limit = int(bottle.request.query.limit or 10) - offset = int(bottle.request.query.offset or 0) - num = int(bottle.request.query.num or 1) - pages = int(bottle.request.query.pages or 1) - the_response = _responses.marketplaces.index(limit, offset, num, pages) - bottle.response.body = serializer(the_response) - return bottle.response - - -@app.post('/marketplaces') -def marketplaces_create(): - bottle.response.status = 201 - bottle.response.content_type = ( - bottle.request.headers.get('Accept', 'application/json')) - serializer = SERIALIZERS[bottle.response.content_type] - if not bottle.request.auth: - the_response = _responses.marketplaces.anonymous_create() - else: - the_response = _responses.marketplaces.anonymous_create() - - bottle.response.body = serializer(the_response) - return bottle.response - - -@app.put('/marketplaces/<_eid>') -def marketplaces_put(_eid): - return marketplaces_create() - - -@app.post('/api_keys') -def api_keys(): - bottle.response.status = 302 - bottle.response.content_type = ( - bottle.request.headers.get('Accept', 'application/json')) - bottle.response.set_header('Location', '/v1/your-mom') - bottle.response.body = json.dumps('') - return bottle.response - - -@app.get('/marketplaces/<_eid>/transactions') -def marketplaces_transactions(_eid): - bottle.response.content_type = ( - bottle.request.headers.get('Accept', 'application/json')) - serializer = SERIALIZERS[bottle.response.content_type] - limit = int(bottle.request.query.limit or 10) - offset = int(bottle.request.query.offset or 0) - the_response = _responses.transactions.index(limit, offset) - bottle.response.body = serializer(the_response) - return bottle.response - - -app.mount('/v1', app) diff --git a/tests/fixtures/__init__.py b/tests/fixtures/__init__.py index e69de29..b20e256 100644 --- a/tests/fixtures/__init__.py +++ b/tests/fixtures/__init__.py @@ -0,0 +1,17 @@ +from __future__ import unicode_literals +import os + +import simplejson as json + + +class ResourceMeta(type): + + def __getattr__(cls, item): + return json.load(open(os.path.join( + os.path.dirname(os.path.abspath(__file__)), + 'resources/{0}.json'.format(item)) + )) + + +class Resources(object): + __metaclass__ = ResourceMeta diff --git a/tests/fixtures/bank_accounts.py b/tests/fixtures/bank_accounts.py deleted file mode 100644 index 8999d4e..0000000 --- a/tests/fixtures/bank_accounts.py +++ /dev/null @@ -1,5 +0,0 @@ -BANK_ACCOUNT = { - 'name': 'Homer Jay', - 'account_number': '112233a', - 'bank_code': '121042882', - } diff --git a/tests/fixtures/cards.py b/tests/fixtures/cards.py deleted file mode 100644 index a0516d4..0000000 --- a/tests/fixtures/cards.py +++ /dev/null @@ -1,80 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals -from datetime import date - - -AUTH_INVALID_CARD = '4444444444444448' - -VERIFY_FAILED_CARD_NUMBER = '4222222222222220' - -TEST_CARDS = { - 'visa': [ - '4112344112344113', - '4110144110144115', - '4114360123456785', - '4061724061724061', - ], - 'mastercard': [ - '5111005111051128', - '5112345112345114', - '5115915115915118', - '5116601234567894', - ], - 'amex': [ - '371144371144376', - '341134113411347', - ], - 'discover': [ - '6011016011016011', - '6559906559906557', - ] -} - - -def generate_international_card_payloads(): - cards = [ - { - 'street_address': '田原3ー8ー1', - 'city': '都留市', - 'region': '山梨県', - 'postal_code': '4020054', - 'country_code': 'JPN', - 'name': '徳川家康', - 'card_number': '4' + '1' * 15, - 'expiration_month': 12, - 'expiration_year': date.today().year + 1, - }, - { - 'street_address': 'Malmö högskola', - 'city': 'Malmö', - 'region': '', - 'postal_code': '205 06', - 'country_code': 'SWE', - 'name': 'Dolph Lundgren', - 'card_number': '4' + '1' * 15, - 'expiration_month': 12, - 'expiration_year': date.today().year + 1, - }, - ] - - for card in cards: - yield card - -CARD = { - 'street_address': '801 High Street', - 'city': 'Palo Alto', - 'region': 'CA', - 'postal_code': '94301', - 'name': 'Johnny Fresh', - 'card_number': '4444424444444440', - 'expiration_month': 12, - 'expiration_year': date.today().year + 1, -} - - -CARD_NO_ADDRESS = { - 'name': 'Johnny Fresh', - 'card_number': '4444424444444440', - 'expiration_month': 12, - 'expiration_year': date.today().year + 1, -} diff --git a/tests/fixtures/merchants.py b/tests/fixtures/merchants.py deleted file mode 100644 index dccab43..0000000 --- a/tests/fixtures/merchants.py +++ /dev/null @@ -1,31 +0,0 @@ -PERSON_MERCHANT = { - 'type': 'person', - 'name': 'William James', - 'tax_id': '393-48-3992', # Should work w/ and w/o dashes - 'street_address': '167 West 74th Street', - 'postal_code': '10023', - 'dob': '1842-01-01', - 'phone_number': '+16505551234', - 'country_code': 'USA', -} - -BUSINESS_PRINCIPAL = { - 'name': 'William James', - 'tax_id': '393483992', - 'street_address': '167 West 74th Street', - 'postal_code': '10023', - 'dob': '1842-01-01', - 'phone_number': '+16505551234', - 'country_code': 'USA', -} - -BUSINESS_MERCHANT = { - 'type': 'business', - 'name': 'Levain Bakery', - 'tax_id': '253912384', - 'street_address': '167 West 74th Street', - 'postal_code': '10023', - 'phone_number': '+16505551234', - 'country_code': 'USA', - 'person': BUSINESS_PRINCIPAL, -} diff --git a/tests/fixtures/resources.py b/tests/fixtures/resources.py deleted file mode 100644 index fe438d0..0000000 --- a/tests/fixtures/resources.py +++ /dev/null @@ -1,17 +0,0 @@ -from __future__ import unicode_literals - - -INVOICES = { - "first_uri": - "/v1/invoices/IV4UKpZTjLHdhiayymMsrHKe/holds?limit=10&offset=0", - "items": [], - "previous_uri": None, - "uri": "/v1/invoices/IV4UKpZTjLHdhiayymMsrHKe/holds?limit=10&offset=0", - "limit": 10, - "offset": 0, - "total": 72, - "next_uri": - "/v1/invoices/IV4UKpZTjLHdhiayymMsrHKe/holds?limit=10&offset=10", - "last_uri": - "/v1/invoices/IV4UKpZTjLHdhiayymMsrHKe/holds?limit=10&offset=70" -} diff --git a/tests/fixtures/resources/api_keys.json b/tests/fixtures/resources/api_keys.json new file mode 100644 index 0000000..6c687bb --- /dev/null +++ b/tests/fixtures/resources/api_keys.json @@ -0,0 +1,13 @@ +{ + "links": {}, + "api_keys": [ + { + "links": {}, + "created_at": "2013-12-23T19:11:49.250551Z", + "secret": "ak-test-DUiuVXnHrQkxy7VfDv84DhnLHr3uSCR6", + "href": "/api_keys/AKztNL7Ly2W5nhpj53pw3vE", + "meta": {}, + "id": "AKztNL7Ly2W5nhpj53pw3vE" + } + ] +} diff --git a/tests/fixtures/resources/marketplaces.json b/tests/fixtures/resources/marketplaces.json new file mode 100644 index 0000000..979be82 --- /dev/null +++ b/tests/fixtures/resources/marketplaces.json @@ -0,0 +1,35 @@ +{ + "marketplaces": [ + { + "in_escrow": 0, + "domain_url": "example.com", + "name": "Test Marketplace", + "links": { + "owner_customer": "CUWXtKGXXgqQbJao7PiZ36g" + }, + "href": "/marketplaces/TEST-MPWWcI92W2mLFdLzSrh6cuQ", + "created_at": "2013-12-23T19:12:10.100302Z", + "support_email_address": "support@example.com", + "updated_at": "2013-12-23T19:12:10.620980Z", + "support_phone_number": "+16505551234", + "production": false, + "meta": {}, + "unsettled_fees": 0, + "id": "TEST-MPWWcI92W2mLFdLzSrh6cuQ" + } + ], + "links": { + "marketplaces.debits": "/debits", + "marketplaces.reversals": "/reversals", + "marketplaces.customers": "/customers", + "marketplaces.credits": "/credits", + "marketplaces.cards": "/cards", + "marketplaces.card_holds": "/card_holds", + "marketplaces.refunds": "/refunds", + "marketplaces.owner_customer": "/customers/{marketplaces.owner_customer}", + "marketplaces.transactions": "/transactions", + "marketplaces.bank_accounts": "/bank_accounts", + "marketplaces.callbacks": "/callbacks", + "marketplaces.events": "/events" + } +} diff --git a/tests/suite.py b/tests/suite.py deleted file mode 100644 index 4a195dd..0000000 --- a/tests/suite.py +++ /dev/null @@ -1,678 +0,0 @@ -# -*- coding: utf-8 -*- - -from __future__ import unicode_literals -from datetime import date -import mock -import warnings -import re - -import unittest2 as unittest -import requests - -import balanced -from balanced.exc import NoResultFound, MoreInformationRequiredError - - -# fixtures - -TEST_CARDS = { - 'visa': [ - '4112344112344113', - '4110144110144115', - '4114360123456785', - '4061724061724061', - ], - 'mastercard': [ - '5111005111051128' - '5112345112345114' - '5115915115915118' - '5116601234567894' - ], - 'amex': [ - '371144371144376', - '341134113411347', - ], - 'discover': [ - '6011016011016011', - '6559906559906557', - ] -} - -PERSON_MERCHANT = { - 'type': 'person', - 'name': 'William James', - 'tax_id': '393-48-3992', # Should work w/ and w/o dashes - 'street_address': '167 West 74th Street', - 'postal_code': '10023', - 'dob': '1842-01-01', - 'phone_number': '+16505551234', - 'country_code': 'USA', -} - -BUSINESS_PRINCIPAL = { - 'name': 'William James', - 'tax_id': '393483992', - 'street_address': '167 West 74th Street', - 'postal_code': '10023', - 'dob': '1842-01-01', - 'phone_number': '+16505551234', - 'country_code': 'USA', -} - -BUSINESS_MERCHANT = { - 'type': 'business', - 'name': 'Levain Bakery', - 'tax_id': '253912384', - 'street_address': '167 West 74th Street', - 'postal_code': '10023', - 'phone_number': '+16505551234', - 'country_code': 'USA', - 'person': BUSINESS_PRINCIPAL, -} - -CARD = { - 'street_address': '123 Fake Street', - 'city': 'Jollywood', - 'region': 'CA', - 'postal_code': '90210', - 'name': 'Johnny Fresh', - 'card_number': '4444424444444440', - 'expiration_month': 12, - 'expiration_year': date.today().year + 1, -} - -INTERNATIONAL_CARD = { - 'street_address': '田原3ー8ー1', - 'city': '都留市', - 'region': '山梨県', - 'postal_code': '4020054', - 'country_code': 'JPN', - 'name': 'Johnny Fresh', - 'card_number': '4444424444444440', - 'expiration_month': 12, - 'expiration_year': date.today().year + 1, -} - -BANK_ACCOUNT = { - 'name': 'Homer Jay', - 'account_number': '112233a', - 'bank_code': '121042882', -} - -PERSON_FAILING_KYC = { - 'type': 'person', - 'name': 'William James', - 'dob': '1842-01-01', - 'phone_number': '+16505551234', - 'street_address': '801 High St', - 'postal_code': '99999', - 'region': 'EX', - 'country_code': 'USA', -} - -BANK_ACCOUNT_W_TYPE = { - 'name': 'Homer Jay', - 'account_number': '112233a', - 'routing_number': '121042882', - 'type': 'checking' -} - -CREDIT = { - 'amount': 9876, - 'description': 'I love money', -} - - -# tests - -class BasicUseCases(unittest.TestCase): - - @classmethod - def setUpClass(cls): - balanced.config.root_uri = 'http://127.0.0.1:5000/' - if not balanced.config.api_key_secret: - api_key = balanced.APIKey().save() - balanced.configure(api_key.secret) - cls.merchant = api_key.merchant - - def test_00_merchant_expectations(self): - self.assertFalse(hasattr(self.merchant, 'principal')) - self.assertFalse(hasattr(self.merchant, 'payout_method')) - self.assertTrue(self.merchant.id.startswith('TEST-MR')) - - def test_01_create_marketplace(self): - self.assertTrue(self.merchant.accounts_uri.endswith('/accounts')) - self.assertIsNotNone(balanced.config.api_key_secret) - marketplace = balanced.Marketplace().save() - self.assertTrue(marketplace.id.startswith('TEST-MP')) - self.merchant = balanced.Merchant.find(self.merchant.uri) - self.assertEqual(marketplace.in_escrow, 0) - - def test_02_create_a_second_marketplace_should_fail(self): - self.assertIsNotNone(balanced.config.api_key_secret) - with self.assertRaises(requests.HTTPError) as exc: - balanced.Marketplace().save() - the_exception = exc.exception - self.assertEqual(the_exception.status_code, 409) - - def test_03_index_the_marketplaces(self): - self.assertIsNotNone(balanced.config.api_key_secret) - mps = balanced.Marketplace.query.all() - self.assertEqual(len(mps), 1) - - def _create_marketplace(self): - try: - return balanced.Marketplace.query.one() - except NoResultFound: - return balanced.Marketplace().save() - - def _find_marketplace(self): - return balanced.Marketplace.query.one() - - def test_04_create_a_buyer(self): - self.assertIsNotNone(balanced.config.api_key_secret) - - card_number = TEST_CARDS['visa'][0] - buyer_name = 'khalkhalash onastick' - card_payload = { - 'street_address': '123 Fake Street', - 'city': 'Jollywood', - 'state': 'CA', - 'postal_code': '90210', - 'name': buyer_name, - 'card_number': card_number, - 'expiration_month': 12, - 'expiration_year': date.today().year + 1, - } - card = balanced.Card(**card_payload).save() - card_uri = card.uri - mp = self._find_marketplace() - - buyer = mp.create_buyer(email_address='m@poundpay.com', - card_uri=card_uri, - meta={'test#': 'test_d'} - ) - self.assertEqual(buyer.name, 'khalkhalash onastick') - self.assertEqual(buyer.roles, ['buyer']) - self.assertIsNotNone(buyer.created_at) - self.assertDictEqual(buyer.meta, {'test#': 'test_d'}) - self.assertIsNotNone(buyer.uri) - self.assertTrue(buyer.uri.startswith(mp.uri + '/accounts')) - - def _find_account(self, role, owner=False, all_accounts=False): - mp = self._find_marketplace() - accounts = list(mp.accounts) - if all_accounts: - return accounts - accounts = [account for account in accounts if role in account.roles] - if not owner: - for account in accounts: - if account.email_address == 'support@example.com': - continue - if 'merchant' in account.roles and role == 'buyer': - continue - break - accounts = [account] - - return accounts[0] - - def test_05_index_accounts(self): - accounts = self._find_account(None, all_accounts=True) - self.assertEqual(len(accounts), 2) - account = self._find_account('buyer') - self.assertEqual(account.name, 'khalkhalash onastick') - self.assertEqual(account.roles, ['buyer']) - self.assertIsNotNone(account.created_at) - self.assertDictEqual(account.meta, {'test#': 'test_d'}) - self.assertIsNotNone(account.uri) - - def test_06_debit_buyer_account_and_refund(self): - account = self._find_account('buyer') - debit = account.debit( - amount=1000, - appears_on_statement_as='atest', - meta={'fraud': 'yes'}, - description='Descripty') - self.assertTrue(debit.id.startswith('W')) - self.assertIsInstance(debit.account, balanced.Account) - self.assertIsInstance(debit.hold, balanced.Hold) - self.assertEqual(debit.description, 'Descripty') - self.assertIsNone(debit.fee) - self.assertEqual(debit.appears_on_statement_as, 'atest') - - refund = debit.refund(amount=100) - self.assertTrue(refund.id.startswith('RF')) - self.assertEqual(refund.debit.uri, debit.uri) - self.assertIsNone(refund.fee) - - another_debit = account.debit( - amount=1000, - meta={'fraud': 'yes'}) - self.assertEqual(another_debit.appears_on_statement_as, 'example.com') - - another_debit.refund() - - def test_07_create_hold_and_void_it(self): - account = self._find_account('buyer') - hold = account.hold(amount=1500, description='Hold me') - self.assertIsNone(hold.fee) - self.assertEqual(hold.account.uri, account.uri) - self.assertFalse(hold.is_void) - self.assertEqual(hold.description, 'Hold me') - hold.void() - self.assertTrue(hold.is_void) - self.assertIsNone(hold.fee) - - def test_08_create_hold_and_debit_it(self): - account = self._find_account('buyer') - hold = account.hold(amount=1500) - self.assertTrue(hold.id.startswith('HL')) - debit = hold.capture() - self.assertIsNone(debit.fee) - - def test_09_create_a_person_merchant(self): - mp = self._find_marketplace() - merchant = mp.create_merchant('mahmoud@poundpay.com', - merchant=PERSON_MERCHANT) - self.assertEqual(merchant.roles, ['merchant']) - - def test_10_create_a_business_merchant(self): - mp = self._create_marketplace() - payload = { - "name": "Levain Bakery LLC", - "account_number": "28304871049", - "bank_code": "121042882", - } - bank_account = balanced.BankAccount(**payload).save() - merchant = mp.create_merchant( - 'mahmoud+khalkhalash@poundpay.com', - merchant=BUSINESS_MERCHANT, - bank_account_uri=bank_account.uri, - ) - self.assertItemsEqual(merchant.roles, ['merchant']) - - def test_11_create_a_business_merchant_with_existing_email_addr(self): - mp = self._find_marketplace() - with self.assertRaises(requests.HTTPError) as exc: - mp.create_merchant('mahmoud@poundpay.com', - merchant=PERSON_MERCHANT) - the_exception = exc.exception - self.assertEqual(the_exception.status_code, 409) - self.assertIn( - 'Account with email address "mahmoud@poundpay.com" already exists', - the_exception.description) - - def test_12_get_business_merchant_for_crediting(self): - buyer = self._find_account('buyer') - buyer.debit(amount=10000) - self.merchant = self.merchant.find(self.merchant.uri) - marketplace = self.merchant.marketplace - original_balance = marketplace.in_escrow - merchants = list(marketplace.accounts.filter( - email_address='mahmoud+khalkhalash@poundpay.com' - )) - merchant = merchants[0] - credit = merchant.credit(amount=1000) - self.assertTrue(credit.id.startswith('CR')) - self.assertEqual(credit.amount, 1000) - marketplace = marketplace.find(marketplace.uri) - self.assertEqual( - marketplace.in_escrow, - original_balance - credit.amount) - - def test_13_credit_more_than_the_escrow_balance_should_fail(self): - buyer = self._find_account('buyer') - buyer.debit(amount=10000) - self.merchant = self.merchant.find(self.merchant.uri) - marketplace = self.merchant.marketplace - original_balance = marketplace.in_escrow - merchant = self._find_account('merchant') - with self.assertRaises(requests.HTTPError) as exc: - merchant.credit(amount=original_balance + 1000) - the_exception = exc.exception - self.assertEqual(the_exception.status_code, 409) - print the_exception - - def test_15_debits_without_an_account(self): - with self.assertRaises(requests.HTTPError) as exc: - balanced.Debit().save() - the_exception = exc.exception - self.assertEqual(the_exception.status_code, 400) - print the_exception - - def test_16_slice_syntax(self): - total_debit = balanced.Debit.query.count() - self.assertNotEqual(total_debit, 2) - self.assertEqual(len(balanced.Debit.query), total_debit) - sliced_debits = balanced.Debit.query[:2] - self.assertEqual(len(sliced_debits), 2) - for debit in sliced_debits: - self.assertIsInstance(debit, balanced.Debit) - all_debits = balanced.Debit.query.all() - last = total_debit * - 1 - for index, debit in enumerate(all_debits): - self.assertEqual(debit.uri, - balanced.Debit.query[last + index].uri) - - def test_17_test_merchant_cache_busting(self): - # cache it. - a_merchant = self.merchant.me - a_merchant.bank_account = { - 'account_number': '112233a', - 'name': 'hald', - 'bank_code': '121042882', - } - self.assertTrue(hasattr(self.merchant.me, 'bank_account')) - a_merchant.save() - self.assertFalse(hasattr(a_merchant, 'bank_account')) - - def test_18_create_and_associate_card(self): - try: - mp = balanced.Marketplace.query.one() - except NoResultFound: - mp = balanced.Marketplace().save() - card = mp.create_card(**CARD) - self.assertTrue(card.id.startswith('CC')) - account = mp.create_merchant('randy@pandy.com', - merchant=PERSON_MERCHANT) - account.add_card(card.uri) - - def test_19_create_and_associate_bank_account(self): - try: - mp = balanced.Marketplace.query.one() - except NoResultFound: - mp = balanced.Marketplace().save() - bank_account = mp.create_bank_account(**BANK_ACCOUNT) - self.assertTrue(bank_account.id.startswith('BA')) - account = mp.create_merchant('free@example.com', - merchant=PERSON_MERCHANT) - account.add_bank_account(bank_account.uri) - - def test_20_test_filter_and_sort(self): - try: - self._find_marketplace() - except balanced.exc.NoResultFound: - balanced.Marketplace().save() - - buyer = self._find_account('buyer') - deb1 = buyer.debit(amount=1122, meta={'tag': '1'}) - deb2 = buyer.debit(amount=3322, meta={'tag': '1'}) - deb3 = buyer.debit(amount=2211, meta={'tag': '2'}) - - debs = (balanced.Debit.query - .filter(balanced.Debit.f.meta.tag == '1') - .all()) - self.assertItemsEqual([deb.id for deb in debs], [deb1.id, deb2.id]) - - debs = (balanced.Debit.query - .filter(balanced.Debit.f.meta.tag == '2') - .all()) - self.assertItemsEqual([deb.id for deb in debs], [deb3.id]) - - debs = (balanced.Debit.query - .filter(balanced.Debit.f.meta.contains('tag')) - .sort(balanced.Debit.f.amount.asc()) - .all()) - self.assertEqual(len(debs), 3) - self.assertEqual([deb.id for deb in debs], [deb1.id, deb3.id, deb2.id]) - - debs = (balanced.Debit.query - .filter(balanced.Debit.f.meta.contains('tag')) - .sort(balanced.Debit.f.amount.desc()) - .all()) - self.assertEqual(len(debs), 3) - self.assertEqual([deb.id for deb in debs], [deb2.id, deb3.id, deb1.id]) - - def test_21_mask_bank_account(self): - mp = self._create_marketplace() - payload = BANK_ACCOUNT.copy() - payload['account_number'] = '1212121-110-019' - bank_account = mp.create_bank_account(**payload) - self.assertEqual(bank_account.last_four, '0019') - - def test_22_create_international_card(self): - mp = self._create_marketplace() - card = mp.create_card(**INTERNATIONAL_CARD) - self.assertTrue(card.id.startswith('CC')) - self.assertEqual(card.street_address, - INTERNATIONAL_CARD['street_address']) - - def test_23_kyc_redirect(self): - mp = self._create_marketplace() - - redirect_pattern = ('https://www.balancedpayments.com' - '/marketplaces/(.*)/kyc') - - with self.assertRaises(MoreInformationRequiredError) as ex: - mp.create_merchant('marshall@poundpay.com', PERSON_FAILING_KYC) - - redirect_uri = ex.exception.redirect_uri - result = re.search(redirect_pattern, redirect_uri) - self.assertTrue(result) - - def test_24_toplevel_bank_account(self): - self._create_marketplace() - count = balanced.BankAccount.query.count() - payload = BANK_ACCOUNT_W_TYPE.copy() - bank_account = balanced.BankAccount(**payload).save() - self.assertFalse(hasattr(bank_account, 'last_four')) - self.assertFalse(hasattr(bank_account, 'bank_code')) - self.assertTrue(hasattr(bank_account, 'routing_number')) - self.assertEqual(bank_account.routing_number, - payload['routing_number']) - self.assertEqual(payload['account_number'][-4:], - bank_account.account_number[-4:]) - self.assertIsNotNone(bank_account.credits_uri) - self.assertEqual(balanced.BankAccount.query.count(), count + 1) - - def test_25_index_toplevel_bank_accounts(self): - self._create_marketplace() - count = balanced.BankAccount.query.count() - bas = balanced.BankAccount.query.all() - self.assertEqual(len(bas), count) - self.assertGreater(count, 0) - - def test_26_toplevel_bank_account_credit(self): - self._create_marketplace() - buyer = self._find_account('buyer') - card = balanced.Marketplace.my_marketplace.create_card(**CARD) - buyer.add_card(card.uri) - buyer.debit(1212121) - - payload = BANK_ACCOUNT_W_TYPE.copy() - bank_account = balanced.BankAccount(**payload).save() - cr = bank_account.credit(50) - self.assertEqual(cr.amount, 50) - - def test_27_toplevel_credit(self): - self._create_marketplace() - buyer = self._find_account('buyer') - card = balanced.Marketplace.my_marketplace.create_card(**CARD) - buyer.add_card(card.uri) - buyer.debit(1212121) - - payload = CREDIT.copy() - payload['bank_account'] = BANK_ACCOUNT_W_TYPE.copy() - credit = balanced.Credit(**payload).save() - self.assertEqual(credit.amount, payload['amount']) - self.assertEqual(credit.description, payload['description']) - self.assertNotIn('id', credit.bank_account) - self.assertNotIn('uri', credit.bank_account) - self.assertNotIn('created_at', credit.bank_account) - - def test_28_on_behalf_of(self): - mp = self._create_marketplace() - buyer = self._find_account('buyer') - merchant = mp.create_merchant('mahmoud2@poundpay.com', - merchant=PERSON_MERCHANT) - - card = balanced.Marketplace.my_marketplace.create_card(**CARD) - buyer.add_card(card.uri) - - self.assertIsNotNone(buyer.debit(2222, on_behalf_of=merchant.uri)) - - with warnings.catch_warnings(record=True) as w: - self.assertIsNotNone(buyer.debit(1111, merchant_uri=merchant.uri)) - self.assertEqual(len(w), 1) - - # test that we extract the uri if you pass the object - with mock.patch('balanced.resources.Debit') as debit: - buyer.debit(2222, on_behalf_of=merchant) - self.assertEqual( - debit.call_args[1]['on_behalf_of_uri'], - merchant.uri) - - # test that we throw an exception if the uri of the merchant is the - # same as the account uri - with self.assertRaises(ValueError) as exc: - buyer.debit(2222, on_behalf_of=buyer) - self.assertEqual( - exc.exception.args[0], - 'The on_behalf_of parameter MAY NOT be the same account as ' - 'the account you are debiting!' - ) - - # test that you can't pass in a bunch of shit - with self.assertRaises(ValueError) as exc: - buyer.debit(2222, on_behalf_of=15) - self.assertEqual( - exc.exception.args[0], - 'The on_behalf_of parameter needs to be an account uri' - ) - - def test_29_customers(self): - mp = self._create_marketplace() - customer = balanced.Customer().save() - - self.assertIsNone(customer.source) - card = mp.create_card(**CARD) - customer.add_card(card.uri) - card = mp.create_card(**CARD) - customer.add_card(card) - customer.add_card(CARD) - self.assertIsNotNone(customer.source) - self.assertEqual(customer.source.id, customer.active_card.id) - - self.assertIsNone(customer.destination) - bank_account = mp.create_bank_account(**BANK_ACCOUNT) - customer.add_bank_account(bank_account.uri) - bank_account = mp.create_bank_account(**BANK_ACCOUNT) - customer.add_bank_account(bank_account) - customer.add_bank_account(BANK_ACCOUNT) - self.assertIsNotNone(customer.destination) - self.assertEqual(customer.destination.id, - customer.active_bank_account.id) - - debit = customer.debit(100) - self.assertEqual(customer.active_card.id, debit.source.id) - - credit = customer.credit(100) - self.assertEqual(customer.active_bank_account.id, - credit.destination.id) - - def test_30_customer_transactions(self): - mp = self._create_marketplace() - customer = balanced.Customer().save() - - self.assertIsNone(customer.source) - card = mp.create_card(**CARD) - bank_account = mp.create_bank_account(**BANK_ACCOUNT) - - with self.assertRaises(balanced.exc.ResourceError): - card.hold(amount=100) - - with self.assertRaises(balanced.exc.ResourceError): - card.debit(amount=100) - - with self.assertRaises(balanced.exc.ResourceError): - bank_account.debit(amount=100) - - customer.add_card(card.uri) - customer.source.hold(amount=100) - customer.source.debit(amount=100) - customer.add_bank_account(bank_account.uri) - customer.destination.credit(amount=100) - - def test_marketplace_customer_helper(self): - mp = self._create_marketplace() - customer = mp.create_customer() - - self.assertIsNone(customer.source) - card = mp.create_card(**CARD) - bank_account = mp.create_bank_account(**BANK_ACCOUNT) - - with self.assertRaises(balanced.exc.ResourceError): - card.hold(amount=100) - - with self.assertRaises(balanced.exc.ResourceError): - card.debit(amount=100) - - with self.assertRaises(balanced.exc.ResourceError): - bank_account.debit(amount=100) - - customer.add_card(card.uri) - customer.source.hold(amount=100) - customer.source.debit(amount=100) - customer.add_bank_account(bank_account.uri) - customer.destination.credit(amount=100) - - hold = customer.source.hold(amount=100) - hold.capture() - - def test_31_reverse(self): - self._create_marketplace() - buyer = self._find_account('buyer') - card = balanced.Marketplace.my_marketplace.create_card(**CARD) - buyer.add_card(card.uri) - buyer.debit(100000) - # create bank account where transactions will switched to payed - merchant = balanced.Customer().save() - ba = balanced.BankAccount( - routing_number="021000021", - account_number="9900000002", - name="lolz ftw", - ).save() - merchant.add_bank_account(ba) - merchant.save() - credit = merchant.credit(amount=5000) - reverse = credit.reverse() - self.assertEqual(reverse.amount, 5000) - self.assertIn('reversal', reverse.uri) - self.assertIn(credit.id, reverse.credit.uri) - - def test_32_delete_bank_account(self): - mp = self._create_marketplace() - customer = balanced.Customer().save() - bank_account = mp.create_bank_account(**BANK_ACCOUNT) - customer.add_bank_account(bank_account) - bank_account.unstore() - - def test_33_delete_card(self): - mp = self._create_marketplace() - customer = balanced.Customer().save() - card = mp.create_card(**CARD) - customer.add_card(card) - card.unstore() - - def test_34_create_merchant_with_attributes(self): - marketplace = self._create_marketplace() - merchant_attributes = { - 'type': 'person', - 'name': 'Billy Jones', - 'street_address': '801 High St.', - 'postal_code': '94301', - 'country': 'USA', - 'dob': '1842-01', - 'phone_number': '+16505551234' - } - bank_account = marketplace.create_bank_account(**BANK_ACCOUNT) - merchant = balanced.Account( - uri=marketplace.accounts_uri, - email_address='merchant@example.org', - merchant=merchant_attributes, - bank_account_uri=bank_account.uri, - name='Jack Q Merchant' - ).save() - self.assertEqual(merchant.email_address, 'merchant@example.org') - self.assertIn('merchant', merchant.roles) - self.assertEqual(merchant.name, 'Jack Q Merchant') diff --git a/tests/test_balanced.py b/tests/test_balanced.py index 0e1b17e..3c7e978 100644 --- a/tests/test_balanced.py +++ b/tests/test_balanced.py @@ -1,7 +1,9 @@ -import unittest2 as unittest +from __future__ import unicode_literals +from tests.utils import TestCase -class TestBalancedImportStar(unittest.TestCase): + +class TestBalancedImportStar(TestCase): def test_import_star(self): # not sure who uses import * any more, but we should @@ -11,5 +13,5 @@ def test_import_star(self): # and doing a "from balanced import *" generates an # unsupressable SyntaxWarning. exec "from balanced import *" # pylint: disable-msg=W0122 - except Exception, exc: + except Exception as exc: raise ImportError("%s" % exc) diff --git a/tests/test_client.py b/tests/test_client.py index d28aca3..d9242da 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -1,173 +1,21 @@ -# -*- coding: utf-8 -*- -import unittest2 as unittest +from __future__ import unicode_literals import balanced -from balanced._http_client import wrap_raise_for_status, before_request_hooks -import mock -import threading +from . import utils -class TestConfig(unittest.TestCase): - def test_default_config(self): - config = balanced.config.__class__() - # this is here because it tests that if you add anything new - # then you should test it here..it's not really all encompassing though - # for example, it won't detect any @property methods.. - self.assertItemsEqual( - config.__dict__.keys(), - ['api_key_secret', 'api_version', 'root_uri', 'requests'] - ) - self.assertEqual(config.root_uri, 'https://api.balancedpayments.com') - self.assertEqual(config.api_version, '1') - self.assertIsNone(config.api_key_secret) - self.assertEqual(config.uri, 'https://api.balancedpayments.com/v1') - self.assertEqual(config.version, 'v1') - - -def no_hook(client, http_op, url, kwargs): - kwargs.pop('hooks', None) - - -class TestClient(unittest.TestCase): +class TestClient(utils.TestCase): def setUp(self): - before_request_hooks.append(no_hook) - - def tearDown(self): - while before_request_hooks: - before_request_hooks.pop() - - def test_http_operations(self): - - ops = ['get', 'post', 'put', 'delete'] - for op in ops: - response = getattr(balanced.http_client, op)( - 'hithere', - ) - self.assertEqual(response.request.method, op.upper()) - self.assertEqual( - response.url, 'https://api.balancedpayments.com/v1/hithere' - ) - - def test_client_reference_config(self): - the_config = balanced.config - self.assertIsNone(balanced.http_client.config.api_key_secret) - the_config.api_key_secret = 'khalkhalash' - self.assertEqual( - balanced.http_client.config.api_key_secret, 'khalkhalash' - ) - - def test_client_key_switch(self): - the_config = balanced.config - current_key = the_config.api_key_secret - with balanced.key_switcher('new_key'): - self.assertEqual(the_config.api_key_secret, 'new_key') - self.assertEqual(the_config.api_key_secret, current_key) - - def test_before_request_hook(self): - momo = mock.Mock() - - before_request_hooks.append(no_hook) - before_request_hooks.append(momo) - - balanced.http_client.get( - 'hithere', - ) - self.assertEqual(momo.call_count, 1) - args, _ = momo.call_args - self.assertEqual(args[0], balanced.http_client) - self.assertIn('hithere', args[2]) - - -class TestHTTPClient(unittest.TestCase): - def test_deserialization(self): - resp = mock.Mock() - resp.headers = { - 'Content-Type': 'text/html', - } - resp.content = 'Unhandled Exception' - client = balanced.HTTPClient() - with self.assertRaises(balanced.exc.BalancedError): - client.deserialize(resp) - resp.headers['Content-Type'] = 'application/json' - resp.content = '{"hi": "world"}' - deserialized = client.deserialize(resp) - self.assertDictEqual(deserialized, {u'hi': u'world'}) + super(TestClient, self).setUp() - def test_deserialization_unicode(self): - resp = mock.Mock() - resp.headers = { - 'Content-Type': 'text/html', + def test_configure(self): + expected_headers = { + 'content-type': 'application/json;revision=1.1', + 'accept': 'application/vnd.api+json;revision=1.1', + 'User-Agent': u'balanced-python/' + balanced.__version__, } - resp.content = 'Unhandled Exception' - client = balanced.HTTPClient() - with self.assertRaises(balanced.exc.BalancedError): - client.deserialize(resp) - resp.headers['Content-Type'] = 'application/json' - resp.content = ('{"\\uc800\\uac74 \\ub610 \\ubb50\\uc57c": "second", ' - '"third": "\\u06a9\\u0647 \\u0686\\u0647 ' - '\\u06a9\\u062b\\u0627\\u0641\\u062a\\u06cc"}') - deserialized = client.deserialize(resp) - self.assertDictEqual(deserialized, { - u'third': (u'\u06a9\u0647 \u0686\u0647 ' - u'\u06a9\u062b\u0627\u0641\u062a\u06cc'), - u'\uc800\uac74 \ub610 \ubb50\uc57c': u'second'}) - - def test_wrap_raise_for_status(self): - api_response = {'additional': ('Valid email address formats may be ' - 'found at http://tools.ietf.org/html' - '/rfc2822#section-3.4'), - 'description': (u'"s\xf8ren.kierkegaard216@yahoo.web" ' - u'must be a valid email address as ' - u'specified by rfc2822 for email_add'), - 'status': 'Bad Request', - 'status_code': 400} - client = mock.Mock() - client.deserialize.return_value = api_response - ex = balanced.exc.HTTPError('Ooops') - setattr(ex, 'response', mock.Mock()) - ex.response.status_code = 400 - response = mock.Mock() - response.raise_for_status.side_effect = ex - - wrapped = wrap_raise_for_status(client) - - with self.assertRaises(balanced.exc.HTTPError) as ex: - wrapped(response) - self.assertEqual(ex.exception.description, api_response['description']) - - -class TestConfigThread(threading.Thread): - def __init__(self): - threading.Thread.__init__(self) - self.key = False - - def run(self): - print balanced.config.api_key_secret, balanced.config - self.key = balanced.config.api_key_secret == 'test' - - -class MultiThreadedUserCases(unittest.TestCase): - def setUp(self): - balanced.configure('not-test') - - def tearDown(self): - balanced.configure(None) - - def test_config_does_not_change_across_threads(self): - threads = [] - - for _ in xrange(2): - t = TestConfigThread() - threads.append(t) - - # change configuration once the threads are created - balanced.configure('test') - - for t in threads: - t.start() - - for t in threads: - t.join(len(threads)) - self.assertTrue(t.key) + self.assertDictContainsSubset( + expected_headers, balanced.config.client.config.headers + ) diff --git a/tests/test_resource.py b/tests/test_resource.py index 7f8f5ad..acb97ab 100644 --- a/tests/test_resource.py +++ b/tests/test_resource.py @@ -1,153 +1,16 @@ from __future__ import unicode_literals -import datetime -import unittest2 as unittest -import urlparse -import warnings -import mock import balanced -from balanced.resources import _RESOURCES as resource_registry -from .application import app -from .utils import WSGIServerTest -from .fixtures import resources +from . import fixtures, utils -class TestResourceConstruction(WSGIServerTest): + +class TestResourceConstruction(utils.TestCase): def setUp(self): super(TestResourceConstruction, self).setUp() - balanced.config.root_uri = 'http://localhost:31337' - - def test_property_conversion_from_uri_task_3833(self): - with self.start_server(app): - txns = [ - t for t in balanced.Transaction.query - if 'TEST-MP778-071-6386/debits/W985-622-9570' in t.uri] - self.assertEqual(txns[0].account_uri, txns[0].account.uri) - - def test_implicit_conversion_to_datetime(self): - with self.start_server(app): - for txn in balanced.Transaction.query: - if isinstance(txn, balanced.Debit): - break - self.assertIsInstance(txn.created_at, datetime.datetime) - - def test_redirects(self): - with self.start_server(app): - with self.assertRaises(balanced.exc.HTTPError) as exc: - balanced.APIKey().save() - exception = exc.exception - self.assertEqual(exception.response.status_code, 302) - self.assertEqual( - exception.response.headers['location'], - '/v1/your-mom' - ) - - def test_does_not_parse_meta(self): - payload = { - 'uri': '/v1/yo-momma', - 'meta': { - 'uri': 'None', - } - } - - balanced.Account(**payload) - - -class TestPage(unittest.TestCase): - - def test_filter2(self): - query = balanced.Marketplace.query - query = query.filter(balanced.Marketplace.f.a == 'b') - query = query.filter(balanced.Marketplace.f.a != '101') - query = query.filter(balanced.Marketplace.f.b < 4) - query = query.filter(balanced.Marketplace.f.b <= 5) - query = query.filter(balanced.Marketplace.f.c > 123) - query = query.filter(balanced.Marketplace.f.c >= 44) - query = query.filter(balanced.Marketplace.f.d.in_(1, 2, 3)) - query = query.filter(~balanced.Marketplace.f.d.in_(6, 33, 55)) - query = query.filter(balanced.Marketplace.f.e.contains('it')) - query = query.filter(~balanced.Marketplace.f.e.contains('soda')) - query = query.filter(balanced.Marketplace.f.f.startswith('la')) - query = query.filter(balanced.Marketplace.f.f.endswith('lo')) - query = query.filter(g=12) - - parsed_uri = urlparse.urlparse(query.uri) - parsed_qs = urlparse.parse_qsl(parsed_uri.query) - - self.assertDictEqual( - dict(parsed_qs), - { - 'a': 'b', - 'a[!=]': '101', - 'b[<=]': '5', - 'b[<]': '4', - 'c[>=]': '44', - 'c[>]': '123', - 'd[!in]': '6,33,55', - 'd[in]': '1,2,3', - 'e[!contains]': 'soda', - 'e[contains]': 'it', - 'f[endswith]': 'lo', - 'f[startswith]': 'la', - 'g': '12', - } - ) - - def test_sort(self): - q = balanced.Marketplace.query - q.sort(balanced.Marketplace.f.me.asc()) - self.assertDictEqual(q.qs, {'sort': ['me,asc']}) - q.sort(balanced.Marketplace.f.u.desc()) - self.assertDictEqual(q.qs, {'sort': ['me,asc', 'u,desc']}) - - def test_from_uri_and_dict(self): - expected = resources.INVOICES.copy() - expected.pop('uri') - page = balanced.resources.Page.from_response(**resources.INVOICES) - self.assertDictEqual(page._lazy_loaded, expected) - - -class TestMarketplace(unittest.TestCase): - - @mock.patch('balanced.resources.Card') - def test_region_deprecation(self, _card): - mkt = balanced.Marketplace() - with warnings.catch_warnings(record=True) as w: - mkt.create_card( - 'John Name', '341111111111111', '12', '2020', - region='CA' - ) - self.assertEqual(len(w), 1) - warning_ = w[0] - self.assertEqual( - warning_.message.message, - ('The region parameter will be deprecated in the ' - 'next minor version of balanced-python') - ) - self.assertTrue(isinstance(warning_.message, UserWarning)) - - -class TestResourceIdentification(unittest.TestCase): - def test_resource(self): - uris = [ - # marketplace - (balanced.Marketplace, '/v1/marketplaces/MP123'), - (balanced.Marketplace, '/v1/marketplaces'), - # nested under marketplace - (balanced.Credit, '/v1/marketplaces/credits'), - (balanced.Credit, '/v1/marketplaces/credits/C1'), - # root - (balanced.Event, '/v1/events'), - (balanced.Event, '/v1/events/E1'), - # nested under events - (balanced.EventCallback, '/v1/events/E1/callbacks'), - (balanced.EventCallback, '/v1/events/E1/callbacks/C1'), - # nested under events and callbacks - (balanced.EventCallbackLog, '/v1/events/E1/callbacks/C1/logs'), - (balanced.EventCallbackLog, '/v1/events/E1/callbacks/C1/logs/L1'), - ] - for expected_type, uri in uris: - derived_type = resource_registry.from_uri(uri) - self.assertEqual(expected_type, derived_type) + def test_load_resource(self): + resp = fixtures.Resources.marketplaces + marketplace = balanced.Marketplace(**resp) + self.assertIsNotNone(marketplace.debits) diff --git a/tests/test_suite.py b/tests/test_suite.py new file mode 100644 index 0000000..17f6361 --- /dev/null +++ b/tests/test_suite.py @@ -0,0 +1,828 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals +import sys +import time +from datetime import date + +import unittest2 as unittest +import requests + +import balanced +from balanced import exc as bexc + +# fixtures + +TEST_CARDS = { + 'visa': [ + '4112344112344113', + '4110144110144115', + '4114360123456785', + '4061724061724061', + ], + 'mastercard': [ + '5111005111051128' + '5112345112345114' + '5115915115915118' + '5116601234567894' + ], + 'amex': [ + '371144371144376', + '341134113411347', + ], + 'discover': [ + '6011016011016011', + '6559906559906557', + ] +} + +PERSON = { + 'name': 'William James', + 'address': { + 'line1': '167 West 74th Street', + 'line2': 'Apt 7', + 'state': 'NY', + 'city': 'NYC', + 'postal_code': '10023', + 'country_code': 'USA', + }, + 'dob': '1842-12', + 'phone': '+16505551234', + 'email': 'python-client@example.org', +} + +BUSINESS = PERSON.copy() +BUSINESS['ein'] = '123456789' +BUSINESS['business_name'] = 'Foo corp' + +CARD = { + 'name': 'Johnny Fresh', + 'number': '4444424444444440', + 'expiration_month': 12, + 'expiration_year': date.today().year + 1, + 'csc': '123', + 'address': { + 'line1': '123 Fake Street', + 'line2': 'Apt 7', + 'city': 'Jollywood', + 'state': 'CA', + 'postal_code': '90210', + 'country_code': 'US', + } +} + +#: a card which will always create a dispute when you debit it +DISPUTE_CARD = CARD.copy() +DISPUTE_CARD['number'] = '6500000000000002' + +CREDITABLE_CARD = { + 'name': 'Johannes Bach', + 'number': '4342561111111118', + 'expiration_month': 05, + 'expiration_year': date.today().year + 1, +} + +NON_CREDITABLE_CARD = { + 'name': 'Georg Telemann', + 'number': '4111111111111111', + 'expiration_month': 12, + 'expiration_year': date.today().year + 1, +} + +INTERNATIONAL_CARD = { + 'name': 'Johnny Fresh', + 'number': '4444424444444440', + 'expiration_month': 12, + 'expiration_year': date.today().year + 1, + 'address': { + 'street_address': '田原3ー8ー1', + 'city': '都留市', + 'state': '山梨県', + 'postal_code': '4020054', + 'country_code': 'JPN', + } +} + +BANK_ACCOUNT = { + 'name': 'Homer Jay', + 'account_number': '112233a', + 'routing_number': '121042882', +} + +BANK_ACCOUNT_W_TYPE = { + 'name': 'Homer Jay', + 'account_number': '112233a', + 'routing_number': '121042882', + 'type': 'checking' +} + + +class BasicUseCases(unittest.TestCase): + + @classmethod + def setUpClass(cls): + cls.marketplace, cls.api_key = cls.create_marketplace() + + def setUp(self): + super(BasicUseCases, self).setUp() + # some test might rewrite api_key, so we need to configure it + # here again + balanced.configure(self.api_key.secret) + + @classmethod + def create_marketplace(self): + balanced.configure(None) + api_key = balanced.APIKey().save() + balanced.configure(api_key.secret) + marketplace = balanced.Marketplace().save() + return marketplace, api_key + + def test_create_a_second_marketplace_should_fail(self): + with self.assertRaises(requests.HTTPError) as exc: + balanced.Marketplace().save() + the_exception = exc.exception + self.assertEqual(the_exception.status_code, 409) + + def test_index_the_marketplaces(self): + self.assertEqual(balanced.Marketplace.query.count(), 1) + + def test_create_a_customer(self): + meta = {'test#': 'test_d'} + card = balanced.Card(**CARD).save() + buyer = balanced.Customer( + source=card, + meta=meta, + **PERSON + ).save() + self.assertEqual(buyer.name, PERSON['name']) + self.assertIsNotNone(buyer.created_at) + self.assertIsNotNone(buyer.href) + self.assertEqual(buyer.cards.count(), 1) + self.assertEqual(buyer.cards.first().id, card.id) + + def test_debit_a_card_and_refund(self): + card = balanced.Card(**CARD).save() + debit = card.debit( + amount=1000, + appears_on_statement_as='atest', + meta={'fraud': 'yes'}, + description='Descripty') + self.assertTrue(debit.id.startswith('W')) + self.assertEqual(debit.description, 'Descripty') + self.assertEqual(debit.appears_on_statement_as, 'BAL*atest') + + refund = debit.refund(amount=100) + self.assertTrue(refund.id.startswith('RF')) + self.assertEqual(refund.debit.href, debit.href) + + another_debit = card.debit( + amount=1000, + meta={'fraud': 'yes'}) + self.assertEqual(another_debit.appears_on_statement_as, + 'BAL*example.com') + + another_debit.refund() + + def test_create_hold_and_void_it(self): + card = balanced.Card(**CARD).save() + hold = card.hold(amount=1500, description='Hold me') + self.assertEqual(hold.description, 'Hold me') + hold.cancel() + self.assertIsNotNone(hold.voided_at) + + def test_create_hold_and_capture_it(self): + card = balanced.Card(**CARD).save() + hold = card.hold(amount=1500) + self.assertTrue(hold.id.startswith('HL')) + debit = hold.capture() + self.assertEqual(debit.amount, 1500) + + def test_create_a_person_customer(self): + customer = balanced.Customer(**PERSON).save() + for key, value in PERSON.iteritems(): + if key == 'dob': + continue + if isinstance(value, dict): + self.assertDictEqual(getattr(customer, key), value) + else: + self.assertEqual(getattr(customer, key), value) + + def test_create_a_business_customer(self): + customer = balanced.Customer(**BUSINESS).save() + for key, value in BUSINESS.iteritems(): + if key == 'dob': + continue + if isinstance(value, dict): + self.assertDictEqual(getattr(customer, key), value) + else: + self.assertEqual(getattr(customer, key), value) + + def test_credit_a_bank_account(self): + self.create_marketplace() # NOTE: fresh mp for escrow checks + card = balanced.Card(**INTERNATIONAL_CARD).save() + bank_account = balanced.BankAccount(**BANK_ACCOUNT).save() + debit = card.debit(amount=10000) + credit = bank_account.credit(amount=1000) + self.assertTrue(credit.id.startswith('CR')) + self.assertEqual(credit.amount, 1000) + with self.assertRaises(requests.HTTPError) as exc: + bank_account.credit(amount=(debit.amount - credit.amount) + 1) + self.assertEqual(exc.exception.status_code, 409) + self.assertEqual(exc.exception.category_code, 'insufficient-funds') + + def test_credit_existing_card(self): + funding_card = balanced.Card(**CARD).save() + card = balanced.Card(**CREDITABLE_CARD).save() + debit = funding_card.debit(amount=250000) + credit = card.credit(amount=250000) + self.assertTrue(credit.id.startswith('CR')) + self.assertEqual(credit.href, '/credits/{0}'.format(credit.id)) + self.assertEqual(credit.status, 'succeeded') + self.assertEqual(credit.amount, 250000) + + def test_credit_card_in_request(self): + funding_card = balanced.Card(**CARD).save() + debit = funding_card.debit(amount=250000) + credit = balanced.Credit( + amount=250000, + description='A sweet ride', + destination=CREDITABLE_CARD + ).save() + self.assertTrue(credit.id.startswith('CR')) + self.assertEqual(credit.href, '/credits/{0}'.format(credit.id)) + self.assertEqual(credit.status, 'succeeded') + self.assertEqual(credit.amount, 250000) + self.assertEqual(credit.description, 'A sweet ride') + + def test_credit_card_can_credit_false(self): + funding_card = balanced.Card(**CARD).save() + debit = funding_card.debit(amount=250000) + card = balanced.Card(**NON_CREDITABLE_CARD).save() + with self.assertRaises(bexc.FundingSourceNotCreditable) as exc: + card.credit(amount=250000) + + def test_credit_card_limit(self): + funding_card = balanced.Card(**CARD).save() + debit = funding_card.debit(amount=250005) + card = balanced.Card(**CREDITABLE_CARD).save() + with self.assertRaises(requests.HTTPError) as exc: + credit = card.credit(amount=250001) + self.assertEqual(exc.exception.status_code, 409) + self.assertEqual(exc.exception.category_code, 'amount-exceeds-limit') + + def test_credit_card_require_name(self): + funding_card = balanced.Card(**CARD).save() + debit = funding_card.debit(amount=250005) + card_payload = CREDITABLE_CARD.copy() + card_payload.pop("name") + card = balanced.Card(**card_payload).save() + with self.assertRaises(requests.HTTPError) as exc: + credit = card.credit(amount=250001) + self.assertEqual(exc.exception.status_code, 400) + self.assertEqual(exc.exception.category_code, 'name-required-to-credit') + + def test_escrow_limit(self): + self.create_marketplace() # NOTE: fresh mp for escrow checks + bank_account = balanced.BankAccount(**BANK_ACCOUNT).save() + original_balance = 0 + with self.assertRaises(requests.HTTPError) as exc: + bank_account.credit(amount=original_balance + 1) + ex = exc.exception + self.assertEqual(ex.status_code, 409) + self.assertEqual(ex.category_code, 'insufficient-funds') + + def test_slice_syntax(self): + total_debit = balanced.Debit.query.count() + self.assertNotEqual(total_debit, 2) + self.assertEqual(len(balanced.Debit.query), total_debit) + sliced_debits = balanced.Debit.query[:2] + self.assertEqual(len(sliced_debits), 2) + for debit in sliced_debits: + self.assertIsInstance(debit, balanced.Debit) + all_debits = balanced.Debit.query.all() + last = total_debit * -1 + for index, debit in enumerate(all_debits): + self.assertEqual(debit.href, + balanced.Debit.query[last + index].href) + + def test_filter_and_sort(self): + card = balanced.Card(**INTERNATIONAL_CARD).save() + debits = [ + card.debit(amount=1122, meta={'tag': meta}) + for meta in ('1', '1', '2') + ] + + for meta in ('1', '2'): + debs = balanced.Debit.query.filter( + balanced.Debit.f.meta.tag == meta + ) + self.assertItemsEqual( + [deb.id for deb in debs], + [deb.id for deb in debits if deb.meta['tag'] == meta] + ) + + debs = balanced.Debit.query.filter( + balanced.Debit.f.meta.contains('tag') + ).sort(balanced.Debit.f.amount.asc()) + self.assertEqual(len(debs), 3) + self.assertItemsEqual([deb.id for deb in debs], + [deb.id for deb in debits]) + + def test_create_international_card(self): + card = balanced.Card(**INTERNATIONAL_CARD).save() + self.assertTrue(card.id.startswith('CC')) + + def test_credit_bank_account(self): + card = balanced.Card(**INTERNATIONAL_CARD).save() + card.debit(50) + bank_account = balanced.BankAccount(**BANK_ACCOUNT_W_TYPE).save() + cr = bank_account.credit(50) + self.assertEqual(cr.amount, 50) + + def test_reverse_a_credit(self): + card = balanced.Card(**INTERNATIONAL_CARD).save() + card.debit(5000) + bank_account = balanced.BankAccount(**BANK_ACCOUNT_W_TYPE).save() + credit = bank_account.credit(amount=5000) + reversal = credit.reverse() + self.assertEqual(reversal.amount, 5000) + self.assertIn(credit.id, reversal.credit.href) + + def test_delete_bank_account(self): + customer = balanced.Customer().save() + bank_account = balanced.BankAccount(**BANK_ACCOUNT_W_TYPE).save() + bank_account.associate_to_customer(customer) + bank_account.unstore() + + def test_delete_card(self): + customer = balanced.Customer().save() + card = balanced.Card(**CARD).save() + card.associate_to_customer(customer) + card.unstore() + + def test_fetch_resource(self): + customer = balanced.Customer().save() + customer2 = balanced.Customer.fetch(customer.href) + for prop in ('id', 'href', 'name', 'created_at'): + self.assertEqual( + getattr(customer, prop), + getattr(customer2, prop), + ) + + def test_order(self): + merchant = balanced.Customer().save() + bank_account = balanced.BankAccount(**BANK_ACCOUNT).save() + bank_account.associate_to_customer(merchant) + + order = merchant.create_order(description='foo order') + + card = balanced.Card(**INTERNATIONAL_CARD).save() + + # debit to increment escrow + card.debit(amount=1000) + + # debit the card and associate with the order. + card.debit(amount=100, order=order) + + order = balanced.Order.fetch(order.href) + + # the order captured the amount of the debit + self.assertEqual(order.amount_escrowed, 100) + + # pay out half + credit = bank_account.credit(amount=50, order=order) + + self.assertEqual(credit.order.href, order.href) + + order = balanced.Order.fetch(order.href) + + # half the money remains + self.assertEqual(order.amount_escrowed, 50) + + # not enough money in the order to pay out + with self.assertRaises(balanced.exc.BalancedError): + bank_account.credit(amount=150, order=order) + + def test_order_restrictions(self): + merchant = balanced.Customer().save() + + order = merchant.create_order(description='foo order') + + card = balanced.Card(**INTERNATIONAL_CARD).save() + + # debit the card and associate with the order. + card.debit(amount=100, order=order) + + another_bank_account = balanced.BankAccount( + account_number="1234567890", + routing_number="321174851", + name="Jack Q Merchant", + ).save() + + # not associated with the order + with self.assertRaises(balanced.exc.BalancedError): + another_bank_account.credit(amount=50, order=order) + + def test_order_helper_methods(self): + merchant = balanced.Customer().save() + order = merchant.create_order() + card = balanced.Card(**INTERNATIONAL_CARD).save() + + order.debit_from(source=card, amount=1234) + bank_account = balanced.BankAccount( + account_number='1234567890', + routing_number='321174851', + name='Someone', + ).save() + bank_account.associate_to_customer(merchant) + order.credit_to(destination=bank_account, amount=1234) + + def test_empty_list(self): + # NOTE: we need a whole new marketplace to reproduce the bug, + # otherwise, it's very likely we will consume records created + # by other tests + self.create_marketplace() + self.assertEqual(balanced.Credit.query.all(), []) + + def test_query_pagination(self): + card = balanced.Card(**CARD).save() + for _ in xrange(30): card.debit(amount=100) + self.assertEqual(len(balanced.Debit.query.all()), balanced.Debit.query.count()) + + def test_dispute(self): + card = balanced.Card(**DISPUTE_CARD).save() + debit = card.debit(amount=100) + + # TODO: this is ugly, I think we should provide a more + # reliable way to generate dispute, at least it should not + # take this long + print >> sys.stderr, ( + 'It takes a while before the dispute record created, ' + 'take and nap and wake up, then it should be done :/ ' + '(last time I tried it took 10 minutes...)' + ) + timeout = 12 * 60 + interval = 10 + begin = time.time() + while True: + if balanced.Dispute.query.count(): + break + time.sleep(interval) + elapsed = time.time() - begin + print >> sys.stderr, 'Polling disputes..., elapsed', elapsed + self.assertLess(elapsed, timeout, 'Ouch, timeout') + + dispute = balanced.Dispute.query.one() + self.assertEqual(dispute.status, 'pending') + self.assertEqual(dispute.reason, 'fraud') + self.assertEqual(dispute.transaction.id, debit.id) + + def test_external_accounts(self): + external_account = balanced.ExternalAccount( + token='123123123', + provider='name_of_provider', + ).save() + debit = external_account.debit( + amount=1234 + ) + self.assertEqual(debit.source.id, external_account.id) + + def test_general_resources(self): + card = balanced.Card(**CARD).save() + customer = balanced.Customer().save() + card.associate_to_customer(customer) + debit = card.debit(amount=1000) + self.assertIsNotNone(debit) + self.assertIsNotNone(debit.source) + self.assertTrue(isinstance(debit.source, balanced.Card)) + + def test_get_none_for_none(self): + card = balanced.Card(**CARD).save() + customer = balanced.Customer().save() + self.assertIsNone(card.customer) + card.associate_to_customer(customer) + card = balanced.Card.get(card.href) + self.assertIsNotNone(card.customer) + self.assertTrue(isinstance(card.customer, balanced.Customer)) + + def test_accounts_credit(self): + merchant = balanced.Customer().save() + order = merchant.create_order() + card = balanced.Card(**INTERNATIONAL_CARD).save() + + order.debit_from(source=card, amount=1234) + payable_account = merchant.payable_account + self.assertEqual(payable_account.balance, 0) + account_credit = payable_account.credit( + amount=1234, order=order.href, + appears_on_statement_as='Payout') + payable_account = merchant.payable_account + self.assertEqual(account_credit.status, 'succeeded') + self.assertEqual(payable_account.balance, 1234) + self.assertEqual(account_credit.appears_on_statement_as, 'Payout') + + def test_accounts_credit_from_multiple_orders(self): + merchant = balanced.Customer().save() + card = balanced.Card(**INTERNATIONAL_CARD).save() + payable_account = merchant.payable_account + self.assertEqual(payable_account.balance, 0) + amount = 1234 + + order_one = merchant.create_order() + order_one.debit_from(source=card, amount=amount) + payable_account.credit(amount=amount, order=order_one.href) + payable_account = merchant.payable_account + self.assertEqual(payable_account.balance, amount) + order_two = merchant.create_order() + order_two.debit_from(source=card, amount=amount) + payable_account.credit(amount=amount, order=order_two.href) + payable_account = merchant.payable_account + self.assertEqual(payable_account.balance, amount*2) + + def test_settlement(self): + merchant = balanced.Customer().save() + order = merchant.create_order() + card = balanced.Card(**INTERNATIONAL_CARD).save() + + order.debit_from(source=card, amount=1234) + payable_account = merchant.payable_account + payable_account.credit( + amount=1234, order=order.href, appears_on_statement_as='Payout') + payable_account = merchant.payable_account + self.assertEqual(payable_account.balance, 1234) + bank_account = balanced.BankAccount( + account_number='1234567890', + routing_number='321174851', + name='Someone', + ).save() + bank_account.associate_to_customer(merchant) + + settlement = payable_account.settle( + funding_instrument=bank_account.href, + appears_on_statement_as="Settlement Oct", + description="Settlement for payouts from October") + self.assertEqual(settlement.amount, 1234) + self.assertEqual(settlement.appears_on_statement_as, + "BAL*Settlement Oct") + self.assertEqual(settlement.description, + "Settlement for payouts from October") + payable_account = merchant.payable_account + self.assertEqual(payable_account.balance, 0) + + def test_settle_reverse_account_credit(self): + merchant = balanced.Customer().save() + order = merchant.create_order() + card = balanced.Card(**INTERNATIONAL_CARD).save() + + order.debit_from(source=card, amount=1234) + payable_account = merchant.payable_account + account_credit = payable_account.credit( + amount=1234, order=order.href, appears_on_statement_as='Payout') + payable_account = merchant.payable_account + self.assertEqual(payable_account.balance, 1234) + + bank_account = balanced.BankAccount( + account_number='1234567890', + routing_number='321174851', + name='Someone', + ).save() + bank_account.associate_to_customer(merchant) + + payable_account.settle( + funding_instrument=bank_account.href, + appears_on_statement_as="Settlement Oct", + description="Settlement for payouts from October") + payable_account = merchant.payable_account + self.assertEqual(payable_account.balance, 0) + + order_two = merchant.create_order() + order_two.debit_from(source=card, amount=1234) + payable_account.credit(amount=1234, order=order_two.href) + + payable_account = merchant.payable_account + self.assertEqual(payable_account.balance, 1234) + + account_credit.reverse(amount=1234) + payable_account = merchant.payable_account + self.assertEqual(payable_account.balance, 0) + + def test_settle_account_negative_balance(self): + merchant = balanced.Customer().save() + order = merchant.create_order() + card = balanced.Card(**INTERNATIONAL_CARD).save() + + order.debit_from(source=card, amount=1234) + payable_account = merchant.payable_account + account_credit = payable_account.credit( + amount=1234, order=order.href, appears_on_statement_as='Payout') + bank_account = balanced.BankAccount( + account_number='1234567890', + routing_number='321174851', + name='Someone', + ).save() + bank_account.associate_to_customer(merchant) + + payable_account.settle( + funding_instrument=bank_account.href, + appears_on_statement_as="Settlement Oct", + description="Settlement for payouts from October") + payable_account = merchant.payable_account + self.assertEqual(payable_account.balance, 0) + + account_credit.reverse(amount=1234) + payable_account = merchant.payable_account + self.assertEqual(payable_account.balance, -1234) + + payable_account.settle( + funding_instrument=bank_account.href, + appears_on_statement_as="Settlement Oct", + description="Settlement for payouts from October") + payable_account = merchant.payable_account + self.assertEqual(payable_account.balance, 0) + + +class Rev0URIBasicUseCases(unittest.TestCase): + """This test case ensures all revision 0 URIs can work without a problem + with current revision 1 client + + """ + + @classmethod + def setUpClass(cls): + # ensure we won't consume API key from other test case + balanced.configure() + cls.api_key = balanced.APIKey().save() + balanced.configure(cls.api_key.secret) + cls.marketplace = balanced.Marketplace().save() + + @classmethod + def _iter_customer_uris(cls, marketplace, customer): + args = dict( + mp=marketplace, + customer=customer, + ) + for pattern in [ + '/v1/customers/{customer.id}', + '/v1/marketplaces/{mp.id}/accounts/{customer.id}', + ]: + yield pattern.format(**args) + + @classmethod + def _iter_card_uris(cls, marketplace, customer, card): + args = dict( + mp=marketplace, + customer=customer, + card=card, + ) + for pattern in [ + '/v1/customers/{customer.id}/cards/{card.id}', + '/v1/marketplaces/{mp.id}/cards/{card.id}', + '/v1/marketplaces/{mp.id}/accounts/{customer.id}/cards/{card.id}', + ]: + yield pattern.format(**args) + + @classmethod + def _iter_bank_account_uris(cls, marketplace, customer, bank_account): + args = dict( + mp=marketplace, + customer=customer, + bank_account=bank_account, + ) + for pattern in [ + '/v1/customers/{customer.id}/bank_accounts/{bank_account.id}', + '/v1/marketplaces/{mp.id}/bank_accounts/{bank_account.id}', + '/v1/marketplaces/{mp.id}/accounts/{customer.id}/bank_accounts/{bank_account.id}', + ]: + yield pattern.format(**args) + + def assert_not_rev0(self, resource): + """Ensures the given resouce is not in revision 0 format + + """ + self.assert_(not hasattr(resource, '_uris')) + + def test_marketplace(self): + uri = '/v1/marketplaces/{0}'.format(self.marketplace.id) + marketplace = balanced.Marketplace.fetch(uri) + self.assertEqual(marketplace.id, self.marketplace.id) + self.assert_not_rev0(marketplace) + + def test_customer(self): + customer = balanced.Customer().save() + for uri in self._iter_customer_uris( + marketplace=self.marketplace, + customer=customer, + ): + result_customer = balanced.Customer.fetch(uri) + self.assertEqual(result_customer.id, customer.id) + self.assert_not_rev0(result_customer) + + def test_associate_card(self): + customer = balanced.Customer().save() + cards = set() + for uri in self._iter_customer_uris( + marketplace=self.marketplace, + customer=customer, + ): + card = balanced.Card(**CARD).save() + card.customer = uri + card.save() + cards.add(card.href) + customer_cards = set(card.href for card in customer.cards) + self.assertEqual(cards, customer_cards) + + def test_associate_bank_account(self): + customer = balanced.Customer().save() + bank_accounts = set() + for uri in self._iter_customer_uris( + marketplace=self.marketplace, + customer=customer, + ): + bank_account = balanced.BankAccount(**BANK_ACCOUNT).save() + bank_account.customer = uri + bank_account.save() + bank_accounts.add(bank_account.href) + + customer_bank_accounts = set( + bank_account.href for bank_account in customer.bank_accounts + ) + self.assertEqual(bank_accounts, customer_bank_accounts) + + def test_set_default_card(self): + customer = balanced.Customer().save() + card1 = balanced.Card(**CARD).save() + card1.associate_to_customer(customer) + card2 = balanced.Card(**CARD).save() + card2.associate_to_customer(customer) + # set card 1 as the default source + customer.source = card1.href + customer.save() + self.assertEqual(customer.source.href, card1.href) + for uri in self._iter_card_uris( + marketplace=self.marketplace, + customer=customer, + card=card2, + ): + # set the source to card2 via rev0 URI + customer.source = uri + customer.save() + self.assertEqual(customer.source.href, card2.href) + + # set the source back to card1 + customer.source = card1.href + customer.save() + self.assertEqual(customer.source.href, card1.href) + + def test_set_default_bank_account(self): + customer = balanced.Customer().save() + bank_account1 = balanced.BankAccount(**BANK_ACCOUNT).save() + bank_account1.associate_to_customer(customer) + bank_account2 = balanced.BankAccount(**BANK_ACCOUNT).save() + bank_account2.associate_to_customer(customer) + # set bank account 1 as the default destination + customer.destination = bank_account1.href + customer.save() + self.assertEqual(customer.destination.href, bank_account1.href) + for uri in self._iter_bank_account_uris( + marketplace=self.marketplace, + customer=customer, + bank_account=bank_account2, + ): + # set the destination to bank_account2 via rev0 URI + customer.destination = uri + customer.save() + self.assertEqual(customer.destination.href, bank_account2.href) + + # set the destination back to bank_account1 + customer.destination = bank_account1.href + customer.save() + self.assertEqual(customer.destination.href, bank_account1.href) + + def test_debit(self): + customer = balanced.Customer().save() + card = balanced.Card(**CARD).save() + card.associate_to_customer(customer) + for uri in self._iter_card_uris( + marketplace=self.marketplace, + customer=customer, + card=card, + ): + debit = balanced.Debit(amount=100, source=uri).save() + self.assertEqual(debit.source.href, card.href) + self.assertEqual(debit.amount, 100) + + def test_credit(self): + # make sufficient amount for credit later + card = balanced.Card(**CARD).save() + card.debit(amount=1000000) + + customer = balanced.Customer().save() + bank_account = balanced.BankAccount(**BANK_ACCOUNT).save() + bank_account.associate_to_customer(customer) + for uri in self._iter_bank_account_uris( + marketplace=self.marketplace, + customer=customer, + bank_account=bank_account, + ): + credit = balanced.Credit(amount=100, destination=uri).save() + self.assertEqual(credit.destination.href, bank_account.href) + self.assertEqual(credit.amount, 100) diff --git a/tests/utils.py b/tests/utils.py index d8b2a17..1948ebc 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + import contextlib import multiprocessing import unittest2 as unittest @@ -5,7 +7,11 @@ from wsgiref.simple_server import make_server -class WSGIServerTest(unittest.TestCase): +class TestCase(unittest.TestCase): + pass + + +class WSGIServerTest(TestCase): def setUp(self): self.server_process = None