lib/active_merchant/billing/gateways/opp.rb in activemerchant-1.106.0 vs lib/active_merchant/billing/gateways/opp.rb in activemerchant-1.107.1
- old
+ new
@@ -11,12 +11,11 @@
# For any questions or comments please contact support@payon.com
#
# == Usage
#
# gateway = ActiveMerchant::Billing::OppGateway.new(
- # user_id: 'merchant user id',
- # password: 'password',
+ # access_token: 'access_token',
# entity_id: 'entity id',
# )
#
# # set up credit card object as in main ActiveMerchant example
# creditcard = ActiveMerchant::Billing::CreditCard.new(
@@ -117,11 +116,11 @@
self.homepage_url = 'https://docs.oppwa.com'
self.display_name = 'Open Payment Platform'
def initialize(options={})
- requires!(options, :user_id, :password, :entity_id)
+ requires!(options, :access_token, :entity_id)
super
end
def purchase(money, payment, options={})
# debit
@@ -165,11 +164,11 @@
true
end
def scrub(transcript)
transcript.
- gsub(%r((authentication\.password=)\w+), '\1[FILTERED]').
+ gsub(%r((Authorization: Bearer )\w+)i, '\1[FILTERED]').
gsub(%r((card\.number=)\d+), '\1[FILTERED]').
gsub(%r((card\.cvv=)\d+), '\1[FILTERED]')
end
private
@@ -201,11 +200,11 @@
add_invoice(post, money, options)
commit(post, authorization, options)
end
def add_authentication(post)
- post[:authentication] = { entityId: @options[:entity_id], password: @options[:password], userId: @options[:user_id]}
+ post[:authentication] = { entityId: @options[:entity_id] }
end
def add_customer_data(post, payment, options)
if options[:customer]
post[:customer] = {
@@ -314,11 +313,11 @@
begin
parse(
ssl_post(
url,
post.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&'),
- 'Content-Type' => 'application/x-www-form-urlencoded;charset=UTF-8'
+ headers
)
)
rescue ResponseError => e
parse(e.response.body)
end
@@ -331,9 +330,16 @@
response,
authorization: authorization_from(response),
test: test?,
error_code: success ? nil : error_code_from(response)
)
+ end
+
+ def headers
+ {
+ 'Content-Type' => 'application/x-www-form-urlencoded;charset=UTF-8',
+ 'Authorization' => "Bearer #{@options[:access_token]}"
+ }
end
def parse(body)
JSON.parse(body)
rescue JSON::ParserError