ccbill_ruby 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +78 -36
- data/images/redirect_path.png +0 -0
- data/lib/ccbill_ruby/dynamic_pricing.rb +25 -5
- data/lib/ccbill_ruby/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 39968023a09afce1fef462927e886edee7bc51e9
|
4
|
+
data.tar.gz: 4e67d3bf54326c605939a446be2edbbb2477187f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c4c8c0de66eaed747eb7a44c982dc9f1f7f7a119fc73b40439631b6b0661d4627fc9503d672dd9e7ce33ded621c6466d18724f78b59122fb86d11e31dccc52c
|
7
|
+
data.tar.gz: f46011f2a0a7eb268224cd66aa25bc6c5670a35a1f26d04f54edaf5c1971abe3afc7fc1d691a06080f682c045ae68fe7bd235ef0e930ea1324d5e9e703f17439
|
data/README.md
CHANGED
@@ -1,6 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
Please Mail me if any - 'dmytro.vasin@gmail.com'
|
1
|
+
**Please mail me if any: dmytro.vasin@gmail.com**
|
4
2
|
|
5
3
|
# CCBill SDK for Ruby
|
6
4
|
|
@@ -14,6 +12,10 @@ This gem provides:
|
|
14
12
|
- Background Post path
|
15
13
|
- Url/Form Generator for test and live mode
|
16
14
|
|
15
|
+
|
16
|
+
> Important! CCBill provides two types of payment forms. FlexForms is our newest (and recommended) system. In this gem we use ONLY FlexForms.
|
17
|
+
|
18
|
+
|
17
19
|
# Getting started
|
18
20
|
|
19
21
|
```ruby
|
@@ -33,6 +35,7 @@ This will create a controller (if one does not exist) and configure it with the
|
|
33
35
|
|
34
36
|
## Example of usage:
|
35
37
|
|
38
|
+
Simple version:
|
36
39
|
```ruby
|
37
40
|
form = Ccbill::DynamicPricing.new({
|
38
41
|
initial_price_in_cents: 355
|
@@ -44,6 +47,17 @@ form.valid? #=> True/False
|
|
44
47
|
form.url #=> URL
|
45
48
|
```
|
46
49
|
|
50
|
+
To prefill the form you can pass additional variables like: `customer_fname`, `customer_lname`, 'address1', etc. [Full list of variables](https://kb.ccbill.com/Webhooks+User+Guide#Payment_Form)
|
51
|
+
|
52
|
+
```ruby
|
53
|
+
form = Ccbill::DynamicPricing.new({
|
54
|
+
initial_price_in_cents: 355
|
55
|
+
initial_period: 30,
|
56
|
+
order_id: 'Any configuration information',
|
57
|
+
customer_fname: 'Dmytro',
|
58
|
+
customer_lname: 'Vasin'
|
59
|
+
})
|
60
|
+
```
|
47
61
|
|
48
62
|
## Controller and methods:
|
49
63
|
|
@@ -112,69 +126,84 @@ Before reading this part - please read [Setup guide](#setup-guide)
|
|
112
126
|
end
|
113
127
|
```
|
114
128
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
129
|
# Payment Flow
|
128
130
|
|
129
|
-
|
130
|
-
TODO: NGrok.
|
131
|
-
TODO: User should be logged in in the admin panel.
|
132
|
-
TODO: Deny redirect happens only after three attempt.
|
131
|
+
To make some payment through CCBill via DynamiPricing:
|
133
132
|
|
134
133
|
The payment form is the CCBill form that will be displayed to customers after they choose to check out using CCBill. The payment form accepts customer payment information, processes the payment, and returns the customer to your Site through callbacks ( GET ) where you can catche the response and do proper redirect:
|
135
134
|
|
136
|
-
|
137
|
-
callbacks_ccbill GET /callbacks/ccbill(.:format) callbacks/ccbills#show
|
138
|
-
POST /callbacks/ccbill(.:format) callbacks/ccbills#create
|
139
|
-
```
|
140
|
-
|
141
|
-
> Important!
|
142
|
-
> CCBill provides two types of payment forms. FlexForms is our newest (and recommended) system. In this gem we use ONLY FlexForms.
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
135
|
+
### Step 1:
|
147
136
|
|
137
|
+
1. You should generate LINK that contains information about order/subscription
|
148
138
|
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
139
|
+
This gem will help you in this, next script will generate link:
|
140
|
+
```ruby
|
141
|
+
Ccbill::DynamicPricing.new({
|
142
|
+
initial_price_in_cents: 355
|
143
|
+
initial_period: 30,
|
144
|
+
order_id: 'Any configuration information'
|
145
|
+
}).url
|
146
|
+
```
|
155
147
|
|
148
|
+
This link contains variables: `initial_price`, `initial_period` and additional variable `order_id`. To enhance security, that url contains `FormDigest` value. The formDigest value is a hex-encoded MD5 hash, calculated using a combination of the fields and a salt value. [More information](https://kb.ccbill.com/Dynamic+Pricing+User+Guide#Generating_the_MD5_Hash)
|
156
149
|
|
157
150
|
|
151
|
+
### Step 2:
|
158
152
|
|
153
|
+
2. By clicking on this link user will be redirected to the CCBill payment form.
|
154
|
+
This form is generated by admin. Find out more at [Configure your CCBill Account:](#configure-your-ccbill-account) section.
|
159
155
|
|
156
|
+
When user fill-in all fields. He can follow 2 way: `Approve` and `Deny`
|
160
157
|
|
158
|
+
But here is two thing:
|
159
|
+
1 On `Deny` response: App will propose to Try Again (User will stay at the payment system)
|
160
|
+
2 On `Deny` response: App will receive `Deny` postback. ( `callbacks/ccbills#create` ). With Deny attributes.
|
161
|
+
3 To Receive `Deny` redirect:
|
162
|
+
> The reason you aren’t redirected to denial URL is because our system sees these declines as ‘soft’ declines, and by default, you need to have at least 3 soft declines in a row until you are redirected to denial url. So if you want to test denial redirection, you will need to click ‘Try again’ and fill out the credit card number for three consecutive times and you will be redirected. If the consumer is ‘hard’ declined(for example transaction is denied by consumer’s bank), he would be redirected after first form submission. Additionally, we can turn off this rule to have soft denial three times before redirection and if you would like us to do so, please confirm.
|
163
|
+
4. Test Cards
|
164
|
+
[Test cards](https://kb.ccbill.com/How+do+I+set+up+a+user+to+process+test+transactions) you can find here. But one thing you should remember: Only `CVV` metters:
|
165
|
+
> When performing test transactions in Sandbox mode, cvv2 higher then 300 will result in approval even though you used denial credit card. If you try to test it in live mode, you would receive denial no matter what cvv2 you are using.
|
161
166
|
|
167
|
+
### Step 2:
|
162
168
|
|
169
|
+
`Approval Path` and `Deny Path` we set up [here](#create-an-approval-url)
|
163
170
|
|
171
|
+
**Approval Path**
|
164
172
|
|
173
|
+
This is the path customers take when their transaction is approved. The Approval Tile is always below the Primary and Deny Tile. When editing the Approval Path, your options are limited.
|
165
174
|
|
175
|
+
**Deny Path**
|
166
176
|
|
177
|
+
This is the path consumers take when they are declined on a transaction. They will be redirected to the deny path to try again. The Deny Tile is always to the right of the Primary Tile.
|
167
178
|
|
179
|
+
To set up a Deny Path:
|
168
180
|
|
181
|
+
- Click the Deny Tile. A new window has opened. It will be very similar to the one you saw when you created the Primary Tile.
|
182
|
+
- Select one of several redirect options along the left side of the screen.
|
183
|
+
- New Form. Create a new FlexForm as you did for the Primary Tile.
|
184
|
+
- Existing Form. Use a previously made Form.
|
185
|
+
- URL. Add an external or internal link. Send customers back to your website or to a third party payment form.
|
169
186
|
|
187
|
+
![Deny Path](https://raw.githubusercontent.com/DmytroVasin/ccbill_ruby/master/images/redirect_path.png)
|
170
188
|
|
171
189
|
|
190
|
+
### Step 3:
|
191
|
+
After previouse steps, ccbill returns the customer to your Site through callbacks ( GET ) where you can catche the response and do proper redirect:
|
172
192
|
|
193
|
+
```ruby
|
194
|
+
callbacks_ccbill GET /callbacks/ccbill(.:format) callbacks/ccbills#show
|
195
|
+
POST /callbacks/ccbill(.:format) callbacks/ccbills#create
|
196
|
+
```
|
173
197
|
|
198
|
+
### Step 4:
|
174
199
|
|
200
|
+
Postback: According to `POST` action in your controller.
|
175
201
|
|
202
|
+
Background Post allows Merchants to receive data posts from our system to a script that the Merchant creates. Merchants can parse that data from the script into their databases/tables for member tracking. Background Post only works for NEW transactions.
|
176
203
|
|
204
|
+
Some kind of background callback to the app that happens on each attempt to Pay
|
177
205
|
|
206
|
+
This callback contains a lot of information of the attempt: [Background Post](https://kb.ccbill.com/Background+Post)
|
178
207
|
|
179
208
|
|
180
209
|
|
@@ -339,6 +368,17 @@ Please read next:
|
|
339
368
|
- [FlexForms Sandbox](https://kb.ccbill.com/FlexForms+Sandbox?page_ref_id=452)
|
340
369
|
- [FlexForms Form Status and Live Mode](https://kb.ccbill.com/FlexForms+Form+Status+and+Live+Mode?page_ref_id=453)
|
341
370
|
|
371
|
+
# Dev Expirience:
|
372
|
+
|
373
|
+
TODO:
|
374
|
+
|
375
|
+
TODO: NGrok.
|
376
|
+
|
377
|
+
TODO: 3) You are able to check the number and amount of test transactions you had in selected timeframe. In order to do so, please navigate to Reports >> Alphabetical list >> C >> Credit/check transactions >> select date range and select Test transactions from Options dropdown menu.
|
378
|
+
|
379
|
+
TODO: !!! All prices must be between $2.95 and $100.
|
380
|
+
|
381
|
+
|
342
382
|
# Useful Links:
|
343
383
|
* [Dynamic Pricing](https://kb.ccbill.com/Dynamic+Pricing)
|
344
384
|
* [FlexForm FAQs](https://kb.ccbill.com/FlexForms+FAQs)
|
@@ -346,6 +386,8 @@ Please read next:
|
|
346
386
|
* [FlexForms Sandbox](https://kb.ccbill.com/FlexForms+Sandbox?page_ref_id=452)
|
347
387
|
* [FlexForms Form Status and Live Mode](https://kb.ccbill.com/FlexForms+Form+Status+and+Live+Mode?page_ref_id=453)
|
348
388
|
* [Test Transactions and Credit Cards](https://kb.ccbill.com/How+do+I+set+up+a+user+to+process+test+transactions)
|
389
|
+
* [Background Post](https://kb.ccbill.com/Background+Post)
|
390
|
+
* [Webhooks - prefil variables](https://kb.ccbill.com/Webhooks+User+Guide#Payment_Form)
|
349
391
|
|
350
392
|
# License
|
351
393
|
|
Binary file
|
@@ -5,6 +5,8 @@ module CCBill
|
|
5
5
|
attr_accessor :variables, :config, :errors
|
6
6
|
|
7
7
|
def initialize(options = {})
|
8
|
+
fail_on_price_set(options)
|
9
|
+
|
8
10
|
modified_options = modify_params(options)
|
9
11
|
|
10
12
|
self.config = CCBill.configuration
|
@@ -31,7 +33,13 @@ module CCBill
|
|
31
33
|
end
|
32
34
|
|
33
35
|
unless (2.96..99.99).include?(variables[:initial_price].to_f)
|
34
|
-
@errors << '
|
36
|
+
@errors << 'Initial price must be between $2.95 and $100.'
|
37
|
+
end
|
38
|
+
|
39
|
+
if recurring?
|
40
|
+
unless (2.96..99.99).include?(variables[:recurring_price].to_f)
|
41
|
+
@errors << 'Recurring price must be between $2.95 and $100.'
|
42
|
+
end
|
35
43
|
end
|
36
44
|
|
37
45
|
@errors.empty?
|
@@ -46,7 +54,7 @@ module CCBill
|
|
46
54
|
variables[:initial_period],
|
47
55
|
variables[:recurring_price],
|
48
56
|
variables[:recurring_period],
|
49
|
-
variables[:
|
57
|
+
variables[:num_rebills],
|
50
58
|
variables[:currency_code],
|
51
59
|
config.salt
|
52
60
|
]
|
@@ -63,7 +71,7 @@ module CCBill
|
|
63
71
|
end
|
64
72
|
|
65
73
|
def recurring?
|
66
|
-
variables[:recurring_price] || variables[:recurring_period] || variables[:
|
74
|
+
variables[:recurring_price] || variables[:recurring_period] || variables[:num_rebills]
|
67
75
|
end
|
68
76
|
|
69
77
|
def required_fields
|
@@ -76,7 +84,7 @@ module CCBill
|
|
76
84
|
req += [
|
77
85
|
:recurring_price,
|
78
86
|
:recurring_period,
|
79
|
-
:
|
87
|
+
:num_rebills
|
80
88
|
]
|
81
89
|
end
|
82
90
|
|
@@ -92,7 +100,7 @@ module CCBill
|
|
92
100
|
currency_code: 'currencyCode',
|
93
101
|
recurring_price: 'recurringPrice',
|
94
102
|
recurring_period: 'recurringPeriod',
|
95
|
-
|
103
|
+
num_rebills: 'numRebills',
|
96
104
|
form_digest: 'formDigest'
|
97
105
|
}[internal] || internal
|
98
106
|
end
|
@@ -115,11 +123,23 @@ module CCBill
|
|
115
123
|
initial_cents = options.delete(:initial_price_in_cents)
|
116
124
|
options[:initial_price] = convert_to_price(initial_cents) if initial_cents
|
117
125
|
|
126
|
+
recurring_cents = options.delete(:recurring_price_in_cents)
|
127
|
+
options[:recurring_price] = convert_to_price(recurring_cents) if recurring_cents
|
128
|
+
|
118
129
|
options
|
119
130
|
end
|
120
131
|
|
121
132
|
def convert_to_price(cents)
|
122
133
|
'%.2f' % (cents / 100.to_f)
|
123
134
|
end
|
135
|
+
|
136
|
+
def fail_on_price_set(options)
|
137
|
+
compared_array = [:initial_price, :recurring_price] & options.keys
|
138
|
+
if compared_array.any?
|
139
|
+
array_with_cents = compared_array.map{|word| word.to_s + '_in_cents' }.join(', ')
|
140
|
+
|
141
|
+
fail SyntaxError, "You misspelled! Gem uses #{array_with_cents} value(s)."
|
142
|
+
end
|
143
|
+
end
|
124
144
|
end
|
125
145
|
end
|
data/lib/ccbill_ruby/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ccbill_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmytro Vasin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-08-
|
11
|
+
date: 2017-08-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -102,6 +102,7 @@ files:
|
|
102
102
|
- images/billing_tools.png
|
103
103
|
- images/disabling_user_management.png
|
104
104
|
- images/encryption_key.png
|
105
|
+
- images/redirect_path.png
|
105
106
|
- images/url_editor.png
|
106
107
|
- images/url_library.png
|
107
108
|
- lib/ccbill_ruby.rb
|