atpay_ruby 0.0.11 → 0.0.12
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.
- checksums.yaml +4 -4
- data/README.md +22 -21
- data/atpay_ruby.gemspec +1 -1
- data/bin/atpay +8 -0
- data/lib/atpay.rb +1 -0
- data/lib/atpay/token/targeted.rb +17 -0
- data/spec/token/targeted_spec.rb +20 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ecb0aa51eec280c6ff9882cb459a0d8368a17198
|
4
|
+
data.tar.gz: bea46f16c8c30d58f9f77080763606582da9f9dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 49e4843cb6fed21a8a5fb5a850274c2b115fc86e5f2ec68de850bfd999e8968034768773f2ad8c8536f84db35cf7cb9615da533dee78b40cdb841a5b6ca81c22
|
7
|
+
data.tar.gz: 357a2dc201c26e0a1a731f5a2a491dfeeab0e281fe908c43975ff88afb9f4efa05b7d3c864eccfd8ff45c51154bd5e7bc41f20ad946d78af0e923fd9cb570103
|
data/README.md
CHANGED
@@ -59,8 +59,8 @@ or a product sales offer, for instance). When a **Token** is sent to
|
|
59
59
|
`transaction@processor.atpay.com` from an address associated with a **Payment Method**,
|
60
60
|
it will create a **Transaction**.
|
61
61
|
|
62
|
-
There are two classes of **Token** @Pay processes - the **
|
63
|
-
be used for sending
|
62
|
+
There are two classes of **Token** @Pay processes - the **Targeted Token**, which should
|
63
|
+
be used for sending transactions applicable to a single
|
64
64
|
recipient, and the **Bulk Token**, which is suitable for email marketing lists.
|
65
65
|
|
66
66
|
An **Email Button** is a link embedded in an email message. When activated, this link
|
@@ -69,19 +69,20 @@ prefilled. By default this email contains one of the two token types. Clicking
|
|
69
69
|
'Send' delivers the email to @Pay and triggers **Transaction** processing. The sender will
|
70
70
|
receive a receipt or further instructions.
|
71
71
|
|
72
|
-
##
|
72
|
+
## Targeted Tokens
|
73
73
|
|
74
|
-
|
75
|
-
only applicable to a single recipient (
|
76
|
-
offers, etc).
|
74
|
+
A **targeted** token is ideal for sending invoices or for transactions that are
|
75
|
+
only applicable to a single recipient (specialized offers, etc).
|
77
76
|
|
78
77
|
The following creates a token for a 20 dollar transaction specifically for the
|
79
78
|
credit card @Pay has associated with 'test@example.com':
|
80
79
|
|
81
80
|
```ruby
|
82
|
-
token = AtPay::Token::
|
81
|
+
token = AtPay::Token::Targeted.new(session, 20.00, 'test@example.com')
|
83
82
|
puts token.to_s
|
84
83
|
```
|
84
|
+
*Note: **Targeted** tokens used to be known as **Invoice** tokens. Please use **Targeted** tokens, as **Invoice** tokens will be deprecated.*
|
85
|
+
|
85
86
|
|
86
87
|
## Bulk Tokens
|
87
88
|
|
@@ -114,7 +115,7 @@ simultaneously. If you're shipping a physical good, or for some other reason
|
|
114
115
|
want to delay the capture, use the `auth_only!` method to adjust this behavior:
|
115
116
|
|
116
117
|
```ruby
|
117
|
-
token = AtPay::Token::
|
118
|
+
token = AtPay::Token::Targeted.new(session, 20.00, 'test@example.com')
|
118
119
|
token.auth_only!
|
119
120
|
email(token.to_s)
|
120
121
|
```
|
@@ -126,7 +127,7 @@ after the expiration results in a polite error message being sent to the sender.
|
|
126
127
|
To adjust the expiration:
|
127
128
|
|
128
129
|
```ruby
|
129
|
-
token = AtPay::Token::
|
130
|
+
token = AtPay::Token::Targeted.new(session, 20.00, 'test@example.com')
|
130
131
|
token.expires_in_seconds = 60 * 60 * 24 * 7 # 1 week
|
131
132
|
```
|
132
133
|
|
@@ -141,7 +142,7 @@ your own site (Enable @Pay Card tokenization on your own page with the
|
|
141
142
|
URL:
|
142
143
|
|
143
144
|
```ruby
|
144
|
-
token = AtPay::Token::
|
145
|
+
token = AtPay::Token::Targeted.new(session, 20.00, 'test@example.com')
|
145
146
|
token.url = 'https://example.com/invoices/123'
|
146
147
|
```
|
147
148
|
|
@@ -164,7 +165,7 @@ when the URL is requested from @Pay prior to the first use. To request the URL,
|
|
164
165
|
must contact @Pay's server:
|
165
166
|
|
166
167
|
```ruby
|
167
|
-
token = AtPay::Token::
|
168
|
+
token = AtPay::Token::Targeted.new(session, 20.00, 'test@example.com')
|
168
169
|
registration = token.register!
|
169
170
|
|
170
171
|
registration.url
|
@@ -186,7 +187,7 @@ consultation.
|
|
186
187
|
You can set an **item name** that will display on the **Hosted Payment Capture Page**.
|
187
188
|
|
188
189
|
```ruby
|
189
|
-
token = AtPay::Token::
|
190
|
+
token = AtPay::Token::Targeted.new(session, 20.00, 'test@example.com')
|
190
191
|
token.name = "A Cool Offer"
|
191
192
|
email(token.to_s, receipient_address)
|
192
193
|
```
|
@@ -197,7 +198,7 @@ You can set an **item details** that will display on the **Hosted Payment Captur
|
|
197
198
|
|
198
199
|
|
199
200
|
```ruby
|
200
|
-
token = AtPay::Token::
|
201
|
+
token = AtPay::Token::Targeted.new(session, 20.00, 'test@example.com')
|
201
202
|
token.item_details = "Lorem Ipsum ..."
|
202
203
|
email(token.to_s, receipient_address)
|
203
204
|
```
|
@@ -210,7 +211,7 @@ of shipping or billing address with `requires_shipping_address=` and
|
|
210
211
|
`requires_billing_address=`:
|
211
212
|
|
212
213
|
```
|
213
|
-
token = AtPay::Token::
|
214
|
+
token = AtPay::Token::Targeted.new(session, 20.00, 'test@example.com')
|
214
215
|
token.requires_shipping_address = true
|
215
216
|
token.requires_billing_address = true
|
216
217
|
email(token.to_s, receipient_address)
|
@@ -221,7 +222,7 @@ email(token.to_s, receipient_address)
|
|
221
222
|
If you are using @Pay's webhook for inventory control, you can specify an initial quantity for the offer you are creating.
|
222
223
|
|
223
224
|
```ruby
|
224
|
-
token = AtPay::Token::
|
225
|
+
token = AtPay::Token::Targeted.new(session, 20.00, 'test@example.com')
|
225
226
|
token.item_quantity = 3
|
226
227
|
email(token.to_s, receipient_address)
|
227
228
|
```
|
@@ -234,7 +235,7 @@ email(token.to_s, receipient_address)
|
|
234
235
|
A Transaction should be Captured only when fulfillment is completed.
|
235
236
|
|
236
237
|
```ruby
|
237
|
-
token = AtPay::Token::
|
238
|
+
token = AtPay::Token::Targeted.new(session, 20.00, 'test@example.com')
|
238
239
|
token.estimated_fulfillment_days = 3
|
239
240
|
email(token.to_s, receipient_address)
|
240
241
|
```
|
@@ -245,7 +246,7 @@ email(token.to_s, receipient_address)
|
|
245
246
|
response on processing the token. It has a limit of 2500 characters.
|
246
247
|
|
247
248
|
```ruby
|
248
|
-
token = AtPay::Token::
|
249
|
+
token = AtPay::Token::Targeted.new(session, 20.00, 'test@example.com')
|
249
250
|
token.custom_user_data = 'some-value'
|
250
251
|
email(token.to_s, receipient_address)
|
251
252
|
```
|
@@ -256,7 +257,7 @@ email(token.to_s, receipient_address)
|
|
256
257
|
To create a friendly button that wraps your token:
|
257
258
|
|
258
259
|
```ruby
|
259
|
-
token = AtPay::Token::
|
260
|
+
token = AtPay::Token::Targeted.new(session, 20.00, 'test@example.com')
|
260
261
|
button = AtPay::Button.new(token.to_s, 20.00, 'My Company', wrap: true).render
|
261
262
|
email(button, recipient_address)
|
262
263
|
```
|
@@ -283,16 +284,16 @@ File.write("code.svg", qr.svg) # Export SVG
|
|
283
284
|
|
284
285
|
## Command Line Usage
|
285
286
|
|
286
|
-
The `atpay` utility generates **
|
287
|
+
The `atpay` utility generates **Targeted Tokens**, **Bulk Tokens**, and **Email Buttons**
|
287
288
|
that you can embed in outgoing email. Run `atpay help` for more details.
|
288
289
|
|
289
290
|
```bash
|
290
|
-
$ atpay token
|
291
|
+
$ atpay token targeted --partner_id=X --private_key=X --amount=20.55 --target=test@example.com --user-data=sku-123
|
291
292
|
=> @...@
|
292
293
|
|
293
294
|
$ atpay token bulk --partner_id=X --private-key=X --amount=20.55 --url="http://example.com/product"
|
294
295
|
=> @...@
|
295
296
|
|
296
|
-
$ atpay token
|
297
|
+
$ atpay token targeted --partner_id=X --private_key=X --amount=20.55 --target=test@example.com --user-data=sku-123 | atpay button generic --amount=20.55 --merchant="Mom's"
|
297
298
|
=> <p>...</p>
|
298
299
|
```
|
data/atpay_ruby.gemspec
CHANGED
@@ -2,7 +2,7 @@ $:.unshift(File.join(File.dirname(__FILE__), 'lib'))
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = 'atpay_ruby'
|
5
|
-
s.version = '0.0.
|
5
|
+
s.version = '0.0.12'
|
6
6
|
s.summary = 'Ruby bindings for the @Pay API'
|
7
7
|
s.description = ""
|
8
8
|
s.authors = ['James Kassemi', 'Isaiah Baca']
|
data/bin/atpay
CHANGED
@@ -21,6 +21,14 @@ module AtPay
|
|
21
21
|
puts AtPay::Token::Invoice.new(session, options[:amount], options[:email], options[:user_data]).to_s
|
22
22
|
end
|
23
23
|
|
24
|
+
desc 'targeted', 'Generate an targeted token'
|
25
|
+
option :amount, type: :numeric, required: true, desc: "Dollar amount to process"
|
26
|
+
option :email, type: :string, required: true, desc: "Email address expected to complete the transaction"
|
27
|
+
option :user_data, default: nil, desc: "Additional data to append to transaction details"
|
28
|
+
def targeted
|
29
|
+
puts AtPay::Token::Targeted.new(session, options[:amount], options[:email], options[:user_data]).to_s
|
30
|
+
end
|
31
|
+
|
24
32
|
desc 'bulk', 'Generate a bulk token'
|
25
33
|
option :amount, type: :numeric, required: true, desc: "Dollar amount to process"
|
26
34
|
option :user_data, default: '', desc: "Additional data to append to transaction details"
|
data/lib/atpay.rb
CHANGED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'atpay/token/core'
|
2
|
+
require 'atpay/token/encoder'
|
3
|
+
|
4
|
+
module AtPay
|
5
|
+
module Token
|
6
|
+
class Targeted < Core
|
7
|
+
def initialize(session, amount, email_address, custom_data={})
|
8
|
+
super
|
9
|
+
|
10
|
+
self.session = session
|
11
|
+
self.amount = amount
|
12
|
+
self.email_address = email_address
|
13
|
+
self.user_data.custom_data = custom_data
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'atpay/session'
|
3
|
+
require 'atpay/token/targeted'
|
4
|
+
|
5
|
+
describe AtPay::Token::Targeted do
|
6
|
+
let(:partner_id) { 1 }
|
7
|
+
let(:private_key) { 'xx5okSjkqJu30biXEFI/y05B68JRCr7ReSdufmtrILY=' }
|
8
|
+
let(:public_key) { 'gOVRRMKRwCHD0nkGiQ1/1EKcSUjO/einHq7MZ/AMkzQ=' }
|
9
|
+
let(:atpay_public_key) { 'x3iJge6NCMx9cYqxoJHmFgUryVyXqCwapGapFURYh18=' }
|
10
|
+
let(:atpay_private_key) { '' }
|
11
|
+
|
12
|
+
let(:session) { AtPay::Session.new(partner_id, public_key, private_key) }
|
13
|
+
let(:amount) { 20.0 }
|
14
|
+
let(:email_address) { 'http://example.com/' }
|
15
|
+
let(:user_data) { 'sku-123' }
|
16
|
+
|
17
|
+
it 'creates a new token without exception' do
|
18
|
+
AtPay::Token::Targeted.new(session, amount, email_address, user_data).to_s
|
19
|
+
end
|
20
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: atpay_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Kassemi
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-09-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rbnacl-libsodium
|
@@ -158,6 +158,7 @@ files:
|
|
158
158
|
- lib/atpay/token/encoder.rb
|
159
159
|
- lib/atpay/token/invoice.rb
|
160
160
|
- lib/atpay/token/registration.rb
|
161
|
+
- lib/atpay/token/targeted.rb
|
161
162
|
- spec/button/qr_code_spec.rb
|
162
163
|
- spec/button_spec.rb
|
163
164
|
- spec/hook_spec.rb
|
@@ -167,6 +168,7 @@ files:
|
|
167
168
|
- spec/token/encoder_spec.rb
|
168
169
|
- spec/token/invoice_spec.rb
|
169
170
|
- spec/token/registration.rb
|
171
|
+
- spec/token/targeted_spec.rb
|
170
172
|
homepage: https://atpay.com
|
171
173
|
licenses:
|
172
174
|
- MIT
|
@@ -201,3 +203,4 @@ test_files:
|
|
201
203
|
- spec/token/encoder_spec.rb
|
202
204
|
- spec/token/invoice_spec.rb
|
203
205
|
- spec/token/registration.rb
|
206
|
+
- spec/token/targeted_spec.rb
|