Skip to content

Commit

Permalink
Merge pull request #9 from 2Checkout/CC-209
Browse files Browse the repository at this point in the history
Cc 209
  • Loading branch information
craigchristenson authored May 12, 2020
2 parents 26f62bc + 67216dd commit a32a96f
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 223 deletions.
24 changes: 11 additions & 13 deletions lib/twocheckout.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
require "twocheckout/version"
require "twocheckout/api"
require "twocheckout/hash_object"
require "twocheckout/validate_response"
require "twocheckout/company"
require "twocheckout/lineitem"
require "twocheckout/invoice"
require "twocheckout/sale"
require "twocheckout/coupon"
require "twocheckout/product"
require "twocheckout/option"
require "twocheckout/checkout"
require "twocheckout/twocheckout_error"
require 'twocheckout/version'
require 'twocheckout/api'
require 'twocheckout/hash_object'
require 'twocheckout/validate_response'
require 'twocheckout/company'
require 'twocheckout/lineitem'
require 'twocheckout/invoice'
require 'twocheckout/sale'
require 'twocheckout/product'
require 'twocheckout/checkout'
require 'twocheckout/twocheckout_error'
8 changes: 3 additions & 5 deletions lib/twocheckout/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@

module Twocheckout
class API
PROD_BASE = 'https://www.2checkout.com'
SANDBOX_BASE = 'https://sandbox.2checkout.com'
API_VERSION = '1'
PROD_BASE = 'https://www.2checkout.com'.freeze
API_VERSION = '1'.freeze

def self.credentials=(opts)
@username = opts[:username]
@password = opts[:password]
@private_key = opts[:private_key]
@seller_id = opts[:seller_id]
@sandbox = opts[:sandbox]
end

def self.request(http_method, api_call, params = nil)
Expand All @@ -33,7 +31,7 @@ def self.request(http_method, api_call, params = nil)
private

def self.set_opts(http_method, api_call, params = null)
url = @sandbox ? SANDBOX_BASE : PROD_BASE
url = PROD_BASE
if api_call == 'authService'
url += '/checkout/api/' + API_VERSION + '/' + @seller_id + '/rs/' + api_call
params['sellerId'] = @seller_id
Expand Down
4 changes: 0 additions & 4 deletions lib/twocheckout/checkout.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ class Checkout < HashObject

@checkout_url = 'https://www.2checkout.com/checkout/purchase'

def self.sandbox(sandbox)
@checkout_url = sandbox ? 'https://sandbox.2checkout.com/checkout/purchase' : @checkout_url;
end

def self.form(params={}, button_text='Proceed to Checkout')
@form = "<form id=\"2checkout\" action=\"#{@checkout_url}\" method=\"post\">\n";
params.each do |k,v|
Expand Down
41 changes: 0 additions & 41 deletions lib/twocheckout/coupon.rb

This file was deleted.

57 changes: 0 additions & 57 deletions lib/twocheckout/option.rb

This file was deleted.

7 changes: 0 additions & 7 deletions lib/twocheckout/sale.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,6 @@ def ship(opts)
Twocheckout::API.request(:post, 'sales/mark_shipped', opts)
end

#
# Reauthorize sale
#
def reauth
Twocheckout::API.request(:post, 'sales/reauth', sale_id: self.sale_id)
end

#
# Get sale list in an array
#
Expand Down
2 changes: 1 addition & 1 deletion lib/twocheckout/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Twocheckout
VERSION = "0.4.0"
VERSION = '0.5.0'.freeze
end
13 changes: 5 additions & 8 deletions test/minitest_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@
require "twocheckout"

Twocheckout::API.credentials = {
:username => 'testlibraryapi901248204',
:password => 'testlibraryapi901248204PASS',
:seller_id => '901248204',
:private_key => 'BE632CB0-BB29-11E3-AFB6-D99C28100996',
:sandbox => true
}

Twocheckout::Checkout.sandbox(true);
:username => 'CREDENTIALS HERE',
:password => 'CREDENTIALS HERE',
:seller_id => 'CREDENTIALS HERE',
:private_key => 'CREDENTIALS HERE',
}
Loading

0 comments on commit a32a96f

Please sign in to comment.