lib/active_merchant/billing/gateways/opp.rb in activemerchant-1.83.0 vs lib/active_merchant/billing/gateways/opp.rb in activemerchant-1.84.0

- old
+ new

@@ -1,114 +1,114 @@ module ActiveMerchant #:nodoc: module Billing #:nodoc: class OppGateway < Gateway - # = Open Payment Platform - # - # The Open Payment Platform includes a powerful omni-channel transaction processing API, - # enabling you to quickly and flexibly build new applications and services on the platform. - # - # This plugin enables connectivity to the Open Payment Platform for activemerchant. - # - # For any questions or comments please contact support@payon.com - # - # == Usage - # - # gateway = ActiveMerchant::Billing::OppGateway.new( - # user_id: 'merchant user id', - # password: 'password', - # entity_id: 'entity id', - # ) - # - # # set up credit card object as in main ActiveMerchant example - # creditcard = ActiveMerchant::Billing::CreditCard.new( - # :type => 'visa', - # :number => '4242424242424242', - # :month => 8, - # :year => 2009, - # :first_name => 'Bob', - # :last_name => 'Bobsen' - # :verification_value: '123') - # - # # Request: complete example, including address, billing address, shipping address - # complete_request_options = { - # order_id: "your merchant/shop order id", # alternative is to set merchantInvoiceId - # merchant_transaction_id: "your merchant/shop transaction id", - # address: address, - # description: 'Store Purchase - Books', - # risk_workflow: false, - # test_mode: 'EXTERNAL' # or 'INTERNAL', valid only for test system - # create_registration: false, # payment details will be stored on the server an latter can be referenced - # - # billing_address: { - # address1: '123 Test Street', - # city: 'Test', - # state: 'TE', - # zip: 'AB12CD', - # country: 'GB', - # }, - # shipping_address: { - # name: 'Muton DeMicelis', - # address1: 'My Street On Upiter, Apt 3.14/2.78', - # city: 'Munich', - # state: 'Bov', - # zip: '81675', - # country: 'DE', - # }, - # customer: { - # merchant_customer_id: "your merchant/customer id", - # givenname: 'Jane', - # surname: 'Jones', - # birth_date: '1965-05-01', - # phone: '(?!?)555-5555', - # mobile: '(?!?)234-23423', - # email: 'jane@jones.com', - # company_name: 'JJ Ltd.', - # identification_doctype: 'PASSPORT', - # identification_docid: 'FakeID2342431234123', - # ip: 101.102.103.104, - # }, - # } - # - # # Request: minimal example - # minimal_request_options = { - # order_id: "your merchant/shop order id", # alternative is to set merchantInvoiceId - # description: 'Store Purchase - Books', - # } - # - # options = - # # run request - # response = gateway.purchase(754, creditcard, options) # charge 7,54 EUR - # - # response.success? # Check whether the transaction was successful - # response.error_code # Retrieve the error message - it's mapped to Gateway::STANDARD_ERROR_CODE - # response.message # Retrieve the message returned by opp - # response.authorization # Retrieve the unique transaction ID returned by opp - # response.params['result']['code'] # Retrieve original return code returned by opp server - # - # == Errors - # If transaction is not successful, response.error_code contains mapped to Gateway::STANDARD_ERROR_CODE error message. - # Complete list of opp error codes can be viewed on https://docs.oppwa.com/ - # Because this list is much bigger than Gateway::STANDARD_ERROR_CODE, only fraction is mapped to Gateway::STANDARD_ERROR_CODE. - # All other codes are mapped as Gateway::STANDARD_ERROR_CODE[:processing_error], so if this is the case, - # you may check the original result code from OPP that can be found in response.params['result']['code'] - # - # == Special features - # For purchase method risk check can be forced when options[:risk_workflow] = true - # This will split (on OPP server side) the transaction into two separate transactions: authorize and capture, - # but capture will be executed only if risk checks are successful. - # - # For testing you may use the test account details listed fixtures.yml under opp. It is important to note that there are two test modes available: - # options[:test_mode]='EXTERNAL' causes test transactions to be forwarded to the processor's test system for 'end-to-end' testing - # options[:test_mode]='INTERNAL' causes transactions to be sent to opp simulators, which is useful when switching to the live endpoint for connectivity testing. - # If no test_mode parameter is sent, test_mode=INTERNAL is the default behaviour. - # - # Billing Address, Shipping Address, Custom Parameters are supported as described under https://docs.oppwa.com/parameters - # See complete example above for details. - # - # == Tokenization - # When create_registration is set to true, the payment details will be stored and a token will be returned in registrationId response field, - # which can subsequently be used to reference the stored payment. + # = Open Payment Platform + # + # The Open Payment Platform includes a powerful omni-channel transaction processing API, + # enabling you to quickly and flexibly build new applications and services on the platform. + # + # This plugin enables connectivity to the Open Payment Platform for activemerchant. + # + # For any questions or comments please contact support@payon.com + # + # == Usage + # + # gateway = ActiveMerchant::Billing::OppGateway.new( + # user_id: 'merchant user id', + # password: 'password', + # entity_id: 'entity id', + # ) + # + # # set up credit card object as in main ActiveMerchant example + # creditcard = ActiveMerchant::Billing::CreditCard.new( + # :type => 'visa', + # :number => '4242424242424242', + # :month => 8, + # :year => 2009, + # :first_name => 'Bob', + # :last_name => 'Bobsen' + # :verification_value: '123') + # + # # Request: complete example, including address, billing address, shipping address + # complete_request_options = { + # order_id: "your merchant/shop order id", # alternative is to set merchantInvoiceId + # merchant_transaction_id: "your merchant/shop transaction id", + # address: address, + # description: 'Store Purchase - Books', + # risk_workflow: false, + # test_mode: 'EXTERNAL' # or 'INTERNAL', valid only for test system + # create_registration: false, # payment details will be stored on the server an latter can be referenced + # + # billing_address: { + # address1: '123 Test Street', + # city: 'Test', + # state: 'TE', + # zip: 'AB12CD', + # country: 'GB', + # }, + # shipping_address: { + # name: 'Muton DeMicelis', + # address1: 'My Street On Upiter, Apt 3.14/2.78', + # city: 'Munich', + # state: 'Bov', + # zip: '81675', + # country: 'DE', + # }, + # customer: { + # merchant_customer_id: "your merchant/customer id", + # givenname: 'Jane', + # surname: 'Jones', + # birth_date: '1965-05-01', + # phone: '(?!?)555-5555', + # mobile: '(?!?)234-23423', + # email: 'jane@jones.com', + # company_name: 'JJ Ltd.', + # identification_doctype: 'PASSPORT', + # identification_docid: 'FakeID2342431234123', + # ip: 101.102.103.104, + # }, + # } + # + # # Request: minimal example + # minimal_request_options = { + # order_id: "your merchant/shop order id", # alternative is to set merchantInvoiceId + # description: 'Store Purchase - Books', + # } + # + # options = + # # run request + # response = gateway.purchase(754, creditcard, options) # charge 7,54 EUR + # + # response.success? # Check whether the transaction was successful + # response.error_code # Retrieve the error message - it's mapped to Gateway::STANDARD_ERROR_CODE + # response.message # Retrieve the message returned by opp + # response.authorization # Retrieve the unique transaction ID returned by opp + # response.params['result']['code'] # Retrieve original return code returned by opp server + # + # == Errors + # If transaction is not successful, response.error_code contains mapped to Gateway::STANDARD_ERROR_CODE error message. + # Complete list of opp error codes can be viewed on https://docs.oppwa.com/ + # Because this list is much bigger than Gateway::STANDARD_ERROR_CODE, only fraction is mapped to Gateway::STANDARD_ERROR_CODE. + # All other codes are mapped as Gateway::STANDARD_ERROR_CODE[:processing_error], so if this is the case, + # you may check the original result code from OPP that can be found in response.params['result']['code'] + # + # == Special features + # For purchase method risk check can be forced when options[:risk_workflow] = true + # This will split (on OPP server side) the transaction into two separate transactions: authorize and capture, + # but capture will be executed only if risk checks are successful. + # + # For testing you may use the test account details listed fixtures.yml under opp. It is important to note that there are two test modes available: + # options[:test_mode]='EXTERNAL' causes test transactions to be forwarded to the processor's test system for 'end-to-end' testing + # options[:test_mode]='INTERNAL' causes transactions to be sent to opp simulators, which is useful when switching to the live endpoint for connectivity testing. + # If no test_mode parameter is sent, test_mode=INTERNAL is the default behaviour. + # + # Billing Address, Shipping Address, Custom Parameters are supported as described under https://docs.oppwa.com/parameters + # See complete example above for details. + # + # == Tokenization + # When create_registration is set to true, the payment details will be stored and a token will be returned in registrationId response field, + # which can subsequently be used to reference the stored payment. self.test_url = 'https://test.oppwa.com/v1/payments' self.live_url = 'https://oppwa.com/v1/payments' self.supported_countries = %w(AD AI AG AR AU AT BS BB BE BZ BM BR BN BG CA HR CY CZ DK DM EE FI FR DE GR GD GY HK HU IS IN IL IT JP LV LI LT LU MY MT MX MC MS NL PA PL PT KN LC MF VC SM SG SK SI ZA ES SR SE CH TR GB US UY) @@ -311,19 +311,17 @@ success, message_from(response), response, authorization: authorization_from(response), test: test?, - error_code: success ? nil : error_code_from(response), + error_code: success ? nil : error_code_from(response) ) end def parse(body) - begin - JSON.parse(body) - rescue JSON::ParserError - json_error(body) - end + JSON.parse(body) + rescue JSON::ParserError + json_error(body) end def json_error(body) message = "Invalid response received #{body.inspect}" { 'result' => {'description' => message, 'code' => 'unknown' } }