telr payment python
1.0.0

該模塊是用於實施API的TELR支付服務的PIP包。為了使用此模塊,您必須通過PIP命令或設置安裝它。
pip install telr_payment通過以下方式將軟件包導入您的項目:
from telr_payment.api import Telr為了使用模塊,請考慮查看示例和文檔。
對於簡單的實施,我提供了兩個簡單的示例,一個用於創建交易,另一個用於檢查這樣的示例
# order_sample.py
from telr_payment . api import Telr
from pprint import pprint
# if you dont want it to run in test mode change the test option according to docs
telr = Telr ( auth_key = "YOUR_AUTH_KEY" , store_id = "YOUR_STORE_ID" , test = 1 )
order_response = telr . order (
order_id = "ORDER_ID_TOKEN" ,
amount = 54.5 ,
return_url = "http://domain.com/path/to/url" ,
return_decl = "http://domain.com/path/to/url" ,
return_can = "http://domain.com/path/to/url" ,
description = "testing"
)
pprint ( order_response ) # check_sample.py
from telr_payment . api import Telr
from pprint import pprint
# if you dont want it to run in test mode change the test option according to docs
telr = Telr ( auth_key = "YOUR_AUTH_KEY" , store_id = "YOUR_STORE_ID" , test = 1 )
status_response = telr . status (
order_reference = "ORDER_REF_TOKEN"
)
pprint ( status_response )檢查交易的狀態表
| 訂單狀態 | 描述 |
|---|---|
| 1 | 待辦的 |
| 2 | 授權(未捕獲的交易,例如驗證交易或銷售 已擱置的交易) |
| 3 | 付費(捕獲的交易,銷售交易,未擱置) |
| -1 | 已到期 |
| -2 | 取消 |
| -3 | 拒絕 |
| 卡號 | 類型 | CVV | MPI |
|---|---|---|---|
| 4000 0000 0000 0002 | 簽證 | 123 | 不 |
| 4111 1111 1111 1111 | 簽證 | 123 | 是的 |
| 4444 3333 2222 1111 | 簽證 | 123 | 是的 |
| 4444 4244 4444 4440 | 簽證 | 123 | 是的 |
| 4444 4444 4444 4448 | 簽證 | 123 | 是的 |
| 4012 8888 8888 1881 | 簽證 | 123 | 是的 |
| 5105 1051 0510 5100 | 萬事達 | 123 | 不 |
| 5454 5454 5454 5454 | 萬事達 | 123 | 是的 |
| 5555 5555 5555 4444 | 萬事達 | 123 | 是的 |
| 5555 5555 5555 5557 | 萬事達 | 123 | 是的 |
| 5581 5822 2222 2229 | 萬事達 | 123 | 是的 |
| 5641 8209 0009 7002 | 英國大師 | 123 | 是的 |
| 6767 0957 4000 0005 | 獨奏 | 123 | 不 |
| 3434 343434 34343 | 美國運通 | 1234 | 不 |
| 3566 0020 2014 0006 | JCB | 123 | 不 |
| 3111 1111 1111 1111 | 馬達 | 123 | 不 |
與測試卡一起使用的卡安全碼(CVV)為123(American Express除外,應為1234)以進行授權響應,其他代碼將被拒絕。
在MPI列中顯示“是”的卡將使用模擬的3D安全身份驗證頁面,從而可以使用Visa或MasterCard SecureCode驗證時測試事務流。
{ 'method' : 'create' ,
'order' : { 'ref' : 'ORDER_REF_TOKEN' ,
'url' : 'https://secure.telr.com/gateway/process.html?o=ORDER_REF_TOKEN' } ,
'trace' : 'xxxx/xxxx/xxxxxxxx' } {
"method" : "create" ,
"error" : {
"message" : "Exx: Error Name" ,
"note" : "Message according to error"
}
} { 'method' : 'check' ,
'order' : { 'amount' : '4.50' ,
'card' : { 'country' : 'AE' ,
'expiry' : { 'month' : x , 'year' : xxxx } ,
'first6' : 'xxxxxx' ,
'last4' : 'xxxx' ,
'type' : 'Visa Credit' } ,
'cartid' : 'ORDER_ID_TOKEN' ,
'currency' : 'AED' ,
'customer' : { 'address' : { 'city' : 'xxxxx' ,
'country' : 'AE' ,
'line1' : 'xxxx,xxx,xxx' ,
'mobile' : '1234567890' } ,
'email' : '[email protected]' ,
'name' : { 'forenames' : 'FIRST_NAME' , 'surname' : 'LAST_NAME' } } ,
'description' : 'testing' ,
'paymethod' : 'Card' ,
'ref' : 'ORDER_REF_TOKEN' ,
'status' : { 'code' : 3 , 'text' : 'Paid' } ,
'test' : 1 ,
'transaction' : { 'class' : 'ECom' ,
'code' : '924861' ,
'date' : '04 Aug 2022 12:56 GST' ,
'message' : 'Authorised' ,
'ref' : 'REF_TOKEN' ,
'status' : 'A' ,
'type' : 'sale' } } ,
'trace' : 'xxxx/xxxx/xxxxxxxx' } { 'method' : 'check' ,
'order' : { 'amount' : '54.50' ,
'cartid' : 'ORDER_ID_TOKEN' ,
'currency' : 'AED' ,
'description' : 'TRANSACTION_DESCRIPTION' ,
'ref' : 'ORDER_REF_TOKEN' ,
'status' : { 'code' : 1 , 'text' : 'Pending' } ,
'test' : 1 ,
'url' : 'https://secure.telr.com/gateway/process.html?o=ORDER_REF_TOKEN' } ,
'trace' : 'xxxx/xxxx/xxxxxxxx' } { 'method' : 'check' ,
'order' : { 'amount' : '54.50' ,
'cartid' : 'ORDER_ID_TOKEN' ,
'currency' : 'AED' ,
'description' : 'TRANSACTION_DESCRIPTION' ,
'ref' : 'ORDER_REF_TOKEN' ,
'status' : { 'code' : - 2 , 'text' : 'Cancelled' } ,
'test' : 1 } ,
'trace' : 'xxxx/xxxx/xxxxxxxx' }