Package simplify
[hide private]
[frames] | no frames]

Source Code for Package simplify

   1   
   2  # 
   3  # Copyright (c) 2013 - 2015 MasterCard International Incorporated 
   4  # All rights reserved. 
   5  #  
   6  # Redistribution and use in source and binary forms, with or without modification, are  
   7  # permitted provided that the following conditions are met: 
   8  #  
   9  # Redistributions of source code must retain the above copyright notice, this list of  
  10  # conditions and the following disclaimer. 
  11  # Redistributions in binary form must reproduce the above copyright notice, this list of  
  12  # conditions and the following disclaimer in the documentation and/or other materials  
  13  # provided with the distribution. 
  14  # Neither the name of the MasterCard International Incorporated nor the names of its  
  15  # contributors may be used to endorse or promote products derived from this software  
  16  # without specific prior written permission. 
  17  # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY  
  18  # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES  
  19  # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT  
  20  # SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,  
  21  # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 
  22  # TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;  
  23  # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER  
  24  # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING  
  25  # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF  
  26  # SUCH DAMAGE. 
  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  # Constants 
  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  # Global variables 
  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 
71 72 73 ################################################################################ 74 # Utilities 75 ################################################################################ 76 77 -def build_query_string(criteria):
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
99 -def handle_http_error(response_body, response_code):
100 101 if response_code == HTTP_REDIRECTED: # this shouldn't happen - if it does it's our problem 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
121 122 ################################################################################ 123 # Authentication 124 ################################################################################ 125 126 -class Authentication:
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
136 - def __init__(self, **kwargs):
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
160 161 -class AccessToken(Domain):
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
191 - def refresh(self, *auth_args):
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 # Exceptions 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
259 - def describe(self):
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
266 267 -class IllegalArgumentError(ValueError):
268 """ 269 Error raised when passing illegal arguments. 270 """ 271 pass
272
273 -class ApiConnectionError(ApiError):
274 """ 275 Error raised when there are communication errors contacting the API. 276 """ 277 pass
278
279 -class AuthenticationError(ApiError):
280 """ 281 Error raised where there are problems authentication a request. 282 """ 283 pass
284
285 -class BadRequestError(ApiError):
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
294 - class FieldError:
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 """
302 - def __init__(self, error_data):
303 self.field_name = error_data['field'] 304 self.error_code = error_data['code'] 305 self.message = error_data['message']
306
307 - def __str__(self):
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
321 - def describe(self):
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
331 -class ObjectNotFoundError(ApiError):
332 """ 333 Error raised when a requested object cannot be found. 334 """ 335 pass
336
337 -class NotAllowedError(ApiError):
338 """ 339 Error raised when a request was not allowed. 340 """ 341 pass
342
343 -class SysError(ApiError):
344 """ 345 Error raised when there was a system error processing a request. 346 """ 347 pass
348
349 350 ################################################################################ 351 # Http - handles the HTTP requests 352 ################################################################################ 353 354 -class Http:
355 - def __init__(self):
356 pass
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
407 - def auth_request(self, auth, url, params):
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 # JWS WebHook Utils 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 # 5 minutes 453
454 - def __init__(self):
455 pass
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
483 - def auth_encode(url, auth, params):
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 # Convert map to param string 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
504 - def decode(params, auth):
505 506 global public_key 507 public_api_key = auth.public_key if auth.public_key else public_key 508 509 if not public_api_key: 510 raise IllegalArgumentError("Must have a valid public key to connect to the API") 511 512 global private_key 513 private_api_key = auth.private_key if auth.private_key else private_key 514 515 if not private_api_key: 516 raise IllegalArgumentError("Must have a valid private key to connect to the API") 517 518 if not 'payload' in params: 519 raise IllegalArgumentError("Event data is missing payload") 520 521 payload = params['payload'].strip() 522 data = payload.split('.') 523 if len(data) != 3: 524 raise IllegalArgumentError("Incorrectly formatted JWS message") 525 526 msg = "{0}.{1}".format(data[0], data[1]) 527 header = Jws().safe_base64_decode(data[0]) 528 payload = Jws().safe_base64_decode(data[1]) 529 signature = data[2] 530 531 url = None 532 if 'url' in params: 533 url = params['url'] 534 Jws().verify(header, url, public_api_key) 535 536 if signature != Jws().sign(private_api_key, msg): 537 raise AuthenticationError("JWS signature does not match") 538 539 return json.loads(payload)
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):
547 548 hdr = json.loads(header) 549 550 if len(hdr) != Jws.NUM_HEADERS: 551 raise AuthenticationError("Incorrect number of JWS header parameters - found {0} but expected {1}".format(len(hdr), Jws.NUM_HEADERS)) 552 553 if not Jws.HDR_ALGORITHM in hdr: 554 raise AuthenticationError("Missing algorithm header") 555 556 if hdr[Jws.HDR_ALGORITHM] != Jws.ALGORITHM: 557 raise AuthenticationError("Incorrect algorithm - found {0} but required {1}".format(hdr[Jws.HDR_ALGORITHM], Jws.ALGORITHM)) 558 559 if not Jws.HDR_TYPE in hdr: 560 raise AuthenticationError("Missing type header") 561 562 if hdr[Jws.HDR_TYPE] != Jws.TYPE: 563 raise AuthenticationError("Incorrect type - found {0} but required {JWS_TYPE}".format(hdr[Jws.HDR_TYPE], Jws.TYPE)) 564 565 if not Jws.HDR_KEY_ID in hdr: 566 raise AuthenticationError("Missing Key ID") 567 568 # keys don't match and it is a live key 569 if hdr[Jws.HDR_KEY_ID] != public_api_key and public_api_key.startswith("lvpb"): 570 raise AuthenticationError("Invalid Key ID") 571 572 if not Jws.HDR_NONCE in hdr: 573 raise AuthenticationError("Missing nonce") 574 575 if not Jws.HDR_URI in hdr: 576 raise AuthenticationError("Missing URI") 577 578 if url != None and hdr[Jws.HDR_URI] != url: 579 raise AuthenticationError("Incorrect URL - found {0} but required {1}".format(hdr[Jws.HDR_URI], url)) 580 581 if not Jws.HDR_TIMESTAMP in hdr: 582 raise AuthenticationError("Missing timestamp") 583 584 if not Jws.HDR_UNAME in hdr: 585 raise AuthenticationError("Missing username") 586 587 # calculate time difference between when the request was created and now 588 time_now = int(round(time.time() * 1000)) 589 timestamp = int(hdr[Jws.HDR_TIMESTAMP]) 590 diff = time_now - timestamp 591 592 if diff > Jws.TIMESTAMP_MAX_DIFF: 593 raise AuthenticationError("Invalid timestamp, the event has expired")
594
595 - def safe_base64_decode(self, url):
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
605 - def encode_json(self, json_str):
606 607 try: 608 return json.dumps(json_str).encode('utf-8') 609 except Exception: 610 raise ApiError("Invalid format for JSON request")
611
612 613 ################################################################################ 614 # PaymentsApi 615 ################################################################################ 616 617 -class PaymentsApi:
618 619
620 - def __init__(self):
621 pass
622 623 @staticmethod
624 - def create_auth_object(auth_args):
625 626 global public_key 627 global private_key 628 629 if len(auth_args) == 0: 630 auth = Authentication(public_key = public_key, private_key = private_key) 631 632 elif len(auth_args) == 1: 633 auth = auth_args[0] 634 if not isinstance(auth, Authentication): 635 raise IllegalArgumentError("Invalid Authentication object passed") 636 637 elif len(auth_args) == 2: 638 public_api_key = auth_args[0] 639 if public_api_key == None: 640 public_api_key = public_key 641 private_api_key = auth_args[1] 642 if private_api_key == None: 643 private_api_key = private_key 644 auth = Authentication(public_key = public_api_key, private_key = private_api_key) 645 646 else: 647 raise IllegalArgumentError("Invalid authentication arguments passed") 648 649 return auth
650 651 652 @staticmethod
653 - def check_auth(auth):
654 655 if auth == None: 656 raise IllegalArgumentError("Missing authentication object") 657 658 if auth.public_key == None: 659 raise IllegalArgumentError("Must have a valid public key to connect to the API") 660 661 if auth.private_key == None: 662 raise IllegalArgumentError("Must have a valid private key to connect to the API")
663 664 665 666 @staticmethod
667 - def create(object_type, auth_args, params):
668 669 auth = PaymentsApi.create_auth_object(auth_args) 670 url = PaymentsApi.build_request_url(object_type) 671 response = PaymentsApi().execute(object_type, auth, url, HTTP_METHOD_POST, params) 672 673 return response
674 675 @staticmethod
676 - def list(object_type, auth_args, criteria):
677 678 auth = PaymentsApi.create_auth_object(auth_args) 679 url = PaymentsApi.build_request_url(object_type) 680 query_string = build_query_string(criteria) 681 if len(query_string) > 0: 682 url = url + '?' + query_string 683 response = PaymentsApi().execute(object_type, auth, url, HTTP_METHOD_GET) 684 685 return response
686 687 @staticmethod
688 - def find(object_type, auth_args, object_id):
689 690 auth = PaymentsApi.create_auth_object(auth_args) 691 if not object_id: 692 raise IllegalArgumentError("object_object_id is a required field") 693 694 url = PaymentsApi.build_request_url(object_type, object_id) 695 response = PaymentsApi().execute(object_type, auth, url, HTTP_METHOD_GET) 696 697 return response
698 699 @staticmethod
700 - def update(object_type, auth_args, object_id, params):
701 702 auth = PaymentsApi.create_auth_object(auth_args) 703 if not object_id: 704 raise IllegalArgumentError("object_id is a required field") 705 706 url = PaymentsApi.build_request_url(object_type, object_id) 707 response = PaymentsApi().execute(object_type, auth, url, HTTP_METHOD_PUT, params) 708 709 return response
710 711 @staticmethod
712 - def delete(object_type, auth_args, object_id):
713 714 auth = PaymentsApi.create_auth_object(auth_args) 715 if not object_id: 716 raise IllegalArgumentError("object_id is a required field") 717 718 url = PaymentsApi.build_request_url(object_type, object_id) 719 response = PaymentsApi().execute(object_type, auth, url, HTTP_METHOD_DELETE) 720 721 return response
722
723 - def decode(self, auth_args, params):
724 725 auth = PaymentsApi.create_auth_object(auth_args) 726 PaymentsApi.check_auth(auth) 727 728 return Jws.decode(params, auth)
729 730
731 - def execute(self, object_type, auth, url_suffix, method, params = None):
732 733 if params is None: 734 params = {} 735 736 PaymentsApi.check_auth(auth) 737 738 http = Http() 739 740 global api_base_sandbox_url 741 global api_base_live_url 742 743 base_url = api_base_sandbox_url 744 if auth.public_key.startswith('lvpb'): 745 base_url = api_base_live_url 746 url = base_url + "/" + url_suffix 747 748 response_body, response_code = http.request(auth, url, method, params) 749 750 if not response_code == HTTP_SUCCESS: 751 handle_http_error(response_body, response_code) 752 753 try: 754 response = json.loads(response_body) 755 except Exception: 756 raise SysError("Invalid response format returned. Have you got the correct URL {0} \n HTTP Status: {1}".format(url, response_code)) 757 758 if "list" in response: 759 obj = DomainFactory.factory("domain") 760 obj.list = [DomainFactory.factory(object_type, values) for values in response["list"]] 761 obj.total = response["total"] 762 return obj 763 else: 764 return DomainFactory.factory(object_type, response)
765 766
767 - def send_auth_request(self, props, context, auth):
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
813 - def get_oauth_error(self, msg, error_code, error_desc):
814 return """{"error" : {"code" : "oauth_error", "message" : "%s, error code '%s', description '%s'" }}""" % (msg, error_code, error_desc)
815 816 817 @classmethod
818 - def build_request_url(cls, object_type, object_id = ''):
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 # Domain classes 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
859 -class Authorization(Domain):
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 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 of residence of the cardholder. For the US, this is a 2-digit USPS code. [max length: 255, 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 [min value: 0, 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{statementDescription => name}: Merchant name B{required } 888 - C{statementDescription => phoneNumber}: Merchant contact phone number. 889 - C{token}: If specified, card associated with card token will be used. [max length: 255] 890 @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. 891 For backwards compatibility the public and private keys may be passed instead of an Authentication object. 892 @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. 893 @return: a Authorization object 894 """ 895 return PaymentsApi.create("authorization", auth_args, params)
896
897 - def delete(self, *auth_args):
898 """ 899 Delete this object 900 @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. 901 For backwards compatibility the public and private keys may be passed instead of an Authentication object. 902 """ 903 return PaymentsApi.delete("authorization", auth_args, self.object_id)
904 905 @staticmethod
906 - def list(criteria = None, *auth_args):
907 """ 908 Retrieve Authorization objects. 909 @param criteria: a dict of parameters; valid keys are: 910 - C{filter} Filters to apply to the list. 911 - C{max} Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20] 912 - C{offset} Used in pagination of the list. This is the start offset of the page. [min value: 0, default: 0] 913 - 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}. 914 @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. 915 For backwards compatibility the public and private keys may be passed instead of an Authentication object. 916 @return: an object which contains the list of Authorization objects in the <code>list</code> property and the total number 917 of objects available for the given criteria in the <code>total</code> property. 918 """ 919 return PaymentsApi.list("authorization", auth_args, criteria)
920 921 @staticmethod
922 - def find(object_id, *auth_args):
923 """ 924 Retrieve a Authorization object from the API 925 @param object_id: ID of object to retrieve 926 @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. 927 For backwards compatibility the public and private keys may be passed instead of an Authentication object. 928 @return: a Authorization object 929 """ 930 return PaymentsApi.find("authorization", auth_args, object_id)
931
932 -class CardToken(Domain):
933 """ 934 A CardToken object. 935 """ 936 937 938 @staticmethod
939 - def create(params, *auth_args):
940 """ 941 Creates an CardToken object 942 @param params: a dict of parameters; valid keys are: 943 - C{callback}: The URL callback for the cardtoken 944 - C{card => addressCity}: City of the cardholder. [max length: 50, min length: 2] 945 - C{card => addressCountry}: Country code (ISO-3166-1-alpha-2 code) of residence of the cardholder. [max length: 2, min length: 2] 946 - C{card => addressLine1}: Address of the cardholder. [max length: 255] 947 - C{card => addressLine2}: Address of the cardholder if needed. [max length: 255] 948 - C{card => addressState}: State of residence of the cardholder. For the US, this is a 2-digit USPS code. [max length: 255, min length: 2] 949 - 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] 950 - C{card => cvc}: CVC security code of the card. This is the code on the back of the card. Example: 123 951 - C{card => expMonth}: Expiration month of the card. Format is MM. Example: January = 01 [min value: 1, max value: 12] B{required } 952 - C{card => expYear}: Expiration year of the card. Format is YY. Example: 2013 = 13 [min value: 0, max value: 99] B{required } 953 - C{card => name}: Name as appears on the card. [max length: 50, min length: 2] 954 - C{card => number}: Card number as it appears on the card. [max length: 19, min length: 13] B{required } 955 - C{key}: Key used to create the card token. 956 @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. 957 For backwards compatibility the public and private keys may be passed instead of an Authentication object. 958 @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. 959 @return: a CardToken object 960 """ 961 return PaymentsApi.create("cardToken", auth_args, params)
962 963 @staticmethod
964 - def find(object_id, *auth_args):
965 """ 966 Retrieve a CardToken object from the API 967 @param object_id: ID of object to retrieve 968 @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. 969 For backwards compatibility the public and private keys may be passed instead of an Authentication object. 970 @return: a CardToken object 971 """ 972 return PaymentsApi.find("cardToken", auth_args, object_id)
973
974 -class Chargeback(Domain):
975 """ 976 A Chargeback object. 977 """ 978 979 980 @staticmethod
981 - def list(criteria = None, *auth_args):
982 """ 983 Retrieve Chargeback objects. 984 @param criteria: a dict of parameters; valid keys are: 985 - C{filter} Filters to apply to the list. 986 - C{max} Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20] 987 - C{offset} Used in paging of the list. This is the start offset of the page. [min value: 0, default: 0] 988 - 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}. 989 @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. 990 For backwards compatibility the public and private keys may be passed instead of an Authentication object. 991 @return: an object which contains the list of Chargeback objects in the <code>list</code> property and the total number 992 of objects available for the given criteria in the <code>total</code> property. 993 """ 994 return PaymentsApi.list("chargeback", auth_args, criteria)
995 996 @staticmethod
997 - def find(object_id, *auth_args):
998 """ 999 Retrieve a Chargeback object from the API 1000 @param object_id: ID of object to retrieve 1001 @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. 1002 For backwards compatibility the public and private keys may be passed instead of an Authentication object. 1003 @return: a Chargeback object 1004 """ 1005 return PaymentsApi.find("chargeback", auth_args, object_id)
1006
1007 -class Coupon(Domain):
1008 """ 1009 A Coupon object. 1010 """ 1011 1012 1013 @staticmethod
1014 - def create(params, *auth_args):
1015 """ 1016 Creates an Coupon object 1017 @param params: a dict of parameters; valid keys are: 1018 - 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] 1019 - C{couponCode}: Code that identifies the coupon to be used. [min length: 2] B{required } 1020 - C{description}: A brief section that describes the coupon. 1021 - C{durationInMonths}: DEPRECATED - Duration in months that the coupon will be applied after it has first been selected. [min value: 1, max value: 9999] 1022 - 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. 1023 - 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] 1024 - C{numTimesApplied}: The number of times a coupon will be applied on a customer's subscription. [min value: 1, max value: 9999] 1025 - 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] 1026 - 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 } 1027 @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. 1028 For backwards compatibility the public and private keys may be passed instead of an Authentication object. 1029 @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. 1030 @return: a Coupon object 1031 """ 1032 return PaymentsApi.create("coupon", auth_args, params)
1033
1034 - def delete(self, *auth_args):
1035 """ 1036 Delete this object 1037 @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. 1038 For backwards compatibility the public and private keys may be passed instead of an Authentication object. 1039 """ 1040 return PaymentsApi.delete("coupon", auth_args, self.object_id)
1041 1042 @staticmethod
1043 - def list(criteria = None, *auth_args):
1044 """ 1045 Retrieve Coupon objects. 1046 @param criteria: a dict of parameters; valid keys are: 1047 - C{filter} Filters to apply to the list. 1048 - C{max} Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20] 1049 - C{offset} Used in paging of the list. This is the start offset of the page. [min value: 0, default: 0] 1050 - 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{numTimesApplied} C{amountOff}. 1051 @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. 1052 For backwards compatibility the public and private keys may be passed instead of an Authentication object. 1053 @return: an object which contains the list of Coupon objects in the <code>list</code> property and the total number 1054 of objects available for the given criteria in the <code>total</code> property. 1055 """ 1056 return PaymentsApi.list("coupon", auth_args, criteria)
1057 1058 @staticmethod
1059 - def find(object_id, *auth_args):
1060 """ 1061 Retrieve a Coupon object from the API 1062 @param object_id: ID of object to retrieve 1063 @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. 1064 For backwards compatibility the public and private keys may be passed instead of an Authentication object. 1065 @return: a Coupon object 1066 """ 1067 return PaymentsApi.find("coupon", auth_args, object_id)
1068
1069 - def update(self, *auth_args):
1070 """ 1071 Updates this object 1072 1073 The properties that can be updated: 1074 - C{endDate} The ending date in UTC millis for the coupon. This must be after the starting date of the coupon. 1075 1076 - 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] 1077 1078 @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. 1079 For backwards compatibility the public and private keys may be passed instead of an Authentication object. 1080 @return: a Coupon object. 1081 """ 1082 return PaymentsApi.update("coupon", auth_args, self.object_id, self.to_dict())
1083
1084 -class Customer(Domain):
1085 """ 1086 A Customer object. 1087 """ 1088 1089 1090 @staticmethod
1091 - def create(params, *auth_args):
1092 """ 1093 Creates an Customer object 1094 @param params: a dict of parameters; valid keys are: 1095 - C{card => addressCity}: City of the cardholder. B{required } 1096 - C{card => addressCountry}: Country code (ISO-3166-1-alpha-2 code) of residence of the cardholder. B{required } 1097 - C{card => addressLine1}: Address of the cardholder B{required } 1098 - C{card => addressLine2}: Address of the cardholder if needed. B{required } 1099 - C{card => addressState}: State of residence of the cardholder. For the US, this is a 2-digit USPS code. B{required } 1100 - 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 } 1101 - C{card => cvc}: CVC security code of the card. This is the code on the back of the card. Example: 123 B{required } 1102 - C{card => expMonth}: Expiration month of the card. Format is MM. Example: January = 01 B{required } 1103 - C{card => expYear}: Expiration year of the card. Format is YY. Example: 2013 = 13 B{required } 1104 - C{card => id}: ID of card. Unused during customer create. 1105 - C{card => name}: Name as appears on the card. B{required } 1106 - C{card => number}: Card number as it appears on the card. [max length: 19, min length: 13] 1107 - C{email}: Email address of the customer B{required } 1108 - C{name}: Customer name [min length: 2] B{required } 1109 - C{reference}: Reference field for external applications use. 1110 - C{subscriptions => amount}: Amount of payment in the smallest unit of your currency. Example: 100 = $1.00USD 1111 - C{subscriptions => billingCycle}: How the plan is billed to the customer. Values must be AUTO (indefinitely until the customer cancels) or FIXED (a fixed number of billing cycles). [default: AUTO] 1112 - C{subscriptions => billingCycleLimit}: The number of fixed billing cycles for a plan. Only used if the billingCycle parameter is set to FIXED. Example: 4 1113 - C{subscriptions => coupon}: Coupon associated with the subscription for the customer. 1114 - C{subscriptions => currency}: Currency code (ISO-4217). Must match the currency associated with your account. [default: USD] 1115 - C{subscriptions => customer}: The customer ID to create the subscription for. Do not supply this when creating a customer. 1116 - C{subscriptions => frequency}: Frequency of payment for the plan. Used in conjunction with frequencyPeriod. Valid values are "DAILY", "WEEKLY", "MONTHLY" and "YEARLY". 1117 - C{subscriptions => frequencyPeriod}: Period of frequency of payment for the plan. Example: if the frequency is weekly, and periodFrequency is 2, then the subscription is billed bi-weekly. 1118 - C{subscriptions => name}: Name describing subscription 1119 - C{subscriptions => plan}: The plan ID that the subscription should be created from. 1120 - C{subscriptions => quantity}: Quantity of the plan for the subscription. [min value: 1] 1121 - C{subscriptions => renewalReminderLeadDays}: If set, how many days before the next billing cycle that a renewal reminder is sent to the customer. If null, then no emails are sent. Minimum value is 7 if set. 1122 - C{token}: If specified, card associated with card token will be used 1123 @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. 1124 For backwards compatibility the public and private keys may be passed instead of an Authentication object. 1125 @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. 1126 @return: a Customer object 1127 """ 1128 return PaymentsApi.create("customer", auth_args, params)
1129
1130 - def delete(self, *auth_args):
1131 """ 1132 Delete this object 1133 @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. 1134 For backwards compatibility the public and private keys may be passed instead of an Authentication object. 1135 """ 1136 return PaymentsApi.delete("customer", auth_args, self.object_id)
1137 1138 @staticmethod
1139 - def list(criteria = None, *auth_args):
1140 """ 1141 Retrieve Customer objects. 1142 @param criteria: a dict of parameters; valid keys are: 1143 - C{filter} Filters to apply to the list. 1144 - C{max} Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20] 1145 - C{offset} Used in paging of the list. This is the start offset of the page. [min value: 0, default: 0] 1146 - 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}. 1147 @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. 1148 For backwards compatibility the public and private keys may be passed instead of an Authentication object. 1149 @return: an object which contains the list of Customer objects in the <code>list</code> property and the total number 1150 of objects available for the given criteria in the <code>total</code> property. 1151 """ 1152 return PaymentsApi.list("customer", auth_args, criteria)
1153 1154 @staticmethod
1155 - def find(object_id, *auth_args):
1156 """ 1157 Retrieve a Customer object from the API 1158 @param object_id: ID of object to retrieve 1159 @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. 1160 For backwards compatibility the public and private keys may be passed instead of an Authentication object. 1161 @return: a Customer object 1162 """ 1163 return PaymentsApi.find("customer", auth_args, object_id)
1164
1165 - def update(self, *auth_args):
1166 """ 1167 Updates this object 1168 1169 The properties that can be updated: 1170 - C{card => addressCity} City of the cardholder. B{(required)} 1171 1172 - C{card => addressCountry} Country code (ISO-3166-1-alpha-2 code) of residence of the cardholder. B{(required)} 1173 1174 - C{card => addressLine1} Address of the cardholder. B{(required)} 1175 1176 - C{card => addressLine2} Address of the cardholder if needed. B{(required)} 1177 1178 - C{card => addressState} State of residence of the cardholder. For the US, this is a 2-digit USPS code. B{(required)} 1179 1180 - 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)} 1181 1182 - C{card => cvc} CVC security code of the card. This is the code on the back of the card. Example: 123 B{(required)} 1183 1184 - C{card => expMonth} Expiration month of the card. Format is MM. Example: January = 01 B{(required)} 1185 1186 - C{card => expYear} Expiration year of the card. Format is YY. Example: 2013 = 13 B{(required)} 1187 1188 - 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. 1189 1190 - C{card => name} Name as appears on the card. B{(required)} 1191 1192 - C{card => number} Card number as it appears on the card. [max length: 19, min length: 13] 1193 1194 - C{email} Email address of the customer B{(required)} 1195 1196 - C{name} Customer name [min length: 2] B{(required)} 1197 1198 - C{reference} Reference field for external applications use. 1199 1200 - C{token} If specified, card associated with card token will be added to the customer 1201 1202 @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. 1203 For backwards compatibility the public and private keys may be passed instead of an Authentication object. 1204 @return: a Customer object. 1205 """ 1206 return PaymentsApi.update("customer", auth_args, self.object_id, self.to_dict())
1207
1208 -class Deposit(Domain):
1209 """ 1210 A Deposit object. 1211 """ 1212 1213 1214 @staticmethod
1215 - def list(criteria = None, *auth_args):
1216 """ 1217 Retrieve Deposit objects. 1218 @param criteria: a dict of parameters; valid keys are: 1219 - C{filter} Filters to apply to the list. 1220 - C{max} Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20] 1221 - C{offset} Used in paging of the list. This is the start offset of the page. [min value: 0, default: 0] 1222 - 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}. 1223 @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. 1224 For backwards compatibility the public and private keys may be passed instead of an Authentication object. 1225 @return: an object which contains the list of Deposit objects in the <code>list</code> property and the total number 1226 of objects available for the given criteria in the <code>total</code> property. 1227 """ 1228 return PaymentsApi.list("deposit", auth_args, criteria)
1229 1230 @staticmethod
1231 - def find(object_id, *auth_args):
1232 """ 1233 Retrieve a Deposit object from the API 1234 @param object_id: ID of object to retrieve 1235 @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. 1236 For backwards compatibility the public and private keys may be passed instead of an Authentication object. 1237 @return: a Deposit object 1238 """ 1239 return PaymentsApi.find("deposit", auth_args, object_id)
1240
1241 -class FraudCheck(Domain):
1242 """ 1243 A FraudCheck object. 1244 """ 1245 1246 1247 @staticmethod
1248 - def create(params, *auth_args):
1249 """ 1250 Creates an FraudCheck object 1251 @param params: a dict of parameters; valid keys are: 1252 - C{amount}: Amount of the transaction to be checked for fraud (in the smallest unit of your currency). Example: 100 = $1.00USD. This field is required if using “full” or “advanced” mode. 1253 - C{card => addressCity}: City of the cardholder. [max length: 50, min length: 2] 1254 - C{card => addressCountry}: Country code (ISO-3166-1-alpha-2 code) of residence of the cardholder. [max length: 2, min length: 2] 1255 - C{card => addressLine1}: Address of the cardholder. [max length: 255] 1256 - C{card => addressLine2}: Address of the cardholder if needed. [max length: 255] 1257 - C{card => addressState}: State of residence of the cardholder. For the US, this is a 2-digit USPS code. [max length: 255, min length: 2] 1258 - 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] 1259 - C{card => cvc}: CVC security code of the card. This is the code on the back of the card. Example: 123 1260 - C{card => expMonth}: Expiration month of the card. Format is MM. Example: January = 01 [min value: 1, max value: 12] B{required } 1261 - C{card => expYear}: Expiration year of the card. Format is YY. Example: 2013 = 13 [min value: 0, max value: 99] B{required } 1262 - C{card => name}: Name as it appears on the card. [max length: 50, min length: 2] 1263 - C{card => number}: Card number as it appears on the card. [max length: 19, min length: 13] B{required } 1264 - C{currency}: Currency code (ISO-4217) for the transaction to be checked for fraud. This field is required if using “full” or “advanced” mode. 1265 - C{description}: - Description of the fraud check. [max length: 255] 1266 - C{ipAddress}: IP Address of the customer for which the fraud check is to be done. [max length: 45] 1267 - C{mode}: Fraud check mode. “simple” only does an AVS and CVC check; “advanced” does a complete fraud check, running the input against the set up rules. [valid values: simple, advanced, full] B{required } 1268 - C{sessionId}: Session ID used during data collection. [max length: 255] 1269 - C{token}: Card token token representing card details for the card to be checked. [max length: 255] 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 FraudCheck object 1274 """ 1275 return PaymentsApi.create("fraudCheck", auth_args, params)
1276 1277 @staticmethod
1278 - def list(criteria = None, *auth_args):
1279 """ 1280 Retrieve FraudCheck objects. 1281 @param criteria: a dict of parameters; valid keys are: 1282 - C{filter} Allows for ascending or descending sorting of the list. 1283 - C{max} Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20] 1284 - C{offset} Used in paging of the list. This is the start offset of the page. [min value: 0, default: 0] 1285 - C{sorting} Used in paging of the list. This is the start offset of the page. The value maps properties to the sort direction (either C{asc} for ascending or C{desc} for descending). Sortable properties are: . 1286 @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. 1287 For backwards compatibility the public and private keys may be passed instead of an Authentication object. 1288 @return: an object which contains the list of FraudCheck objects in the <code>list</code> property and the total number 1289 of objects available for the given criteria in the <code>total</code> property. 1290 """ 1291 return PaymentsApi.list("fraudCheck", auth_args, criteria)
1292 1293 @staticmethod
1294 - def find(object_id, *auth_args):
1295 """ 1296 Retrieve a FraudCheck object from the API 1297 @param object_id: ID of object to retrieve 1298 @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. 1299 For backwards compatibility the public and private keys may be passed instead of an Authentication object. 1300 @return: a FraudCheck object 1301 """ 1302 return PaymentsApi.find("fraudCheck", auth_args, object_id)
1303
1304 -class Invoice(Domain):
1305 """ 1306 A Invoice object. 1307 """ 1308 1309 1310 @staticmethod
1311 - def create(params, *auth_args):
1312 """ 1313 Creates an Invoice object 1314 @param params: a dict of parameters; valid keys are: 1315 - C{billingAddress => city}: Billing address city of the location where the goods or services were supplied. [max length: 255, min length: 2] 1316 - C{billingAddress => country}: Billing address country of the location where the goods or services were supplied. [max length: 2, min length: 2] 1317 - C{billingAddress => line1}: Billing address line 1 of the location where the goods or services were supplied. [max length: 255] 1318 - C{billingAddress => line2}: Billing address line 2 of the location where the goods or services were supplied. [max length: 255] 1319 - C{billingAddress => name}: Billing address name of the location where the goods or services were supplied. Will use the customer name if not provided. [max length: 255] 1320 - C{billingAddress => state}: Billing address state of the location where the goods or services were supplied. [max length: 255] 1321 - C{billingAddress => zip}: Billing address zip of the location where the goods or services were supplied. [max length: 32] 1322 - C{businessAddress => city}: Address city of the business that is sending the invoice. [max length: 255, min length: 2] 1323 - C{businessAddress => country}: Address country of the business that is sending the invoice. [max length: 2, min length: 2] 1324 - C{businessAddress => line1}: Address line 1 of the business that is sending the invoice. [max length: 255] 1325 - C{businessAddress => line2}: Address line 2 of the business that is sending the invoice. [max length: 255] 1326 - C{businessAddress => name}: The name of the business that is sending the invoice. [max length: 255] 1327 - C{businessAddress => state}: Address state of the business that is sending the invoice. [max length: 255] 1328 - C{businessAddress => zip}: Address zip of the business that is sending the invoice. [max length: 32] 1329 - C{currency}: Currency code (ISO-4217). Must match the currency associated with your account. [max length: 3, min length: 3, default: USD] 1330 - C{customer}: The customer ID of the customer we are invoicing. This is optional if invoiceToCopy or a name and email are provided 1331 - C{customerTaxNo}: The tax number or VAT id of the person to whom the goods or services were supplied. [max length: 255] 1332 - 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] 1333 - 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. 1334 - C{email}: The email of the customer we are invoicing. This is optional if customer or invoiceToCopy is provided. A new customer will be created using the the name and email. 1335 - C{invoiceId}: User defined invoice id. If not provided the system will generate a numeric id. [max length: 255] 1336 - C{invoiceToCopy}: The id of an existing invoice to be copied. This is optional if customer or a name and email are provided 1337 - C{items => amount}: Amount of the invoice item (the smallest unit of your currency). Example: 100 = $1.00USD [min value: -9999900, max value: 9999900] B{required } 1338 - C{items => description}: The description of the invoice item. [max length: 1024] 1339 - C{items => invoice}: The ID of the invoice this item belongs to. 1340 - C{items => product}: The product this invoice item refers to. 1341 - 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] 1342 - C{items => reference}: User defined reference field. [max length: 255] 1343 - C{items => tax}: The tax ID of the tax charge in the invoice item. 1344 - 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] 1345 - C{memo}: A memo that is displayed to the customer on the invoice payment screen. [max length: 4000] 1346 - C{name}: The name of the customer we are invoicing. This is optional if customer or invoiceToCopy is provided. A new customer will be created using the the name and email. [max length: 50, min length: 2] 1347 - C{note}: This field can be used to store a note that is not displayed to the customer. [max length: 4000] 1348 - C{reference}: User defined reference field. [max length: 255] 1349 - C{shippingAddress => city}: Address city of the location where the goods or services were supplied. [max length: 255, min length: 2] 1350 - C{shippingAddress => country}: Address country of the location where the goods or services were supplied. [max length: 2, min length: 2] 1351 - C{shippingAddress => line1}: Address line 1 of the location where the goods or services were supplied. [max length: 255] 1352 - C{shippingAddress => line2}: Address line 2 of the location where the goods or services were supplied. [max length: 255] 1353 - C{shippingAddress => name}: Address name of the location where the goods or services were supplied. [max length: 255] 1354 - C{shippingAddress => state}: Address state of the location where the goods or services were supplied. [max length: 255] 1355 - C{shippingAddress => zip}: Address zip of the location where the goods or services were supplied. [max length: 32] 1356 - C{suppliedDate}: The date on which the goods or services were supplied. 1357 - C{taxNo}: The tax number or VAT id of the person who supplied the goods or services. [max length: 255] 1358 - C{type}: The type of invoice. One of WEB or MOBILE. [valid values: WEB, MOBILE, default: WEB] 1359 @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. 1360 For backwards compatibility the public and private keys may be passed instead of an Authentication object. 1361 @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. 1362 @return: a Invoice object 1363 """ 1364 return PaymentsApi.create("invoice", auth_args, params)
1365
1366 - def delete(self, *auth_args):
1367 """ 1368 Delete this object 1369 @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. 1370 For backwards compatibility the public and private keys may be passed instead of an Authentication object. 1371 """ 1372 return PaymentsApi.delete("invoice", auth_args, self.object_id)
1373 1374 @staticmethod
1375 - def list(criteria = None, *auth_args):
1376 """ 1377 Retrieve Invoice objects. 1378 @param criteria: a dict of parameters; valid keys are: 1379 - C{filter} Filters to apply to the list. 1380 - C{max} Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20] 1381 - C{offset} Used in paging of the list. This is the start offset of the page. [min value: 0, default: 0] 1382 - 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} C{dateCreated}. 1383 @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. 1384 For backwards compatibility the public and private keys may be passed instead of an Authentication object. 1385 @return: an object which contains the list of Invoice objects in the <code>list</code> property and the total number 1386 of objects available for the given criteria in the <code>total</code> property. 1387 """ 1388 return PaymentsApi.list("invoice", auth_args, criteria)
1389 1390 @staticmethod
1391 - def find(object_id, *auth_args):
1392 """ 1393 Retrieve a Invoice object from the API 1394 @param object_id: ID of object to retrieve 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 @return: a Invoice object 1398 """ 1399 return PaymentsApi.find("invoice", auth_args, object_id)
1400
1401 - def update(self, *auth_args):
1402 """ 1403 Updates this object 1404 1405 The properties that can be updated: 1406 - C{billingAddress => city} Billing address city of the location where the goods or services were supplied. [max length: 255, min length: 2] 1407 1408 - C{billingAddress => country} Billing address country of the location where the goods or services were supplied. [max length: 2, min length: 2] 1409 1410 - C{billingAddress => line1} Billing address line 1 of the location where the goods or services were supplied. [max length: 255] 1411 1412 - C{billingAddress => line2} Billing address line 2 of the location where the goods or services were supplied. [max length: 255] 1413 1414 - C{billingAddress => name} Billing address name of the location where the goods or services were supplied. [max length: 255] 1415 1416 - C{billingAddress => state} Billing address state of the location where the goods or services were supplied. [max length: 255] 1417 1418 - C{billingAddress => zip} Billing address zip of the location where the goods or services were supplied. [max length: 32] 1419 1420 - C{businessAddress => city} Business address city of the business that is sending the invoice. [max length: 255, min length: 2] 1421 1422 - C{businessAddress => country} Business address country of the business that is sending the invoice. [max length: 2, min length: 2] 1423 1424 - C{businessAddress => line1} Business address line 1 of the business that is sending the invoice. [max length: 255] 1425 1426 - C{businessAddress => line2} Business address line 2 of the business that is sending the invoice. [max length: 255] 1427 1428 - C{businessAddress => name} Business address name of the business that is sending the invoice. [max length: 255] 1429 1430 - C{businessAddress => state} Business address state of the business that is sending the invoice. [max length: 255] 1431 1432 - C{businessAddress => zip} Business address zip of the business that is sending the invoice. [max length: 32] 1433 1434 - C{currency} Currency code (ISO-4217). Must match the currency associated with your account. [max length: 3, min length: 3] 1435 1436 - C{customerTaxNo} The tax number or VAT id of the person to whom the goods or services were supplied. [max length: 255] 1437 1438 - C{datePaid} This is the date the invoice was PAID in UTC millis. 1439 1440 - 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] 1441 1442 - 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. 1443 1444 - C{email} The email of the customer we are invoicing. This is optional if customer or invoiceToCopy is provided. A new customer will be created using the the name and email. 1445 1446 - C{invoiceId} User defined invoice id. If not provided the system will generate a numeric id. [max length: 255] 1447 1448 - C{items => amount} Amount of the invoice item in the smallest unit of your currency. Example: 100 = $1.00USD [min value: -9999900, max value: 9999900] B{(required)} 1449 1450 - C{items => description} The description of the invoice item. [max length: 1024] 1451 1452 - C{items => invoice} The ID of the invoice this item belongs to. 1453 1454 - C{items => product} The Id of the product this item refers to. 1455 1456 - 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] 1457 1458 - C{items => reference} User defined reference field. [max length: 255] 1459 1460 - C{items => tax} The tax ID of the tax charge in the invoice item. 1461 1462 - 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] 1463 1464 - C{memo} A memo that is displayed to the customer on the invoice payment screen. [max length: 4000] 1465 1466 - C{name} The name of the customer we are invoicing. This is optional if customer or invoiceToCopy is provided. A new customer will be created using the the name and email. [max length: 50, min length: 2] 1467 1468 - C{note} This field can be used to store a note that is not displayed to the customer. [max length: 4000] 1469 1470 - C{payment} The ID of the payment. Use this ID to query the /payment API. [max length: 255] 1471 1472 - C{reference} User defined reference field. [max length: 255] 1473 1474 - C{shippingAddress => city} Address city of the location where the goods or services were supplied. [max length: 255, min length: 2] 1475 1476 - C{shippingAddress => country} Address country of the location where the goods or services were supplied. [max length: 2, min length: 2] 1477 1478 - C{shippingAddress => line1} Address line 1 of the location where the goods or services were supplied. [max length: 255] 1479 1480 - C{shippingAddress => line2} Address line 2 of the location where the goods or services were supplied. [max length: 255] 1481 1482 - C{shippingAddress => name} Address name of the location where the goods or services were supplied. [max length: 255] 1483 1484 - C{shippingAddress => state} Address state of the location where the goods or services were supplied. [max length: 255] 1485 1486 - C{shippingAddress => zip} Address zip of the location where the goods or services were supplied. [max length: 32] 1487 1488 - C{status} New status of the invoice. 1489 1490 - C{suppliedDate} The date on which the goods or services were supplied. 1491 1492 - C{taxNo} The tax number or VAT id of the person who supplied the goods or services. [max length: 255] 1493 1494 @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. 1495 For backwards compatibility the public and private keys may be passed instead of an Authentication object. 1496 @return: a Invoice object. 1497 """ 1498 return PaymentsApi.update("invoice", auth_args, self.object_id, self.to_dict())
1499
1500 -class InvoiceItem(Domain):
1501 """ 1502 A InvoiceItem object. 1503 """ 1504 1505 1506 @staticmethod
1507 - def create(params, *auth_args):
1508 """ 1509 Creates an InvoiceItem object 1510 @param params: a dict of parameters; valid keys are: 1511 - C{amount}: Amount of the invoice item in the smallest unit of your currency. Example: 100 = $1.00USD [min value: -9999900, max value: 9999900] B{required } 1512 - C{description}: Individual items of an invoice [max length: 1024] 1513 - C{invoice}: The ID of the invoice this item belongs to. 1514 - C{product}: Product ID this item relates to. 1515 - 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] 1516 - C{reference}: User defined reference field. [max length: 255] 1517 - C{tax}: The tax ID of the tax charge in the invoice item. 1518 @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. 1519 For backwards compatibility the public and private keys may be passed instead of an Authentication object. 1520 @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. 1521 @return: a InvoiceItem object 1522 """ 1523 return PaymentsApi.create("invoiceItem", auth_args, params)
1524
1525 - def delete(self, *auth_args):
1526 """ 1527 Delete this object 1528 @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. 1529 For backwards compatibility the public and private keys may be passed instead of an Authentication object. 1530 """ 1531 return PaymentsApi.delete("invoiceItem", auth_args, self.object_id)
1532 1533 @staticmethod
1534 - def find(object_id, *auth_args):
1535 """ 1536 Retrieve a InvoiceItem object from the API 1537 @param object_id: ID of object to retrieve 1538 @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. 1539 For backwards compatibility the public and private keys may be passed instead of an Authentication object. 1540 @return: a InvoiceItem object 1541 """ 1542 return PaymentsApi.find("invoiceItem", auth_args, object_id)
1543
1544 - def update(self, *auth_args):
1545 """ 1546 Updates this object 1547 1548 The properties that can be updated: 1549 - C{amount} Amount of the invoice item in the smallest unit of your currency. Example: 100 = $1.00USD [min value: 1] 1550 1551 - C{description} Individual items of an invoice 1552 1553 - C{quantity} Quantity of the item. This total amount of the invoice item is the amount * quantity. [min value: 1, max value: 999999] 1554 1555 - C{reference} User defined reference field. 1556 1557 - C{tax} The tax ID of the tax charge in the invoice item. 1558 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 InvoiceItem object. 1562 """ 1563 return PaymentsApi.update("invoiceItem", auth_args, self.object_id, self.to_dict())
1564
1565 -class Payment(Domain):
1566 """ 1567 A Payment object. 1568 """ 1569 1570 1571 @staticmethod
1572 - def create(params, *auth_args):
1573 """ 1574 Creates an Payment object 1575 @param params: a dict of parameters; valid keys are: 1576 - C{amount}: Amount of the payment (in the smallest unit of your currency). Example: 100 = $1.00USD 1577 - C{authorization}: The ID of the authorization being used to capture the payment. 1578 - C{card => addressCity}: City of the cardholder. [max length: 50, min length: 2] 1579 - C{card => addressCountry}: Country code (ISO-3166-1-alpha-2 code) of residence of the cardholder. [max length: 2, min length: 2] 1580 - C{card => addressLine1}: Address of the cardholder. [max length: 255] 1581 - C{card => addressLine2}: Address of the cardholder if needed. [max length: 255] 1582 - C{card => addressState}: State of residence of the cardholder. For the US, this is a 2-digit USPS code. [max length: 255, min length: 2] 1583 - 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] 1584 - C{card => cvc}: CVC security code of the card. This is the code on the back of the card. Example: 123 1585 - C{card => expMonth}: Expiration month of the card. Format is MM. Example: January = 01 [min value: 1, max value: 12] B{required } 1586 - C{card => expYear}: Expiration year of the card. Format is YY. Example: 2013 = 13 [min value: 0, max value: 99] B{required } 1587 - C{card => name}: Name as it appears on the card. [max length: 50, min length: 2] 1588 - C{card => number}: Card number as it appears on the card. [max length: 19, min length: 13] B{required } 1589 - C{currency}: Currency code (ISO-4217) for the transaction. Must match the currency associated with your account. [default: USD] B{required } 1590 - C{customer}: ID of customer. If specified, card on file of customer will be used. 1591 - 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] 1592 - C{invoice}: ID of invoice for which this payment is being made. 1593 - C{reference}: Custom reference field to be used with outside systems. 1594 - 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] 1595 - C{statementDescription => name}: Merchant name. B{required } 1596 - C{statementDescription => phoneNumber}: Merchant contact phone number. 1597 - C{token}: If specified, card associated with card token will be used. [max length: 255] 1598 @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. 1599 For backwards compatibility the public and private keys may be passed instead of an Authentication object. 1600 @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. 1601 @return: a Payment object 1602 """ 1603 return PaymentsApi.create("payment", auth_args, params)
1604 1605 @staticmethod
1606 - def list(criteria = None, *auth_args):
1607 """ 1608 Retrieve Payment objects. 1609 @param criteria: a dict of parameters; valid keys are: 1610 - C{filter} Filters to apply to the list. 1611 - C{max} Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20] 1612 - C{offset} Used in paging of the list. This is the start offset of the page. [min value: 0, default: 0] 1613 - 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{createdBy} C{amount} C{id} C{description} C{paymentDate}. 1614 @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. 1615 For backwards compatibility the public and private keys may be passed instead of an Authentication object. 1616 @return: an object which contains the list of Payment objects in the <code>list</code> property and the total number 1617 of objects available for the given criteria in the <code>total</code> property. 1618 """ 1619 return PaymentsApi.list("payment", auth_args, criteria)
1620 1621 @staticmethod
1622 - def find(object_id, *auth_args):
1623 """ 1624 Retrieve a Payment object from the API 1625 @param object_id: ID of object to retrieve 1626 @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. 1627 For backwards compatibility the public and private keys may be passed instead of an Authentication object. 1628 @return: a Payment object 1629 """ 1630 return PaymentsApi.find("payment", auth_args, object_id)
1631
1632 - def update(self, *auth_args):
1633 """ 1634 Updates this object 1635 1636 The properties that can be updated: 1637 @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. 1638 For backwards compatibility the public and private keys may be passed instead of an Authentication object. 1639 @return: a Payment object. 1640 """ 1641 return PaymentsApi.update("payment", auth_args, self.object_id, self.to_dict())
1642
1643 -class Plan(Domain):
1644 """ 1645 A Plan object. 1646 """ 1647 1648 1649 @staticmethod
1650 - def create(params, *auth_args):
1651 """ 1652 Creates an Plan object 1653 @param params: a dict of parameters; valid keys are: 1654 - C{amount}: Amount of payment for the plan in the smallest unit of your currency. Example: 100 = $1.00USD B{required } 1655 - C{billingCycle}: How the plan is billed to the customer. Values must be AUTO (indefinitely until the customer cancels) or FIXED (a fixed number of billing cycles). [default: AUTO] 1656 - C{billingCycleLimit}: The number of fixed billing cycles for a plan. Only used if the billingCycle parameter is set to FIXED. Example: 4 1657 - C{currency}: Currency code (ISO-4217) for the plan. Must match the currency associated with your account. [default: USD] B{required } 1658 - C{frequency}: Frequency of payment for the plan. Used in conjunction with frequencyPeriod. Valid values are "DAILY", "WEEKLY", "MONTHLY" and "YEARLY". [default: MONTHLY] B{required } 1659 - C{frequencyPeriod}: Period of frequency of payment for the plan. Example: if the frequency is weekly, and periodFrequency is 2, then the subscription is billed bi-weekly. [min value: 1, default: 1] B{required } 1660 - C{name}: Name of the plan [max length: 50, min length: 2] B{required } 1661 - C{renewalReminderLeadDays}: If set, how many days before the next billing cycle that a renewal reminder is sent to the customer. If null, then no emails are sent. Minimum value is 7 if set. 1662 - C{trialPeriod}: Plan free trial period selection. Must be Days, Weeks, or Month [default: NONE] B{required } 1663 - C{trialPeriodQuantity}: Quantity of the trial period. Must be greater than 0 and a whole number. [min value: 1] 1664 @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. 1665 For backwards compatibility the public and private keys may be passed instead of an Authentication object. 1666 @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. 1667 @return: a Plan object 1668 """ 1669 return PaymentsApi.create("plan", auth_args, params)
1670
1671 - def delete(self, *auth_args):
1672 """ 1673 Delete this object 1674 @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. 1675 For backwards compatibility the public and private keys may be passed instead of an Authentication object. 1676 """ 1677 return PaymentsApi.delete("plan", auth_args, self.object_id)
1678 1679 @staticmethod
1680 - def list(criteria = None, *auth_args):
1681 """ 1682 Retrieve Plan objects. 1683 @param criteria: a dict of parameters; valid keys are: 1684 - C{filter} Filters to apply to the list. 1685 - C{max} Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20] 1686 - C{offset} Used in paging of the list. This is the start offset of the page. [min value: 0, default: 0] 1687 - 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}. 1688 @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. 1689 For backwards compatibility the public and private keys may be passed instead of an Authentication object. 1690 @return: an object which contains the list of Plan objects in the <code>list</code> property and the total number 1691 of objects available for the given criteria in the <code>total</code> property. 1692 """ 1693 return PaymentsApi.list("plan", auth_args, criteria)
1694 1695 @staticmethod
1696 - def find(object_id, *auth_args):
1697 """ 1698 Retrieve a Plan object from the API 1699 @param object_id: ID of object to retrieve 1700 @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. 1701 For backwards compatibility the public and private keys may be passed instead of an Authentication object. 1702 @return: a Plan object 1703 """ 1704 return PaymentsApi.find("plan", auth_args, object_id)
1705
1706 - def update(self, *auth_args):
1707 """ 1708 Updates this object 1709 1710 The properties that can be updated: 1711 - C{name} Name of the plan. [min length: 2] B{(required)} 1712 1713 @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. 1714 For backwards compatibility the public and private keys may be passed instead of an Authentication object. 1715 @return: a Plan object. 1716 """ 1717 return PaymentsApi.update("plan", auth_args, self.object_id, self.to_dict())
1718
1719 -class Refund(Domain):
1720 """ 1721 A Refund object. 1722 """ 1723 1724 1725 @staticmethod
1726 - def create(params, *auth_args):
1727 """ 1728 Creates an Refund object 1729 @param params: a dict of parameters; valid keys are: 1730 - C{amount}: Amount of the refund in the smallest unit of your currency. Example: 100 = $1.00USD [min value: 1] B{required } 1731 - C{payment}: ID of the payment for the refund B{required } 1732 - C{reason}: Reason for the refund 1733 - C{reference}: Custom reference field to be used with outside systems. 1734 - 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] 1735 - C{statementDescription => name}: Merchant name. B{required } 1736 - C{statementDescription => phoneNumber}: Merchant contact phone number. 1737 @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. 1738 For backwards compatibility the public and private keys may be passed instead of an Authentication object. 1739 @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. 1740 @return: a Refund object 1741 """ 1742 return PaymentsApi.create("refund", auth_args, params)
1743 1744 @staticmethod
1745 - def list(criteria = None, *auth_args):
1746 """ 1747 Retrieve Refund 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. [min value: 0, max value: 50, default: 20] 1751 - C{offset} Used in paging of the list. This is the start offset of the page. [min value: 0, 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{amount} C{description} C{dateCreated} C{paymentDate}. 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 Refund 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("refund", auth_args, criteria)
1759 1760 @staticmethod
1761 - def find(object_id, *auth_args):
1762 """ 1763 Retrieve a Refund 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 Refund object 1768 """ 1769 return PaymentsApi.find("refund", auth_args, object_id)
1770
1771 -class Subscription(Domain):
1772 """ 1773 A Subscription object. 1774 """ 1775 1776 1777 @staticmethod
1778 - def create(params, *auth_args):
1779 """ 1780 Creates an Subscription object 1781 @param params: a dict of parameters; valid keys are: 1782 - C{amount}: Amount of the payment in the smallest unit of your currency. Example: 100 = $1.00USD 1783 - C{billingCycle}: How the plan is billed to the customer. Values must be AUTO (indefinitely until the customer cancels) or FIXED (a fixed number of billing cycles). [default: AUTO] 1784 - C{billingCycleLimit}: The number of fixed billing cycles for a plan. Only used if the billingCycle parameter is set to FIXED. Example: 4 1785 - C{coupon}: Coupon ID associated with the subscription 1786 - C{currency}: Currency code (ISO-4217). Must match the currency associated with your account. [default: USD] 1787 - C{customer}: Customer that is enrolling in the subscription. 1788 - C{frequency}: Frequency of payment for the plan. Used in conjunction with frequencyPeriod. Valid values are "DAILY", "WEEKLY", "MONTHLY" and "YEARLY". 1789 - C{frequencyPeriod}: Period of frequency of payment for the plan. Example: if the frequency is weekly, and periodFrequency is 2, then the subscription is billed bi-weekly. 1790 - C{name}: Name describing subscription 1791 - C{plan}: The ID of the plan that should be used for the subscription. 1792 - C{quantity}: Quantity of the plan for the subscription. [min value: 1] 1793 - C{renewalReminderLeadDays}: If set, how many days before the next billing cycle that a renewal reminder is sent to the customer. If null, then no emails are sent. Minimum value is 7 if set. 1794 @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. 1795 For backwards compatibility the public and private keys may be passed instead of an Authentication object. 1796 @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. 1797 @return: a Subscription object 1798 """ 1799 return PaymentsApi.create("subscription", auth_args, params)
1800
1801 - def delete(self, *auth_args):
1802 """ 1803 Delete this object 1804 @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. 1805 For backwards compatibility the public and private keys may be passed instead of an Authentication object. 1806 """ 1807 return PaymentsApi.delete("subscription", auth_args, self.object_id)
1808 1809 @staticmethod
1810 - def list(criteria = None, *auth_args):
1811 """ 1812 Retrieve Subscription objects. 1813 @param criteria: a dict of parameters; valid keys are: 1814 - C{filter} Filters to apply to the list. 1815 - C{max} Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20] 1816 - C{offset} Used in paging of the list. This is the start offset of the page. [min value: 0, default: 0] 1817 - 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}. 1818 @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. 1819 For backwards compatibility the public and private keys may be passed instead of an Authentication object. 1820 @return: an object which contains the list of Subscription objects in the <code>list</code> property and the total number 1821 of objects available for the given criteria in the <code>total</code> property. 1822 """ 1823 return PaymentsApi.list("subscription", auth_args, criteria)
1824 1825 @staticmethod
1826 - def find(object_id, *auth_args):
1827 """ 1828 Retrieve a Subscription object from the API 1829 @param object_id: ID of object to retrieve 1830 @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. 1831 For backwards compatibility the public and private keys may be passed instead of an Authentication object. 1832 @return: a Subscription object 1833 """ 1834 return PaymentsApi.find("subscription", auth_args, object_id)
1835
1836 - def update(self, *auth_args):
1837 """ 1838 Updates this object 1839 1840 The properties that can be updated: 1841 - C{amount} Amount of the payment in the smallest unit of your currency. Example: 100 = $1.00USD 1842 1843 - C{billingCycle} How the plan is billed to the customer. Values must be AUTO (indefinitely until the customer cancels) or FIXED (a fixed number of billing cycles). [default: AUTO] 1844 1845 - C{billingCycleLimit} The number of fixed billing cycles for a plan. Only used if the billingCycle parameter is set to FIXED. Example: 4 1846 1847 - C{coupon} Coupon being assigned to this subscription 1848 1849 - C{currency} Currency code (ISO-4217). Must match the currency associated with your account. [default: USD] 1850 1851 - C{frequency} Frequency of payment for the plan. Used in conjunction with frequencyPeriod. Valid values are "DAILY", "WEEKLY", "MONTHLY" and "YEARLY". 1852 1853 - C{frequencyPeriod} Period of frequency of payment for the plan. Example: if the frequency is weekly, and periodFrequency is 2, then the subscription is billed bi-weekly. [min value: 1] 1854 1855 - C{name} Name describing subscription 1856 1857 - C{plan} Plan that should be used for the subscription. 1858 1859 - C{prorate} Whether to prorate existing subscription. [default: true] B{(required)} 1860 1861 - C{quantity} Quantity of the plan for the subscription. [min value: 1] 1862 1863 - C{renewalReminderLeadDays} If set, how many days before the next billing cycle that a renewal reminder is sent to the customer. If null or 0, no emails are sent. Minimum value is 7 if set. 1864 1865 @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. 1866 For backwards compatibility the public and private keys may be passed instead of an Authentication object. 1867 @return: a Subscription object. 1868 """ 1869 return PaymentsApi.update("subscription", auth_args, self.object_id, self.to_dict())
1870
1871 -class Tax(Domain):
1872 """ 1873 A Tax object. 1874 """ 1875 1876 1877 @staticmethod
1878 - def create(params, *auth_args):
1879 """ 1880 Creates an Tax object 1881 @param params: a dict of parameters; valid keys are: 1882 - C{label}: The label of the tax object. [max length: 255] B{required } 1883 - C{rate}: The tax rate. Decimal value up three decimal places. e.g 12.501. [max length: 6] B{required } 1884 @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. 1885 For backwards compatibility the public and private keys may be passed instead of an Authentication object. 1886 @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. 1887 @return: a Tax object 1888 """ 1889 return PaymentsApi.create("tax", auth_args, params)
1890
1891 - def delete(self, *auth_args):
1892 """ 1893 Delete this object 1894 @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. 1895 For backwards compatibility the public and private keys may be passed instead of an Authentication object. 1896 """ 1897 return PaymentsApi.delete("tax", auth_args, self.object_id)
1898 1899 @staticmethod
1900 - def list(criteria = None, *auth_args):
1901 """ 1902 Retrieve Tax objects. 1903 @param criteria: a dict of parameters; valid keys are: 1904 - C{filter} Filters to apply to the list. 1905 - C{max} Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20] 1906 - C{offset} Used in paging of the list. This is the start offset of the page. [min value: 0, default: 0] 1907 - 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}. 1908 @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. 1909 For backwards compatibility the public and private keys may be passed instead of an Authentication object. 1910 @return: an object which contains the list of Tax objects in the <code>list</code> property and the total number 1911 of objects available for the given criteria in the <code>total</code> property. 1912 """ 1913 return PaymentsApi.list("tax", auth_args, criteria)
1914 1915 @staticmethod
1916 - def find(object_id, *auth_args):
1917 """ 1918 Retrieve a Tax object from the API 1919 @param object_id: ID of object to retrieve 1920 @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. 1921 For backwards compatibility the public and private keys may be passed instead of an Authentication object. 1922 @return: a Tax object 1923 """ 1924 return PaymentsApi.find("tax", auth_args, object_id)
1925
1926 -class TransactionReview(Domain):
1927 """ 1928 A TransactionReview object. 1929 """ 1930 1931 1932 @staticmethod
1933 - def create(params, *auth_args):
1934 """ 1935 Creates an TransactionReview object 1936 @param params: a dict of parameters; valid keys are: 1937 @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. 1938 For backwards compatibility the public and private keys may be passed instead of an Authentication object. 1939 @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. 1940 @return: a TransactionReview object 1941 """ 1942 return PaymentsApi.create("transactionReview", auth_args, params)
1943
1944 - def delete(self, *auth_args):
1945 """ 1946 Delete this object 1947 @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. 1948 For backwards compatibility the public and private keys may be passed instead of an Authentication object. 1949 """ 1950 return PaymentsApi.delete("transactionReview", auth_args, self.object_id)
1951 1952 @staticmethod
1953 - def list(criteria = None, *auth_args):
1954 """ 1955 Retrieve TransactionReview objects. 1956 @param criteria: a dict of parameters; valid keys are: 1957 - C{filter} Allows for ascending or descending sorting of the list. 1958 - C{max} Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20] 1959 - C{offset} Filters to apply to the list. [min value: 0, default: 0] 1960 - C{sorting} Used in paging of the list. This is the start offset of the page. The value maps properties to the sort direction (either C{asc} for ascending or C{desc} for descending). Sortable properties are: C{dateCreated} C{status}. 1961 @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. 1962 For backwards compatibility the public and private keys may be passed instead of an Authentication object. 1963 @return: an object which contains the list of TransactionReview objects in the <code>list</code> property and the total number 1964 of objects available for the given criteria in the <code>total</code> property. 1965 """ 1966 return PaymentsApi.list("transactionReview", auth_args, criteria)
1967 1968 @staticmethod
1969 - def find(object_id, *auth_args):
1970 """ 1971 Retrieve a TransactionReview object from the API 1972 @param object_id: ID of object to retrieve 1973 @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. 1974 For backwards compatibility the public and private keys may be passed instead of an Authentication object. 1975 @return: a TransactionReview object 1976 """ 1977 return PaymentsApi.find("transactionReview", auth_args, object_id)
1978
1979 - def update(self, *auth_args):
1980 """ 1981 Updates this object 1982 1983 The properties that can be updated: 1984 - C{status} Status of the transaction review. 1985 1986 @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. 1987 For backwards compatibility the public and private keys may be passed instead of an Authentication object. 1988 @return: a TransactionReview object. 1989 """ 1990 return PaymentsApi.update("transactionReview", auth_args, self.object_id, self.to_dict())
1991
1992 -class Webhook(Domain):
1993 """ 1994 A Webhook object. 1995 """ 1996 1997 1998 @staticmethod
1999 - def create(params, *auth_args):
2000 """ 2001 Creates an Webhook object 2002 @param params: a dict of parameters; valid keys are: 2003 - C{url}: Endpoint URL B{required } 2004 @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. 2005 For backwards compatibility the public and private keys may be passed instead of an Authentication object. 2006 @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. 2007 @return: a Webhook object 2008 """ 2009 return PaymentsApi.create("webhook", auth_args, params)
2010
2011 - def delete(self, *auth_args):
2012 """ 2013 Delete this object 2014 @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. 2015 For backwards compatibility the public and private keys may be passed instead of an Authentication object. 2016 """ 2017 return PaymentsApi.delete("webhook", auth_args, self.object_id)
2018 2019 @staticmethod
2020 - def list(criteria = None, *auth_args):
2021 """ 2022 Retrieve Webhook objects. 2023 @param criteria: a dict of parameters; valid keys are: 2024 - C{filter} Filters to apply to the list. 2025 - C{max} Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20] 2026 - C{offset} Used in paging of the list. This is the start offset of the page. [min value: 0, default: 0] 2027 - 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}. 2028 @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. 2029 For backwards compatibility the public and private keys may be passed instead of an Authentication object. 2030 @return: an object which contains the list of Webhook objects in the <code>list</code> property and the total number 2031 of objects available for the given criteria in the <code>total</code> property. 2032 """ 2033 return PaymentsApi.list("webhook", auth_args, criteria)
2034 2035 @staticmethod
2036 - def find(object_id, *auth_args):
2037 """ 2038 Retrieve a Webhook object from the API 2039 @param object_id: ID of object to retrieve 2040 @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. 2041 For backwards compatibility the public and private keys may be passed instead of an Authentication object. 2042 @return: a Webhook object 2043 """ 2044 return PaymentsApi.find("webhook", auth_args, object_id)
2045
2046 - def update(self, *auth_args):
2047 """ 2048 Updates this object 2049 2050 The properties that can be updated: 2051 - C{url} Endpoint URL B{(required)} 2052 2053 @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. 2054 For backwards compatibility the public and private keys may be passed instead of an Authentication object. 2055 @return: a Webhook object. 2056 """ 2057 return PaymentsApi.update("webhook", auth_args, self.object_id, self.to_dict())
2058