1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 from urllib2 import Request, urlopen, quote, URLError, HTTPError
31 import sys
32 import base64
33 import json
34 import hmac
35 import hashlib
36 import time
37 import random
38
39
40 from simplify.constants import Constants
41 from simplify.domain import DomainFactory, Domain
42
43
44
45
46
47 HTTP_SUCCESS = 200
48 HTTP_REDIRECTED = 302
49 HTTP_UNAUTHORIZED = 401
50 HTTP_NOT_FOUND = 404
51 HTTP_NOT_ALLOWED = 405
52 HTTP_BAD_REQUEST = 400
53
54 HTTP_METHOD_POST = "POST"
55 HTTP_METHOD_PUT = "PUT"
56 HTTP_METHOD_GET = "GET"
57 HTTP_METHOD_DELETE = "DELETE"
58
59
60
61
62
63
64
65 public_key = None
66 private_key = None
67 api_base_sandbox_url = Constants.api_base_sandbox_url
68 api_base_live_url = Constants.api_base_live_url
69 oauth_base_url = Constants.oauth_base_url
70 user_agent = None
78
79 if criteria == None:
80 return ''
81
82 query_string = []
83 if 'max' in criteria:
84 query_string.append("max=" + str(criteria['max']))
85
86 if 'offset' in criteria:
87 query_string.append("offset=" + str(criteria['offset']))
88
89 if 'sorting' in criteria:
90 for key, value in criteria['sorting'].iteritems():
91 query_string.append("sorting[" + key + "]=" + quote(str(value)))
92
93 if 'filter' in criteria:
94 for key, value in criteria['filter'].iteritems():
95 query_string.append("filter[" + key + "]=" + quote(str(value)))
96
97 return '&'.join(query_string)
98
100
101 if response_code == HTTP_REDIRECTED:
102 raise BadRequestError("Unexpected response code returned from the API, have you got the correct URL?", response_code, response_body)
103 elif response_code == HTTP_BAD_REQUEST:
104 raise BadRequestError("Bad request", response_code, response_body)
105
106 elif response_code == HTTP_UNAUTHORIZED:
107 raise AuthenticationError("You are not authorized to make this request. Are you using the correct API keys?", response_code, response_body)
108
109 elif response_code == HTTP_NOT_FOUND:
110 raise ObjectNotFoundError("Object not found", response_code, response_body)
111
112 elif response_code == HTTP_NOT_ALLOWED:
113 raise NotAllowedError("Operation not allowed", response_code, response_body)
114
115 elif response_code < 500:
116 raise BadRequestError("Bad request", response_code, response_body)
117
118 else:
119 raise SysError("An unexpected error has been raised. Looks like there's something wrong at our end." , response_code, response_body)
120
127
128 """
129 Holds authentication information used when accessing the API.
130
131 @ivar public_key: Public key used to access the API.
132 @ivar private_key: Private key used to access the API.
133 @ivar access_token: OAuth token used to access the API.
134 """
135
137 """
138 Constructs an Authentication object.
139
140 @param kwargs: contains initial values for the instance variables. Valid keywords
141 are public_key, private_key and access_token. If no value is passed for
142 public_key or its value is None then simplify.public_key is used. If no
143 value is passed for private_key or its value is None then simplify.private_key
144 is used.
145 @return: an Authentication object
146 """
147
148 self.public_key = kwargs['public_key'] if 'public_key' in kwargs else None
149 if self.public_key == None:
150 global public_key
151 self.public_key = public_key
152
153 self.private_key = kwargs['private_key'] if 'private_key' in kwargs else None
154 if self.private_key == None:
155 global private_key
156 self.private_key = private_key
157
158 self.access_token = kwargs['access_token'] if 'access_token' in kwargs else None
159
162 """
163 OAuth access token.
164
165 @ivar access_token: Access token used when making an API call authenticated using OAuth
166 @ivar refresh_token: Token used when refreshing an access token.
167 @ivar expires_in: Number of seconds from the time the token was created till it expires.
168 """
169
170 @staticmethod
171 - def create(auth_code, redirect_uri, *auth_args):
172 """
173 Creates an AccessToken object.
174
175 @param auth_codes: OAuth authentication code.
176 @param redirect_uri: URI to which OAuth requests are redirected.
177 @param auth_args: an Authentication object used for the API call. If no value is passed the gloabl keys simplify.public_key and simplify.private_key are used.
178 @return: an AccessToken object object
179 """
180
181 props = {
182 'grant_type' : 'authorization_code',
183 'code' : auth_code,
184 'redirect_uri' : redirect_uri
185 }
186
187 h = PaymentsApi().send_auth_request(props, 'token', PaymentsApi.create_auth_object(auth_args))
188 return AccessToken(h)
189
190
192 """
193 Refreshes an AccessToken object. If successful the access_token, refresh_token and expires_in attributes are updated.
194
195 @param auth_args: an Authentication object used for the API call. If no value is passed the global keys simplify.public_key and simplify.private_key are used.
196 """
197
198 rt = self['refresh_token']
199 if not rt:
200 raise IllegalArgumentError("Cannot refresh access token; refresh token is invalid.")
201
202 props = {
203 'grant_type' : 'refresh_token',
204 'refresh_token' : rt
205 }
206
207 h = PaymentsApi().send_auth_request(props, 'token', PaymentsApi.create_auth_object(auth_args))
208 self.__dict__.update(h)
209
210
211 - def revoke(self, *auth_args):
212 """
213 Revokes an AccessToken object.
214
215 @param auth_args: an Authentication object used for the API call. If no value is passed the global keys simplify.public_key and simplify.private_key are used.
216 """
217
218 token = self['access_token']
219 if not token:
220 raise IllegalArgumentError("Cannot revoke access token; access token is invalid.")
221
222 props = {
223 'token' : token,
224 'refresh_token' : token
225 }
226
227 h = PaymentsApi().send_auth_request(props, 'revoke', PaymentsApi.create_auth_object(auth_args))
228 self.__dict__.clear()
229
230
231
232
233
234
235
236 -class ApiError(Exception):
237 """
238 Base class for all API errors.
239
240 @ivar status: HTTP status code (or None if there is no status).
241 @ivar reference: reference for the error (or None if there is no reference).
242 @ivar error_code: string code for the error (or None if there is no error code).
243 @ivar message: string description of the error (or None if there is no message).
244 @ivar error_data: dictionary containing all the error data (or None if there is no data)
245 """
246
247 - def __init__(self, message=None, status=500, error_data=None):
248 self.status = status
249
250 self.error_data = json.loads(error_data) if error_data else {}
251 err = self.error_data['error'] if 'error' in self.error_data else {}
252
253 self.reference = self.error_data['reference'] if 'reference' in self.error_data else None
254 self.error_code = err['code'] if 'code' in err else None
255 self.message = err['message'] if 'code' in err else message
256 super(ApiError, self).__init__(self.message)
257
258
260 """
261 Returns a string describing the error.
262 @return: a string describing the error.
263 """
264 return "{0}: \"{1}\" (status: {2}, error code: {3}, reference: {4})".format(self.__class__.__name__, self.message, self.status, self.error_code, self.reference)
265
268 """
269 Error raised when passing illegal arguments.
270 """
271 pass
272
274 """
275 Error raised when there are communication errors contacting the API.
276 """
277 pass
278
280 """
281 Error raised where there are problems authentication a request.
282 """
283 pass
284
286
287 """
288 Error raised when the request contains errors.
289
290 @ivar has_field_errors: boolean indicating whether there are field errors.
291 @ivar field_errors: a list containing all field errors.
292 """
293
295 """
296 Represents a single error in a field of data sent in a request to the API.
297
298 @ivar field_name: the name of the field with the error.
299 @ivar error_code: a string code for the error.
300 @ivar message: a string description of the error.
301 """
303 self.field_name = error_data['field']
304 self.error_code = error_data['code']
305 self.message = error_data['message']
306
308 return "Field error: {0} \"{1}\" ({2})".format(self.field_name, self.message, self.error_code)
309
310
311 - def __init__(self, message, status = 400, error_data = None):
312 super(BadRequestError, self).__init__(message, status, error_data)
313
314 self.field_errors = []
315 err = self.error_data['error'] if 'error' in self.error_data else {}
316 field_errors = err['fieldErrors'] if 'fieldErrors' in err else []
317 for field_error in field_errors:
318 self.field_errors.append(BadRequestError.FieldError(field_error))
319 self.has_field_errors = len(self.field_errors) > 0
320
322 """
323 Returns a string describing the error.
324 @return: a string describing the error.
325 """
326 txt = ApiError.describe(self)
327 for field_error in self.field_errors:
328 txt = txt + "\n" + str(field_error)
329 return txt + "\n"
330
332 """
333 Error raised when a requested object cannot be found.
334 """
335 pass
336
338 """
339 Error raised when a request was not allowed.
340 """
341 pass
342
344 """
345 Error raised when there was a system error processing a request.
346 """
347 pass
348
349
350
351
352
353
354 -class Http:
357
358 - def request(self, auth, url, method, params = None):
359
360 if params is None:
361 params = {}
362
363 jws_signature = Jws.encode(url, auth, params, method == HTTP_METHOD_POST or method == HTTP_METHOD_PUT)
364
365 if method == HTTP_METHOD_POST:
366 request = Request(url, jws_signature)
367 request.add_header("Content-Type", "application/json")
368
369 elif method == HTTP_METHOD_PUT:
370 request = Request(url, jws_signature)
371 request.add_header("Content-Type", "application/json")
372
373 elif method == HTTP_METHOD_DELETE:
374 request = Request(url)
375 request.add_header("Authorization", "JWS " + jws_signature)
376 request.get_method = lambda: HTTP_METHOD_DELETE
377
378 elif method == HTTP_METHOD_GET:
379 request = Request(url)
380 request.add_header("Authorization", "JWS " + jws_signature)
381
382 else:
383 raise ApiConnectionError("HTTP Method {0} not recognised".format(method))
384
385 request.add_header("Accept", "application/json")
386 global user_agent
387
388 user_agent_hdr = "Python-SDK/" + Constants.version
389 if user_agent != None:
390 user_agent_hdr = user_agent_hdr + " " + user_agent
391 request.add_header("User-Agent", user_agent_hdr)
392
393 try:
394 response = urlopen(request)
395 response_body = response.read()
396 response_code = response.code
397 except HTTPError as err:
398 response_body = err.read()
399 response_code = err.code
400 except URLError as err:
401 msg = "Looks like there's a problem connecting to the API endpoint: {0}\nError: {1}".format(url, str(err))
402 raise ApiConnectionError(msg)
403
404 return response_body, response_code
405
406
408
409 jws_signature = Jws.auth_encode(url, auth, params)
410
411 request = Request(url, jws_signature)
412 request.add_header("Content-Type", "application/json")
413 request.add_header("Accept", "application/json")
414
415 global user_agent
416 user_agent_hdr = "Python-SDK/" + Constants.version
417 if user_agent != None:
418 user_agent_hdr = user_agent_hdr + " " + user_agent
419 request.add_header("User-Agent", user_agent_hdr)
420
421 try:
422 response = urlopen(request)
423 response_body = response.read()
424 response_code = response.code
425 except HTTPError as err:
426 response_body = err.read()
427 response_code = err.code
428 except URLError as err:
429 msg = "Looks like there's a problem connecting to the API endpoint: {0}\nError: {1}".format(url, str(err))
430 raise ApiConnectionError(msg)
431
432 return response_body, response_code
433
434
435
436
437
438
439 -class Jws:
440
441 NUM_HEADERS = 7
442 ALGORITHM = 'HS256'
443 TYPE = 'JWS'
444 HDR_URI = 'api.simplifycommerce.com/uri'
445 HDR_TIMESTAMP = 'api.simplifycommerce.com/timestamp'
446 HDR_NONCE = 'api.simplifycommerce.com/nonce'
447 HDR_TOKEN = "api.simplifycommerce.com/token";
448 HDR_UNAME = 'uname'
449 HDR_ALGORITHM = 'alg'
450 HDR_TYPE = 'typ'
451 HDR_KEY_ID = 'kid'
452 TIMESTAMP_MAX_DIFF = 1000 * 60 * 5
453
456
457 @staticmethod
458 - def encode(url, auth, params, has_payload):
459
460 jws_hdr = {'typ': Jws.TYPE,
461 'alg': Jws.ALGORITHM,
462 'kid': auth.public_key,
463 Jws.HDR_URI: url,
464 Jws.HDR_TIMESTAMP: int(round(time.time() * 1000)),
465 Jws.HDR_NONCE: str(random.randint(1, 10*1000))}
466
467 token = auth.access_token
468 if token:
469 jws_hdr[Jws.HDR_TOKEN] = token
470
471 header = base64.urlsafe_b64encode(Jws().encode_json(jws_hdr)).replace('=', '')
472 payload = ''
473 if has_payload:
474 payload = Jws().encode_json(params)
475 payload = base64.urlsafe_b64encode(payload).replace('=', '')
476
477 msg = header + "." + payload
478 signature = Jws().sign(auth.private_key, msg)
479 return msg + "." + signature
480
481
482 @staticmethod
484
485 jws_hdr = {'typ': Jws.TYPE,
486 'alg': Jws.ALGORITHM,
487 'kid': auth.public_key,
488 Jws.HDR_URI: url,
489 Jws.HDR_TIMESTAMP: int(round(time.time() * 1000)),
490 Jws.HDR_NONCE: str(random.randint(1, 10*1000))}
491
492 header = base64.urlsafe_b64encode(Jws().encode_json(jws_hdr)).replace('=', '')
493
494
495 payload = '&'.join([ "%s=%s" % (k,v) for k,v in params.iteritems()])
496 payload = base64.urlsafe_b64encode(payload).replace('=', '')
497
498 msg = header + "." + payload
499 signature = Jws().sign(auth.private_key, msg)
500 return msg + "." + signature
501
502
503 @staticmethod
540
541 - def sign(self, private_api_key, msg):
542 decoded_private_api_key = Jws().safe_base64_decode(private_api_key)
543 signature = hmac.new(decoded_private_api_key, msg, hashlib.sha256).digest()
544 return base64.urlsafe_b64encode(signature).replace('=', '')
545
546 - def verify(self, header, url, public_api_key):
594
596
597 length = len(url) % 4
598 if length == 2:
599 return base64.urlsafe_b64decode(url + "==")
600 if length == 3:
601 return base64.urlsafe_b64decode(url + "=")
602
603 return base64.urlsafe_b64decode(url)
604
606
607 try:
608 return json.dumps(json_str).encode('utf-8')
609 except Exception:
610 raise ApiError("Invalid format for JSON request")
611
618
619
622
623 @staticmethod
650
651
652 @staticmethod
663
664
665
666 @staticmethod
667 - def create(object_type, auth_args, params):
674
675 @staticmethod
676 - def list(object_type, auth_args, criteria):
686
687 @staticmethod
688 - def find(object_type, auth_args, object_id):
698
699 @staticmethod
700 - def update(object_type, auth_args, object_id, params):
710
711 @staticmethod
712 - def delete(object_type, auth_args, object_id):
722
723 - def decode(self, auth_args, params):
729
730
731 - def execute(self, object_type, auth, url_suffix, method, params = None):
765
766
768
769 PaymentsApi.check_auth(auth)
770
771 http = Http()
772
773 global oauth_base_url
774
775 url = oauth_base_url + "/" + context
776
777 response_body, response_code = http.auth_request(auth, url, props)
778
779
780 try:
781 response = json.loads(response_body)
782 except Exception:
783 raise SysError("Invalid response format returned. Have you got the correct URL {0} \n HTTP Status: {1}".format(url, response_code))
784
785 if response_code == HTTP_SUCCESS:
786 return response
787 elif response_code == HTTP_REDIRECTED:
788 raise BadRequestError("", response_code)
789 elif response_code >= HTTP_BAD_REQUEST:
790 error_code = response['error']
791 error_desc = response['error_description']
792 if error_code == 'invalid_request':
793 raise BadRequestError("", response_code, self.get_oauth_error("Error during OAuth request", error_code, error_desc))
794 elif error_code == 'access_denied':
795 raise AuthenticationError("", response_code, self.get_oauth_error("Access denied for OAuth request", error_code, error_desc))
796 elif error_code == 'invalid_client':
797 raise AuthenticationError("", response_code, self.get_oauth_error("Invalid client ID in OAuth request", error_code, error_desc))
798 elif error_code == 'unauthorized_client':
799 raise AuthenticationError("", response_code, self.get_oauth_error("Unauthorized client in OAuth request", error_code, error_desc))
800 elif error_code == 'unsupported_grant_type':
801 raise BadRequestError("", response_code, self.get_oauth_error("Unsupported grant type in OAuth request", error_code, error_desc))
802 elif error_code == 'invalid_scope':
803 raise BadRequestError("", response_code, self.get_oauth_error("Invalid scope in OAuth request", error_code, error_desc))
804 else:
805 raise BadRequestError("", e.response_code, self.get_oauth_error("Unknown OAuth error", error_code, error_desc))
806 end
807 elif response_code < 500:
808 raise BadRequestError("Bad request", response_code, {})
809 else:
810 raise SysError("Bad request", response_code, {})
811
812
814 return """{"error" : {"code" : "oauth_error", "message" : "%s, error code '%s', description '%s'" }}""" % (msg, error_code, error_desc)
815
816
817 @classmethod
819
820 url = object_type
821 if object_id:
822 url = "{0}/{1}".format(url, object_id)
823
824 return url
825
826
827
828
829
830
831
832
833 -class Event(Domain):
834
835 """
836 A Event object.
837 """
838
839 @staticmethod
840 - def create(params, *auth_args):
841
842 """
843 Create an Event object.
844 @param params: a dict of parameters; valid keys are:
845 - C{payload}: The raw JWS message payload. B{required}
846 - C{url}: The URL for the webhook. If present it must match the URL registered for the webhook.
847 @param auth_args: an Authentication object used for the API call. If no value is passed the gloabl keys simplify.public_key and simplify.private_key are used.
848 For backwards compatibility the public and private keys may be passed instead of an Authentication object.
849 @return: an Event object
850 """
851
852 obj = PaymentsApi().decode(auth_args, params)
853
854 if not 'event' in obj:
855 raise ApiError("Incorrect data in webhook event")
856
857 return DomainFactory.factory('event', obj['event'])
858
860 """
861 A Authorization object.
862 """
863
864
865 @staticmethod
866 - def create(params, *auth_args):
867 """
868 Creates an Authorization object
869 @param params: a dict of parameters; valid keys are:
870 - C{amount}: Amount of the payment (in the smallest unit of your currency). Example: 100 = $1.00USD [min value: 50, max value: 9999900] B{required }
871 - C{card => addressCity}: City of the cardholder. [max length: 50, min length: 2]
872 - C{card => addressCountry}: Country code (ISO-3166-1-alpha-2 code) of residence of the cardholder. [max length: 2, min length: 2]
873 - C{card => addressLine1}: Address of the cardholder. [max length: 255]
874 - C{card => addressLine2}: Address of the cardholder if needed. [max length: 255]
875 - C{card => addressState}: State code (USPS code) of residence of the cardholder. [max length: 2, min length: 2]
876 - C{card => addressZip}: Postal code of the cardholder. The postal code size is between 5 and 9 characters in length and only contains numbers or letters. [max length: 9, min length: 3]
877 - C{card => cvc}: CVC security code of the card. This is the code on the back of the card. Example: 123
878 - C{card => expMonth}: Expiration month of the card. Format is MM. Example: January = 01 [min value: 1, max value: 12] B{required }
879 - C{card => expYear}: Expiration year of the card. Format is YY. Example: 2013 = 13 [max value: 99] B{required }
880 - C{card => name}: Name as it appears on the card. [max length: 50, min length: 2]
881 - C{card => number}: Card number as it appears on the card. [max length: 19, min length: 13] B{required }
882 - C{currency}: Currency code (ISO-4217) for the transaction. Must match the currency associated with your account. [default: USD] B{required }
883 - C{customer}: ID of customer. If specified, card on file of customer will be used.
884 - C{description}: Free form text field to be used as a description of the payment. This field is echoed back with the payment on any find or list operations. [max length: 1024]
885 - C{reference}: Custom reference field to be used with outside systems.
886 - C{replayId}: An identifier that can be sent to uniquely identify a payment request to facilitate retries due to I/O related issues. This identifier must be unique for your account (sandbox or live) across all of your payments. If supplied, we will check for a payment on your account that matches this identifier, and if one is found we will attempt to return an identical response of the original request. [max length: 50, min length: 1]
887 - C{token}: If specified, card associated with card token will be used. [max length: 255]
888 @param auth_args: an Authentication object used for the API call. If no value is passed the gloabl keys simplify.public_key and simplify.private_key are used.
889 For backwards compatibility the public and private keys may be passed instead of an Authentication object.
890 @param private_api_key: Private key to use for the API call. If C{None}, the value of C{simplify.private_key} will be used.
891 @return: a Authorization object
892 """
893 return PaymentsApi.create("authorization", auth_args, params)
894
895 - def delete(self, *auth_args):
896 """
897 Delete this object
898 @param auth_args: an Authentication object used for the API call. If no value is passed the gloabl keys simplify.public_key and simplify.private_key are used.
899 For backwards compatibility the public and private keys may be passed instead of an Authentication object.
900 """
901 return PaymentsApi.delete("authorization", auth_args, self.object_id)
902
903 @staticmethod
904 - def list(criteria = None, *auth_args):
905 """
906 Retrieve Authorization objects.
907 @param criteria: a dict of parameters; valid keys are:
908 - C{filter} Filters to apply to the list.
909 - C{max} Allows up to a max of 50 list items to return. [max value: 50, default: 20]
910 - C{offset} Used in pagination of the list. This is the start offset of the page. [default: 0]
911 - C{sorting} Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either C{asc} for ascending or C{desc} for descending). Sortable properties are: C{dateCreated} C{amount} C{id} C{description} C{paymentDate}.
912 @param auth_args: an Authentication object used for the API call. If no value is passed the gloabl keys simplify.public_key and simplify.private_key are used.
913 For backwards compatibility the public and private keys may be passed instead of an Authentication object.
914 @return: an object which contains the list of Authorization objects in the <code>list</code> property and the total number
915 of objects available for the given criteria in the <code>total</code> property.
916 """
917 return PaymentsApi.list("authorization", auth_args, criteria)
918
919 @staticmethod
920 - def find(object_id, *auth_args):
921 """
922 Retrieve a Authorization object from the API
923 @param object_id: ID of object to retrieve
924 @param auth_args: an Authentication object used for the API call. If no value is passed the gloabl keys simplify.public_key and simplify.private_key are used.
925 For backwards compatibility the public and private keys may be passed instead of an Authentication object.
926 @return: a Authorization object
927 """
928 return PaymentsApi.find("authorization", auth_args, object_id)
929
931 """
932 A CardToken object.
933 """
934
935
936 @staticmethod
937 - def create(params, *auth_args):
938 """
939 Creates an CardToken object
940 @param params: a dict of parameters; valid keys are:
941 - C{callback}: The URL callback for the cardtoken
942 - C{card => addressCity}: City of the cardholder. [max length: 50, min length: 2]
943 - C{card => addressCountry}: Country code (ISO-3166-1-alpha-2 code) of residence of the cardholder. [max length: 2, min length: 2]
944 - C{card => addressLine1}: Address of the cardholder. [max length: 255]
945 - C{card => addressLine2}: Address of the cardholder if needed. [max length: 255]
946 - C{card => addressState}: State code (USPS code) of residence of the cardholder. [max length: 2, min length: 2]
947 - C{card => addressZip}: Postal code of the cardholder. The postal code size is between 5 and 9 in length and only contain numbers or letters. [max length: 9, min length: 3]
948 - C{card => cvc}: CVC security code of the card. This is the code on the back of the card. Example: 123
949 - C{card => expMonth}: Expiration month of the card. Format is MM. Example: January = 01 [min value: 1, max value: 12] B{required }
950 - C{card => expYear}: Expiration year of the card. Format is YY. Example: 2013 = 13 [max value: 99] B{required }
951 - C{card => name}: Name as appears on the card. [max length: 50, min length: 2]
952 - C{card => number}: Card number as it appears on the card. [max length: 19, min length: 13] B{required }
953 - C{key}: Key used to create the card token.
954 @param auth_args: an Authentication object used for the API call. If no value is passed the gloabl keys simplify.public_key and simplify.private_key are used.
955 For backwards compatibility the public and private keys may be passed instead of an Authentication object.
956 @param private_api_key: Private key to use for the API call. If C{None}, the value of C{simplify.private_key} will be used.
957 @return: a CardToken object
958 """
959 return PaymentsApi.create("cardToken", auth_args, params)
960
961 @staticmethod
962 - def find(object_id, *auth_args):
963 """
964 Retrieve a CardToken object from the API
965 @param object_id: ID of object to retrieve
966 @param auth_args: an Authentication object used for the API call. If no value is passed the gloabl keys simplify.public_key and simplify.private_key are used.
967 For backwards compatibility the public and private keys may be passed instead of an Authentication object.
968 @return: a CardToken object
969 """
970 return PaymentsApi.find("cardToken", auth_args, object_id)
971
973 """
974 A Chargeback object.
975 """
976
977
978 @staticmethod
979 - def list(criteria = None, *auth_args):
980 """
981 Retrieve Chargeback objects.
982 @param criteria: a dict of parameters; valid keys are:
983 - C{filter} Filters to apply to the list.
984 - C{max} Allows up to a max of 50 list items to return. [max value: 50, default: 20]
985 - C{offset} Used in paging of the list. This is the start offset of the page. [default: 0]
986 - C{sorting} Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either C{asc} for ascending or C{desc} for descending). Sortable properties are: C{id} C{amount} C{description} C{dateCreated}.
987 @param auth_args: an Authentication object used for the API call. If no value is passed the gloabl keys simplify.public_key and simplify.private_key are used.
988 For backwards compatibility the public and private keys may be passed instead of an Authentication object.
989 @return: an object which contains the list of Chargeback objects in the <code>list</code> property and the total number
990 of objects available for the given criteria in the <code>total</code> property.
991 """
992 return PaymentsApi.list("chargeback", auth_args, criteria)
993
994 @staticmethod
995 - def find(object_id, *auth_args):
996 """
997 Retrieve a Chargeback object from the API
998 @param object_id: ID of object to retrieve
999 @param auth_args: an Authentication object used for the API call. If no value is passed the gloabl keys simplify.public_key and simplify.private_key are used.
1000 For backwards compatibility the public and private keys may be passed instead of an Authentication object.
1001 @return: a Chargeback object
1002 """
1003 return PaymentsApi.find("chargeback", auth_args, object_id)
1004
1006 """
1007 A Coupon object.
1008 """
1009
1010
1011 @staticmethod
1012 - def create(params, *auth_args):
1013 """
1014 Creates an Coupon object
1015 @param params: a dict of parameters; valid keys are:
1016 - C{amountOff}: Amount off of the price of the product in the smallest units of the currency of the merchant. While this field is optional, you must provide either amountOff or percentOff for a coupon. Example: 100 = $1.00USD [min value: 1, max value: 9999900]
1017 - C{couponCode}: Code that identifies the coupon to be used. [min length: 2] B{required }
1018 - C{description}: A brief section that describes the coupon.
1019 - C{durationInMonths}: Duration in months that the coupon will be applied after it has first been selected. [min value: 1, max value: 9999]
1020 - C{endDate}: Last date of the coupon in UTC millis that the coupon can be applied to a subscription. This ends at 23:59:59 of the merchant timezone.
1021 - C{maxRedemptions}: Maximum number of redemptions allowed for the coupon. A redemption is defined as when the coupon is applied to the subscription for the first time. [min value: 1]
1022 - C{percentOff}: Percentage off of the price of the product. While this field is optional, you must provide either amountOff or percentOff for a coupon. The percent off is a whole number. [min value: 1, max value: 100]
1023 - C{startDate}: First date of the coupon in UTC millis that the coupon can be applied to a subscription. This starts at midnight of the merchant timezone. B{required }
1024 @param auth_args: an Authentication object used for the API call. If no value is passed the gloabl keys simplify.public_key and simplify.private_key are used.
1025 For backwards compatibility the public and private keys may be passed instead of an Authentication object.
1026 @param private_api_key: Private key to use for the API call. If C{None}, the value of C{simplify.private_key} will be used.
1027 @return: a Coupon object
1028 """
1029 return PaymentsApi.create("coupon", auth_args, params)
1030
1031 - def delete(self, *auth_args):
1032 """
1033 Delete this object
1034 @param auth_args: an Authentication object used for the API call. If no value is passed the gloabl keys simplify.public_key and simplify.private_key are used.
1035 For backwards compatibility the public and private keys may be passed instead of an Authentication object.
1036 """
1037 return PaymentsApi.delete("coupon", auth_args, self.object_id)
1038
1039 @staticmethod
1040 - def list(criteria = None, *auth_args):
1041 """
1042 Retrieve Coupon objects.
1043 @param criteria: a dict of parameters; valid keys are:
1044 - C{filter} Filters to apply to the list.
1045 - C{max} Allows up to a max of 50 list items to return. [max value: 50, default: 20]
1046 - C{offset} Used in paging of the list. This is the start offset of the page. [default: 0]
1047 - C{sorting} Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either C{asc} for ascending or C{desc} for descending). Sortable properties are: C{dateCreated} C{maxRedemptions} C{timesRedeemed} C{id} C{startDate} C{endDate} C{percentOff} C{couponCode} C{durationInMonths} C{amountOff}.
1048 @param auth_args: an Authentication object used for the API call. If no value is passed the gloabl keys simplify.public_key and simplify.private_key are used.
1049 For backwards compatibility the public and private keys may be passed instead of an Authentication object.
1050 @return: an object which contains the list of Coupon objects in the <code>list</code> property and the total number
1051 of objects available for the given criteria in the <code>total</code> property.
1052 """
1053 return PaymentsApi.list("coupon", auth_args, criteria)
1054
1055 @staticmethod
1056 - def find(object_id, *auth_args):
1057 """
1058 Retrieve a Coupon object from the API
1059 @param object_id: ID of object to retrieve
1060 @param auth_args: an Authentication object used for the API call. If no value is passed the gloabl keys simplify.public_key and simplify.private_key are used.
1061 For backwards compatibility the public and private keys may be passed instead of an Authentication object.
1062 @return: a Coupon object
1063 """
1064 return PaymentsApi.find("coupon", auth_args, object_id)
1065
1066 - def update(self, *auth_args):
1067 """
1068 Updates this object
1069
1070 The properties that can be updated:
1071 - C{endDate} The ending date in UTC millis for the coupon. This must be after the starting date of the coupon.
1072
1073 - C{maxRedemptions} Maximum number of redemptions allowed for the coupon. A redemption is defined as when the coupon is applied to the subscription for the first time. [min value: 1]
1074
1075 @param auth_args: an Authentication object used for the API call. If no value is passed the gloabl keys simplify.public_key and simplify.private_key are used.
1076 For backwards compatibility the public and private keys may be passed instead of an Authentication object.
1077 @return: a Coupon object.
1078 """
1079 return PaymentsApi.update("coupon", auth_args, self.object_id, self.to_dict())
1080
1082 """
1083 A Customer object.
1084 """
1085
1086
1087 @staticmethod
1088 - def create(params, *auth_args):
1089 """
1090 Creates an Customer object
1091 @param params: a dict of parameters; valid keys are:
1092 - C{card => addressCity}: City of the cardholder. B{required }
1093 - C{card => addressCountry}: Country code (ISO-3166-1-alpha-2 code) of residence of the cardholder. B{required }
1094 - C{card => addressLine1}: Address of the cardholder B{required }
1095 - C{card => addressLine2}: Address of the cardholder if needed. B{required }
1096 - C{card => addressState}: State code (USPS code) of residence of the cardholder. B{required }
1097 - C{card => addressZip}: Postal code of the cardholder. The postal code size is between 5 and 9 in length and only contain numbers or letters. B{required }
1098 - C{card => cvc}: CVC security code of the card. This is the code on the back of the card. Example: 123 B{required }
1099 - C{card => expMonth}: Expiration month of the card. Format is MM. Example: January = 01 B{required }
1100 - C{card => expYear}: Expiration year of the card. Format is YY. Example: 2013 = 13 B{required }
1101 - C{card => id}: ID of card. Unused during customer create.
1102 - C{card => name}: Name as appears on the card. B{required }
1103 - C{card => number}: Card number as it appears on the card. [max length: 19, min length: 13]
1104 - C{email}: Email address of the customer B{required }
1105 - C{name}: Customer name [min length: 2] B{required }
1106 - C{reference}: Reference field for external applications use.
1107 - C{subscriptions => amount}: Amount of payment in the smallest unit of your currency. Example: 100 = $1.00USD [min value: 50, max value: 9999900]
1108 - C{subscriptions => coupon}: Coupon associated with the subscription for the customer.
1109 - C{subscriptions => currency}: Currency code (ISO-4217). Must match the currency associated with your account. [default: USD]
1110 - C{subscriptions => customer}: The customer ID to create the subscription for. Do not supply this when creating a customer.
1111 - C{subscriptions => frequency}: Frequency of payment for the plan. Example: Monthly
1112 - C{subscriptions => name}: Name describing subscription
1113 - C{subscriptions => plan}: The plan ID that the subscription should be created from.
1114 - C{subscriptions => quantity}: Quantity of the plan for the subscription. [min value: 1]
1115 - C{token}: If specified, card associated with card token will be used
1116 @param auth_args: an Authentication object used for the API call. If no value is passed the gloabl keys simplify.public_key and simplify.private_key are used.
1117 For backwards compatibility the public and private keys may be passed instead of an Authentication object.
1118 @param private_api_key: Private key to use for the API call. If C{None}, the value of C{simplify.private_key} will be used.
1119 @return: a Customer object
1120 """
1121 return PaymentsApi.create("customer", auth_args, params)
1122
1123 - def delete(self, *auth_args):
1124 """
1125 Delete this object
1126 @param auth_args: an Authentication object used for the API call. If no value is passed the gloabl keys simplify.public_key and simplify.private_key are used.
1127 For backwards compatibility the public and private keys may be passed instead of an Authentication object.
1128 """
1129 return PaymentsApi.delete("customer", auth_args, self.object_id)
1130
1131 @staticmethod
1132 - def list(criteria = None, *auth_args):
1133 """
1134 Retrieve Customer objects.
1135 @param criteria: a dict of parameters; valid keys are:
1136 - C{filter} Filters to apply to the list.
1137 - C{max} Allows up to a max of 50 list items to return. [max value: 50, default: 20]
1138 - C{offset} Used in paging of the list. This is the start offset of the page. [default: 0]
1139 - C{sorting} Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either C{asc} for ascending or C{desc} for descending). Sortable properties are: C{dateCreated} C{id} C{name} C{email} C{reference}.
1140 @param auth_args: an Authentication object used for the API call. If no value is passed the gloabl keys simplify.public_key and simplify.private_key are used.
1141 For backwards compatibility the public and private keys may be passed instead of an Authentication object.
1142 @return: an object which contains the list of Customer objects in the <code>list</code> property and the total number
1143 of objects available for the given criteria in the <code>total</code> property.
1144 """
1145 return PaymentsApi.list("customer", auth_args, criteria)
1146
1147 @staticmethod
1148 - def find(object_id, *auth_args):
1149 """
1150 Retrieve a Customer object from the API
1151 @param object_id: ID of object to retrieve
1152 @param auth_args: an Authentication object used for the API call. If no value is passed the gloabl keys simplify.public_key and simplify.private_key are used.
1153 For backwards compatibility the public and private keys may be passed instead of an Authentication object.
1154 @return: a Customer object
1155 """
1156 return PaymentsApi.find("customer", auth_args, object_id)
1157
1158 - def update(self, *auth_args):
1159 """
1160 Updates this object
1161
1162 The properties that can be updated:
1163 - C{card => addressCity} City of the cardholder. B{(required)}
1164
1165 - C{card => addressCountry} Country code (ISO-3166-1-alpha-2 code) of residence of the cardholder. B{(required)}
1166
1167 - C{card => addressLine1} Address of the cardholder. B{(required)}
1168
1169 - C{card => addressLine2} Address of the cardholder if needed. B{(required)}
1170
1171 - C{card => addressState} State code (USPS code) of residence of the cardholder. B{(required)}
1172
1173 - C{card => addressZip} Postal code of the cardholder. The postal code size is between 5 and 9 in length and only contain numbers or letters. B{(required)}
1174
1175 - C{card => cvc} CVC security code of the card. This is the code on the back of the card. Example: 123 B{(required)}
1176
1177 - C{card => expMonth} Expiration month of the card. Format is MM. Example: January = 01 B{(required)}
1178
1179 - C{card => expYear} Expiration year of the card. Format is YY. Example: 2013 = 13 B{(required)}
1180
1181 - C{card => id} ID of card. If present, card details for the customer will not be updated. If not present, the customer will be updated with the supplied card details.
1182
1183 - C{card => name} Name as appears on the card. B{(required)}
1184
1185 - C{card => number} Card number as it appears on the card. [max length: 19, min length: 13]
1186
1187 - C{email} Email address of the customer B{(required)}
1188
1189 - C{name} Customer name [min length: 2] B{(required)}
1190
1191 - C{reference} Reference field for external applications use.
1192
1193 - C{token} If specified, card associated with card token will be added to the customer
1194
1195 @param auth_args: an Authentication object used for the API call. If no value is passed the gloabl keys simplify.public_key and simplify.private_key are used.
1196 For backwards compatibility the public and private keys may be passed instead of an Authentication object.
1197 @return: a Customer object.
1198 """
1199 return PaymentsApi.update("customer", auth_args, self.object_id, self.to_dict())
1200
1202 """
1203 A Deposit object.
1204 """
1205
1206
1207 @staticmethod
1208 - def list(criteria = None, *auth_args):
1209 """
1210 Retrieve Deposit objects.
1211 @param criteria: a dict of parameters; valid keys are:
1212 - C{filter} Filters to apply to the list.
1213 - C{max} Allows up to a max of 50 list items to return. [max value: 50, default: 20]
1214 - C{offset} Used in paging of the list. This is the start offset of the page. [default: 0]
1215 - C{sorting} Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either C{asc} for ascending or C{desc} for descending). Sortable properties are: C{amount} C{dateCreated} C{depositDate}.
1216 @param auth_args: an Authentication object used for the API call. If no value is passed the gloabl keys simplify.public_key and simplify.private_key are used.
1217 For backwards compatibility the public and private keys may be passed instead of an Authentication object.
1218 @return: an object which contains the list of Deposit objects in the <code>list</code> property and the total number
1219 of objects available for the given criteria in the <code>total</code> property.
1220 """
1221 return PaymentsApi.list("deposit", auth_args, criteria)
1222
1223 @staticmethod
1224 - def find(object_id, *auth_args):
1225 """
1226 Retrieve a Deposit object from the API
1227 @param object_id: ID of object to retrieve
1228 @param auth_args: an Authentication object used for the API call. If no value is passed the gloabl keys simplify.public_key and simplify.private_key are used.
1229 For backwards compatibility the public and private keys may be passed instead of an Authentication object.
1230 @return: a Deposit object
1231 """
1232 return PaymentsApi.find("deposit", auth_args, object_id)
1233
1235 """
1236 A Invoice object.
1237 """
1238
1239
1240 @staticmethod
1241 - def create(params, *auth_args):
1242 """
1243 Creates an Invoice object
1244 @param params: a dict of parameters; valid keys are:
1245 - C{currency}: Currency code (ISO-4217). Must match the currency associated with your account. [max length: 3, min length: 3, default: USD]
1246 - C{customer}: The customer ID of the customer we are invoicing. This is optional is a name and email are provided
1247 - C{discountRate}: The discount percent as a decimal e.g. 12.5. This is used to calculate the discount amount which is subtracted from the total amount due before any tax is applied. [max length: 6]
1248 - C{dueDate}: The date invoice payment is due. If a late fee is provided this will be added to the invoice total is the due date has past.
1249 - C{email}: The email of the customer we are invoicing. This is optional if a customer id is provided. A new customer will be created using the the name and email.
1250 - C{invoiceId}: User defined invoice id. If not provided the system will generate a numeric id. [max length: 255]
1251 - C{items => amount}: Amount of the invoice item (the smallest unit of your currency). Example: 100 = $1.00USD [min value: 1, max value: 9999900] B{required }
1252 - C{items => description}: The description of the invoice item. [max length: 1024]
1253 - C{items => invoice}: The ID of the invoice this item belongs to.
1254 - C{items => product}: The product this invoice item refers to. B{required }
1255 - C{items => quantity}: Quantity of the item. This total amount of the invoice item is the amount * quantity. [min value: 1, max value: 999999, default: 1]
1256 - C{items => reference}: User defined reference field. [max length: 255]
1257 - C{items => tax}: The tax ID of the tax charge in the invoice item.
1258 - C{lateFee}: The late fee amount that will be added to the invoice total is the due date is past due. Value provided must be in the smallest unit of your currency. Example: 100 = $1.00USD [max value: 9999900]
1259 - C{memo}: A memo that is displayed to the customer on the invoice payment screen. [max length: 4000]
1260 - C{name}: The name of the customer we are invoicing. This is optional if a customer id is provided. A new customer will be created using the the name and email. [max length: 50, min length: 2]
1261 - C{note}: This field can be used to store a note that is not displayed to the customer. [max length: 4000]
1262 - C{reference}: User defined reference field. [max length: 255]
1263 - C{shippingAddressLine1}: Address Line 1 where the product should be shipped. [max length: 255]
1264 - C{shippingAddressLine2}: Address Line 2 where the product should be shipped. [max length: 255]
1265 - C{shippingCity}: City where the product should be shipped. [max length: 255, min length: 2]
1266 - C{shippingCountry}: Country where the product should be shipped. [max length: 2, min length: 2]
1267 - C{shippingState}: State where the product should be shipped. [max length: 2, min length: 2]
1268 - C{shippingZip}: ZIP code where the product should be shipped. [max length: 9, min length: 5]
1269 - C{type}: The type of invoice. One of WEB or MOBILE. [valid values: WEB, MOBILE, default: WEB]
1270 @param auth_args: an Authentication object used for the API call. If no value is passed the gloabl keys simplify.public_key and simplify.private_key are used.
1271 For backwards compatibility the public and private keys may be passed instead of an Authentication object.
1272 @param private_api_key: Private key to use for the API call. If C{None}, the value of C{simplify.private_key} will be used.
1273 @return: a Invoice object
1274 """
1275 return PaymentsApi.create("invoice", auth_args, params)
1276
1277 - def delete(self, *auth_args):
1278 """
1279 Delete this object
1280 @param auth_args: an Authentication object used for the API call. If no value is passed the gloabl keys simplify.public_key and simplify.private_key are used.
1281 For backwards compatibility the public and private keys may be passed instead of an Authentication object.
1282 """
1283 return PaymentsApi.delete("invoice", auth_args, self.object_id)
1284
1285 @staticmethod
1286 - def list(criteria = None, *auth_args):
1287 """
1288 Retrieve Invoice objects.
1289 @param criteria: a dict of parameters; valid keys are:
1290 - C{filter} Filters to apply to the list.
1291 - C{max} Allows up to a max of 50 list items to return. [max value: 50, default: 20]
1292 - C{offset} Used in paging of the list. This is the start offset of the page. [default: 0]
1293 - C{sorting} Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either C{asc} for ascending or C{desc} for descending). Sortable properties are: C{id} C{invoiceDate} C{dueDate} C{datePaid} C{customer} C{status}.
1294 @param auth_args: an Authentication object used for the API call. If no value is passed the gloabl keys simplify.public_key and simplify.private_key are used.
1295 For backwards compatibility the public and private keys may be passed instead of an Authentication object.
1296 @return: an object which contains the list of Invoice objects in the <code>list</code> property and the total number
1297 of objects available for the given criteria in the <code>total</code> property.
1298 """
1299 return PaymentsApi.list("invoice", auth_args, criteria)
1300
1301 @staticmethod
1302 - def find(object_id, *auth_args):
1303 """
1304 Retrieve a Invoice object from the API
1305 @param object_id: ID of object to retrieve
1306 @param auth_args: an Authentication object used for the API call. If no value is passed the gloabl keys simplify.public_key and simplify.private_key are used.
1307 For backwards compatibility the public and private keys may be passed instead of an Authentication object.
1308 @return: a Invoice object
1309 """
1310 return PaymentsApi.find("invoice", auth_args, object_id)
1311
1312 - def update(self, *auth_args):
1313 """
1314 Updates this object
1315
1316 The properties that can be updated:
1317 - C{datePaid} This is the date the invoice was PAID in UTC millis.
1318
1319 - C{discountRate} The discount percent as a decimal e.g. 12.5. This is used to calculate the discount amount which is subtracted from the total amount due before any tax is applied. [max length: 6]
1320
1321 - C{dueDate} The date invoice payment is due. If a late fee is provided this will be added to the invoice total is the due date has past.
1322
1323 - C{items => amount} Amount of the invoice item in the smallest unit of your currency. Example: 100 = $1.00USD [min value: 1, max value: 9999900] B{(required)}
1324
1325 - C{items => description} The description of the invoice item. [max length: 1024]
1326
1327 - C{items => invoice} The ID of the invoice this item belongs to.
1328
1329 - C{items => product} The Id of the product this item refers to. B{(required)}
1330
1331 - C{items => quantity} Quantity of the item. This total amount of the invoice item is the amount * quantity. [min value: 1, max value: 999999, default: 1]
1332
1333 - C{items => reference} User defined reference field. [max length: 255]
1334
1335 - C{items => tax} The tax ID of the tax charge in the invoice item.
1336
1337 - C{lateFee} The late fee amount that will be added to the invoice total is the due date is past due. Value provided must be in the smallest unit of your currency. Example: 100 = $1.00USD
1338
1339 - C{memo} A memo that is displayed to the customer on the invoice payment screen. [max length: 4000]
1340
1341 - C{note} This field can be used to store a note that is not displayed to the customer. [max length: 4000]
1342
1343 - C{payment} The ID of the payment. Use this ID to query the /payment API. [max length: 255]
1344
1345 - C{reference} User defined reference field. [max length: 255]
1346
1347 - C{shippingAddressLine1} The shipping address line 1 for the product. [max length: 255]
1348
1349 - C{shippingAddressLine2} The shipping address line 2 for the product. [max length: 255]
1350
1351 - C{shippingCity} The shipping city for the product. [max length: 255, min length: 2]
1352
1353 - C{shippingCountry} The shipping country for the product. [max length: 2, min length: 2]
1354
1355 - C{shippingState} The shipping state for the product. [max length: 2, min length: 2]
1356
1357 - C{shippingZip} The shipping ZIP code for the product. [max length: 9, min length: 5]
1358
1359 - C{status} New status of the invoice.
1360
1361 @param auth_args: an Authentication object used for the API call. If no value is passed the gloabl keys simplify.public_key and simplify.private_key are used.
1362 For backwards compatibility the public and private keys may be passed instead of an Authentication object.
1363 @return: a Invoice object.
1364 """
1365 return PaymentsApi.update("invoice", auth_args, self.object_id, self.to_dict())
1366
1368 """
1369 A InvoiceItem object.
1370 """
1371
1372
1373 @staticmethod
1374 - def create(params, *auth_args):
1375 """
1376 Creates an InvoiceItem object
1377 @param params: a dict of parameters; valid keys are:
1378 - C{amount}: Amount of the invoice item in the smallest unit of your currency. Example: 100 = $1.00USD [min value: 1, max value: 9999900] B{required }
1379 - C{description}: Individual items of an invoice [max length: 1024]
1380 - C{invoice}: The ID of the invoice this item belongs to.
1381 - C{product}: Product ID this item relates to. B{required }
1382 - C{quantity}: Quantity of the item. This total amount of the invoice item is the amount * quantity. [min value: 1, max value: 999999, default: 1]
1383 - C{reference}: User defined reference field. [max length: 255]
1384 - C{tax}: The tax ID of the tax charge in the invoice item.
1385 @param auth_args: an Authentication object used for the API call. If no value is passed the gloabl keys simplify.public_key and simplify.private_key are used.
1386 For backwards compatibility the public and private keys may be passed instead of an Authentication object.
1387 @param private_api_key: Private key to use for the API call. If C{None}, the value of C{simplify.private_key} will be used.
1388 @return: a InvoiceItem object
1389 """
1390 return PaymentsApi.create("invoiceItem", auth_args, params)
1391
1392 - def delete(self, *auth_args):
1393 """
1394 Delete this object
1395 @param auth_args: an Authentication object used for the API call. If no value is passed the gloabl keys simplify.public_key and simplify.private_key are used.
1396 For backwards compatibility the public and private keys may be passed instead of an Authentication object.
1397 """
1398 return PaymentsApi.delete("invoiceItem", auth_args, self.object_id)
1399
1400 @staticmethod
1401 - def find(object_id, *auth_args):
1402 """
1403 Retrieve a InvoiceItem object from the API
1404 @param object_id: ID of object to retrieve
1405 @param auth_args: an Authentication object used for the API call. If no value is passed the gloabl keys simplify.public_key and simplify.private_key are used.
1406 For backwards compatibility the public and private keys may be passed instead of an Authentication object.
1407 @return: a InvoiceItem object
1408 """
1409 return PaymentsApi.find("invoiceItem", auth_args, object_id)
1410
1411 - def update(self, *auth_args):
1412 """
1413 Updates this object
1414
1415 The properties that can be updated:
1416 - C{amount} Amount of the invoice item in the smallest unit of your currency. Example: 100 = $1.00USD [min value: 1, max value: 9999900]
1417
1418 - C{description} Individual items of an invoice
1419
1420 - C{quantity} Quantity of the item. This total amount of the invoice item is the amount * quantity. [min value: 1, max value: 999999]
1421
1422 - C{reference} User defined reference field.
1423
1424 - C{tax} The tax ID of the tax charge in the invoice item.
1425
1426 @param auth_args: an Authentication object used for the API call. If no value is passed the gloabl keys simplify.public_key and simplify.private_key are used.
1427 For backwards compatibility the public and private keys may be passed instead of an Authentication object.
1428 @return: a InvoiceItem object.
1429 """
1430 return PaymentsApi.update("invoiceItem", auth_args, self.object_id, self.to_dict())
1431
1433 """
1434 A Payment object.
1435 """
1436
1437
1438 @staticmethod
1439 - def create(params, *auth_args):
1440 """
1441 Creates an Payment object
1442 @param params: a dict of parameters; valid keys are:
1443 - C{amount}: Amount of the payment (in the smallest unit of your currency). Example: 100 = $1.00USD [min value: 50, max value: 9999900]
1444 - C{authorization}: The ID of the authorization being used to capture the payment.
1445 - C{card => addressCity}: City of the cardholder. [max length: 50, min length: 2]
1446 - C{card => addressCountry}: Country code (ISO-3166-1-alpha-2 code) of residence of the cardholder. [max length: 2, min length: 2]
1447 - C{card => addressLine1}: Address of the cardholder. [max length: 255]
1448 - C{card => addressLine2}: Address of the cardholder if needed. [max length: 255]
1449 - C{card => addressState}: State code (USPS code) of residence of the cardholder. [max length: 2, min length: 2]
1450 - C{card => addressZip}: Postal code of the cardholder. The postal code size is between 5 and 9 in length and only contain numbers or letters. [max length: 9, min length: 3]
1451 - C{card => cvc}: CVC security code of the card. This is the code on the back of the card. Example: 123
1452 - C{card => expMonth}: Expiration month of the card. Format is MM. Example: January = 01 [min value: 1, max value: 12] B{required }
1453 - C{card => expYear}: Expiration year of the card. Format is YY. Example: 2013 = 13 [max value: 99] B{required }
1454 - C{card => name}: Name as it appears on the card. [max length: 50, min length: 2]
1455 - C{card => number}: Card number as it appears on the card. [max length: 19, min length: 13] B{required }
1456 - C{currency}: Currency code (ISO-4217) for the transaction. Must match the currency associated with your account. [default: USD] B{required }
1457 - C{customer}: ID of customer. If specified, card on file of customer will be used.
1458 - C{description}: Free form text field to be used as a description of the payment. This field is echoed back with the payment on any find or list operations. [max length: 1024]
1459 - C{invoice}: ID of invoice for which this payment is being made.
1460 - C{reference}: Custom reference field to be used with outside systems.
1461 - C{replayId}: An identifier that can be sent to uniquely identify a payment request to facilitate retries due to I/O related issues. This identifier must be unique for your account (sandbox or live) across all of your payments. If supplied, we will check for a payment on your account that matches this identifier. If found will attempt to return an identical response of the original request. [max length: 50, min length: 1]
1462 - C{token}: If specified, card associated with card token will be used. [max length: 255]
1463 @param auth_args: an Authentication object used for the API call. If no value is passed the gloabl keys simplify.public_key and simplify.private_key are used.
1464 For backwards compatibility the public and private keys may be passed instead of an Authentication object.
1465 @param private_api_key: Private key to use for the API call. If C{None}, the value of C{simplify.private_key} will be used.
1466 @return: a Payment object
1467 """
1468 return PaymentsApi.create("payment", auth_args, params)
1469
1470 @staticmethod
1471 - def list(criteria = None, *auth_args):
1472 """
1473 Retrieve Payment objects.
1474 @param criteria: a dict of parameters; valid keys are:
1475 - C{filter} Filters to apply to the list.
1476 - C{max} Allows up to a max of 50 list items to return. [max value: 50, default: 20]
1477 - C{offset} Used in paging of the list. This is the start offset of the page. [default: 0]
1478 - C{sorting} Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either C{asc} for ascending or C{desc} for descending). Sortable properties are: C{dateCreated} C{amount} C{id} C{description} C{paymentDate}.
1479 @param auth_args: an Authentication object used for the API call. If no value is passed the gloabl keys simplify.public_key and simplify.private_key are used.
1480 For backwards compatibility the public and private keys may be passed instead of an Authentication object.
1481 @return: an object which contains the list of Payment objects in the <code>list</code> property and the total number
1482 of objects available for the given criteria in the <code>total</code> property.
1483 """
1484 return PaymentsApi.list("payment", auth_args, criteria)
1485
1486 @staticmethod
1487 - def find(object_id, *auth_args):
1488 """
1489 Retrieve a Payment object from the API
1490 @param object_id: ID of object to retrieve
1491 @param auth_args: an Authentication object used for the API call. If no value is passed the gloabl keys simplify.public_key and simplify.private_key are used.
1492 For backwards compatibility the public and private keys may be passed instead of an Authentication object.
1493 @return: a Payment object
1494 """
1495 return PaymentsApi.find("payment", auth_args, object_id)
1496
1497 - def update(self, *auth_args):
1498 """
1499 Updates this object
1500
1501 The properties that can be updated:
1502 @param auth_args: an Authentication object used for the API call. If no value is passed the gloabl keys simplify.public_key and simplify.private_key are used.
1503 For backwards compatibility the public and private keys may be passed instead of an Authentication object.
1504 @return: a Payment object.
1505 """
1506 return PaymentsApi.update("payment", auth_args, self.object_id, self.to_dict())
1507
1508 -class Plan(Domain):
1509 """
1510 A Plan object.
1511 """
1512
1513
1514 @staticmethod
1515 - def create(params, *auth_args):
1516 """
1517 Creates an Plan object
1518 @param params: a dict of parameters; valid keys are:
1519 - C{amount}: Amount of payment for the plan in the smallest unit of your currency. Example: 100 = $1.00USD [min value: 50, max value: 9999900] B{required }
1520 - C{currency}: Currency code (ISO-4217) for the plan. Must match the currency associated with your account. [default: USD] B{required }
1521 - C{frequency}: Frequency of payment for the plan. Example: Monthly B{required }
1522 - C{name}: Name of the plan [max length: 50, min length: 2] B{required }
1523 @param auth_args: an Authentication object used for the API call. If no value is passed the gloabl keys simplify.public_key and simplify.private_key are used.
1524 For backwards compatibility the public and private keys may be passed instead of an Authentication object.
1525 @param private_api_key: Private key to use for the API call. If C{None}, the value of C{simplify.private_key} will be used.
1526 @return: a Plan object
1527 """
1528 return PaymentsApi.create("plan", auth_args, params)
1529
1530 - def delete(self, *auth_args):
1531 """
1532 Delete this object
1533 @param auth_args: an Authentication object used for the API call. If no value is passed the gloabl keys simplify.public_key and simplify.private_key are used.
1534 For backwards compatibility the public and private keys may be passed instead of an Authentication object.
1535 """
1536 return PaymentsApi.delete("plan", auth_args, self.object_id)
1537
1538 @staticmethod
1539 - def list(criteria = None, *auth_args):
1540 """
1541 Retrieve Plan objects.
1542 @param criteria: a dict of parameters; valid keys are:
1543 - C{filter} Filters to apply to the list.
1544 - C{max} Allows up to a max of 50 list items to return. [max value: 50, default: 20]
1545 - C{offset} Used in paging of the list. This is the start offset of the page. [default: 0]
1546 - C{sorting} Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either C{asc} for ascending or C{desc} for descending). Sortable properties are: C{dateCreated} C{amount} C{frequency} C{name} C{id}.
1547 @param auth_args: an Authentication object used for the API call. If no value is passed the gloabl keys simplify.public_key and simplify.private_key are used.
1548 For backwards compatibility the public and private keys may be passed instead of an Authentication object.
1549 @return: an object which contains the list of Plan objects in the <code>list</code> property and the total number
1550 of objects available for the given criteria in the <code>total</code> property.
1551 """
1552 return PaymentsApi.list("plan", auth_args, criteria)
1553
1554 @staticmethod
1555 - def find(object_id, *auth_args):
1556 """
1557 Retrieve a Plan object from the API
1558 @param object_id: ID of object to retrieve
1559 @param auth_args: an Authentication object used for the API call. If no value is passed the gloabl keys simplify.public_key and simplify.private_key are used.
1560 For backwards compatibility the public and private keys may be passed instead of an Authentication object.
1561 @return: a Plan object
1562 """
1563 return PaymentsApi.find("plan", auth_args, object_id)
1564
1565 - def update(self, *auth_args):
1566 """
1567 Updates this object
1568
1569 The properties that can be updated:
1570 - C{name} Name of the plan. [min length: 2] B{(required)}
1571
1572 @param auth_args: an Authentication object used for the API call. If no value is passed the gloabl keys simplify.public_key and simplify.private_key are used.
1573 For backwards compatibility the public and private keys may be passed instead of an Authentication object.
1574 @return: a Plan object.
1575 """
1576 return PaymentsApi.update("plan", auth_args, self.object_id, self.to_dict())
1577
1579 """
1580 A Refund object.
1581 """
1582
1583
1584 @staticmethod
1585 - def create(params, *auth_args):
1586 """
1587 Creates an Refund object
1588 @param params: a dict of parameters; valid keys are:
1589 - C{amount}: Amount of the refund in the smallest unit of your currency. Example: 100 = $1.00USD [min value: 1, max value: 9999900] B{required }
1590 - C{payment}: ID of the payment for the refund B{required }
1591 - C{reason}: Reason for the refund
1592 - C{reference}: Custom reference field to be used with outside systems.
1593 - C{replayId}: An identifier that can be sent to uniquely identify a refund request to facilitate retries due to I/O related issues. This identifier must be unique for your account (sandbox or live) across all of your refunds. If supplied, we will check for a refund on your account that matches this identifier. If found we will return an identical response to that of the original request. [max length: 50, min length: 1]
1594 @param auth_args: an Authentication object used for the API call. If no value is passed the gloabl keys simplify.public_key and simplify.private_key are used.
1595 For backwards compatibility the public and private keys may be passed instead of an Authentication object.
1596 @param private_api_key: Private key to use for the API call. If C{None}, the value of C{simplify.private_key} will be used.
1597 @return: a Refund object
1598 """
1599 return PaymentsApi.create("refund", auth_args, params)
1600
1601 @staticmethod
1602 - def list(criteria = None, *auth_args):
1603 """
1604 Retrieve Refund objects.
1605 @param criteria: a dict of parameters; valid keys are:
1606 - C{filter} Filters to apply to the list.
1607 - C{max} Allows up to a max of 50 list items to return. [max value: 50, default: 20]
1608 - C{offset} Used in paging of the list. This is the start offset of the page. [default: 0]
1609 - C{sorting} Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either C{asc} for ascending or C{desc} for descending). Sortable properties are: C{id} C{amount} C{description} C{dateCreated} C{paymentDate}.
1610 @param auth_args: an Authentication object used for the API call. If no value is passed the gloabl keys simplify.public_key and simplify.private_key are used.
1611 For backwards compatibility the public and private keys may be passed instead of an Authentication object.
1612 @return: an object which contains the list of Refund objects in the <code>list</code> property and the total number
1613 of objects available for the given criteria in the <code>total</code> property.
1614 """
1615 return PaymentsApi.list("refund", auth_args, criteria)
1616
1617 @staticmethod
1618 - def find(object_id, *auth_args):
1619 """
1620 Retrieve a Refund object from the API
1621 @param object_id: ID of object to retrieve
1622 @param auth_args: an Authentication object used for the API call. If no value is passed the gloabl keys simplify.public_key and simplify.private_key are used.
1623 For backwards compatibility the public and private keys may be passed instead of an Authentication object.
1624 @return: a Refund object
1625 """
1626 return PaymentsApi.find("refund", auth_args, object_id)
1627
1629 """
1630 A Subscription object.
1631 """
1632
1633
1634 @staticmethod
1635 - def create(params, *auth_args):
1636 """
1637 Creates an Subscription object
1638 @param params: a dict of parameters; valid keys are:
1639 - C{amount}: Amount of the payment in the smallest unit of your currency. Example: 100 = $1.00USD [min value: 50, max value: 9999900]
1640 - C{coupon}: Coupon ID associated with the subscription
1641 - C{currency}: Currency code (ISO-4217). Must match the currency associated with your account. [default: USD]
1642 - C{customer}: Customer that is enrolling in the subscription.
1643 - C{frequency}: Frequency of payment for the plan. Example: Monthly
1644 - C{name}: Name describing subscription
1645 - C{plan}: The ID of the plan that should be used for the subscription.
1646 - C{quantity}: Quantity of the plan for the subscription. [min value: 1]
1647 @param auth_args: an Authentication object used for the API call. If no value is passed the gloabl keys simplify.public_key and simplify.private_key are used.
1648 For backwards compatibility the public and private keys may be passed instead of an Authentication object.
1649 @param private_api_key: Private key to use for the API call. If C{None}, the value of C{simplify.private_key} will be used.
1650 @return: a Subscription object
1651 """
1652 return PaymentsApi.create("subscription", auth_args, params)
1653
1654 - def delete(self, *auth_args):
1655 """
1656 Delete this object
1657 @param auth_args: an Authentication object used for the API call. If no value is passed the gloabl keys simplify.public_key and simplify.private_key are used.
1658 For backwards compatibility the public and private keys may be passed instead of an Authentication object.
1659 """
1660 return PaymentsApi.delete("subscription", auth_args, self.object_id)
1661
1662 @staticmethod
1663 - def list(criteria = None, *auth_args):
1664 """
1665 Retrieve Subscription objects.
1666 @param criteria: a dict of parameters; valid keys are:
1667 - C{filter} Filters to apply to the list.
1668 - C{max} Allows up to a max of 50 list items to return. [max value: 50, default: 20]
1669 - C{offset} Used in paging of the list. This is the start offset of the page. [default: 0]
1670 - C{sorting} Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either C{asc} for ascending or C{desc} for descending). Sortable properties are: C{id} C{plan}.
1671 @param auth_args: an Authentication object used for the API call. If no value is passed the gloabl keys simplify.public_key and simplify.private_key are used.
1672 For backwards compatibility the public and private keys may be passed instead of an Authentication object.
1673 @return: an object which contains the list of Subscription objects in the <code>list</code> property and the total number
1674 of objects available for the given criteria in the <code>total</code> property.
1675 """
1676 return PaymentsApi.list("subscription", auth_args, criteria)
1677
1678 @staticmethod
1679 - def find(object_id, *auth_args):
1680 """
1681 Retrieve a Subscription object from the API
1682 @param object_id: ID of object to retrieve
1683 @param auth_args: an Authentication object used for the API call. If no value is passed the gloabl keys simplify.public_key and simplify.private_key are used.
1684 For backwards compatibility the public and private keys may be passed instead of an Authentication object.
1685 @return: a Subscription object
1686 """
1687 return PaymentsApi.find("subscription", auth_args, object_id)
1688
1689 - def update(self, *auth_args):
1690 """
1691 Updates this object
1692
1693 The properties that can be updated:
1694 - C{amount} Amount of the payment in the smallest unit of your currency. Example: 100 = $1.00USD [min value: 50, max value: 9999900]
1695
1696 - C{coupon} Coupon being assigned to this subscription
1697
1698 - C{currency} Currency code (ISO-4217). Must match the currency associated with your account. [default: USD]
1699
1700 - C{frequency} Frequency of payment for the plan. Example: Monthly
1701
1702 - C{name} Name describing subscription
1703
1704 - C{plan} Plan that should be used for the subscription.
1705
1706 - C{prorate} Whether to prorate existing subscription. [default: true] B{(required)}
1707
1708 - C{quantity} Quantity of the plan for the subscription. [min value: 1]
1709
1710 @param auth_args: an Authentication object used for the API call. If no value is passed the gloabl keys simplify.public_key and simplify.private_key are used.
1711 For backwards compatibility the public and private keys may be passed instead of an Authentication object.
1712 @return: a Subscription object.
1713 """
1714 return PaymentsApi.update("subscription", auth_args, self.object_id, self.to_dict())
1715
1717 """
1718 A Tax object.
1719 """
1720
1721
1722 @staticmethod
1723 - def create(params, *auth_args):
1724 """
1725 Creates an Tax object
1726 @param params: a dict of parameters; valid keys are:
1727 - C{label}: The label of the tax object. [max length: 255] B{required }
1728 - C{rate}: The tax rate. Decimal value up three decimal places. e.g 12.501. [max length: 6] B{required }
1729 @param auth_args: an Authentication object used for the API call. If no value is passed the gloabl keys simplify.public_key and simplify.private_key are used.
1730 For backwards compatibility the public and private keys may be passed instead of an Authentication object.
1731 @param private_api_key: Private key to use for the API call. If C{None}, the value of C{simplify.private_key} will be used.
1732 @return: a Tax object
1733 """
1734 return PaymentsApi.create("tax", auth_args, params)
1735
1736 - def delete(self, *auth_args):
1737 """
1738 Delete this object
1739 @param auth_args: an Authentication object used for the API call. If no value is passed the gloabl keys simplify.public_key and simplify.private_key are used.
1740 For backwards compatibility the public and private keys may be passed instead of an Authentication object.
1741 """
1742 return PaymentsApi.delete("tax", auth_args, self.object_id)
1743
1744 @staticmethod
1745 - def list(criteria = None, *auth_args):
1746 """
1747 Retrieve Tax objects.
1748 @param criteria: a dict of parameters; valid keys are:
1749 - C{filter} Filters to apply to the list.
1750 - C{max} Allows up to a max of 50 list items to return. [max value: 50, default: 20]
1751 - C{offset} Used in paging of the list. This is the start offset of the page. [default: 0]
1752 - C{sorting} Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either C{asc} for ascending or C{desc} for descending). Sortable properties are: C{id} C{label}.
1753 @param auth_args: an Authentication object used for the API call. If no value is passed the gloabl keys simplify.public_key and simplify.private_key are used.
1754 For backwards compatibility the public and private keys may be passed instead of an Authentication object.
1755 @return: an object which contains the list of Tax objects in the <code>list</code> property and the total number
1756 of objects available for the given criteria in the <code>total</code> property.
1757 """
1758 return PaymentsApi.list("tax", auth_args, criteria)
1759
1760 @staticmethod
1761 - def find(object_id, *auth_args):
1762 """
1763 Retrieve a Tax object from the API
1764 @param object_id: ID of object to retrieve
1765 @param auth_args: an Authentication object used for the API call. If no value is passed the gloabl keys simplify.public_key and simplify.private_key are used.
1766 For backwards compatibility the public and private keys may be passed instead of an Authentication object.
1767 @return: a Tax object
1768 """
1769 return PaymentsApi.find("tax", auth_args, object_id)
1770
1772 """
1773 A Webhook object.
1774 """
1775
1776
1777 @staticmethod
1778 - def create(params, *auth_args):
1779 """
1780 Creates an Webhook object
1781 @param params: a dict of parameters; valid keys are:
1782 - C{url}: Endpoint URL B{required }
1783 @param auth_args: an Authentication object used for the API call. If no value is passed the gloabl keys simplify.public_key and simplify.private_key are used.
1784 For backwards compatibility the public and private keys may be passed instead of an Authentication object.
1785 @param private_api_key: Private key to use for the API call. If C{None}, the value of C{simplify.private_key} will be used.
1786 @return: a Webhook object
1787 """
1788 return PaymentsApi.create("webhook", auth_args, params)
1789
1790 - def delete(self, *auth_args):
1791 """
1792 Delete this object
1793 @param auth_args: an Authentication object used for the API call. If no value is passed the gloabl keys simplify.public_key and simplify.private_key are used.
1794 For backwards compatibility the public and private keys may be passed instead of an Authentication object.
1795 """
1796 return PaymentsApi.delete("webhook", auth_args, self.object_id)
1797
1798 @staticmethod
1799 - def list(criteria = None, *auth_args):
1800 """
1801 Retrieve Webhook objects.
1802 @param criteria: a dict of parameters; valid keys are:
1803 - C{filter} Filters to apply to the list.
1804 - C{max} Allows up to a max of 50 list items to return. [max value: 50, default: 20]
1805 - C{offset} Used in paging of the list. This is the start offset of the page. [default: 0]
1806 - C{sorting} Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either C{asc} for ascending or C{desc} for descending). Sortable properties are: C{dateCreated}.
1807 @param auth_args: an Authentication object used for the API call. If no value is passed the gloabl keys simplify.public_key and simplify.private_key are used.
1808 For backwards compatibility the public and private keys may be passed instead of an Authentication object.
1809 @return: an object which contains the list of Webhook objects in the <code>list</code> property and the total number
1810 of objects available for the given criteria in the <code>total</code> property.
1811 """
1812 return PaymentsApi.list("webhook", auth_args, criteria)
1813
1814 @staticmethod
1815 - def find(object_id, *auth_args):
1816 """
1817 Retrieve a Webhook object from the API
1818 @param object_id: ID of object to retrieve
1819 @param auth_args: an Authentication object used for the API call. If no value is passed the gloabl keys simplify.public_key and simplify.private_key are used.
1820 For backwards compatibility the public and private keys may be passed instead of an Authentication object.
1821 @return: a Webhook object
1822 """
1823 return PaymentsApi.find("webhook", auth_args, object_id)
1824
1825 - def update(self, *auth_args):
1826 """
1827 Updates this object
1828
1829 The properties that can be updated:
1830 - C{url} Endpoint URL B{(required)}
1831
1832 @param auth_args: an Authentication object used for the API call. If no value is passed the gloabl keys simplify.public_key and simplify.private_key are used.
1833 For backwards compatibility the public and private keys may be passed instead of an Authentication object.
1834 @return: a Webhook object.
1835 """
1836 return PaymentsApi.update("webhook", auth_args, self.object_id, self.to_dict())
1837