Skip to content

Commit 15b8fc4

Browse files
20180705 deployment
1 parent ca0a8d7 commit 15b8fc4

12 files changed

Lines changed: 133 additions & 20 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ GlobalPayments.Api.egg-info/
55
__pycache__/
66

77
*.pyc
8+
MANIFEST
9+
dist/

globalpayments/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import api.builders

globalpayments/api/builders/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,8 @@ def add_search_criteria(self, key, value):
355355
def __init__(self, transaction_type, entity=None):
356356
TransactionBuilder.__init__(self, transaction_type)
357357
self.entity = entity
358-
self.key = entity.key
358+
if entity is not None:
359+
self.key = entity.key
359360
self.search_criteria = {}
360361

361362
def execute(self, config_name=None):

globalpayments/api/gateways/__init__.py

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def process_recurring(self, builder):
135135
self._build_schedule(request, builder.entity,
136136
builder.transaction_type)
137137
elif builder.transaction_type is TransactionType.Search:
138-
for key, value in builder.search_criteria:
138+
for key, value in builder.search_criteria.iteritems():
139139
request[key] = value
140140

141141
response = self.do_transaction(
@@ -233,9 +233,7 @@ def _map_url(self, builder):
233233

234234
if isinstance(builder.entity, Schedule):
235235
return '{}{}'.format(
236-
'searchSchedules' \
237-
if builder.transaction_type == TransactionType.Search \
238-
else 'schedules',
236+
'searchSchedules' if builder.transaction_type == TransactionType.Search else 'schedules',
239237
suffix
240238
)
241239

@@ -562,11 +560,19 @@ def _hydrate_schedule(self, response):
562560
return schedule
563561

564562
def _has_token(self, payment_method):
565-
if isinstance(payment_method,
566-
Tokenizable) and payment_method.token is not None:
563+
if self._has_attr(payment_method, 'token') and payment_method.token is not None:
567564
return True, payment_method.token
568565
return False, None
569566

567+
def _has_attr(self, obj, attr):
568+
if not obj:
569+
return False
570+
571+
try:
572+
return getattr(obj, attr)
573+
except AttributeError as _exc:
574+
return False
575+
570576

571577
class PorticoConnector(XmlGateway):
572578
site_id = None
@@ -708,15 +714,20 @@ def process_authorization(self, builder):
708714
et.SubElement(manual_entry, 'TokenValue' if has_token else
709715
'CardNbr').text = token_value or card.number
710716

711-
et.SubElement(manual_entry, 'ExpMonth').text = card.exp_month
712-
et.SubElement(manual_entry, 'ExpYear').text = card.exp_year
713-
et.SubElement(manual_entry, 'CVV2').text = card.cvn
717+
if card.exp_month is not None:
718+
et.SubElement(manual_entry, 'ExpMonth').text = card.exp_month
719+
if card.exp_year is not None:
720+
et.SubElement(manual_entry, 'ExpYear').text = card.exp_year
721+
if card.cvn is not None:
722+
et.SubElement(manual_entry, 'CVV2').text = card.cvn
723+
714724
et.SubElement(
715725
manual_entry,
716726
'ReaderPresent').text = 'Y' if card.reader_present else 'N'
717727
et.SubElement(
718728
manual_entry,
719729
'CardPresent').text = 'Y' if card.card_present else 'N'
730+
720731
block1.append(card_data)
721732

722733
if isinstance(card, CreditCardData):
@@ -1031,11 +1042,11 @@ def process_report(self, builder):
10311042

10321043
if builder.start_date is not None:
10331044
et.SubElement(transaction,
1034-
'RptStartUtcDT').text = builder.start_date
1045+
'RptStartUtcDT').text = builder.start_date.strftime("%Y-%m-%dT%H:%M:%S.%f")
10351046

10361047
if builder.end_date is not None:
10371048
et.SubElement(transaction,
1038-
'RptEndUtcDT').text = builder.end_date
1049+
'RptEndUtcDT').text = builder.end_date.strftime("%Y-%m-%dT%H:%M:%S.%f")
10391050

10401051
if builder.transaction_id:
10411052
et.SubElement(transaction,
@@ -1378,10 +1389,8 @@ def _map_report_type(report_type):
13781389

13791390
raise UnsupportedTransactionException()
13801391

1381-
@staticmethod
1382-
def _has_token(payment_method):
1383-
if isinstance(payment_method,
1384-
Tokenizable) and payment_method.token is not None:
1392+
def _has_token(self, payment_method):
1393+
if self._has_attr(payment_method, 'token') and payment_method.token is not None:
13851394
return True, payment_method.token
13861395

13871396
return False, None

setup.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,17 @@
66

77
setup(
88
name='GlobalPayments.Api',
9-
version='1.0.0',
9+
version='1.0.1',
1010
author='Heartland Payment Systems',
1111
author_email='EntApp_DevPortal@e-hps.com',
12-
packages=[],
12+
packages=[
13+
'globalpayments', 'globalpayments.api', 'globalpayments.api.builders',
14+
'globalpayments.api.builders.validations',
15+
'globalpayments.api.entities',
16+
'globalpayments.api.entities.table_service',
17+
'globalpayments.api.gateways', 'globalpayments.api.payment_methods',
18+
'globalpayments.api.services', 'globalpayments.api.utils'
19+
],
1320
scripts=[],
1421
url='https://developer.heartlandpaymentsystems.com/',
1522
license='LICENSE.md',

tests/integration/gateways/payplan_connector/__init__.py

Whitespace-only changes.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
'''
2+
Test Recurring
3+
'''
4+
import datetime
5+
import unittest
6+
from globalpayments.api import ServicesConfig, ServicesContainer
7+
from globalpayments.api.entities import RecurringPaymentMethod
8+
9+
10+
class IntegrationGatewaysPorticoConnectorDebitTests(unittest.TestCase):
11+
'''
12+
Ensure recurring transactions work
13+
'''
14+
15+
config = ServicesConfig()
16+
config.secret_api_key = 'skapi_cert_MaePAQBr-1QAqjfckFC8FTbRTT120bVQUlfVOjgCBw'
17+
config.service_url = 'https://cert.api2.heartlandportico.com'
18+
19+
ServicesContainer.configure(config, 'recurring')
20+
21+
@staticmethod
22+
def payment_id(payment_type):
23+
return '{0}-GlobalApi-{1}'.format(datetime.date.today().isoformat(), payment_type)
24+
25+
def test_check_crypto_gold_standard(self):
26+
gold_config = ServicesConfig()
27+
gold_config.secret_api_key = 'skapi_cert_MTyMAQBiHVEAewvIzXVFcmUd2UcyBge_eCpaASUp0A'
28+
gold_config.service_url = 'https://cert.api2-c.heartlandportico.com'
29+
30+
ServicesContainer.configure(gold_config, 'gold standard')
31+
32+
payment_method = RecurringPaymentMethod.find(self.payment_id('credit'), config_name='gold standard')
33+
self.assertNotEqual(None, payment_method)
34+
35+
response = payment_method.charge(14.01)\
36+
.with_currency('USD')\
37+
.with_allow_duplicates(True)\
38+
.execute('gold standard')
39+
self.assertNotEqual(None, response)
40+
self.assertEqual('00', response.response_code)

tests/integration/gateways/portico_connector/certifications/test_ecommerce.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class IntegrationGatewaysPorticoConnectorCertificationEcommerceTests(
3333

3434
ServicesContainer.configure(config, 'ecommerce')
3535

36-
use_tokens = False
36+
use_tokens = True
3737

3838
def test_000_close_batch(self):
3939
try:

tests/integration/gateways/portico_connector/test_ach.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,18 @@ def test_check_void_from_transaction_id(self):
6464

6565
self.assertNotEqual(None, void_response)
6666
self.assertEqual('00', void_response.response_code)
67+
68+
def test_check_crypto_gold_standard(self):
69+
gold_config = ServicesConfig()
70+
gold_config.secret_api_key = 'skapi_cert_MTyMAQBiHVEAewvIzXVFcmUd2UcyBge_eCpaASUp0A'
71+
gold_config.service_url = 'https://cert.api2-c.heartlandportico.com'
72+
73+
ServicesContainer.configure(gold_config, 'gold standard')
74+
75+
response = self.check.charge(10)\
76+
.with_currency('USD')\
77+
.with_address(self.address)\
78+
.with_allow_duplicates(True)\
79+
.execute('gold standard')
80+
self.assertNotEqual(None, response);
81+
self.assertEqual('00', response.response_code)

tests/integration/gateways/portico_connector/test_credit.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,3 +356,16 @@ def test_credit_void_from_transaction_id(self):
356356

357357
self.assertNotEqual(None, void_response)
358358
self.assertEqual('00', void_response.response_code)
359+
360+
def test_check_crypto_gold_standard(self):
361+
gold_config = ServicesConfig()
362+
gold_config.secret_api_key = 'skapi_cert_MTyMAQBiHVEAewvIzXVFcmUd2UcyBge_eCpaASUp0A'
363+
gold_config.service_url = 'https://cert.api2-c.heartlandportico.com'
364+
365+
ServicesContainer.configure(gold_config, 'gold standard')
366+
response = self.card.authorize(10)\
367+
.with_currency('USD')\
368+
.with_allow_duplicates(True)\
369+
.execute('gold standard')
370+
self.assertNotEqual(None, response)
371+
self.assertEqual('00', response.response_code)

0 commit comments

Comments
 (0)