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

Source Code for Package simplify

   1   
   2  # 
   3  # Copyright (c) 2013, 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  user_agent = None 
70 71 72 ################################################################################ 73 # Utilities 74 ################################################################################ 75 76 -def build_query_string(criteria):
77 78 if criteria == None: 79 return '' 80 81 query_string = [] 82 if 'max' in criteria: 83 query_string.append("max=" + str(criteria['max'])) 84 85 if 'offset' in criteria: 86 query_string.append("offset=" + str(criteria['offset'])) 87 88 if 'sorting' in criteria: 89 for key, value in criteria['sorting'].iteritems(): 90 query_string.append("sorting[" + key + "]=" + quote(str(value))) 91 92 if 'filter' in criteria: 93 for key, value in criteria['filter'].iteritems(): 94 query_string.append("filter[" + key + "]=" + quote(str(value))) 95 96 return '&'.join(query_string)
97
98 -def handle_http_error(response_body, response_code):
99 100 if response_code == HTTP_REDIRECTED: # this shouldn't happen - if it does it's our problem 101 raise BadRequestError("Unexpected response code returned from the API, have you got the correct URL?", response_code, response_body) 102 elif response_code == HTTP_BAD_REQUEST: 103 raise BadRequestError("Bad request", response_code, response_body) 104 105 elif response_code == HTTP_UNAUTHORIZED: 106 raise AuthenticationError("You are not authorized to make this request. Are you using the correct API keys?", response_code, response_body) 107 108 elif response_code == HTTP_NOT_FOUND: 109 raise ObjectNotFoundError("Object not found", response_code, response_body) 110 111 elif response_code == HTTP_NOT_ALLOWED: 112 raise NotAllowedError("Operation not allowed", response_code, response_body) 113 114 elif response_code < 500: 115 raise BadRequestError("Bad request", response_code, response_body) 116 117 else: 118 raise SysError("An unexpected error has been raised. Looks like there's something wrong at our end." , response_code, response_body)
119
120 121 ################################################################################ 122 # Exceptions 123 ################################################################################ 124 125 126 -class ApiError(Exception):
127 """ 128 Base class for all API errors. 129 130 @ivar status: HTTP status code (or None if there is no status). 131 @ivar reference: reference for the error (or None if there is no reference). 132 @ivar error_code: string code for the error (or None if there is no error code). 133 @ivar message: string description of the error (or None if there is no message). 134 @ivar error_data: dictionary containing all the error data (or None if there is no data) 135 """ 136
137 - def __init__(self, message=None, status=500, error_data=None):
138 self.status = status 139 140 self.error_data = json.loads(error_data) if error_data else {} 141 err = self.error_data['error'] if 'error' in self.error_data else {} 142 143 self.reference = self.error_data['reference'] if 'reference' in self.error_data else None 144 self.error_code = err['code'] if 'code' in err else None 145 self.message = err['message'] if 'code' in err else message 146 super(ApiError, self).__init__(self.message)
147 148
149 - def describe(self):
150 """ 151 Returns a string describing the error. 152 @return: a string describing the error. 153 """ 154 return "{0}: \"{1}\" (status: {2}, error code: {3}, reference: {4})".format(self.__class__.__name__, self.message, self.status, self.error_code, self.reference)
155
156 157 -class IllegalArgumentError(ValueError):
158 """ 159 Error raised when passing illegal arguments. 160 """ 161 pass
162
163 -class ApiConnectionError(ApiError):
164 """ 165 Error raised when there are communication errors contacting the API. 166 """ 167 pass
168
169 -class AuthenticationError(ApiError):
170 """ 171 Error raised where there are problems authentication a request. 172 """ 173 pass
174
175 -class BadRequestError(ApiError):
176 177 """ 178 Error raised when the request contains errors. 179 180 @ivar has_field_errors: boolean indicating whether there are field errors. 181 @ivar field_errors: a list containing all field errors. 182 """ 183
184 - class FieldError:
185 """ 186 Represents a single error in a field of data sent in a request to the API. 187 188 @ivar field_name: the name of the field with the error. 189 @ivar error_code: a string code for the error. 190 @ivar message: a string description of the error. 191 """
192 - def __init__(self, error_data):
193 self.field_name = error_data['field'] 194 self.error_code = error_data['code'] 195 self.message = error_data['message']
196
197 - def __str__(self):
198 return "Field error: {0} \"{1}\" ({2})".format(self.field_name, self.message, self.error_code)
199 200
201 - def __init__(self, message, status = 400, error_data = None):
202 super(BadRequestError, self).__init__(message, status, error_data) 203 204 self.field_errors = [] 205 err = self.error_data['error'] if 'error' in self.error_data else {} 206 field_errors = err['fieldErrors'] if 'fieldErrors' in err else [] 207 for field_error in field_errors: 208 self.field_errors.append(BadRequestError.FieldError(field_error)) 209 self.has_field_errors = len(self.field_errors) > 0
210
211 - def describe(self):
212 """ 213 Returns a string describing the error. 214 @return: a string describing the error. 215 """ 216 txt = ApiError.describe(self) 217 for field_error in self.field_errors: 218 txt = txt + "\n" + str(field_error) 219 return txt + "\n"
220
221 -class ObjectNotFoundError(ApiError):
222 """ 223 Error raised when a requested object cannot be found. 224 """ 225 pass
226
227 -class NotAllowedError(ApiError):
228 """ 229 Error raised when a request was not allowed. 230 """ 231 pass
232
233 -class SysError(ApiError):
234 """ 235 Error raised when there was a system error processing a request. 236 """ 237 pass
238
239 240 ################################################################################ 241 # Http - handles the HTTP requests 242 ################################################################################ 243 244 -class Http:
245 - def __init__(self):
246 pass
247
248 - def request(self, public_api_key, private_api_key, url, method, params = None):
249 250 if params is None: 251 params = {} 252 253 jws_signature = Jws.encode(url, public_api_key, private_api_key, params, method == HTTP_METHOD_POST or method == HTTP_METHOD_PUT) 254 255 if method == HTTP_METHOD_POST: 256 request = Request(url, jws_signature) 257 request.add_header("Content-Type", "application/json") 258 259 elif method == HTTP_METHOD_PUT: 260 request = Request(url, jws_signature) 261 request.add_header("Content-Type", "application/json") 262 263 elif method == HTTP_METHOD_DELETE: 264 request = Request(url) 265 request.add_header("Authorization", "JWS " + jws_signature) 266 request.get_method = lambda: HTTP_METHOD_DELETE 267 268 elif method == HTTP_METHOD_GET: 269 request = Request(url) 270 request.add_header("Authorization", "JWS " + jws_signature) 271 272 else: 273 raise ApiConnectionError("HTTP Method {0} not recognised".format(method)) 274 275 request.add_header("Accept", "application/json") 276 global user_agent 277 278 user_agent_hdr = "Python-SDK/" + Constants.version 279 if user_agent != None: 280 user_agent_hdr = user_agent_hdr + " " + user_agent 281 request.add_header("User-Agent", user_agent_hdr) 282 283 try: 284 response = urlopen(request) 285 response_body = response.read() 286 response_code = response.code 287 except HTTPError as err: 288 response_body = err.read() 289 response_code = err.code 290 except URLError as err: 291 msg = "Looks like there's a problem connecting to the API endpoint: {0}\nError: {1}".format(url, str(err)) 292 raise ApiConnectionError(msg) 293 294 return response_body, response_code
295
296 ################################################################################ 297 # JWS WebHook Utils 298 ################################################################################ 299 300 -class Jws:
301 302 NUM_HEADERS = 7 303 ALGORITHM = 'HS256' 304 TYPE = 'JWS' 305 HDR_URI = 'api.simplifycommerce.com/uri' 306 HDR_TIMESTAMP = 'api.simplifycommerce.com/timestamp' 307 HDR_NONCE = 'api.simplifycommerce.com/nonce' 308 HDR_UNAME = 'uname' 309 HDR_ALGORITHM = 'alg' 310 HDR_TYPE = 'typ' 311 HDR_KEY_ID = 'kid' 312 TIMESTAMP_MAX_DIFF = 1000 * 60 * 5 # 5 minutes 313
314 - def __init__(self):
315 pass
316 317 @staticmethod
318 - def encode(url, public_api_key, private_api_key, params, has_payload):
319 320 jws_hdr = {'typ': Jws.TYPE, 321 'alg': Jws.ALGORITHM, 322 'kid': public_api_key, 323 Jws.HDR_URI: url, 324 Jws.HDR_TIMESTAMP: int(round(time.time() * 1000)), 325 Jws.HDR_NONCE: str(random.randint(1, 10*1000))} 326 327 header = base64.urlsafe_b64encode(Jws().encode_json(jws_hdr)).replace('=', '') 328 payload = '' 329 if has_payload: 330 payload = Jws().encode_json(params) 331 payload = base64.urlsafe_b64encode(payload).replace('=', '') 332 333 msg = header + "." + payload 334 signature = Jws().sign(private_api_key, msg) 335 return msg + "." + signature
336 337 @staticmethod
338 - def decode(params, public_api_key, private_api_key):
339 340 if not public_api_key: 341 raise IllegalArgumentError("Must have a valid Public Key to connect to the API") 342 343 if not private_api_key: 344 raise IllegalArgumentError("Must have a valid Private Key to connect to the API") 345 346 if not 'payload' in params: 347 raise IllegalArgumentError("Event data is missing payload") 348 349 payload = params['payload'].strip() 350 data = payload.split('.') 351 if len(data) != 3: 352 raise IllegalArgumentError("Incorrectly formatted JWS message") 353 354 msg = "{0}.{1}".format(data[0], data[1]) 355 header = Jws().safe_base64_decode(data[0]) 356 payload = Jws().safe_base64_decode(data[1]) 357 signature = data[2] 358 359 url = None 360 if 'url' in params: 361 url = params['url'] 362 Jws().verify(header, url, public_api_key) 363 364 if signature != Jws().sign(private_api_key, msg): 365 raise AuthenticationError("JWS signature does not match") 366 367 return json.loads(payload)
368
369 - def sign(self, private_api_key, msg):
370 decoded_private_api_key = Jws().safe_base64_decode(private_api_key) 371 signature = hmac.new(decoded_private_api_key, msg, hashlib.sha256).digest() 372 return base64.urlsafe_b64encode(signature).replace('=', '')
373
374 - def verify(self, header, url, public_api_key):
375 376 hdr = json.loads(header) 377 378 if len(hdr) != Jws.NUM_HEADERS: 379 raise AuthenticationError("Incorrect number of JWS header parameters - found {0} but expected {1}".format(len(hdr), Jws.NUM_HEADERS)) 380 381 if not Jws.HDR_ALGORITHM in hdr: 382 raise AuthenticationError("Missing algorithm header") 383 384 if hdr[Jws.HDR_ALGORITHM] != Jws.ALGORITHM: 385 raise AuthenticationError("Incorrect algorithm - found {0} but required {1}".format(hdr[Jws.HDR_ALGORITHM], Jws.ALGORITHM)) 386 387 if not Jws.HDR_TYPE in hdr: 388 raise AuthenticationError("Missing type header") 389 390 if hdr[Jws.HDR_TYPE] != Jws.TYPE: 391 raise AuthenticationError("Incorrect type - found {0} but required {JWS_TYPE}".format(hdr[Jws.HDR_TYPE], Jws.TYPE)) 392 393 if not Jws.HDR_KEY_ID in hdr: 394 raise AuthenticationError("Missing Key ID") 395 396 # keys don't match and it is a live key 397 if hdr[Jws.HDR_KEY_ID] != public_api_key and public_api_key.startswith("lvpb"): 398 raise AuthenticationError("Invalid Key ID") 399 400 if not Jws.HDR_NONCE in hdr: 401 raise AuthenticationError("Missing nonce") 402 403 if not Jws.HDR_URI in hdr: 404 raise AuthenticationError("Missing URI") 405 406 if url != None and hdr[Jws.HDR_URI] != url: 407 raise AuthenticationError("Incorrect URL - found {0} but required {1}".format(hdr[Jws.HDR_URI], url)) 408 409 if not Jws.HDR_TIMESTAMP in hdr: 410 raise AuthenticationError("Missing timestamp") 411 412 if not Jws.HDR_UNAME in hdr: 413 raise AuthenticationError("Missing username") 414 415 # calculate time difference between when the request was created and now 416 time_now = int(round(time.time() * 1000)) 417 timestamp = int(hdr[Jws.HDR_TIMESTAMP]) 418 diff = time_now - timestamp 419 420 if diff > Jws.TIMESTAMP_MAX_DIFF: 421 raise AuthenticationError("Invalid timestamp, the event has expired")
422
423 - def safe_base64_decode(self, url):
424 425 length = len(url) % 4 426 if length == 2: 427 return base64.urlsafe_b64decode(url + "==") 428 if length == 3: 429 return base64.urlsafe_b64decode(url + "=") 430 431 return base64.urlsafe_b64decode(url)
432
433 - def encode_json(self, json_str):
434 435 try: 436 return json.dumps(json_str).encode('utf-8') 437 except Exception: 438 raise ApiError("Invalid format for JSON request")
439
440 441 ################################################################################ 442 # PaymentsApi 443 ################################################################################ 444 445 -class PaymentsApi:
446 447
448 - def __init__(self):
449 pass
450 451 @staticmethod
452 - def create(object_type, public_api_key, private_api_key, params):
453 454 url = PaymentsApi.buiild_request_url(object_type) 455 response = PaymentsApi().execute(object_type, public_api_key, private_api_key, url, HTTP_METHOD_POST, params) 456 457 return response
458 459 @staticmethod
460 - def list(object_type, public_api_key, private_api_key, criteria):
461 462 url = PaymentsApi.buiild_request_url(object_type) 463 query_string = build_query_string(criteria) 464 if len(query_string) > 0: 465 url = url + '?' + query_string 466 response = PaymentsApi().execute(object_type, public_api_key, private_api_key, url, HTTP_METHOD_GET) 467 468 return response
469 470 @staticmethod
471 - def find(object_type, public_api_key, private_api_key, object_id):
472 473 if not object_id: 474 raise IllegalArgumentError("object_object_id is a required field") 475 476 url = PaymentsApi.buiild_request_url(object_type, object_id) 477 response = PaymentsApi().execute(object_type, public_api_key, private_api_key, url, HTTP_METHOD_GET) 478 479 return response
480 481 @staticmethod
482 - def update(object_type, public_api_key, private_api_key, object_id, params):
483 if not object_id: 484 raise IllegalArgumentError("object_id is a required field") 485 486 url = PaymentsApi.buiild_request_url(object_type, object_id) 487 response = PaymentsApi().execute(object_type, public_api_key, private_api_key, url, HTTP_METHOD_PUT, params) 488 489 return response
490 491 @staticmethod
492 - def delete(object_type, public_api_key, private_api_key, object_id):
493 if not object_id: 494 raise IllegalArgumentError("object_id is a required field") 495 496 url = PaymentsApi.buiild_request_url(object_type, object_id) 497 response = PaymentsApi().execute(object_type, public_api_key, private_api_key, url, HTTP_METHOD_DELETE) 498 499 return response
500
501 - def execute(self, object_type, public_api_key, private_api_key, url_suffix, method, params = None):
502 503 if params is None: 504 params = {} 505 506 http = Http() 507 508 global public_key 509 public_api_key = public_api_key if public_api_key else public_key 510 511 if not public_api_key: 512 raise IllegalArgumentError("Must have a valid public key to connect to the API") 513 514 global private_key 515 private_api_key = private_api_key if private_api_key else private_key 516 517 if not private_api_key: 518 raise IllegalArgumentError("Must have a valid private key to connect to the API") 519 520 global api_base_sandbox_url 521 global api_base_live_url 522 523 base_url = api_base_sandbox_url 524 if public_api_key.startswith('lvpb'): 525 base_url = api_base_live_url 526 url = base_url + "/" + url_suffix 527 528 response_body, response_code = http.request(public_api_key, private_api_key, url, method, params) 529 530 if not response_code == HTTP_SUCCESS: 531 handle_http_error(response_body, response_code) 532 533 try: 534 response = json.loads(response_body) 535 except Exception: 536 raise SysError("Invalid response format returned. Have you got the correct URL {0} \n HTTP Status: {1}".format(url, response_code)) 537 538 if "list" in response: 539 obj = DomainFactory.factory("domain") 540 obj.list = [DomainFactory.factory(object_type, values) for values in response["list"]] 541 obj.total = response["total"] 542 return obj 543 else: 544 return DomainFactory.factory(object_type, response)
545 546 @classmethod
547 - def buiild_request_url(cls, object_type, object_id = ''):
548 549 url = object_type 550 if object_id: 551 url = "{0}/{1}".format(url, object_id) 552 553 return url
554
555 556 557 ################################################################################ 558 # Domain classes 559 ################################################################################ 560 561 562 -class Event(Domain):
563 564 """ 565 A Event object. 566 """ 567 568 @staticmethod
569 - def create(params, public_api_key = None, private_api_key = None):
570 571 """ 572 Create an Event object. 573 @param params: a dict of parameters; valid keys are: 574 - C{payload}: The raw JWS message payload. B{required} 575 - C{url}: The URL for the webhook. If present it must match the URL registered for the webhook. 576 @param public_api_key: Public key to use for the API call. If C{None}, the value of C{simplify.public_key} will be used. 577 @param private_api_key: API key to use for the API call. If C{None}, the value of C{simplify.private_key} will be used. 578 @return: an Event object 579 """ 580 581 global public_key 582 public_api_key = public_api_key if public_api_key else public_key 583 584 global private_key 585 private_api_key = private_api_key if private_api_key else private_key 586 587 obj = Jws.decode(params, public_api_key, private_api_key) 588 589 if not 'event' in obj: 590 raise ApiError("Incorrect data in webhook event") 591 592 return DomainFactory.factory('event', obj['event'])
593
594 -class CardToken(Domain):
595 """ 596 A CardToken object. 597 """ 598 599 600 @staticmethod
601 - def create(params, public_api_key = None, private_api_key = None):
602 """ 603 Creates an CardToken object 604 @param params: a dict of parameters; valid keys are: 605 - C{callback}: The URL callback for the cardtoken 606 - C{card => addressCity}: City of the cardholder. 607 - C{card => addressCountry}: Country code (ISO-3166-1-alpha-2 code) of residence of the cardholder. 608 - C{card => addressLine1}: Address of the cardholder. 609 - C{card => addressLine2}: Address of the cardholder if needed. 610 - C{card => addressState}: State code (USPS code) of residence of the cardholder. 611 - C{card => addressZip}: Postal code of the cardholder. 612 - C{card => cvc}: CVC security code of the card. This is the code on the back of the card. Example: 123 613 - C{card => expMonth}: Expiration month of the card. Format is MM. Example: January = 01 B{required } 614 - C{card => expYear}: Expiration year of the card. Format is YY. Example: 2013 = 13 B{required } 615 - C{card => name}: Name as appears on the card. 616 - C{card => number}: Card number as it appears on the card. B{required } 617 - C{key}: Key used to create the card token. 618 @param public_api_key: Public key to use for the API call. If C{None}, the value of C{simplify.public_key} will be used. 619 @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. 620 @return: a CardToken object 621 """ 622 return PaymentsApi.create("cardToken", public_api_key, private_api_key, params)
623 624 @staticmethod
625 - def find(object_id, public_api_key = None, private_api_key = None):
626 """ 627 Retrieve a CardToken object from the API 628 @param object_id: ID of object to retrieve 629 @param public_api_key: Public key to use for the API call. If C{None}, the value of C{simplify.public_key} will be used. 630 @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. 631 @return: a CardToken object 632 """ 633 return PaymentsApi.find("cardToken", public_api_key, private_api_key, object_id)
634
635 -class Chargeback(Domain):
636 """ 637 A Chargeback object. 638 """ 639 640 641 @staticmethod
642 - def list(criteria = None, public_api_key = None, private_api_key = None):
643 """ 644 Retrieve Chargeback objects. 645 @param criteria: a dict of parameters; valid keys are: 646 - C{filter} Filters to apply to the list. 647 - C{max} Allows up to a max of 50 list items to return. B{default:20} 648 - C{offset} Used in paging of the list. This is the start offset of the page. B{default:0} 649 - 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}. 650 @param public_api_key: Public key to use for the API call. If C{None}, the value of C{simplify.public_key} will be used. 651 @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. 652 @return: an object which contains the list of Chargeback objects in the <code>list</code> property and the total number 653 of objects available for the given criteria in the <code>total</code> property. 654 """ 655 return PaymentsApi.list("chargeback", public_api_key, private_api_key, criteria)
656 657 @staticmethod
658 - def find(object_id, public_api_key = None, private_api_key = None):
659 """ 660 Retrieve a Chargeback object from the API 661 @param object_id: ID of object to retrieve 662 @param public_api_key: Public key to use for the API call. If C{None}, the value of C{simplify.public_key} will be used. 663 @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. 664 @return: a Chargeback object 665 """ 666 return PaymentsApi.find("chargeback", public_api_key, private_api_key, object_id)
667
668 -class Coupon(Domain):
669 """ 670 A Coupon object. 671 """ 672 673 674 @staticmethod
675 - def create(params, public_api_key = None, private_api_key = None):
676 """ 677 Creates an Coupon object 678 @param params: a dict of parameters; valid keys are: 679 - C{amountOff}: Amount off of the price of the product in minor units in the currency of the merchant. While this field is optional, you must provide either amountOff or percentOff for a coupon. Example: 1000 = 10.00 680 - C{couponCode}: Code that identifies the coupon to be used. B{required } 681 - C{description}: A brief section that describes the coupon. 682 - C{durationInMonths}: Duration in months that the coupon will be applied after it has first been selected. 683 - 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. 684 - 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. 685 - 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. 686 - 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 } 687 @param public_api_key: Public key to use for the API call. If C{None}, the value of C{simplify.public_key} will be used. 688 @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. 689 @return: a Coupon object 690 """ 691 return PaymentsApi.create("coupon", public_api_key, private_api_key, params)
692
693 - def delete(self, public_api_key = None, private_api_key = None):
694 """ 695 Delete this object 696 @param public_api_key: Public key to use for the API call. If C{None}, the value of C{simplify.public_key} will be used. 697 @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. 698 """ 699 return PaymentsApi.delete("coupon", public_api_key, private_api_key, self.object_id)
700 701 @staticmethod
702 - def list(criteria = None, public_api_key = None, private_api_key = None):
703 """ 704 Retrieve Coupon objects. 705 @param criteria: a dict of parameters; valid keys are: 706 - C{filter} Filters to apply to the list. 707 - C{max} Allows up to a max of 50 list items to return. B{default:20} 708 - C{offset} Used in paging of the list. This is the start offset of the page. B{default:0} 709 - C{sorting} Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either C{asc} for ascending or C{desc} for descending). Sortable properties are: C{dateCreated} C{maxRedemptions} C{timesRedeemed} C{id} C{startDate} C{endDate} C{percentOff} C{couponCode} C{durationInMonths} C{amountOff}. 710 @param public_api_key: Public key to use for the API call. If C{None}, the value of C{simplify.public_key} will be used. 711 @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. 712 @return: an object which contains the list of Coupon objects in the <code>list</code> property and the total number 713 of objects available for the given criteria in the <code>total</code> property. 714 """ 715 return PaymentsApi.list("coupon", public_api_key, private_api_key, criteria)
716 717 @staticmethod
718 - def find(object_id, public_api_key = None, private_api_key = None):
719 """ 720 Retrieve a Coupon object from the API 721 @param object_id: ID of object to retrieve 722 @param public_api_key: Public key to use for the API call. If C{None}, the value of C{simplify.public_key} will be used. 723 @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. 724 @return: a Coupon object 725 """ 726 return PaymentsApi.find("coupon", public_api_key, private_api_key, object_id)
727
728 - def update(self, public_api_key = None, private_api_key = None):
729 """ 730 Updates this object 731 732 The properties that can be updated: 733 - C{endDate} The ending date in UTC millis for the coupon. This must be after the starting date of the coupon. 734 735 - 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. 736 737 @param public_api_key: Public key to use for the API call. If C{None}, the value of C{simplify.public_key} will be used. 738 @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. 739 @return: a Coupon object. 740 """ 741 return PaymentsApi.update("coupon", public_api_key, private_api_key, self.object_id, self.to_dict())
742
743 -class Customer(Domain):
744 """ 745 A Customer object. 746 """ 747 748 749 @staticmethod
750 - def create(params, public_api_key = None, private_api_key = None):
751 """ 752 Creates an Customer object 753 @param params: a dict of parameters; valid keys are: 754 - C{card => addressCity}: City of the cardholder. 755 - C{card => addressCountry}: Country code (ISO-3166-1-alpha-2 code) of residence of the cardholder. 756 - C{card => addressLine1}: Address of the cardholder 757 - C{card => addressLine2}: Address of the cardholder if needed. 758 - C{card => addressState}: State code (USPS code) of residence of the cardholder. 759 - C{card => addressZip}: Postal code of the cardholder. 760 - C{card => cvc}: CVC security code of the card. This is the code on the back of the card. Example: 123 761 - C{card => expMonth}: Expiration month of the card. Format is MM. Example: January = 01 B{required } 762 - C{card => expYear}: Expiration year of the card. Format is YY. Example: 2013 = 13 B{required } 763 - C{card => name}: Name as appears on the card. 764 - C{card => number}: Card number as it appears on the card. B{required } 765 - C{email}: Email address of the customer B{required } 766 - C{name}: Customer name B{required } 767 - C{reference}: Reference field for external applications use. 768 - C{subscriptions => amount}: Amount of payment in minor units. Example: 1000 = 10.00 769 - C{subscriptions => coupon}: Coupon associated with the subscription for the customer. 770 - C{subscriptions => currency}: Currency code (ISO-4217). Must match the currency associated with your account. B{default:USD} 771 - C{subscriptions => customer}: The customer ID to create the subscription for. Do not supply this when creating a customer. 772 - C{subscriptions => frequency}: Frequency of payment for the plan. Example: Monthly 773 - C{subscriptions => name}: Name describing subscription 774 - C{subscriptions => plan}: The plan ID that the subscription should be created from. 775 - C{subscriptions => quantity}: Quantity of the plan for the subscription. 776 @param public_api_key: Public key to use for the API call. If C{None}, the value of C{simplify.public_key} will be used. 777 @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. 778 @return: a Customer object 779 """ 780 return PaymentsApi.create("customer", public_api_key, private_api_key, params)
781
782 - def delete(self, public_api_key = None, private_api_key = None):
783 """ 784 Delete this object 785 @param public_api_key: Public key to use for the API call. If C{None}, the value of C{simplify.public_key} will be used. 786 @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. 787 """ 788 return PaymentsApi.delete("customer", public_api_key, private_api_key, self.object_id)
789 790 @staticmethod
791 - def list(criteria = None, public_api_key = None, private_api_key = None):
792 """ 793 Retrieve Customer objects. 794 @param criteria: a dict of parameters; valid keys are: 795 - C{filter} Filters to apply to the list. 796 - C{max} Allows up to a max of 50 list items to return. B{default:20} 797 - C{offset} Used in paging of the list. This is the start offset of the page. B{default:0} 798 - 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}. 799 @param public_api_key: Public key to use for the API call. If C{None}, the value of C{simplify.public_key} will be used. 800 @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. 801 @return: an object which contains the list of Customer objects in the <code>list</code> property and the total number 802 of objects available for the given criteria in the <code>total</code> property. 803 """ 804 return PaymentsApi.list("customer", public_api_key, private_api_key, criteria)
805 806 @staticmethod
807 - def find(object_id, public_api_key = None, private_api_key = None):
808 """ 809 Retrieve a Customer object from the API 810 @param object_id: ID of object to retrieve 811 @param public_api_key: Public key to use for the API call. If C{None}, the value of C{simplify.public_key} will be used. 812 @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. 813 @return: a Customer object 814 """ 815 return PaymentsApi.find("customer", public_api_key, private_api_key, object_id)
816
817 - def update(self, public_api_key = None, private_api_key = None):
818 """ 819 Updates this object 820 821 The properties that can be updated: 822 - C{card => addressCity} City of the cardholder. 823 824 - C{card => addressCountry} Country code (ISO-3166-1-alpha-2 code) of residence of the cardholder. 825 826 - C{card => addressLine1} Address of the cardholder. 827 828 - C{card => addressLine2} Address of the cardholder if needed. 829 830 - C{card => addressState} State code (USPS code) of residence of the cardholder. 831 832 - C{card => addressZip} Postal code of the cardholder. 833 834 - C{card => cvc} CVC security code of the card. This is the code on the back of the card. Example: 123 835 836 - C{card => expMonth} Expiration month of the card. Format is MM. Example: January = 01 B{(required)} 837 838 - C{card => expYear} Expiration year of the card. Format is YY. Example: 2013 = 13 B{(required)} 839 840 - C{card => name} Name as appears on the card. 841 842 - C{card => number} Card number as it appears on the card. B{(required)} 843 844 - C{email} Email address of the customer B{(required)} 845 846 - C{name} Customer name B{(required)} 847 848 - C{reference} Reference field for external applications use. 849 850 @param public_api_key: Public key to use for the API call. If C{None}, the value of C{simplify.public_key} will be used. 851 @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. 852 @return: a Customer object. 853 """ 854 return PaymentsApi.update("customer", public_api_key, private_api_key, self.object_id, self.to_dict())
855
856 -class Deposit(Domain):
857 """ 858 A Deposit object. 859 """ 860 861 862 @staticmethod
863 - def list(criteria = None, public_api_key = None, private_api_key = None):
864 """ 865 Retrieve Deposit objects. 866 @param criteria: a dict of parameters; valid keys are: 867 - C{filter} Filters to apply to the list. 868 - C{max} Allows up to a max of 50 list items to return. B{default:20} 869 - C{offset} Used in paging of the list. This is the start offset of the page. B{default:0} 870 - 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}. 871 @param public_api_key: Public key to use for the API call. If C{None}, the value of C{simplify.public_key} will be used. 872 @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. 873 @return: an object which contains the list of Deposit objects in the <code>list</code> property and the total number 874 of objects available for the given criteria in the <code>total</code> property. 875 """ 876 return PaymentsApi.list("deposit", public_api_key, private_api_key, criteria)
877 878 @staticmethod
879 - def find(object_id, public_api_key = None, private_api_key = None):
880 """ 881 Retrieve a Deposit object from the API 882 @param object_id: ID of object to retrieve 883 @param public_api_key: Public key to use for the API call. If C{None}, the value of C{simplify.public_key} will be used. 884 @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. 885 @return: a Deposit object 886 """ 887 return PaymentsApi.find("deposit", public_api_key, private_api_key, object_id)
888
889 -class Invoice(Domain):
890 """ 891 A Invoice object. 892 """ 893 894 895 @staticmethod
896 - def list(criteria = None, public_api_key = None, private_api_key = None):
897 """ 898 Retrieve Invoice objects. 899 @param criteria: a dict of parameters; valid keys are: 900 - C{filter} Filters to apply to the list. 901 - C{max} Allows up to a max of 50 list items to return. B{default:20} 902 - C{offset} Used in paging of the list. This is the start offset of the page. B{default:0} 903 - 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{customer} C{amount} C{processedDate}. 904 @param public_api_key: Public key to use for the API call. If C{None}, the value of C{simplify.public_key} will be used. 905 @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. 906 @return: an object which contains the list of Invoice objects in the <code>list</code> property and the total number 907 of objects available for the given criteria in the <code>total</code> property. 908 """ 909 return PaymentsApi.list("invoice", public_api_key, private_api_key, criteria)
910 911 @staticmethod
912 - def find(object_id, public_api_key = None, private_api_key = None):
913 """ 914 Retrieve a Invoice object from the API 915 @param object_id: ID of object to retrieve 916 @param public_api_key: Public key to use for the API call. If C{None}, the value of C{simplify.public_key} will be used. 917 @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. 918 @return: a Invoice object 919 """ 920 return PaymentsApi.find("invoice", public_api_key, private_api_key, object_id)
921
922 - def update(self, public_api_key = None, private_api_key = None):
923 """ 924 Updates this object 925 926 The properties that can be updated: 927 - C{status} Status of the invoice. Examples: OPEN = Invoice has not been processed and can have invoice items added to it. PAID = Invoice has been paid. UNPAID = Invoice was not paid when the card was processed. System will try up to 5 times to process the card. B{(required)} 928 929 @param public_api_key: Public key to use for the API call. If C{None}, the value of C{simplify.public_key} will be used. 930 @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. 931 @return: a Invoice object. 932 """ 933 return PaymentsApi.update("invoice", public_api_key, private_api_key, self.object_id, self.to_dict())
934
935 -class InvoiceItem(Domain):
936 """ 937 A InvoiceItem object. 938 """ 939 940 941 @staticmethod
942 - def create(params, public_api_key = None, private_api_key = None):
943 """ 944 Creates an InvoiceItem object 945 @param params: a dict of parameters; valid keys are: 946 - C{amount}: Amount of the invoice item (minor units). Example: 1000 = 10.00 B{required } 947 - C{currency}: Currency code (ISO-4217) for the invoice item. Must match the currency associated with your account. B{required }B{default:USD} 948 - C{description}: Individual items of an invoice 949 - C{invoice}: Description of the invoice item B{required } 950 @param public_api_key: Public key to use for the API call. If C{None}, the value of C{simplify.public_key} will be used. 951 @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. 952 @return: a InvoiceItem object 953 """ 954 return PaymentsApi.create("invoiceItem", public_api_key, private_api_key, params)
955
956 - def delete(self, public_api_key = None, private_api_key = None):
957 """ 958 Delete this object 959 @param public_api_key: Public key to use for the API call. If C{None}, the value of C{simplify.public_key} will be used. 960 @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. 961 """ 962 return PaymentsApi.delete("invoiceItem", public_api_key, private_api_key, self.object_id)
963 964 @staticmethod
965 - def list(criteria = None, public_api_key = None, private_api_key = None):
966 """ 967 Retrieve InvoiceItem objects. 968 @param criteria: a dict of parameters; valid keys are: 969 - C{filter} Filters to apply to the list. 970 - C{max} Allows up to a max of 50 list items to return. B{default:20} 971 - C{offset} Used in paging of the list. This is the start offset of the page. B{default:0} 972 - 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{invoice}. 973 @param public_api_key: Public key to use for the API call. If C{None}, the value of C{simplify.public_key} will be used. 974 @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. 975 @return: an object which contains the list of InvoiceItem objects in the <code>list</code> property and the total number 976 of objects available for the given criteria in the <code>total</code> property. 977 """ 978 return PaymentsApi.list("invoiceItem", public_api_key, private_api_key, criteria)
979 980 @staticmethod
981 - def find(object_id, public_api_key = None, private_api_key = None):
982 """ 983 Retrieve a InvoiceItem object from the API 984 @param object_id: ID of object to retrieve 985 @param public_api_key: Public key to use for the API call. If C{None}, the value of C{simplify.public_key} will be used. 986 @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. 987 @return: a InvoiceItem object 988 """ 989 return PaymentsApi.find("invoiceItem", public_api_key, private_api_key, object_id)
990
991 - def update(self, public_api_key = None, private_api_key = None):
992 """ 993 Updates this object 994 995 The properties that can be updated: 996 - C{amount} Amount of the invoice item (minor units). Example: 1000 = 10.00 997 998 - C{currency} Currency code (ISO-4217) for the invoice item. Must match the currency associated with your account. 999 1000 - C{description} Individual items of an invoice 1001 1002 @param public_api_key: Public key to use for the API call. If C{None}, the value of C{simplify.public_key} will be used. 1003 @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. 1004 @return: a InvoiceItem object. 1005 """ 1006 return PaymentsApi.update("invoiceItem", public_api_key, private_api_key, self.object_id, self.to_dict())
1007
1008 -class Payment(Domain):
1009 """ 1010 A Payment object. 1011 """ 1012 1013 1014 @staticmethod
1015 - def create(params, public_api_key = None, private_api_key = None):
1016 """ 1017 Creates an Payment object 1018 @param params: a dict of parameters; valid keys are: 1019 - C{amount}: Amount of the payment (minor units). Example: 1000 = 10.00 B{required } 1020 - C{card => addressCity}: City of the cardholder. 1021 - C{card => addressCountry}: Country code (ISO-3166-1-alpha-2 code) of residence of the cardholder. 1022 - C{card => addressLine1}: Address of the cardholder. 1023 - C{card => addressLine2}: Address of the cardholder if needed. 1024 - C{card => addressState}: State code (USPS code) of residence of the cardholder. 1025 - C{card => addressZip}: Postal code of the cardholder. 1026 - C{card => cvc}: CVC security code of the card. This is the code on the back of the card. Example: 123 1027 - C{card => expMonth}: Expiration month of the card. Format is MM. Example: January = 01 B{required } 1028 - C{card => expYear}: Expiration year of the card. Format is YY. Example: 2013 = 13 B{required } 1029 - C{card => name}: Name as it appears on the card. 1030 - C{card => number}: Card number as it appears on the card. B{required } 1031 - C{currency}: Currency code (ISO-4217) for the transaction. Must match the currency associated with your account. B{required }B{default:USD} 1032 - C{customer}: ID of customer. If specified, card on file of customer will be used. 1033 - C{description}: Custom naming of payment for external systems to use. 1034 - C{token}: If specified, card associated with card token will be used. 1035 @param public_api_key: Public key to use for the API call. If C{None}, the value of C{simplify.public_key} will be used. 1036 @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. 1037 @return: a Payment object 1038 """ 1039 return PaymentsApi.create("payment", public_api_key, private_api_key, params)
1040 1041 @staticmethod
1042 - def list(criteria = None, public_api_key = None, private_api_key = None):
1043 """ 1044 Retrieve Payment objects. 1045 @param criteria: a dict of parameters; valid keys are: 1046 - C{filter} Filters to apply to the list. 1047 - C{max} Allows up to a max of 50 list items to return. B{default:20} 1048 - C{offset} Used in paging of the list. This is the start offset of the page. B{default:0} 1049 - 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}. 1050 @param public_api_key: Public key to use for the API call. If C{None}, the value of C{simplify.public_key} will be used. 1051 @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. 1052 @return: an object which contains the list of Payment objects in the <code>list</code> property and the total number 1053 of objects available for the given criteria in the <code>total</code> property. 1054 """ 1055 return PaymentsApi.list("payment", public_api_key, private_api_key, criteria)
1056 1057 @staticmethod
1058 - def find(object_id, public_api_key = None, private_api_key = None):
1059 """ 1060 Retrieve a Payment object from the API 1061 @param object_id: ID of object to retrieve 1062 @param public_api_key: Public key to use for the API call. If C{None}, the value of C{simplify.public_key} will be used. 1063 @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. 1064 @return: a Payment object 1065 """ 1066 return PaymentsApi.find("payment", public_api_key, private_api_key, object_id)
1067
1068 -class Plan(Domain):
1069 """ 1070 A Plan object. 1071 """ 1072 1073 1074 @staticmethod
1075 - def create(params, public_api_key = None, private_api_key = None):
1076 """ 1077 Creates an Plan object 1078 @param params: a dict of parameters; valid keys are: 1079 - C{amount}: Amount of payment for the plan in minor units. Example: 1000 = 10.00 B{required } 1080 - C{currency}: Currency code (ISO-4217) for the plan. Must match the currency associated with your account. B{required }B{default:USD} 1081 - C{frequency}: Frequency of payment for the plan. Example: Monthly B{required } 1082 - C{name}: Name of the plan B{required } 1083 @param public_api_key: Public key to use for the API call. If C{None}, the value of C{simplify.public_key} will be used. 1084 @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. 1085 @return: a Plan object 1086 """ 1087 return PaymentsApi.create("plan", public_api_key, private_api_key, params)
1088
1089 - def delete(self, public_api_key = None, private_api_key = None):
1090 """ 1091 Delete this object 1092 @param public_api_key: Public key to use for the API call. If C{None}, the value of C{simplify.public_key} will be used. 1093 @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. 1094 """ 1095 return PaymentsApi.delete("plan", public_api_key, private_api_key, self.object_id)
1096 1097 @staticmethod
1098 - def list(criteria = None, public_api_key = None, private_api_key = None):
1099 """ 1100 Retrieve Plan objects. 1101 @param criteria: a dict of parameters; valid keys are: 1102 - C{filter} Filters to apply to the list. 1103 - C{max} Allows up to a max of 50 list items to return. B{default:20} 1104 - C{offset} Used in paging of the list. This is the start offset of the page. B{default:0} 1105 - 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}. 1106 @param public_api_key: Public key to use for the API call. If C{None}, the value of C{simplify.public_key} will be used. 1107 @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. 1108 @return: an object which contains the list of Plan objects in the <code>list</code> property and the total number 1109 of objects available for the given criteria in the <code>total</code> property. 1110 """ 1111 return PaymentsApi.list("plan", public_api_key, private_api_key, criteria)
1112 1113 @staticmethod
1114 - def find(object_id, public_api_key = None, private_api_key = None):
1115 """ 1116 Retrieve a Plan object from the API 1117 @param object_id: ID of object to retrieve 1118 @param public_api_key: Public key to use for the API call. If C{None}, the value of C{simplify.public_key} will be used. 1119 @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. 1120 @return: a Plan object 1121 """ 1122 return PaymentsApi.find("plan", public_api_key, private_api_key, object_id)
1123
1124 - def update(self, public_api_key = None, private_api_key = None):
1125 """ 1126 Updates this object 1127 1128 The properties that can be updated: 1129 - C{name} Name of the plan. B{(required)} 1130 1131 @param public_api_key: Public key to use for the API call. If C{None}, the value of C{simplify.public_key} will be used. 1132 @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. 1133 @return: a Plan object. 1134 """ 1135 return PaymentsApi.update("plan", public_api_key, private_api_key, self.object_id, self.to_dict())
1136
1137 -class Refund(Domain):
1138 """ 1139 A Refund object. 1140 """ 1141 1142 1143 @staticmethod
1144 - def create(params, public_api_key = None, private_api_key = None):
1145 """ 1146 Creates an Refund object 1147 @param params: a dict of parameters; valid keys are: 1148 - C{amount}: Amount of the refund in minor units. Example: 1000 = 10.00 B{required } 1149 - C{payment}: ID of the payment for the refund B{required } 1150 - C{reason}: Reason for the refund 1151 @param public_api_key: Public key to use for the API call. If C{None}, the value of C{simplify.public_key} will be used. 1152 @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. 1153 @return: a Refund object 1154 """ 1155 return PaymentsApi.create("refund", public_api_key, private_api_key, params)
1156 1157 @staticmethod
1158 - def list(criteria = None, public_api_key = None, private_api_key = None):
1159 """ 1160 Retrieve Refund objects. 1161 @param criteria: a dict of parameters; valid keys are: 1162 - C{filter} Filters to apply to the list. 1163 - C{max} Allows up to a max of 50 list items to return. B{default:20} 1164 - C{offset} Used in paging of the list. This is the start offset of the page. B{default:0} 1165 - 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}. 1166 @param public_api_key: Public key to use for the API call. If C{None}, the value of C{simplify.public_key} will be used. 1167 @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. 1168 @return: an object which contains the list of Refund objects in the <code>list</code> property and the total number 1169 of objects available for the given criteria in the <code>total</code> property. 1170 """ 1171 return PaymentsApi.list("refund", public_api_key, private_api_key, criteria)
1172 1173 @staticmethod
1174 - def find(object_id, public_api_key = None, private_api_key = None):
1175 """ 1176 Retrieve a Refund object from the API 1177 @param object_id: ID of object to retrieve 1178 @param public_api_key: Public key to use for the API call. If C{None}, the value of C{simplify.public_key} will be used. 1179 @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. 1180 @return: a Refund object 1181 """ 1182 return PaymentsApi.find("refund", public_api_key, private_api_key, object_id)
1183
1184 -class Subscription(Domain):
1185 """ 1186 A Subscription object. 1187 """ 1188 1189 1190 @staticmethod
1191 - def create(params, public_api_key = None, private_api_key = None):
1192 """ 1193 Creates an Subscription object 1194 @param params: a dict of parameters; valid keys are: 1195 - C{amount}: Amount of the payment (minor units). Example: 1000 = 10.00 1196 - C{coupon}: Coupon ID associated with the subscription 1197 - C{currency}: Currency code (ISO-4217). Must match the currency associated with your account. B{default:USD} 1198 - C{customer}: Customer that is enrolling in the subscription. 1199 - C{frequency}: Frequency of payment for the plan. Example: Monthly 1200 - C{name}: Name describing subscription 1201 - C{plan}: The ID of the plan that should be used for the subscription. 1202 - C{quantity}: Quantity of the plan for the subscription. 1203 @param public_api_key: Public key to use for the API call. If C{None}, the value of C{simplify.public_key} will be used. 1204 @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. 1205 @return: a Subscription object 1206 """ 1207 return PaymentsApi.create("subscription", public_api_key, private_api_key, params)
1208
1209 - def delete(self, public_api_key = None, private_api_key = None):
1210 """ 1211 Delete this object 1212 @param public_api_key: Public key to use for the API call. If C{None}, the value of C{simplify.public_key} will be used. 1213 @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. 1214 """ 1215 return PaymentsApi.delete("subscription", public_api_key, private_api_key, self.object_id)
1216 1217 @staticmethod
1218 - def list(criteria = None, public_api_key = None, private_api_key = None):
1219 """ 1220 Retrieve Subscription objects. 1221 @param criteria: a dict of parameters; valid keys are: 1222 - C{filter} Filters to apply to the list. 1223 - C{max} Allows up to a max of 50 list items to return. B{default:20} 1224 - C{offset} Used in paging of the list. This is the start offset of the page. B{default:0} 1225 - 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}. 1226 @param public_api_key: Public key to use for the API call. If C{None}, the value of C{simplify.public_key} will be used. 1227 @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. 1228 @return: an object which contains the list of Subscription objects in the <code>list</code> property and the total number 1229 of objects available for the given criteria in the <code>total</code> property. 1230 """ 1231 return PaymentsApi.list("subscription", public_api_key, private_api_key, criteria)
1232 1233 @staticmethod
1234 - def find(object_id, public_api_key = None, private_api_key = None):
1235 """ 1236 Retrieve a Subscription object from the API 1237 @param object_id: ID of object to retrieve 1238 @param public_api_key: Public key to use for the API call. If C{None}, the value of C{simplify.public_key} will be used. 1239 @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. 1240 @return: a Subscription object 1241 """ 1242 return PaymentsApi.find("subscription", public_api_key, private_api_key, object_id)
1243
1244 - def update(self, public_api_key = None, private_api_key = None):
1245 """ 1246 Updates this object 1247 1248 The properties that can be updated: 1249 - C{amount} Amount of the payment (minor units). Example: 1000 = 10.00 1250 1251 - C{coupon} Coupon being assigned to this subscription 1252 1253 - C{currency} Currency code (ISO-4217). Must match the currency associated with your account. 1254 1255 - C{frequency} Frequency of payment for the plan. Example: Monthly 1256 1257 - C{name} Name describing subscription 1258 1259 - C{plan} Plan that should be used for the subscription. 1260 1261 - C{prorate} Whether to prorate existing subscription. B{(required)} 1262 1263 - C{quantity} Quantity of the plan for the subscription. 1264 1265 @param public_api_key: Public key to use for the API call. If C{None}, the value of C{simplify.public_key} will be used. 1266 @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. 1267 @return: a Subscription object. 1268 """ 1269 return PaymentsApi.update("subscription", public_api_key, private_api_key, self.object_id, self.to_dict())
1270
1271 -class Webhook(Domain):
1272 """ 1273 A Webhook object. 1274 """ 1275 1276 1277 @staticmethod
1278 - def create(params, public_api_key = None, private_api_key = None):
1279 """ 1280 Creates an Webhook object 1281 @param params: a dict of parameters; valid keys are: 1282 - C{url}: Endpoint URL B{required } 1283 @param public_api_key: Public key to use for the API call. If C{None}, the value of C{simplify.public_key} will be used. 1284 @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. 1285 @return: a Webhook object 1286 """ 1287 return PaymentsApi.create("webhook", public_api_key, private_api_key, params)
1288
1289 - def delete(self, public_api_key = None, private_api_key = None):
1290 """ 1291 Delete this object 1292 @param public_api_key: Public key to use for the API call. If C{None}, the value of C{simplify.public_key} will be used. 1293 @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. 1294 """ 1295 return PaymentsApi.delete("webhook", public_api_key, private_api_key, self.object_id)
1296 1297 @staticmethod
1298 - def list(criteria = None, public_api_key = None, private_api_key = None):
1299 """ 1300 Retrieve Webhook objects. 1301 @param criteria: a dict of parameters; valid keys are: 1302 - C{filter} Filters to apply to the list. 1303 - C{max} Allows up to a max of 50 list items to return. B{default:20} 1304 - C{offset} Used in paging of the list. This is the start offset of the page. B{default:0} 1305 - 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}. 1306 @param public_api_key: Public key to use for the API call. If C{None}, the value of C{simplify.public_key} will be used. 1307 @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. 1308 @return: an object which contains the list of Webhook objects in the <code>list</code> property and the total number 1309 of objects available for the given criteria in the <code>total</code> property. 1310 """ 1311 return PaymentsApi.list("webhook", public_api_key, private_api_key, criteria)
1312 1313 @staticmethod
1314 - def find(object_id, public_api_key = None, private_api_key = None):
1315 """ 1316 Retrieve a Webhook object from the API 1317 @param object_id: ID of object to retrieve 1318 @param public_api_key: Public key to use for the API call. If C{None}, the value of C{simplify.public_key} will be used. 1319 @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. 1320 @return: a Webhook object 1321 """ 1322 return PaymentsApi.find("webhook", public_api_key, private_api_key, object_id)
1323
1324 - def update(self, public_api_key = None, private_api_key = None):
1325 """ 1326 Updates this object 1327 1328 The properties that can be updated: 1329 - C{url} Endpoint URL B{(required)} 1330 1331 @param public_api_key: Public key to use for the API call. If C{None}, the value of C{simplify.public_key} will be used. 1332 @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. 1333 @return: a Webhook object. 1334 """ 1335 return PaymentsApi.update("webhook", public_api_key, private_api_key, self.object_id, self.to_dict())
1336