paymentonline 0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +26 -0
- data/README +5 -0
- data/bin/example.rb +89 -0
- data/lib/paymentonline.rb +52 -0
- metadata +42 -0
data/LICENSE
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# Copyright (c) 2005, Payment Online Inc
|
2
|
+
# All rights reserved.
|
3
|
+
|
4
|
+
# Redistribution and use in source and binary forms, with or without
|
5
|
+
# modification, are permitted provided that the following conditions are met:
|
6
|
+
#
|
7
|
+
# * Redistributions of source code must retain the above copyright notice,
|
8
|
+
# this list of conditions and the following disclaimer.
|
9
|
+
# * Redistributions in binary form must reproduce the above copyright notice,
|
10
|
+
# this list of conditions and the following disclaimer in the
|
11
|
+
# documentation and/or other materials provided with the distribution.
|
12
|
+
# * Neither the name of Payment Online nor the names of its contributors
|
13
|
+
# may be used to endorse or promote products derived from this software
|
14
|
+
# without specific prior written permission.
|
15
|
+
#
|
16
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
17
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
18
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
19
|
+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
20
|
+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
21
|
+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
22
|
+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
23
|
+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
24
|
+
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
25
|
+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
26
|
+
|
data/README
ADDED
data/bin/example.rb
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'paymentonline'
|
5
|
+
|
6
|
+
include PaymentOnline
|
7
|
+
|
8
|
+
# Payment.new takes two hashes as arguments. The first has just one valid value which is the debug flag. The second hash
|
9
|
+
# is uses to pass the Direct Connect API fields and values. Please see the Direct Connect API documentation for details.
|
10
|
+
|
11
|
+
s = Payment.new({'debug' => true},
|
12
|
+
{'mer_id' => '23498237HDBE8',
|
13
|
+
'site_id' => '12345',
|
14
|
+
'trans_type' => 'SALE',
|
15
|
+
'response_api' => 'text_1',
|
16
|
+
'card_exp_mon' => '10',
|
17
|
+
'card_exp_yr' => '02',
|
18
|
+
'card_num' => '5454545454545454',
|
19
|
+
'cvv_value' => '111',
|
20
|
+
'cust_email' => 'orders@mydomain.com',
|
21
|
+
'cust_firstname' => 'Test',
|
22
|
+
'cust_lastname' => 'Customer',
|
23
|
+
'cust_address' => '1234 abc street',
|
24
|
+
'cust_address2' => '',
|
25
|
+
'cust_city' => 'Kirkland',
|
26
|
+
'cust_state' => 'WA',
|
27
|
+
'cust_zip' => '98034',
|
28
|
+
'cust_phone' => nil,
|
29
|
+
'cust_country' => 'US',
|
30
|
+
'cust_username' => nil,
|
31
|
+
'cust_password' => nil,
|
32
|
+
'ship_firstname' => 'Test',
|
33
|
+
'ship_lastname' => 'Customer',
|
34
|
+
'ship_address' => '4321 cba ave',
|
35
|
+
'ship_address2' => nil,
|
36
|
+
'ship_city' => 'Redmond',
|
37
|
+
'ship_state' => 'WA',
|
38
|
+
'ship_zip' => '87654',
|
39
|
+
'ship_country' => 'US',
|
40
|
+
'separate_shipping' => '1',
|
41
|
+
'shipping_charge' => nil,
|
42
|
+
'tax_charge' => nil,
|
43
|
+
'cust_receipt' => 1,
|
44
|
+
'membership_system' => '1',
|
45
|
+
'www_post' => nil,
|
46
|
+
'username' => nil,
|
47
|
+
'password' => nil,
|
48
|
+
'prepaid' => nil,
|
49
|
+
'custom_var1' => nil,
|
50
|
+
'custom_var2' => nil,
|
51
|
+
'custom_var3' => nil,
|
52
|
+
'custom_var4' => nil,
|
53
|
+
'custom_var5' => nil,
|
54
|
+
'custom_var6' => nil})
|
55
|
+
|
56
|
+
# Create a hash for each item being ordered as follows. Items fields which are not used should be passed as nil.
|
57
|
+
item1 = {'item_sku' => 'test1',
|
58
|
+
'item_desc' => 'test1 descript',
|
59
|
+
'item_type' => 'SUB',
|
60
|
+
'item_price' => '1.00',
|
61
|
+
'quantity' => 1,
|
62
|
+
'recur_bill_amount' => '2.00',
|
63
|
+
'bill_cycle' => '1 month',
|
64
|
+
'num_cycles' => 500,
|
65
|
+
'prorate_first_billing' => 0,
|
66
|
+
'first_billing_date' => nil,
|
67
|
+
'recur_bill_day' => nil}
|
68
|
+
|
69
|
+
item2 = item1.clone
|
70
|
+
item2['item_sku'] = 'test2'
|
71
|
+
|
72
|
+
# call additem to add the item to the order
|
73
|
+
s.additem(item1)
|
74
|
+
s.additem(item2)
|
75
|
+
|
76
|
+
# Submit the order for processing
|
77
|
+
code,message,r = s.submit
|
78
|
+
|
79
|
+
# Print out the response
|
80
|
+
puts "HTTP CODE: #{code}"
|
81
|
+
puts "HTTP RESPONSE: #{message}"
|
82
|
+
puts "Payment response code: #{r['response_code']}"
|
83
|
+
puts "Payment response: #{r['response']}"
|
84
|
+
puts "Payment response text: #{r['response_text']}"
|
85
|
+
puts "Payment order id: #{r['order_id']}"
|
86
|
+
puts "Payment transaction id: #{r['trans_id']}"
|
87
|
+
puts "Payment transaction amount: #{r['trans_amount']}"
|
88
|
+
puts "Payment authorization code: #{r['auth_code']}"
|
89
|
+
puts "Payment avs result: #{r['avs_result']}"
|
@@ -0,0 +1,52 @@
|
|
1
|
+
|
2
|
+
require 'net/https'
|
3
|
+
require 'cgi'
|
4
|
+
|
5
|
+
module PaymentOnline
|
6
|
+
|
7
|
+
class Payment
|
8
|
+
|
9
|
+
FIELDS = ['card_exp_mon','card_exp_yr','card_num','cust_address','cust_address2','cust_city','cust_country','cust_email','cust_firstname','cust_lastname','cust_username','cust_password','cust_phone','cust_receipt','cust_state','cust_zip','custom_var1','custom_var2','cvv_value','membership_system','mer_id','password','prepaid','response_api','separate_shipping','ship_address','ship_address2','ship_city','ship_country','ship_firstname','ship_lastname','ship_state','ship_zip','shipping_charge','site_id','tax_charge','trans_type','username','www_post','custom_var1','custom_var2','custom_var3','custom_var4','custom_var5','custom_var6']
|
10
|
+
|
11
|
+
ITEMFIELDS = ['item_sku','item_desc','item_type','item_price','quantity','recur_bill_amount','bill_cycle','num_cycles','prorate_first_billing','first_billing_date','recur_bill_day']
|
12
|
+
|
13
|
+
def initialize(options = {},orderinfo = {})
|
14
|
+
postarray = []
|
15
|
+
@postdata = nil
|
16
|
+
@orderitems = []
|
17
|
+
@customerdata = []
|
18
|
+
@debug = options['debug']
|
19
|
+
@debug == true ? @debug = true : @debug = false
|
20
|
+
value = nil
|
21
|
+
FIELDS.each do |field|
|
22
|
+
unless orderinfo[field].nil?
|
23
|
+
value = CGI.escape(orderinfo[field].to_s)
|
24
|
+
@customerdata << "#{field}=#{value}".to_s
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def additem(item)
|
30
|
+
@oitem = []
|
31
|
+
ITEMFIELDS.each do |field|
|
32
|
+
item[field] = '' if item[field].nil?
|
33
|
+
puts "#{field}=#{item[field]}" if @debug
|
34
|
+
@oitem << item[field]
|
35
|
+
end
|
36
|
+
@orderitems << @oitem.join(';')
|
37
|
+
end
|
38
|
+
|
39
|
+
def submit
|
40
|
+
r = {}
|
41
|
+
itemlist = CGI.escape(@orderitems.join('|'))
|
42
|
+
@postdata = "itemlist=#{itemlist}&" + @customerdata.join('&')
|
43
|
+
puts @postdata if @debug
|
44
|
+
site = Net::HTTP.new( 'paygw.sea.paymentonline.com', 443 )
|
45
|
+
site.use_ssl = true
|
46
|
+
response = site.post('/transact', @postdata)
|
47
|
+
(r['response_code'],r['response'],r['response_text'],r['auth_code'],r['avs_result'],r['order_id'],r['trans_id'],r['trans_amount']) = response.body.split(',')
|
48
|
+
return response.code,response.message,r
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
metadata
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
rubygems_version: 0.8.11
|
3
|
+
specification_version: 1
|
4
|
+
name: paymentonline
|
5
|
+
version: !ruby/object:Gem::Version
|
6
|
+
version: "0.1"
|
7
|
+
date: 2005-12-02 00:00:00 -08:00
|
8
|
+
summary: Ruby interface for the Payment Online Direct Connect API
|
9
|
+
require_paths:
|
10
|
+
- lib
|
11
|
+
email: chris@paymentonline.com
|
12
|
+
homepage:
|
13
|
+
rubyforge_project:
|
14
|
+
description:
|
15
|
+
autorequire: paymentonline
|
16
|
+
default_executable:
|
17
|
+
bindir: bin
|
18
|
+
has_rdoc: true
|
19
|
+
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
+
requirements:
|
21
|
+
-
|
22
|
+
- ">"
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: 0.0.0
|
25
|
+
version:
|
26
|
+
platform: ruby
|
27
|
+
signing_key:
|
28
|
+
cert_chain:
|
29
|
+
authors:
|
30
|
+
- Payment Online Inc
|
31
|
+
files:
|
32
|
+
- README
|
33
|
+
- LICENSE
|
34
|
+
- lib/paymentonline.rb
|
35
|
+
- bin/example.rb
|
36
|
+
test_files: []
|
37
|
+
rdoc_options: []
|
38
|
+
extra_rdoc_files: []
|
39
|
+
executables: []
|
40
|
+
extensions: []
|
41
|
+
requirements: []
|
42
|
+
dependencies: []
|