Skip to content
This repository was archived by the owner on Jun 26, 2025. It is now read-only.

Commit aa8716a

Browse files
authored
Add applepay and stcpay sources (#13)
* Support ApplePay and STCPay * update packages * update version
1 parent dd39a64 commit aa8716a

5 files changed

Lines changed: 23 additions & 27 deletions

File tree

moyasar/payment.py

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,42 +4,38 @@
44
from moyasar.actions.refund import Refund
55
from moyasar.actions.capture import Capture
66
from moyasar.actions.void import Void
7-
from moyasar.helpers import Constructor
8-
from moyasar.helpers import Format
7+
from moyasar.helpers import Constructor, Format
98

109

1110
class Source(Constructor, Format):
12-
1311
@classmethod
1412
def build(cls, source):
15-
if source['type'] == "creditcard":
16-
source = Source.source_to_creditcard(source)
17-
else:
18-
source = Source.source_to_sadad(source)
19-
return source
20-
21-
@classmethod
22-
def source_to_creditcard(cls, data):
23-
data.pop('type')
24-
return CreditCard(data)
25-
26-
@classmethod
27-
def source_to_sadad(cls, data):
28-
data.pop('type')
29-
return Sadad(data)
13+
source_klass = sources[source.pop('type')]
14+
return source_klass(source)
3015

3116

3217
class CreditCard(Source):
3318
def __str__(self):
3419
return json.dumps(self.__dict__)
3520

36-
3721
class Sadad(Source):
3822
pass
3923

24+
class ApplePay(Source):
25+
pass
4026

41-
class Payment(Resource, Refund, Capture, Void, Format):
27+
class STCPay(Source):
28+
pass
4229

30+
sources = {
31+
'creditcard': CreditCard,
32+
'sadad': Sadad,
33+
'applepay': ApplePay,
34+
'stcpay': STCPay,
35+
}
36+
37+
38+
class Payment(Resource, Refund, Capture, Void, Format):
4339
def __init__(self, data):
4440
super().__init__(data)
4541
self.source = Source.build(self.source)

moyasar/resource.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44

55

66
class Resource(Fetch, List, Update):
7-
pass
7+
pass

requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ idna==2.8
1212
isort==4.3.4
1313
jsonrpclib==0.1.7
1414
lazy-object-proxy==1.3.1
15-
markdown2==2.3.7
15+
markdown2==2.3.9
1616
mccabe==0.6.1
1717
more-itertools==6.0.0
1818
pbr==5.1.2
@@ -23,10 +23,10 @@ py-bcrypt==0.4
2323
Pygments==2.3.1
2424
pytest==4.3.0
2525
PyYAML==4.2b1
26-
requests==2.21.0
26+
requests==2.24.0
2727
six==1.12.0
2828
smmap2==2.0.5
2929
stevedore==1.30.0
3030
tornado==4.3
31-
urllib3==1.24.2
31+
urllib3==1.25.7
3232
wrapt==1.11.1

setup.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
with open("README.rst", "r") as fh:
44
long_description = fh.read()
5+
56
setuptools.setup(
67
name="moyasar",
7-
version="0.6.5",
8+
version="0.7.0",
89
author="Moyasar",
910
author_email="developers@moyasar.com",
1011
description="Moyasar Python language wrapper",
@@ -24,5 +25,5 @@
2425
'httpretty',
2526
'pytest'
2627
],
27-
download_url='https://github.com/moyasar/moyasar-python/archive/v0.6.1.tar.gz'
28+
download_url="https://github.com/moyasar/moyasar-python/archive/v{0}.tar.gz".format(version)
2829
)

tests/moyasar_test.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
def test_that_it_has_a_version_number():
77
assert moyasar.api_version is not ''
88

9-
109
def test_should_accept_api_key():
1110
moyasar.api_key = 'sk_test_BQokikJOvBiI2HlWgH4olfQ2'
1211
assert moyasar.api_key is not ''

0 commit comments

Comments
 (0)