Package: elepay-python-sdk
Elepay Python SDKelepay APIはRESTをベースに構成された決済APIです。支払い処理、返金処理など、決済に関わる運用における様々なことができます。This Python package is automatically generated by theOpenAPI Generatorproject:API version: 1.2.0SDK version: 1.2.0For more information, please visitElepay HomepageandAPI ReferenceInstallationpip install (Recommended)pipinstallelepay-python-sdk==1.2.0If it is failed by root permission, trysudo pip install elepay-python-sdk==1.2.0.pip install from GitHubInstall from this repository directly using:pipinstallgit+https://github.com/elestyle/elepay-python-sdk.git@v1.2.0(you may need to runpipwith root permission)Setuptools (Not recommended)Install viaSetuptools.Clone this repository and installed bysetup.py:gitclonehttps://github.com/elestyle/elepay-python-sdk.gitcdelepay-python-sdk
pythonsetup.pyinstall--user(orsudo python setup.py installto install the package for all users)Requirements.Python >=3.7Rules of SDK GenerationThe SDK Generator uses spec case for all (object) property names and parameter names.If the spec has a property name likepaymentMethod, it will keep to usepaymentMethodinstead ofpayment_methodIt will be easy to serialize / deserialize between Elepay API <-> Your Server <-> Your ClientEndpoint request parameters should be assigned to different argumentsQuery parameters should be assigned toquery_params, likecharge_api.list_charges(query_params={"paymentMethod": someMethods})Path parameters should be assigned topath_paramsBody should be assigned tobodyetc. See also each schema of endpoint parameters andElepay API Reference.Endpoint responses include the originalurllib3.HTTPResponseand deserialized response bodyUseresponse.bodyto access deserialized dataUseresponse.responseto access originalurllib3.HTTPResponseAll deserialized data is instantiated in an instance that subclasses all validatedSchemaclasses andDecimal/str/list/tuple/frozendict/NoneClass/BoolClass/bytes/io.FileIOThis means that you can useisinstanceto check if a payload validated against a schema classThis means that no data will be of typeNone/True/FalseIngestedNonewill subclassNoneClassIngestedTruewill subclassBoolClassIngestedFalsewill subclassBoolClassUseinstance.is_true_oapg()/.is_false_oapg()/.is_none_oapg()to check ifinstanceisNone/True/FalseAll validated class instances are immutablePlease do not change values or property values after a class has been instantiatedString + Number types with formatsString type data is stored as a string and if you need to access types based on its format like date,
date-time, uuid, number etc then you will need to use accessor functions on the instancetype string + format: See.as_date_oapg,.as_datetime_oapg,.as_decimal_oapg,.as_uuid_oapgtype number + format: See.as_float_oapg,.as_int_oapgthis was done because openapi / json-schema defines constraints. string data may be type string with no format
keyword in one schema, and include a format constraint in another schemaUseas_date_oapg/as_datetime_oapg/as_decimal_oapg/as_uuid_oapgto access a string format based typeUseas_int_oapg/as_float_oapgto access a number format based typeProperty access onAnyType(unset)orobject(dict)schemasOnly required keys with valid python names are properties like.somePropand have type hintsAll optional keys may not exist, so properties are not defined for themOne can access optional values withdict_instance['optionalProp']andKeyErrorwill be raised if it does not existUseget_item_oapgif you need a way to always get a value whether or not the key existsIf the key does not exist,schemas.unsetis returned from callingdict_instance.get_item_oapg('optionalProp')If the key exist but the value isNone,NoneClasswill be returnedAll required and optional keys have type hints for this method, and@typing.overloadis usedA type hint is also generated for additional properties accessed using this methodUsesome_instance['optionalProp']to access optional property and additional property values likeextraThe location of the api classesPackageelepay.apis.tag_to_apiwill contain all APIs classes which is split by tag (Recommended)Packageelepay.apis.tagswill contain each tag classExample:elepay.apis.tags.charge_apiwill containChargeApi, which have been tagged aschargePackageelepay.apis.path_to_apiwill contain all APIs classes which is split by path (Not recommended)See alsoNotefor more help if import failsWhat is theOapgand_oapg?It is just a method / class postfix which is providered by SDK GeneratorThe OAPG stands for OpenApi Python GeneratorGetting StartedPlease follow theinstallation procedureand then run the following:frompprintimportpprintfromuuidimportuuid4fromelepayimportApiExceptionfromelepay.modelsimportChargeReq,PaymentMethodType,ResourceType,RefundReqfromelepay.apis.tag_to_apiimportChargeApi# Or elepay.apis.tags.charge_apifromelepay.api_clientimportJSONEncoder,ApiClient,Configuration# Defining the host is optional and defaults to https://api.elepay.io# The client must configure the authentication and authorization parameters# in accordance with the API server security policy.# Examples for each auth method are provided below, use the example that# satisfies your auth use case.# Simple to configure Elepay HTTP authorization:configuration=Configuration('sk_live_******')# Generate your order number, please use a unique id in your systemorder_number=str(uuid4())# Enter a context with an instance of the API client# Should close it before exitapi_client=ApiClient(configuration)# Create an instance of the API classcharge_api=ChargeApi(api_client)# Request to create a simple charge, see API document or __new__ for a list of all supported parameterscharge_req=ChargeReq(amount=1500,# 1500, currency default is JPY, or set currency to other allowed valuesorderNo=order_number,paymentMethod=PaymentMethodType.CREDITCARD,resource=ResourceType.WEB,# Please make sure the client is running on the correct resource type)try:response=charge_api.create_charge(body=charge_req)# elepay.models.ChargeDto is the type of response.body# bytes is the type of response.response.data which is also original body# Use response original body bytes like:original_body=response.response.data.decode("utf-8")# Or re-serialize response body like:json_body=JSONEncoder().encode(response.body)# Then return the original_body or json_body to client.# Example for Django with original body bytes:#   django.http.HttpResponse(content=response.response.data, content_type='application/json')# Or re-serialize:#   django.http.JsonResponse(data=response.body, encoder=JSONEncoder)exceptApiExceptionase:pprint("Exception when calling ChargeApi->create_charge:%s\n"%e)The Elepay client SDK can handle theChargeDtoto invoke the payment popup.API EndpointsSeeElepay API Reference.AuthorELESTYLE, Inc.NoteIf the OpenAPI document is large, imports inelepay.apisandelepay.modelsmay fail with aRecursionErrorindicating the maximum recursion limit has been exceeded. In that case, there are a couple of solutions:Solution 1:
Use specific imports for apis and models like:from elepay.apis.charge_api import ChargeApifrom elepay.model.charge_req import ChargeReqSolution 2:
Before importing the package, adjust the maximum recursion limit as shown below:importsys# Or some value else, default value should be 1000, but it may be different in some environments.sys.setrecursionlimit(2000)importelepayfromelepay.apisimport*fromelepay.modelsimport*