Skip to content

Commit 13174be

Browse files
committed
Merge branch 'develop' into 'master'
Develop See merge request Modules/fasterpay-python3!6
2 parents 1804063 + 2db7a73 commit 13174be

5 files changed

Lines changed: 67 additions & 24 deletions

File tree

fasterpay/config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ def __init__(self, privateKey, publicKey, is_test = False, apiVersion = None):
44
self.publicKey = publicKey
55
self.privateKey = privateKey
66
if is_test is True :
7-
self.API_BASE_URL = "http://pay.fasterpay.com"
7+
self.API_BASE_URL = "https://pay.fasterpay.com"
88
else:
9-
self.API_BASE_URL = "http://pay.sandbox.fasterpay.com"
9+
self.API_BASE_URL = "https://pay.sandbox.fasterpay.com"
1010

1111
if apiVersion is not None :
1212
self.VERSION = apiVersion

fasterpay/gateway.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from fasterpay.paymentform import PaymentForm
55
from fasterpay.refund import Refund
66
from fasterpay.subscription import Subscription
7+
from fasterpay.transaction import Transaction
78

89

910
class Gateway:
@@ -29,5 +30,5 @@ def refund(self):
2930
def subscription(self):
3031
return Subscription(self)
3132

32-
33-
33+
def transaction(self):
34+
return Transaction(self)

fasterpay/tests/test-delivery.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/bash
2+
3+
from fasterpay.gateway import Gateway
4+
5+
if __name__ == "__main__":
6+
7+
# Initialize the Gateway
8+
gateway = Gateway("<YOUR PRIVATE KEY>", "<YOUR PUBLIC KEY>", True)
9+
10+
# Prepare Delivery Information
11+
deliveryInfo = {
12+
"payment_order_id": "46157868",
13+
"merchant_order_id": "1078972173",
14+
"type": "digital",
15+
"public_key": gateway.get_config().get_public_key(),
16+
"status": "order_placed",
17+
"refundable": 1,
18+
"details": "Order placed today",
19+
"shipping_address[email]": "jon.doe@example.com"
20+
}
21+
22+
deliverResponse = gateway.transaction().deliver(deliveryInfo)
23+
24+
print(deliverResponse)

fasterpay/transaction.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/python
2+
import requests
3+
4+
5+
class Transaction:
6+
7+
def __init__(self, gateway):
8+
self.gateway = gateway
9+
10+
def refund(self, order_id=None, amount=None):
11+
refund_response = self.do_http_post_request(
12+
self.gateway.config.get_api_url() + "/payment/" + str(order_id) + "/refund",
13+
{"amount": amount},
14+
{"X-ApiKey": self.gateway.config.get_private_key()})
15+
return refund_response
16+
17+
def deliver(self, delivery_info):
18+
delivery_response = self.do_http_post_request(self.gateway.config.get_api_url() + "/api/v1/deliveries",
19+
delivery_info,
20+
{"X-ApiKey": self.gateway.config.get_private_key()})
21+
return delivery_response
22+
23+
@staticmethod
24+
def do_http_post_request(url, data, headers):
25+
response = requests.post(url, data=data, headers=headers)
26+
return response.json()

setup.py

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,21 @@
11
from distutils.core import setup
2-
3-
# read the contents of README file
4-
from os import path
5-
this_directory = path.abspath(path.dirname(__file__))
6-
with open(path.join(this_directory, 'README.md'), encoding='utf-8') as f:
7-
long_description = f.read()
8-
92
setup(
10-
name = 'FasterPay Python3 SDK',
11-
packages = ['fasterpay'],
12-
version = '1.0',
3+
name='fasterpay-python3',
4+
packages=['fasterpay'],
5+
version='1.2',
136
license='MIT',
14-
description = 'FasterPay Python SDK enables you to integrate the FasterPay’s Checkout Page seamlessly without having the hassle of integrating everything from Scratch. Once your customer is ready to pay, FasterPay will take care of the payment, notify your system about the payment and return the customer back to your Thank You page.',
15-
long_description = long_description,
16-
author = 'FasterPay Integration Team',
17-
author_email = 'integration@fasterpay.com',
18-
url = 'https://github.com/FasterPay/fasterpay-python',
19-
download_url = 'https://github.com/FasterPay/fasterpay-python/releases',
20-
keywords = ['FASTERPAY', 'PAYMENTS', 'CARD PROCESSING'],
21-
install_requires=['requests']
7+
description='Integrate FasterPay into your application using fasterpay-python SDK',
8+
author='FasterPay Integrations Team',
9+
author_email='integration@fasterpay.com',
10+
url='https://github.com/FasterPay/fasterpay-python3',
11+
download_url='https://github.com/FasterPay/fasterpay-python3/releases',
12+
keywords=['FASTERPAY', 'PAYMENTS', 'CARD PROCESSING'],
13+
install_requires=['requests'],
2214
classifiers=[
2315
'Development Status :: 5 - Production/Stable',
2416
'Intended Audience :: Developers',
25-
'Topic :: Software Development :: Payment Gateway',
26-
'License :: MIT License',
17+
'Topic :: Software Development :: Libraries :: Python Modules',
18+
'License :: OSI Approved :: MIT License',
2719
'Programming Language :: Python :: 3',
2820
],
2921
)

0 commit comments

Comments
 (0)