def test_010_charge_visa(self): global visa_token card = TestCards.visa_manual() address = Address() address.street_address_1 = '6860 Dallas Pkwy' address.postal_code = '75024' if self.use_tokens: card = CreditCardData() card.token = visa_token response = card.charge(17.01) \ .with_currency('USD') \ .with_address(address) \ .with_invoice_number('123456') \ .with_allow_duplicates(True) \ .execute('ecommerce') self.assertNotEqual(None, response) self.assertEqual('00', response.response_code, response.response_message) void_response = response.void().execute('ecommerce') self.assertNotEqual(None, void_response) self.assertEqual('00', void_response.response_code, void_response.response_message)
def global_create_json(self, **kwargs): _logger.info( 'Beginning global payment form_feedback with post data %s', pprint.pformat(kwargs)) cr, uid, context = request.cr, request.uid, request.context transaction_obj = request.env['payment.transaction'] order = request.website.sale_get_order() tx = request.website.sale_get_transaction() print(order, tx) request.env['payment.acquirer'].configure_client() card = CreditCardData() card.number = kwargs['card-number'] card.exp_month = kwargs['expiry-date-mm'] card.exp_year = kwargs['expiry-date-yy'] card.cvn = kwargs['cvn'] card.card_holder_name = kwargs['cardholder-name'] try: check_verification = card.verify() \ .with_currency(tx.currency_id.name) \ .execute() response = check_verification.response_code print('****', response) card.charge(tx.amount) \ .with_currency(tx.currency_id.name) \ .execute() if tx: # button cliked but no more info -> rewrite on tx or create a new one ? tx.write({ 'acquirer_id': request.env.ref('payment.payment_acquirer_global').id, 'amount': order.amount_total, 'state': 'pending' }) else: tx_id = transaction_obj.sudo().create( { 'acquirer_id': kwargs['acquirer_id'], 'type': 'form', 'amount': order.amount_total, 'currency_id': order.pricelist_id.currency_id.id, 'partner_id': order.partner_id.id, 'partner_country_id': order.partner_id.country_id.id, 'reference': order.name, 'sale_order_id': order.id, 'state': 'done' }, context=context) request.session['sale_transaction_id'] = tx_id # update quotation order.sudo().action_confirm() return request.render('e3k_payment_globalpay.confirm_g_payment', { 'data': kwargs, 'order': tx.sale_order_id }) except GatewayException as e: if int(e.response_code) == 506: _logger.info('Bad Geteway****506****')
class CreditAuthTests(unittest.TestCase): ''' Ensure CreditAuth transaction works ''' config = ServicesConfig() config.secret_api_key = 'skapi_cert_MTeSAQAfG1UA9qQDrzl-kz4toXvARyieptFwSKP24w' config.service_url = 'https://cert.api2.heartlandportico.com' ServicesContainer.configure(config) card = CreditCardData() card.number = '4111111111111111' card.exp_month = '12' card.exp_year = '2025' card.cvn = '123' card.card_holder_name = 'Joe Smith' def test_credit_auth(self): response = self.card.authorize(10) \ .with_currency('USD') \ .with_allow_duplicates(True) \ .execute() self.assertNotEqual(None, response) self.assertEqual('00', response.response_code)
def amex_manual(card_present=False, reader_present=False): data = CreditCardData() data.number = '372700699251018' data.exp_month = '12' data.exp_year = '2025' data.cvn = '1234' data.card_present = card_present data.reader_present = reader_present return data
def mastercard_manual(card_present=False, reader_present=False): data = CreditCardData() data.number = '5473500000000014' data.exp_month = '12' data.exp_year = '2025' data.cvn = '123' data.card_present = card_present data.reader_present = reader_present return data
def mastercard_series2_manual(card_present=False, reader_present=False): data = CreditCardData() data.number = '2223000010005798' data.exp_month = '12' data.exp_year = '2019' data.cvn = '999' data.card_present = card_present data.reader_present = reader_present return data
def discover_manual(card_present=False, reader_present=False): data = CreditCardData() data.number = '6011000990156527' data.exp_month = '12' data.exp_year = '2025' data.cvn = '123' data.card_present = card_present data.reader_present = reader_present return data
def visa_manual(card_present=False, reader_present=False): data = CreditCardData() data.number = '4012002000060016' data.exp_month = '12' data.exp_year = '2025' data.cvn = '123' data.card_present = card_present data.reader_present = reader_present return data
def jcb_manual(card_present=False, reader_present=False): data = CreditCardData() data.number = '3566007770007321' data.exp_month = '12' data.exp_year = '2025' data.cvn = '123' data.card_present = card_present data.reader_present = reader_present return data
def test_002c_edit_payment_method_exp_date_only(self): payment_method = RecurringPaymentMethod(self.customer_id(), self.payment_id('Credit')) payment_method.payment_method = CreditCardData() payment_method.payment_method.card_type = 'MC' payment_method.payment_method.exp_month = '10' payment_method.payment_method.exp_year = '2020' payment_method.payment_method.card_holder_name = 'Philip Marlowe' payment_method.save_changes('realex')
def test_002b_edit_payment_method(self): payment_method = RecurringPaymentMethod(self.customer_id(), self.payment_id('Credit')) payment_method.payment_method = CreditCardData() payment_method.payment_method.number = '5425230000004415' payment_method.payment_method.exp_month = '10' payment_method.payment_method.exp_year = '2020' payment_method.payment_method.card_holder_name = 'Philip Marlowe' payment_method.save_changes('realex')
def test_012_charge_discover(self): global discover_token card = TestCards.discover_manual() address = Address() address.street_address_1 = '6860' address.postal_code = '750241234' if self.use_tokens: card = CreditCardData() card.token = discover_token response = card.charge(17.03) \ .with_currency('USD') \ .with_address(address) \ .with_invoice_number('123456') \ .with_allow_duplicates(True) \ .execute('ecommerce') self.assertNotEqual(None, response) self.assertEqual('00', response.response_code, response.response_message)
class IntegrationGatewaysPorticoConnectorCreditTests(unittest.TestCase): ''' Ensure credit transactions work ''' config = ServicesConfig() config.secret_api_key = 'skapi_cert_MTeSAQAfG1UA9qQDrzl-kz4toXvARyieptFwSKP24w' config.service_url = 'https://cert.api2.heartlandportico.com' config.developer_id = '000000' config.version_number = '0000' ServicesContainer.configure(config) card = CreditCardData() card.number = '4111111111111111' card.exp_month = '12' card.exp_year = '2025' card.cvn = '123' card.card_holder_name = 'Joe Smith' track = CreditTrackData() track.value = '<E1050711%B4012001000000016^VI TEST CREDIT^251200000000000000000000?|LO04K0WFOmdkDz0um+GwUkILL8ZZOP6Zc4rCpZ9+kg2T3JBT4AEOilWTI|+++++++Dbbn04ekG|11;4012001000000016=25120000000000000000?|1u2F/aEhbdoPixyAPGyIDv3gBfF|+++++++Dbbn04ekG|00|||/wECAQECAoFGAgEH2wYcShV78RZwb3NAc2VjdXJlZXhjaGFuZ2UubmV0PX50qfj4dt0lu9oFBESQQNkpoxEVpCW3ZKmoIV3T93zphPS3XKP4+DiVlM8VIOOmAuRrpzxNi0TN/DWXWSjUC8m/PI2dACGdl/hVJ/imfqIs68wYDnp8j0ZfgvM26MlnDbTVRrSx68Nzj2QAgpBCHcaBb/FZm9T7pfMr2Mlh2YcAt6gGG1i2bJgiEJn8IiSDX5M2ybzqRT86PCbKle/XCTwFFe1X|>;' track.encryption_data = EncryptionData() track.encryption_data.version = '01' def test_credit_auth(self): response = self.card.authorize(14) \ .with_currency('USD') \ .with_allow_duplicates(True) \ .execute() self.assertNotEqual(None, response) self.assertEqual('00', response.response_code) capture = response.capture(16).with_gratuity(2).execute() self.assertNotEqual(None, capture) self.assertEqual('00', capture.response_code) def test_credit_auth_with_convenience(self): response = self.card.authorize(14) \ .with_currency('USD') \ .with_allow_duplicates(True) \ .with_convenience_amt(2) \ .execute() self.assertNotEqual(None, response) self.assertEqual('00', response.response_code) def test_credit_auth_with_shipping(self): response = self.card.authorize(14) \ .with_currency('USD') \ .with_allow_duplicates(True) \ .with_shipping_amt(2) \ .execute() self.assertNotEqual(None, response) self.assertEqual('00', response.response_code) def test_credit_sale(self): response = self.card.charge(15) \ .with_currency('USD') \ .with_allow_duplicates(True) \ .execute() self.assertNotEqual(None, response) self.assertEqual('00', response.response_code) def test_credit_sale_with_convenience(self): response = self.card.charge(15) \ .with_currency('USD') \ .with_allow_duplicates(True) \ .with_convenience_amt(2) \ .execute() self.assertNotEqual(None, response) self.assertEqual('00', response.response_code) def test_credit_sale_with_shipping(self): response = self.card.charge(15) \ .with_currency('USD') \ .with_allow_duplicates(True) \ .with_shipping_amt(2) \ .execute() self.assertNotEqual(None, response) self.assertEqual('00', response.response_code) def test_credit_offline_auth(self): response = self.card.authorize(16) \ .with_currency('USD') \ .with_offline_auth_code('123456') \ .with_allow_duplicates(True) \ .execute() self.assertNotEqual(None, response) self.assertEqual('00', response.response_code) def test_credit_offline_auth_with_convenience(self): response = self.card.authorize(16) \ .with_currency('USD') \ .with_offline_auth_code('123456') \ .with_allow_duplicates(True) \ .with_convenience_amt(2) \ .execute() self.assertNotEqual(None, response) self.assertEqual('00', response.response_code) def test_credit_offline_auth_with_shipping(self): response = self.card.authorize(16) \ .with_currency('USD') \ .with_offline_auth_code('123456') \ .with_allow_duplicates(True) \ .with_shipping_amt(2) \ .execute() self.assertNotEqual(None, response) self.assertEqual('00', response.response_code) def test_credit_offline_sale(self): response = self.card.charge(17) \ .with_currency('USD') \ .with_offline_auth_code('123456') \ .with_allow_duplicates(True) \ .execute() self.assertNotEqual(None, response) self.assertEqual('00', response.response_code) def test_credit_offline_sale_with_convenience(self): response = self.card.charge(17) \ .with_currency('USD') \ .with_offline_auth_code('123456') \ .with_allow_duplicates(True) \ .with_convenience_amt(2) \ .execute() self.assertNotEqual(None, response) self.assertEqual('00', response.response_code) def test_credit_offline_sale_with_shipping(self): response = self.card.charge(17) \ .with_currency('USD') \ .with_offline_auth_code('123456') \ .with_allow_duplicates(True) \ .with_shipping_amt(2) \ .execute() self.assertNotEqual(None, response) self.assertEqual('00', response.response_code) def test_credit_refund(self): response = self.card.refund(16) \ .with_currency('USD') \ .with_allow_duplicates(True) \ .execute() self.assertNotEqual(None, response) self.assertEqual('00', response.response_code) def test_credit_reverse(self): response = self.card.reverse(15) \ .with_allow_duplicates(True) \ .execute() self.assertNotEqual(None, response) self.assertEqual('00', response.response_code) def test_credit_swipe_auth(self): response = self.track.authorize(14) \ .with_currency('USD') \ .with_allow_duplicates(True) \ .execute() self.assertNotEqual(None, response) self.assertEqual('00', response.response_code) capture = response.capture(16).with_gratuity(2).execute() self.assertNotEqual(None, capture) self.assertEqual('00', capture.response_code) def test_credit_swipe_auth_with_convenience(self): response = self.track.authorize(14) \ .with_currency('USD') \ .with_allow_duplicates(True) \ .with_convenience_amt(2) \ .execute() self.assertNotEqual(None, response) self.assertEqual('00', response.response_code) def test_credit_swipe_auth_with_shipping(self): response = self.track.authorize(14) \ .with_currency('USD') \ .with_allow_duplicates(True) \ .with_shipping_amt(2) \ .execute() self.assertNotEqual(None, response) self.assertEqual('00', response.response_code) def test_credit_swipe_sale(self): response = self.track.charge(15) \ .with_currency('USD') \ .with_allow_duplicates(True) \ .execute() self.assertNotEqual(None, response) self.assertEqual('00', response.response_code) def test_credit_swipe_sale_with_convenience(self): response = self.track.charge(15) \ .with_currency('USD') \ .with_allow_duplicates(True) \ .with_convenience_amt(2) \ .execute() self.assertNotEqual(None, response) self.assertEqual('00', response.response_code) def test_credit_swipe_sale_with_shipping(self): response = self.track.charge(15) \ .with_currency('USD') \ .with_allow_duplicates(True) \ .with_shipping_amt(2) \ .execute() self.assertNotEqual(None, response) self.assertEqual('00', response.response_code) def test_credit_swipe_offline_auth(self): response = self.track.authorize(16) \ .with_currency('USD') \ .with_offline_auth_code('123456') \ .with_allow_duplicates(True) \ .execute() self.assertNotEqual(None, response) self.assertEqual('00', response.response_code) def test_credit_swipe_offline_auth_with_convenience(self): response = self.track.authorize(16) \ .with_currency('USD') \ .with_offline_auth_code('123456') \ .with_allow_duplicates(True) \ .with_convenience_amt(2) \ .execute() self.assertNotEqual(None, response) self.assertEqual('00', response.response_code) def test_credit_swipe_offline_auth_with_shipping(self): response = self.track.authorize(16) \ .with_currency('USD') \ .with_offline_auth_code('123456') \ .with_allow_duplicates(True) \ .with_shipping_amt(2) \ .execute() self.assertNotEqual(None, response) self.assertEqual('00', response.response_code) def test_credit_swipe_offline_sale(self): response = self.track.charge(17) \ .with_currency('USD') \ .with_offline_auth_code('123456') \ .with_allow_duplicates(True) \ .execute() self.assertNotEqual(None, response) self.assertEqual('00', response.response_code) def test_credit_swipe_offline_sale_with_convenience(self): response = self.track.charge(17) \ .with_currency('USD') \ .with_offline_auth_code('123456') \ .with_allow_duplicates(True) \ .with_convenience_amt(2) \ .execute() self.assertNotEqual(None, response) self.assertEqual('00', response.response_code) def test_credit_swipe_offline_sale_with_shipping(self): response = self.track.charge(17) \ .with_currency('USD') \ .with_offline_auth_code('123456') \ .with_allow_duplicates(True) \ .with_shipping_amt(2) \ .execute() self.assertNotEqual(None, response) self.assertEqual('00', response.response_code) def test_credit_swipe_balance_inquiry(self): response = self.track.balance_inquiry().execute() self.assertNotEqual(None, response) self.assertEqual('00', response.response_code) def test_credit_swipe_refund(self): response = self.track.refund(16) \ .with_currency('USD') \ .with_allow_duplicates(True) \ .execute() self.assertNotEqual(None, response) self.assertEqual('00', response.response_code) def test_credit_swipe_reverse(self): response = self.track.charge(19) \ .with_currency('USD') \ .with_allow_duplicates(True) \ .execute() self.assertNotEqual(None, response) self.assertEqual('00', response.response_code) reverse_response = self.track.reverse(15) \ .with_allow_duplicates(True) \ .execute() self.assertNotEqual(None, reverse_response) self.assertEqual('00', reverse_response.response_code) def test_credit_swipe_verify(self): response = self.track.verify() \ .with_allow_duplicates(True) \ .execute() self.assertNotEqual(None, response) self.assertEqual('00', response.response_code) def test_credit_void_from_transaction_id(self): response = self.card.authorize(10) \ .with_currency('USD') \ .with_allow_duplicates(True) \ .execute() self.assertNotEqual(None, response) self.assertEqual('00', response.response_code) void_response = Transaction.from_id(response.transaction_id) \ .void() \ .execute() 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)
class IntegrationGatewaysPorticoConnectorEbtTests(unittest.TestCase): ''' Ensure ecommerce transactions work ''' config = ServicesConfig() config.secret_api_key = 'skapi_cert_MTyMAQBiHVEAewvIzXVFcmUd2UcyBge_eCpaASUp0A' config.service_url = 'https://cert.api2.heartlandportico.com' ServicesContainer.configure(config, 'ecommerce') card = CreditCardData() card.number = '4012002000060016' card.exp_month = '12' card.exp_year = '2025' card.cvn = '123' def test_ecom_with_moto(self): ecom = ECommerceInfo() ecom.channel = ECommerceChannel.MOTO response = self.card.charge(9) \ .with_currency('USD') \ .with_ecommerce_info(ecom) \ .with_allow_duplicates(True) \ .execute('ecommerce') self.assertNotEqual(None, response) self.assertEqual('00', response.response_code) def test_ecom_with_direct_market_ship_date(self): ecom = ECommerceInfo() ecom.channel = ECommerceChannel.ECOM ecom.ship_day = '25' ecom.ship_month = '12' response = self.card.charge(9) \ .with_currency('USD') \ .with_ecommerce_info(ecom) \ .with_allow_duplicates(True) \ .execute('ecommerce') self.assertNotEqual(None, response) self.assertEqual('00', response.response_code) def test_ecom_with_direct_market_invoice_no_ship_date(self): response = self.card.charge(9) \ .with_currency('USD') \ .with_ecommerce_info(ECommerceInfo()) \ .with_invoice_number('1234567890') \ .with_allow_duplicates(True) \ .execute('ecommerce') self.assertNotEqual(None, response) self.assertEqual('00', response.response_code) def test_ecom_with_direct_market_invoice_and_ship_date(self): ecom = ECommerceInfo() ecom.channel = ECommerceChannel.ECOM ecom.ship_month = '25' ecom.ship_month = '12' response = self.card.charge(9) \ .with_currency('USD') \ .with_ecommerce_info(ecom) \ .with_invoice_number('1234567890') \ .with_allow_duplicates(True) \ .execute('ecommerce') self.assertNotEqual(None, response) self.assertEqual('00', response.response_code) def test_ecom_with_secure_ecommerce(self): ecom = ECommerceInfo() ecom.channel = ECommerceChannel.ECOM ecom.payment_data_source = 'ApplePay' ecom.cavv = 'XXXXf98AAajXbDRg3HSUMAACAAA=' ecom.eci = '5' response = self.card.charge(9) \ .with_currency('USD') \ .with_ecommerce_info(ecom) \ .with_allow_duplicates(True) \ .execute('ecommerce') self.assertNotEqual(None, response) self.assertEqual('00', response.response_code)
def gsb_manual(): data = CreditCardData() data.number = '6277220572999800' data.exp_month = '12' data.exp_year = '2049' return data
class AuthorizationBuilderValidationTests(unittest.TestCase): ''' Ensure AuthorizationBuilder validations work ''' config = ServicesConfig() config.secret_api_key = 'skapi_cert_MTeSAQAfG1UA9qQDrzl-kz4toXvARyieptFwSKP24w' config.service_url = 'https://cert.api2.heartlandportico.com' ServicesContainer.configure(config) card = CreditCardData() card.number = '4111111111111111' card.exp_month = '12' card.exp_year = '2025' card.cvn = '123' card.card_holder_name = 'Joe Smith' def test_credit_auth_no_amount(self): with self.assertRaises(BuilderException): self.card.authorize().execute() def test_credit_auth_no_currency(self): with self.assertRaises(BuilderException): self.card.authorize(14).execute() def test_credit_auth_no_payment_method(self): with self.assertRaises(BuilderException): self.card.authorize(14) \ .with_currency('USD') \ .with_payment_method(None) \ .execute() def test_credit_auth_no_validation_error(self): try: self.card.authorize(14) \ .with_currency('USD') \ .with_allow_duplicates(True) \ .execute() except BuilderException: self.fail( 'Properly configured auth builder should not raise exception') def test_credit_sale_no_amount(self): with self.assertRaises(BuilderException): self.card.charge().execute() def test_credit_sale_no_currency(self): with self.assertRaises(BuilderException): self.card.charge(14).execute() def test_credit_sale_no_payment_method(self): with self.assertRaises(BuilderException): self.card.charge(14) \ .with_currency('USD') \ .with_payment_method(None) \ .execute() def test_credit_offline_no_amount(self): with self.assertRaises(BuilderException): self.card.authorize() \ .with_offline_auth_code('12345') \ .execute() def test_credit_offline_no_currency(self): with self.assertRaises(BuilderException): self.card.authorize(14) \ .with_offline_auth_code('12345') \ .execute() def test_credit_offline_no_auth_code(self): with self.assertRaises(BuilderException): self.card.authorize(14) \ .with_currency('USD') \ .with_offline_auth_code(None) \ .execute()
class IntegrationGatewaysRealexConnectorRecurringTests(unittest.TestCase): ''' Ensure Recurring transactions works ''' config = ServicesConfig() config.merchant_id = 'heartlandgpsandbox' config.account_id = 'api' config.shared_secret = 'secret' config.rebate_password = '******' config.refund_password = '******' config.service_url = 'https://api.sandbox.realexpayments.com/epage-remote.cgi' ServicesContainer.configure(config, "realex") card = CreditCardData() card.number = '4263970000005262' card.exp_month = '05' card.exp_year = '2019' card.cvn = '123' card.card_holder_name = 'James Mason' new_customer = Customer() new_customer.key = '{}-Realex'.format(datetime.now().strftime('%Y%m%d')) new_customer.title = 'Mr.' new_customer.first_name = 'James' new_customer.last_name = 'Mason' new_customer.company = 'Realex Payments' new_customer.address = Address() new_customer.address.street_address_1 = 'Flat 123' new_customer.address.street_address_2 = 'House 456' new_customer.address.street_address_3 = 'The Cul-De-Sac' new_customer.address.city = 'Halifax' new_customer.address.province = 'West Yorkshire' new_customer.address.postal_code = 'W6 9HR' new_customer.address.country = 'United Kingdom' new_customer.home_phone = '+35312345678' new_customer.work_phone = '+3531987654321' new_customer.fax = '+24546871258' new_customer.mobile_phone = '+25544778544' new_customer.email = '*****@*****.**' new_customer.comments = 'Campaign Ref E7373G' def customer_id(self): return '{}-Realex'.format(datetime.now().strftime('%Y%m%d')) def payment_id(self, t): return '{}-Realex-{}'.format(datetime.now().strftime('%Y%m%d'), t) def test_001a_create_customer(self): try: customer = self.new_customer.create('realex') self.assertNotEqual(None, customer) except GatewayException as exc: if int(exc.response_code) != 501: raise exc def test_001b_create_payment_method(self): try: payment_method = self.new_customer.add_payment_method( self.payment_id('credit'), self.card).create('realex') self.assertNotEqual(None, payment_method) except GatewayException as exc: if int(exc.response_code) != 520: raise exc def test_002a_edit_customer(self): customer = Customer() customer.key = self.customer_id() customer.first_name = 'Perry' customer.save_changes('realex') def test_002b_edit_payment_method(self): payment_method = RecurringPaymentMethod(self.customer_id(), self.payment_id('Credit')) payment_method.payment_method = CreditCardData() payment_method.payment_method.number = '5425230000004415' payment_method.payment_method.exp_month = '10' payment_method.payment_method.exp_year = '2020' payment_method.payment_method.card_holder_name = 'Philip Marlowe' payment_method.save_changes('realex') def test_002c_edit_payment_method_exp_date_only(self): payment_method = RecurringPaymentMethod(self.customer_id(), self.payment_id('Credit')) payment_method.payment_method = CreditCardData() payment_method.payment_method.card_type = 'MC' payment_method.payment_method.exp_month = '10' payment_method.payment_method.exp_year = '2020' payment_method.payment_method.card_holder_name = 'Philip Marlowe' payment_method.save_changes('realex') def test_003_find_customer_throws_exception(self): with self.assertRaises(UnsupportedTransactionException): Customer.find(self.customer_id(), 'realex') def test_004a_charge_stored_card(self): payment_method = RecurringPaymentMethod(self.customer_id(), self.payment_id('Credit')) response = payment_method.charge(10) \ .with_currency('USD') \ .with_cvn('123') \ .execute('realex') self.assertNotEqual(None, response) self.assertEqual('00', response.response_code, response.response_message) def test_004b_verify_stored_card(self): payment_method = RecurringPaymentMethod(self.customer_id(), self.payment_id('Credit')) response = payment_method.verify() \ .with_cvn('123') \ .execute('realex') self.assertNotEqual(None, response) self.assertEqual('00', response.response_code, response.response_message) def test_004c_refund_stored_card(self): payment_method = RecurringPaymentMethod(self.customer_id(), self.payment_id('Credit')) response = payment_method.refund(10.01) \ .with_currency('USD') \ .execute('realex') self.assertNotEqual(None, response) self.assertEqual('00', response.response_code, response.response_message) def test_005_recurring_payment(self): payment_method = RecurringPaymentMethod(self.customer_id(), self.payment_id('Credit')) response = payment_method.charge(12) \ .with_currency('USD') \ .with_recurring_info(RecurringType.Fixed, RecurringSequence.First) \ .execute('realex') self.assertNotEqual(None, response) self.assertEqual('00', response.response_code, response.response_message) def test_006_delete_payment_method(self): payment_method = RecurringPaymentMethod(self.customer_id(), self.payment_id('Credit')) payment_method.delete(config_name='realex')
class IntegrationGatewaysRealexConnectorCreditTests(unittest.TestCase): ''' Ensure Credit transactions works ''' config = ServicesConfig() config.merchant_id = 'heartlandgpsandbox' config.account_id = 'api' config.shared_secret = 'secret' config.rebate_password = '******' config.refund_password = '******' config.service_url = 'https://api.sandbox.realexpayments.com/epage-remote.cgi' ServicesContainer.configure(config, "realex") card = CreditCardData() card.number = '4111111111111111' card.exp_month = '12' card.exp_year = '2025' card.cvn = '123' card.card_holder_name = 'Joe Smith' def test_credit_authorization(self): response = self.card.authorize(14) \ .with_currency('USD') \ .with_allow_duplicates(True) \ .execute("realex") self.assertNotEqual(None, response) self.assertEqual('00', response.response_code) capture = response.capture(14).execute("realex") self.assertNotEqual(None, capture) self.assertEqual('00', capture.response_code) def test_credit_sale(self): response = self.card.charge(15) \ .with_currency('USD') \ .with_allow_duplicates(True) \ .execute("realex") self.assertNotEqual(None, response) self.assertEqual('00', response.response_code) def test_credit_sale_with_recurring(self): response = self.card.charge(15) \ .with_currency('USD') \ .with_recurring_info(RecurringType.Fixed, RecurringSequence.First) \ .with_allow_duplicates(True) \ .execute("realex") self.assertNotEqual(None, response) self.assertEqual('00', response.response_code) def test_credit_refund(self): response = self.card.refund(16) \ .with_currency('USD') \ .with_allow_duplicates(True) \ .execute("realex") self.assertNotEqual(None, response) self.assertEqual('00', response.response_code) def test_credit_rebate(self): response = self.card.charge(17) \ .with_currency('USD') \ .with_allow_duplicates(True) \ .execute("realex") self.assertNotEqual(None, response) self.assertEqual('00', response.response_code) rebate = response.refund(17) \ .with_currency('USD') \ .execute("realex") self.assertNotEqual(None, rebate) self.assertEqual('00', rebate.response_code) def test_credit_void(self): response = self.card.charge(15) \ .with_currency('USD') \ .with_allow_duplicates(True) \ .execute("realex") self.assertNotEqual(None, response) self.assertEqual('00', response.response_code) void_response = response.void().execute("realex") self.assertNotEqual(None, void_response) self.assertEqual('00', void_response.response_code) def test_credit_verify(self): response = self.card.verify() \ .with_allow_duplicates(True) \ .execute("realex") self.assertNotEqual(None, response) self.assertEqual('00', response.response_code) def test_credit_fraud_response(self): billing_address = Address() billing_address.street_address_1 = 'Flat 123' billing_address.street_address_2 = 'House 456' billing_address.street_address_3 = 'Cul-De-Sac' billing_address.city = 'Halifax' billing_address.province = 'West Yorkshire' billing_address.state = 'Yorkshire and the Humber' billing_address.country = 'GB' billing_address.postal_code = 'E77 4QJ' shipping_address = Address() shipping_address.street_address_1 = 'House 456' shipping_address.street_address_2 = '987 The Street' shipping_address.street_address_3 = 'Basement Flat' shipping_address.city = 'Chicago' shipping_address.state = 'Illinois' shipping_address.province = 'Mid West' shipping_address.country = 'US' shipping_address.postal_code = '5001' response = self.card.charge(199.99) \ .with_currency('EUR') \ .with_address(billing_address, AddressType.Billing) \ .with_address(shipping_address, AddressType.Shipping) \ .with_product_id('SID9838383') \ .with_client_transaction_id('Car Part HV') \ .with_customer_id('E8953893489') \ .with_customer_ip_address('123.123.123.123') \ .execute("realex") self.assertNotEqual(None, response) self.assertEqual('00', response.response_code)