Skip to content

Commit

Permalink
20180705 deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
securesubmit-buildmaster committed Jul 5, 2018
1 parent ca0a8d7 commit 15b8fc4
Show file tree
Hide file tree
Showing 12 changed files with 133 additions and 20 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ GlobalPayments.Api.egg-info/
__pycache__/

*.pyc
MANIFEST
dist/
1 change: 1 addition & 0 deletions globalpayments/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import api.builders
3 changes: 2 additions & 1 deletion globalpayments/api/builders/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,8 @@ def add_search_criteria(self, key, value):
def __init__(self, transaction_type, entity=None):
TransactionBuilder.__init__(self, transaction_type)
self.entity = entity
self.key = entity.key
if entity is not None:
self.key = entity.key
self.search_criteria = {}

def execute(self, config_name=None):
Expand Down
39 changes: 24 additions & 15 deletions globalpayments/api/gateways/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def process_recurring(self, builder):
self._build_schedule(request, builder.entity,
builder.transaction_type)
elif builder.transaction_type is TransactionType.Search:
for key, value in builder.search_criteria:
for key, value in builder.search_criteria.iteritems():
request[key] = value

response = self.do_transaction(
Expand Down Expand Up @@ -233,9 +233,7 @@ def _map_url(self, builder):

if isinstance(builder.entity, Schedule):
return '{}{}'.format(
'searchSchedules' \
if builder.transaction_type == TransactionType.Search \
else 'schedules',
'searchSchedules' if builder.transaction_type == TransactionType.Search else 'schedules',
suffix
)

Expand Down Expand Up @@ -562,11 +560,19 @@ def _hydrate_schedule(self, response):
return schedule

def _has_token(self, payment_method):
if isinstance(payment_method,
Tokenizable) and payment_method.token is not None:
if self._has_attr(payment_method, 'token') and payment_method.token is not None:
return True, payment_method.token
return False, None

def _has_attr(self, obj, attr):
if not obj:
return False

try:
return getattr(obj, attr)
except AttributeError as _exc:
return False


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

et.SubElement(manual_entry, 'ExpMonth').text = card.exp_month
et.SubElement(manual_entry, 'ExpYear').text = card.exp_year
et.SubElement(manual_entry, 'CVV2').text = card.cvn
if card.exp_month is not None:
et.SubElement(manual_entry, 'ExpMonth').text = card.exp_month
if card.exp_year is not None:
et.SubElement(manual_entry, 'ExpYear').text = card.exp_year
if card.cvn is not None:
et.SubElement(manual_entry, 'CVV2').text = card.cvn

et.SubElement(
manual_entry,
'ReaderPresent').text = 'Y' if card.reader_present else 'N'
et.SubElement(
manual_entry,
'CardPresent').text = 'Y' if card.card_present else 'N'

block1.append(card_data)

if isinstance(card, CreditCardData):
Expand Down Expand Up @@ -1031,11 +1042,11 @@ def process_report(self, builder):

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

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

if builder.transaction_id:
et.SubElement(transaction,
Expand Down Expand Up @@ -1378,10 +1389,8 @@ def _map_report_type(report_type):

raise UnsupportedTransactionException()

@staticmethod
def _has_token(payment_method):
if isinstance(payment_method,
Tokenizable) and payment_method.token is not None:
def _has_token(self, payment_method):
if self._has_attr(payment_method, 'token') and payment_method.token is not None:
return True, payment_method.token

return False, None
Expand Down
11 changes: 9 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,17 @@

setup(
name='GlobalPayments.Api',
version='1.0.0',
version='1.0.1',
author='Heartland Payment Systems',
author_email='[email protected]',
packages=[],
packages=[
'globalpayments', 'globalpayments.api', 'globalpayments.api.builders',
'globalpayments.api.builders.validations',
'globalpayments.api.entities',
'globalpayments.api.entities.table_service',
'globalpayments.api.gateways', 'globalpayments.api.payment_methods',
'globalpayments.api.services', 'globalpayments.api.utils'
],
scripts=[],
url='https://developer.heartlandpaymentsystems.com/',
license='LICENSE.md',
Expand Down
Empty file.
40 changes: 40 additions & 0 deletions tests/integration/gateways/payplan_connector/test_recurring.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
'''
Test Recurring
'''
import datetime
import unittest
from globalpayments.api import ServicesConfig, ServicesContainer
from globalpayments.api.entities import RecurringPaymentMethod


class IntegrationGatewaysPorticoConnectorDebitTests(unittest.TestCase):
'''
Ensure recurring transactions work
'''

config = ServicesConfig()
config.secret_api_key = 'skapi_cert_MaePAQBr-1QAqjfckFC8FTbRTT120bVQUlfVOjgCBw'
config.service_url = 'https://cert.api2.heartlandportico.com'

ServicesContainer.configure(config, 'recurring')

@staticmethod
def payment_id(payment_type):
return '{0}-GlobalApi-{1}'.format(datetime.date.today().isoformat(), payment_type)

def test_check_crypto_gold_standard(self):
gold_config = ServicesConfig()
gold_config.secret_api_key = 'skapi_cert_MTyMAQBiHVEAewvIzXVFcmUd2UcyBge_eCpaASUp0A'
gold_config.service_url = 'https://cert.api2-c.heartlandportico.com'

ServicesContainer.configure(gold_config, 'gold standard')

payment_method = RecurringPaymentMethod.find(self.payment_id('credit'), config_name='gold standard')
self.assertNotEqual(None, payment_method)

response = payment_method.charge(14.01)\
.with_currency('USD')\
.with_allow_duplicates(True)\
.execute('gold standard')
self.assertNotEqual(None, response)
self.assertEqual('00', response.response_code)
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class IntegrationGatewaysPorticoConnectorCertificationEcommerceTests(

ServicesContainer.configure(config, 'ecommerce')

use_tokens = False
use_tokens = True

def test_000_close_batch(self):
try:
Expand Down
15 changes: 15 additions & 0 deletions tests/integration/gateways/portico_connector/test_ach.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,18 @@ def test_check_void_from_transaction_id(self):

self.assertNotEqual(None, void_response)
self.assertEqual('00', void_response.response_code)

def test_check_crypto_gold_standard(self):
gold_config = ServicesConfig()
gold_config.secret_api_key = 'skapi_cert_MTyMAQBiHVEAewvIzXVFcmUd2UcyBge_eCpaASUp0A'
gold_config.service_url = 'https://cert.api2-c.heartlandportico.com'

ServicesContainer.configure(gold_config, 'gold standard')

response = self.check.charge(10)\
.with_currency('USD')\
.with_address(self.address)\
.with_allow_duplicates(True)\
.execute('gold standard')
self.assertNotEqual(None, response);
self.assertEqual('00', response.response_code)
13 changes: 13 additions & 0 deletions tests/integration/gateways/portico_connector/test_credit.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,3 +356,16 @@ def test_credit_void_from_transaction_id(self):

self.assertNotEqual(None, void_response)
self.assertEqual('00', void_response.response_code)

def test_check_crypto_gold_standard(self):
gold_config = ServicesConfig()
gold_config.secret_api_key = 'skapi_cert_MTyMAQBiHVEAewvIzXVFcmUd2UcyBge_eCpaASUp0A'
gold_config.service_url = 'https://cert.api2-c.heartlandportico.com'

ServicesContainer.configure(gold_config, 'gold standard')
response = self.card.authorize(10)\
.with_currency('USD')\
.with_allow_duplicates(True)\
.execute('gold standard')
self.assertNotEqual(None, response)
self.assertEqual('00', response.response_code)
13 changes: 13 additions & 0 deletions tests/integration/gateways/portico_connector/test_debit.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,16 @@ def test_debit_cannot_reverse_from_transaction_id_only(self):
.reverse() \
.with_currency('USD') \
.execute('debit')

def test_check_crypto_gold_standard(self):
gold_config = ServicesConfig()
gold_config.secret_api_key = 'skapi_cert_MaePAQBr-1QAqjfckFC8FTbRTT120bVQUlfVOjgCBw'
gold_config.service_url = 'https://cert.api2-c.heartlandportico.com'

ServicesContainer.configure(gold_config, 'gold standard')
response = self.track.charge(10)\
.with_currency('USD')\
.with_allow_duplicates(True)\
.execute('gold standard')
self.assertNotEqual(None, response)
self.assertEqual('00', response.response_code)
14 changes: 13 additions & 1 deletion tests/integration/gateways/portico_connector/test_reporting.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'''
Test reporting
'''

import datetime
import unittest
from globalpayments.api import ServicesConfig, ServicesContainer
from globalpayments.api.services import ReportingService
Expand Down Expand Up @@ -37,3 +37,15 @@ def test_transaction_detail(self):

self.assertNotEqual(None, response)
self.assertEqual('00', response.gateway_response_code)

def test_check_crypto_gold_standard(self):
gold_config = ServicesConfig()
gold_config.secret_api_key = 'skapi_cert_MTyMAQBiHVEAewvIzXVFcmUd2UcyBge_eCpaASUp0A'
gold_config.service_url = 'https://cert.api2-c.heartlandportico.com'

ServicesContainer.configure(gold_config, 'gold standard')
summary = ReportingService.activity()\
.with_start_date(datetime.datetime.today() + datetime.timedelta(days=-7))\
.with_end_date(datetime.datetime.today() + datetime.timedelta(days=-1))\
.execute('gold standard')
self.assertNotEqual(None, summary)

0 comments on commit 15b8fc4

Please sign in to comment.