atpay_buttons 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/Gemfile +2 -2
- data/README.md +33 -9
- data/atpay_buttons.gemspec +1 -1
- data/bin/atpay_buttons +19 -3
- data/lib/atpay/button/template.rb +1 -4
- data/spec/command_line_spec.rb +1 -1
- data/spec/spec_helper.rb +8 -8
- metadata +22 -12
- checksums.yaml +0 -7
data/.gitignore
CHANGED
data/Gemfile
CHANGED
@@ -15,8 +15,8 @@ end
|
|
15
15
|
|
16
16
|
group :development, :test do
|
17
17
|
gem 'pry'
|
18
|
-
gem 'minitest'
|
19
|
-
gem 'minitest-reporters', '>= 0.5.0', :
|
18
|
+
gem 'minitest'
|
19
|
+
gem 'minitest-reporters', '>= 0.5.0', github: "atpay/minitest-reporters", require: false
|
20
20
|
gem 'simplecov'
|
21
21
|
gem 'mocha'
|
22
22
|
end
|
data/README.md
CHANGED
@@ -31,7 +31,7 @@ library.
|
|
31
31
|
If your application is based on Ruby and you use Bundler, add the following line
|
32
32
|
to your application's Gemfile:
|
33
33
|
|
34
|
-
gem '
|
34
|
+
gem 'atpay_buttons'
|
35
35
|
|
36
36
|
And then execute:
|
37
37
|
|
@@ -40,7 +40,7 @@ And then execute:
|
|
40
40
|
If you'd like to use the command line interface, or are not using Bundler, you
|
41
41
|
can install the gem on your system with:
|
42
42
|
|
43
|
-
$ gem install
|
43
|
+
$ gem install atpay_buttons
|
44
44
|
|
45
45
|
## Requirements
|
46
46
|
|
@@ -54,11 +54,11 @@ multiple partners and can generate buttons on behalf of merchants that use their
|
|
54
54
|
system.
|
55
55
|
|
56
56
|
After installing the atpay-button-generator gem, you'll have
|
57
|
-
`
|
57
|
+
`atpay_buttons` script in your gem binpath. Run it with
|
58
58
|
the help flag to get information on how to use it:
|
59
59
|
|
60
60
|
|
61
|
-
$
|
61
|
+
$ atpay_buttons --help
|
62
62
|
|
63
63
|
The button generator requires a few flags up front:
|
64
64
|
|
@@ -76,9 +76,15 @@ The button generator requires a few flags up front:
|
|
76
76
|
<p><strong>partner-id (required):</strong> <br />
|
77
77
|
<i> The partner ID given to you by @Pay</i></p>
|
78
78
|
|
79
|
+
<p><strong><sup>**</sup>universal:</strong> <br />
|
80
|
+
<i> This flag indicates that a universal payment button should be returned.</i></p>
|
81
|
+
|
79
82
|
<p><strong>subject:</strong> <br />
|
80
83
|
<i> The subject of the mailto: email <br/> (the message that a user will be sending to @Pay's servers after clicking the button)</i></p>
|
81
84
|
|
85
|
+
<p><strong>signup-url:</strong> <br />
|
86
|
+
<i> The signup URL for a Universal Button offer. This option should only be present if you use the universal flag.</i></p>
|
87
|
+
|
82
88
|
<p><strong>image:</strong> <br />
|
83
89
|
<i> The URL to a small thumbnail image to be used in the button <br /> Default: https://www.atpay.com/wp-content/themes/atpay/images/bttn_cart.png</i></p>
|
84
90
|
|
@@ -106,6 +112,9 @@ The button generator requires a few flags up front:
|
|
106
112
|
|
107
113
|
<sup>*</sup>Reads from STDIN a comma delimmited file with each line containing the
|
108
114
|
email address you're sending the button to and the credit card token you've
|
115
|
+
|
116
|
+
<sup>**</sup>With a universal button the program doesn't look for an input stream, as it only ever generates one button.
|
117
|
+
|
109
118
|
received from @Pay for that button:
|
110
119
|
|
111
120
|
test1@example.com,TL1UwJFXVN7e4p6+0B5N8hy4qQyqeNxVllmC663MLcMupuAWXdHJ9g8PRAnlIh+AMZBgpaIrfWStZ5/3hYi6vCAV7q6+3M6LLqxk
|
@@ -114,7 +123,7 @@ received from @Pay for that button:
|
|
114
123
|
|
115
124
|
### Example
|
116
125
|
|
117
|
-
$
|
126
|
+
$ atpay_buttons --title "Pay" --amount 50.00 --subject "Payment for fifty bucks" --private-key "" --public-key "" --partner-id 20 --input input.txt
|
118
127
|
|
119
128
|
Where input.txt contains
|
120
129
|
|
@@ -137,11 +146,10 @@ A button from the example above looks like this:
|
|
137
146
|
After following the installation instructions above, you'll have the @Pay button
|
138
147
|
generator library loaded in your application. Let's create an array containing
|
139
148
|
hashes with our users' email address and html code for a button to deliver to
|
140
|
-
|
149
|
+
them:
|
141
150
|
|
142
151
|
```ruby
|
143
|
-
require '
|
144
|
-
require 'atpay-button-generator'
|
152
|
+
require 'atpay_buttons'
|
145
153
|
|
146
154
|
button_maker = AtPay::Button::Generator.new({
|
147
155
|
public_key: ATPAY_PUBLIC,
|
@@ -156,11 +164,27 @@ htem:
|
|
156
164
|
User.active.each do |user|
|
157
165
|
output << {
|
158
166
|
email: user.email,
|
159
|
-
button_html: button_maker.generate
|
167
|
+
button_html: button_maker.generate email: user.email, source: user.source
|
160
168
|
}
|
161
169
|
end
|
162
170
|
|
163
171
|
puts output.inspect
|
172
|
+
```
|
173
|
+
|
174
|
+
Generating a Universal button is similar to the process above. However as the same button will work for multiple buyers you only need to make the one call to generate. The source should be the URL a customer should visit to register their card info with @Pay. This can be any page that implements the @Pay Javascript SDK.
|
175
|
+
|
176
|
+
```
|
177
|
+
require 'atpay_buttons'
|
178
|
+
|
179
|
+
button_maker = AtPay::Button::Generator.new({
|
180
|
+
public_key: ATPAY_PUBLIC,
|
181
|
+
private_key: ATPAY_PRIVATE,
|
182
|
+
partner_id: ATPAY_PATNER,
|
183
|
+
environment: :sandbox,
|
184
|
+
amount: 20
|
185
|
+
})
|
186
|
+
|
187
|
+
puts button_maker.generate email: 'none', type: :url, source: 'https://special.example.com/signup'
|
164
188
|
```
|
165
189
|
|
166
190
|
### ActionMailer Example
|
data/atpay_buttons.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "atpay_buttons"
|
7
|
-
spec.version = '1.
|
7
|
+
spec.version = '1.1.0'
|
8
8
|
spec.date = '2013-08-02'
|
9
9
|
spec.authors = ["Thomas Pastinsky", "Glen Holcomb", "James Kassemi", "Isaiah Baca"]
|
10
10
|
spec.email = ["dev@atpay.com"]
|
data/bin/atpay_buttons
CHANGED
@@ -5,9 +5,9 @@ require_relative '../lib/atpay_buttons.rb'
|
|
5
5
|
|
6
6
|
|
7
7
|
@opts = Trollop::options do
|
8
|
-
version "
|
8
|
+
version "atpay_buttons v1.1"
|
9
9
|
banner <<-USAGE
|
10
|
-
To generate
|
10
|
+
To generate a Targeted @Pay Button, follow these steps:
|
11
11
|
Create a text file, e.g. data.txt, containing an email address and the associated credit card token separated by a comma. Enter multiple lines for multiple buttons:
|
12
12
|
|
13
13
|
test1@example.com,TL1UwJFXVN7e4p6+0B5N8hy4qQyqeNxVllmC663MLcMupuAWXdHJ9g8PRAnlIh+AMZBgpaIrfWStZ5/3hYi6vCAV7q6+3M6LLqxk
|
@@ -16,14 +16,22 @@ require_relative '../lib/atpay_buttons.rb'
|
|
16
16
|
|
17
17
|
Then run the following from the console in the same location as the file you created:
|
18
18
|
|
19
|
-
$
|
19
|
+
$ atpay_buttons --title "Pay" --amount 50.00 --subject "Payment for fifty bucks" --private-key "plBs9X+Zvr65z6iCa0oLNdAEGYZ85Dzf74Qy1yPTris=" --public-key "06zK82iu9NUUMmDiZsEvoUH25tbIE6R3R+zPnDK8YGQ=" --partner-id 20 --input data.txt
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
To generate a Universal @Pay Button, run the following command:
|
24
|
+
|
25
|
+
$ atpay_buttons --universal true --title "Pay" --amount 50.00 --subject "Payment for fifty bucks" --private-key "plBs9X+Zvr65z6iCa0oLNdAEGYZ85Dzf74Qy1yPTris=" --public-key "06zK82iu9NUUMmDiZsEvoUH25tbIE6R3R+zPnDK8YGQ=" --partner-id 20
|
20
26
|
USAGE
|
21
27
|
|
22
28
|
opt :amount, "The amount a user should be charged for transactions after clicking the generated button", :default => 5.0, :required => true
|
23
29
|
opt :private_key, "The private key given to you by @Pay", :type => :string, :required => true
|
24
30
|
opt :public_key, "@Pay's public key, given to you by @Pay", :type => :string, :required => true
|
25
31
|
opt :partner_id, "The partner ID given to you by @Pay", :type => :integer, :required => true
|
32
|
+
opt :universal, "This will build a non-targeted payment button", :type => :boolean, :default => false
|
26
33
|
opt :subject, "The subject of the mailto: email (the message that a user will be sending to @Pay's servers after clicking the button", :type => :string
|
34
|
+
opt :signup_url, "This is the signup url for recipients that don't have @Pay Records", :type => :string
|
27
35
|
opt :image_url, "The URL to a small thumbnail image to be used in the button. Default: https://www.atpay.com/wp-content/themes/atpay/images/bttn_cart.png", :type => :string, :default => "https://www.atpay.com/wp-content/themes/atpay/images/bttn_cart.png"
|
28
36
|
opt :color, "The background color of the button. Default: #6dbe45", :type => :string, :default => "#6dbe45"
|
29
37
|
opt :title, "The title for each button", :type => :string
|
@@ -48,7 +56,11 @@ def parse
|
|
48
56
|
|
49
57
|
symbolize_values
|
50
58
|
@generator = AtPay::Button::Generator.new @opts.dup
|
59
|
+
|
60
|
+
@opts[:universal] ? puts(universal_button) : targeted_buttons
|
61
|
+
end
|
51
62
|
|
63
|
+
def targeted_buttons
|
52
64
|
while !@opts[:input].eof?
|
53
65
|
data = @opts[:input].readline.strip.split(',')
|
54
66
|
|
@@ -59,4 +71,8 @@ def parse
|
|
59
71
|
end
|
60
72
|
end
|
61
73
|
|
74
|
+
def universal_button
|
75
|
+
@generator.generate source: @opts[:signup_url], type: :url, email: 'default@template.please' # Yep literal hardcoded junk. This screams for a refactor of underlying behaviors.
|
76
|
+
end
|
77
|
+
|
62
78
|
parse
|
@@ -1,12 +1,9 @@
|
|
1
1
|
require 'liquid'
|
2
|
-
require 'active_support/number_helper'
|
3
2
|
require 'uri'
|
4
3
|
|
5
4
|
module AtPay
|
6
5
|
module Button
|
7
6
|
class Template
|
8
|
-
include ActiveSupport::NumberHelper
|
9
|
-
|
10
7
|
# Requires destination and email in addition to this, which should just be strings...
|
11
8
|
def initialize(options)
|
12
9
|
@options = {
|
@@ -35,7 +32,7 @@ module AtPay
|
|
35
32
|
|
36
33
|
private
|
37
34
|
def amount
|
38
|
-
|
35
|
+
"$%.2f" % @options[:amount].to_f
|
39
36
|
end
|
40
37
|
|
41
38
|
def string_hash(hsh)
|
data/spec/command_line_spec.rb
CHANGED
@@ -6,7 +6,7 @@ describe "atpay_buttons" do
|
|
6
6
|
let(:public_key) { '06zK82iu9NUUMmDiZsEvoUH25tbIE6R3R+zPnDK8YGQ=' }
|
7
7
|
let(:private_key) { 'plBs9X+Zvr65z6iCa0oLNdAEGYZ85Dzf74Qy1yPTris=' }
|
8
8
|
let(:options) { {partner_id: 1, public_key: public_key, private_key: private_key, amount: '12', env: :sandbox, user_data: 'aaaaaaaa'} }
|
9
|
-
let(:cli_input) { "bin/atpay_buttons --amount 5.0 -
|
9
|
+
let(:cli_input) { "bin/atpay_buttons --amount 5.0 --private-key #{private_key} --public-key #{public_key} --partner-id #{options[:partner_id]} --subject subject --image-url imageurl --color color --title title --wrap false --env sandbox --input #{file_info}" }
|
10
10
|
let(:cli_output) {`#{cli_input}`}
|
11
11
|
|
12
12
|
describe "button creation" do
|
data/spec/spec_helper.rb
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
require 'simplecov'
|
2
|
-
SimpleCov.start
|
2
|
+
SimpleCov.start do
|
3
|
+
add_filter '/coverage/'
|
4
|
+
add_filter '/spec/'
|
5
|
+
add_filter '/vendor/'
|
6
|
+
end
|
3
7
|
|
4
8
|
require 'pry'
|
5
9
|
require File.dirname(__FILE__) + '/../lib/atpay_buttons'
|
6
|
-
|
7
|
-
# require 'minitest'
|
8
10
|
require 'minitest/autorun'
|
9
|
-
|
10
11
|
require 'mocha/setup'
|
11
12
|
|
12
13
|
# See http://www.jetbrains.com/ruby/webhelp/minitest.html
|
13
14
|
if ENV["RM_INFO"] || ENV["TEAMCITY_VERSION"]
|
14
|
-
|
15
|
-
|
16
|
-
|
15
|
+
require 'active_support'
|
16
|
+
require 'minitest/reporters'
|
17
|
+
MiniTest::Reporters.use! MiniTest::Reporters::RubyMineReporter.new
|
17
18
|
end
|
18
|
-
|
metadata
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: atpay_buttons
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- Thomas Pastinsky
|
@@ -16,6 +17,7 @@ dependencies:
|
|
16
17
|
- !ruby/object:Gem::Dependency
|
17
18
|
name: bundler
|
18
19
|
requirement: !ruby/object:Gem::Requirement
|
20
|
+
none: false
|
19
21
|
requirements:
|
20
22
|
- - ~>
|
21
23
|
- !ruby/object:Gem::Version
|
@@ -23,6 +25,7 @@ dependencies:
|
|
23
25
|
type: :development
|
24
26
|
prerelease: false
|
25
27
|
version_requirements: !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
26
29
|
requirements:
|
27
30
|
- - ~>
|
28
31
|
- !ruby/object:Gem::Version
|
@@ -30,43 +33,49 @@ dependencies:
|
|
30
33
|
- !ruby/object:Gem::Dependency
|
31
34
|
name: rake
|
32
35
|
requirement: !ruby/object:Gem::Requirement
|
36
|
+
none: false
|
33
37
|
requirements:
|
34
|
-
- - '>='
|
38
|
+
- - ! '>='
|
35
39
|
- !ruby/object:Gem::Version
|
36
40
|
version: '0'
|
37
41
|
type: :development
|
38
42
|
prerelease: false
|
39
43
|
version_requirements: !ruby/object:Gem::Requirement
|
44
|
+
none: false
|
40
45
|
requirements:
|
41
|
-
- - '>='
|
46
|
+
- - ! '>='
|
42
47
|
- !ruby/object:Gem::Version
|
43
48
|
version: '0'
|
44
49
|
- !ruby/object:Gem::Dependency
|
45
50
|
name: atpay_tokens
|
46
51
|
requirement: !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
47
53
|
requirements:
|
48
|
-
- - '>='
|
54
|
+
- - ! '>='
|
49
55
|
- !ruby/object:Gem::Version
|
50
56
|
version: '0'
|
51
57
|
type: :runtime
|
52
58
|
prerelease: false
|
53
59
|
version_requirements: !ruby/object:Gem::Requirement
|
60
|
+
none: false
|
54
61
|
requirements:
|
55
|
-
- - '>='
|
62
|
+
- - ! '>='
|
56
63
|
- !ruby/object:Gem::Version
|
57
64
|
version: '0'
|
58
65
|
- !ruby/object:Gem::Dependency
|
59
66
|
name: liquid
|
60
67
|
requirement: !ruby/object:Gem::Requirement
|
68
|
+
none: false
|
61
69
|
requirements:
|
62
|
-
- - '>='
|
70
|
+
- - ! '>='
|
63
71
|
- !ruby/object:Gem::Version
|
64
72
|
version: '0'
|
65
73
|
type: :runtime
|
66
74
|
prerelease: false
|
67
75
|
version_requirements: !ruby/object:Gem::Requirement
|
76
|
+
none: false
|
68
77
|
requirements:
|
69
|
-
- - '>='
|
78
|
+
- - ! '>='
|
70
79
|
- !ruby/object:Gem::Version
|
71
80
|
version: '0'
|
72
81
|
description: Atpay button generator
|
@@ -105,26 +114,27 @@ files:
|
|
105
114
|
- test_data.txt
|
106
115
|
homepage: http://atpay.com
|
107
116
|
licenses: []
|
108
|
-
metadata: {}
|
109
117
|
post_install_message:
|
110
118
|
rdoc_options: []
|
111
119
|
require_paths:
|
112
120
|
- lib
|
113
121
|
required_ruby_version: !ruby/object:Gem::Requirement
|
122
|
+
none: false
|
114
123
|
requirements:
|
115
|
-
- - '>='
|
124
|
+
- - ! '>='
|
116
125
|
- !ruby/object:Gem::Version
|
117
126
|
version: '0'
|
118
127
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
128
|
+
none: false
|
119
129
|
requirements:
|
120
|
-
- - '>='
|
130
|
+
- - ! '>='
|
121
131
|
- !ruby/object:Gem::Version
|
122
132
|
version: '0'
|
123
133
|
requirements: []
|
124
134
|
rubyforge_project:
|
125
|
-
rubygems_version:
|
135
|
+
rubygems_version: 1.8.23
|
126
136
|
signing_key:
|
127
|
-
specification_version:
|
137
|
+
specification_version: 3
|
128
138
|
summary: Command line tool and Ruby library for generating @Pay 2 click email buttons
|
129
139
|
test_files:
|
130
140
|
- spec/command_line_spec.rb
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: bc892b9c316fd7e96cc99f42ebe7a0bba1f53949
|
4
|
-
data.tar.gz: b8c61bd615e5e89262731cce90b096a188f7e0c7
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: edc1c99a639364a7ecd3cee17dfe41b2f92cb74174d224c9b3cd43d4e8bdcb21e5e4171b1b16cd66014a1f60a8dd0744f0c88211dab1a66090676ad0b6e7f276
|
7
|
-
data.tar.gz: ff483113e4bd40af28c2635c9c720daf2411da5c98a64ad140efbeef6aefa8ac4988ee8806e5f9b4f2adc31fa084b551e71e39215a3124fe5f736aa39367c1e2
|