elepay API リファレンス
Project description
Elepay Python SDK
elepay APIはRESTをベースに構成された決済APIです。支払い処理、返金処理など、決済に関わる運用における様々なことができます。
This Python package is automatically generated by the OpenAPI Generator project:
- API version: 1.2.0
- SDK version: 1.2.0
For more information, please visit Elepay Homepage and API Reference
Installation
pip install (Recommended)
pip install elepay-python-sdk==1.2.0
If it is failed by root permission, try sudo pip install elepay-python-sdk==1.2.0.
pip install from GitHub
Install from this repository directly using:
pip install git+https://github.com/elestyle/elepay-python-sdk.git@v1.2.0
(you may need to run pip with root permission)
Setuptools (Not recommended)
Install via Setuptools.
Clone this repository and installed by setup.py:
git clone https://github.com/elestyle/elepay-python-sdk.git
cd elepay-python-sdk
python setup.py install --user
(or sudo python setup.py install to install the package for all users)
Requirements.
Python >=3.7
Rules of SDK Generation
- The SDK Generator uses spec case for all (object) property names and parameter names.
- If the spec has a property name like
paymentMethod, it will keep to usepaymentMethodinstead ofpayment_method - It will be easy to serialize / deserialize between Elepay API <-> Your Server <-> Your Client
- If the spec has a property name like
- Endpoint request parameters should be assigned to different arguments
- Query parameters should be assigned to
query_params, likecharge_api.list_charges(query_params={"paymentMethod": someMethods}) - Path parameters should be assigned to
path_params - Body should be assigned to
body - etc. See also each schema of endpoint parameters and Elepay API Reference.
- Query parameters should be assigned to
- Endpoint responses include the original
urllib3.HTTPResponseand deserialized response body- Use
response.bodyto access deserialized data - Use
response.responseto access originalurllib3.HTTPResponse
- Use
- All deserialized data is instantiated in an instance that subclasses all validated
Schemaclasses andDecimal/str/list/tuple/frozendict/NoneClass/BoolClass/bytes/io.FileIO- This means that you can use
isinstanceto check if a payload validated against a schema class - This means that no data will be of type
None/True/False- Ingested
Nonewill subclassNoneClass - Ingested
Truewill subclassBoolClass - Ingested
Falsewill subclassBoolClass - Use
instance.is_true_oapg()/.is_false_oapg()/.is_none_oapg()to check ifinstanceisNone/True/False
- Ingested
- This means that you can use
- All validated class instances are immutable
- Please do not change values or property values after a class has been instantiated
- String + Number types with formats
- String 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 instance
- type string + format: See
.as_date_oapg,.as_datetime_oapg,.as_decimal_oapg,.as_uuid_oapg - type number + format: See
.as_float_oapg,.as_int_oapg - this 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 schema
- Use
as_date_oapg/as_datetime_oapg/as_decimal_oapg/as_uuid_oapgto access a string format based type - Use
as_int_oapg/as_float_oapgto access a number format based type
- Property access on
AnyType(unset)orobject(dict)schemas- Only required keys with valid python names are properties like
.somePropand have type hints - All optional keys may not exist, so properties are not defined for them
- One can access optional values with
dict_instance['optionalProp']andKeyErrorwill be raised if it does not exist - Use
get_item_oapgif you need a way to always get a value whether or not the key exists- If the key does not exist,
schemas.unsetis returned from callingdict_instance.get_item_oapg('optionalProp') - If the key exist but the value is
None,NoneClasswill be returned - All required and optional keys have type hints for this method, and
@typing.overloadis used - A type hint is also generated for additional properties accessed using this method
- If the key does not exist,
- Use
some_instance['optionalProp']to access optional property and additional property values likeextra
- Only required keys with valid python names are properties like
- The location of the api classes
- Package
elepay.apis.tag_to_apiwill contain all APIs classes which is split by tag (Recommended) - Package
elepay.apis.tagswill contain each tag class- Example:
elepay.apis.tags.charge_apiwill containChargeApi, which have been tagged ascharge
- Example:
- Package
elepay.apis.path_to_apiwill contain all APIs classes which is split by path (Not recommended) - See also Note for more help if import fails
- Package
- What is the
Oapgand_oapg?- It is just a method / class postfix which is providered by SDK Generator
- The OAPG stands for OpenApi Python Generator
Getting Started
Please follow the installation procedure and then run the following:
from pprint import pprint
from uuid import uuid4
from elepay import ApiException
from elepay.models import ChargeReq, PaymentMethodType, ResourceType, RefundReq
from elepay.apis.tag_to_api import ChargeApi # Or elepay.apis.tags.charge_api
from elepay.api_client import JSONEncoder, 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 system
order_number=str(uuid4())
# Enter a context with an instance of the API client
# Should close it before exit
api_client = ApiClient(configuration)
# Create an instance of the API class
charge_api = ChargeApi(api_client)
# Request to create a simple charge, see API document or __new__ for a list of all supported parameters
charge_req = ChargeReq(
amount=1500, # 1500, currency default is JPY, or set currency to other allowed values
orderNo=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)
except ApiException as e:
pprint("Exception when calling ChargeApi->create_charge: %s\n" % e)
The Elepay client SDK can handle the ChargeDto to invoke the payment popup.
API Endpoints
See Elepay API Reference.
Author
Note
If the OpenAPI document is large, imports in elepay.apis and elepay.models may fail with a
RecursionError indicating 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 ChargeReq
Solution 2: Before importing the package, adjust the maximum recursion limit as shown below:
import sys
# Or some value else, default value should be 1000, but it may be different in some environments.
sys.setrecursionlimit(2000)
import elepay
from elepay.apis import *
from elepay.models import *
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file elepay-python-sdk-1.2.0.tar.gz.
File metadata
- Download URL: elepay-python-sdk-1.2.0.tar.gz
- Upload date:
- Size: 103.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e7d70f527434e55391280eddc90d03f812eea22b591dbf8dcf7276d944282648
|
|
| MD5 |
70c8f87accd1efb68b9af9312a50658a
|
|
| BLAKE2b-256 |
502e5ed939d19938759ae4aadabaecfb989c90709fead4c064e8e58ae375d85b
|
File details
Details for the file elepay_python_sdk-1.2.0-py3-none-any.whl.
File metadata
- Download URL: elepay_python_sdk-1.2.0-py3-none-any.whl
- Upload date:
- Size: 250.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c4fa2898c2a145e8b9231a51bdccc3e165dc587cc7a704836baa8afb94c54da1
|
|
| MD5 |
732e1a7a43d87f173f511b03c28c608e
|
|
| BLAKE2b-256 |
bf7fc5c5a3c8afb924c8ba447686945b7f4fef48fd450fca7418f5d8a3c9120d
|