# Ginger Python bindings
[![Build Status](https://travis-ci.org/gingerpayments/ginger-php.svg)](https://travis-ci.org/gingerpayments/ginger-python.svg)
[![MIT License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](https://github.com/gingerpayments/ginger-php/blob/master/LICENSE)
## Requirements
* Python 3.6 or later
* requests 2.20 or later
## Installation
You can install the Python bindings from PyPI:
```shell script
pip install ginger-sdk
```
You can also use the Python bindings without using the Python Package Index by placing the ginger_sdk directory
somewhere in your `PYTHONPATH`.
## Getting started
First create a new API client with your API key and API endpoint:
```python
from ginger_sdk import Ginger
client = Ginger.create_client('https://api.example.com', 'your-api-key')
```
### Initiating a payment
You can start a new payment by creating a new order:
```python
order = client.create_order(
{
'merchant_order_id': 'my-custom-order-id-12345',
'currency': 'EUR',
'amount': 2500, # Amount in cents
'description': 'Purchase order 12345',
'return_url': 'https://www.example.com',
'transactions': [
{
'payment_method': 'credit-card',
}
]
}
)
```
Once you've created your order, a transaction is created and associated with it. You will need to redirect the user to
the transaction's payment URL, which you can retrieve as follows:
```python
payment_url = order['order_url']
```
It is also recommended that you store the order's ID somewhere, so you can retrieve information about it later:
```python
order_id = order['id']
```
There is a lot more data related to an order. Please refer to the API documentation provided by your PSP to learn more
about the various payment methods and options.
### Getting an order
If you want to retrieve an existing order, use the `get_order` method on the client:
```python
order = client.get_order(order_id)
```
This will return an associative array with all order information.
### Updating an order
Some fields are not read-only and you are able to update them after order has been created. You can do this using
the `update_order` method on the client:
```python
order = client.get_order(order_id)
order['description'] = 'New Order Description'
updated_order = client.update_order(order)
```
### Initiating a refund
You can refund an existing order by using the `refund_order` method on the client:
```python
refund_order = client.refund_order(order_id, {'amount': 123, 'description': 'My refund'})
```
### Capturing an order
You can initiate a capture of an order's transaction by using the `capture_order_transaction` method:
```python
client.capture_order_transaction(order_id, transaction_id)
```
### Getting the iDEAL issuers
When you create an order with the iDEAL payment method, you need to provide an issuer ID. The issuer ID is an identifier
of the bank the user has selected. You can retrieve all possible issuers by using the `get_ideal_issuers` method:
```python
issuers = client.get_ideal_issuers()
```
You can then use this information to present a list to the user of possible banks to choose from.
### Custom requests
You can send any request that the API accepts using the `send` method. E.g. instead of using the `create_order` method
you could also use the following:
```python
result = client.send(
'POST', # Request method
'/orders/', # API path
order_data # Data to send with the request; optional
)
```
The `$result` variable would then contain the decoded JSON returned by the API.
## Using a different CA bundle
If you need to use a different CA bundle than the one that comes with your system, you can install the Certifi package
from PyPI.
```shell script
pip install certifi
```
The certificates supplied by Certifi will be automatically used.
## Custom HTTP client
This library ships with its own minimal HTTP client for compatibility reasons. If you would like to use a different HTTP
client, you can do so by extending the `ginger_sdk.http_client.HttpClient` abstract base class and then constructing
your own client:
```python
from ginger_sdk.api_client import ApiClient
my_http_client = MyHttpClient()
client = ApiClient(my_http_client)
```
Make sure your HTTP client prefixes the endpoint URL and API version to all requests, and uses HTTP basic auth to
authenticate with the API using your API key.
## API documentation
For the complete API documentation please prefer to the resources provided by your PSP.
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
共14个文件
py:5个
txt:4个
pkg-info:2个
资源分类:Python库 所属语言:Python 资源全名:ginger-sdk-2.1.3.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
资源推荐
资源详情
资源评论
收起资源包目录
ginger-sdk-2.1.3.tar.gz (14个子文件)
ginger-sdk-2.1.3
MANIFEST.in 55B
PKG-INFO 6KB
setup.cfg 38B
ginger_sdk.egg-info
PKG-INFO 6KB
requires.txt 17B
SOURCES.txt 294B
top_level.txt 11B
dependency_links.txt 1B
setup.py 998B
ginger_sdk
http_client.py 2KB
ginger.py 881B
__init__.py 47B
api_client.py 5KB
README.md 4KB
共 14 条
- 1
资源评论
挣扎的蓝藻
- 粉丝: 13w+
- 资源: 15万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- vue自定义指令( 复制、拖动、权限)
- json格式文件备份redis数据库 工具
- Multi-Agent-Flocking.zip
- 指标公式未来函数检测工具V1.2
- projectData
- SQL Server 性能监视器,它旨在提供开箱即用的全面监控,并作为您自己的项目或应用程序的监控框架 它在本地数据库中收集性能
- Python 程序语言设计模式思路-并发模式:线程池模式:管理线程池,优化线程创建和销毁
- 股事汇投资工具-实时新闻、财经日历、市场快讯、持仓查询、外汇兑换、换算工具、大盘云图、江恩工具、指标检测等
- webrtc-streamer
- html+css+'青春献礼二十大 红色旅游助乡村'为主题的网页设计 2022年参与学校网页设计比赛时完成的
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功