offsite_payments_pay2go 0.1.0 → 0.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 17bc7be70ded1c3fd6045587e7813a9a9c9b4f0c
4
- data.tar.gz: 69c2f763aebd5dacb6e209bfee4b3fa8d348e6fa
3
+ metadata.gz: 91b58534844c0d1a92130ef6ac346836d28fc042
4
+ data.tar.gz: 9e0ceada3a305c63d5a4c66b8dd290477283caf0
5
5
  SHA512:
6
- metadata.gz: d6d0f95efe41dcd1c4658d15205efb5fec833ccdd0f259c1e3c7d5615a907aa6058e8fad8d2ee4fdddd8e5bffe18291b9c1ba75e8be2fbd350c175f2ba2df53f
7
- data.tar.gz: 787dc54e0b52f904da74a85edb47f81d3151a7da448c255d930a5e5bc0b9a87c3743f5c3bf0a522f0838409bd78671b07f75bcbb97c98be4e5f6b91a602df2a3
6
+ metadata.gz: b689d51d1ea6bd12d01f01070028a8d53fd710bbb82f94de8bc256b44e0ad501ac9770bd0f4a715ce29284133bb309ac4c19dd44771623121a4e896c8345f1e4
7
+ data.tar.gz: 9f74c7bb84026a7178f0ac53a0915644f617adb240ff34a82cc1f75ae6b9df97118983ef35f8beba192f5fef389c83edbd01781fd06fc44be6ca1b72dd6df794
@@ -48,13 +48,13 @@ GEM
48
48
  arel (6.0.4)
49
49
  builder (3.2.3)
50
50
  concurrent-ruby (1.1.5)
51
- crass (1.0.4)
51
+ crass (1.0.5)
52
52
  erubis (2.7.0)
53
53
  globalid (0.4.2)
54
54
  activesupport (>= 4.2.0)
55
55
  i18n (0.9.5)
56
56
  concurrent-ruby (~> 1.0)
57
- loofah (2.2.3)
57
+ loofah (2.3.1)
58
58
  crass (~> 1.0.2)
59
59
  nokogiri (>= 1.5.9)
60
60
  mail (2.7.1)
@@ -67,7 +67,7 @@ GEM
67
67
  metaclass (~> 0.0.1)
68
68
  money (6.13.3)
69
69
  i18n (>= 0.6.4, <= 2)
70
- nokogiri (1.9.1)
70
+ nokogiri (1.10.5)
71
71
  mini_portile2 (~> 2.4.0)
72
72
  offsite_payments (2.7.11)
73
73
  actionpack (>= 3.2.20, < 6.0)
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # OffsitePaymentsPay2go
2
2
 
3
- OffsitePayments Integrations 介面串接 pay2go 的金流服務。這是非官方實作。
3
+ OffsitePayments Integrations 介面串接 pay2go 的金流服務。這是非官方實作。
4
+ This plugin is an OffsitePayments patch for Pay2go(智付通) online payment in Taiwan.
5
+ Now it supports Credit card(信用卡), ATM(ATM轉帳), and CVS(超商繳費).
4
6
 
5
7
  ## Installation
6
8
 
@@ -17,7 +19,89 @@ And then execute:
17
19
 
18
20
  ## Usage
19
21
 
20
- 實作 OffsitePayments 介面,使用者瀏覽器需在金流提供業者的網站下付款。
22
+ You can get Payment API and SPEC in [Pay2go API](https://www.pay2go.com/info/site_description/api_description).
23
+ Then create an initializer, like initializers/pay2go.rb. Add the following configurations depends on your settings.
24
+
25
+ ``` ruby
26
+
27
+ # config/environments/development.rb
28
+ config.after_initialize do
29
+ OffsitePayments::Base.integration_mode = :development
30
+ end
31
+
32
+ # config/environments/production.rb
33
+ config.after_initialize do
34
+ OffsitePayments::Base.integration_mode = :production
35
+ end
36
+
37
+ ```
38
+
39
+ ``` ruby
40
+
41
+ # initializers/pay2go.rb
42
+ OffsitePayments::Integrations::Pay2go.setup do |pay2go|
43
+ if Rails.env.development?
44
+ # change to yours
45
+ pay2go.merchant_id = '5455626'
46
+ pay2go.hash_key = '5294y06JbISpM5x9'
47
+ pay2go.hash_iv = 'v77hoKGq4kWxNNIS'
48
+ else
49
+ # change to yours
50
+ pay2go.merchant_id = '7788520'
51
+ pay2go.hash_key = 'adfas123412343j'
52
+ pay2go.hash_iv = '123ddewqerasdfas'
53
+ end
54
+ end
55
+ ```
56
+
57
+ ## Example Usage
58
+
59
+ Once you’ve configured ActiveMerchantPay2go, you need a checkout form; it looks like:
60
+
61
+ ``` ruby
62
+ <% payment_service_for @order,
63
+ @order.user.email,
64
+ :service => :pay2go,
65
+ :html => { :id => 'pay2go-checkout-form', :method => :post } do |service| %>
66
+ <% service.merchant_order_no @order.payments.last.identifier %>
67
+ <% service.respond_type "String" %>
68
+ <% service.time_stamp @order.created_at.to_i %>
69
+ <% service.version "1.2" %>
70
+ <% service.item_desc @order.number %>
71
+ <% service.amt @order.money %>
72
+ <% service.email @order.buyer.email %>
73
+ <% service.login_type 0 %>
74
+ <% service.client_back_url spree.orders_account_url %>
75
+ <% service.notify_url pay2go_return_url %>
76
+ <% service.encrypted_data %>
77
+ <%= submit_tag 'Buy!' %>
78
+ <% end %>
79
+ ```
80
+
81
+ Also need a notification action when Pay2go service notifies your server; it looks like:
82
+
83
+ ``` ruby
84
+ def notify
85
+ notification = OffsitePayments::Integrations::Pay2go::Notification.new(request.raw_post)
86
+
87
+ order = Order.find_by_number(notification.merchant_order_no)
88
+
89
+ if notification.status && notification.checksum_ok?
90
+ # payment is compeleted
91
+ else
92
+ # payment is failed
93
+ end
94
+
95
+ render text: '1|OK', status: 200
96
+ end
97
+ ```
98
+
99
+ ## Troublechooting
100
+ If you get a error "undefined method \`payment\_service\_for\`", you can add following configurations to initializers/pay2go.rb.
101
+ ```
102
+ require "offsite_payments/integrations/action_view_helper"
103
+ ActionView::Base.send(:include, OffsitePayments::Integrations::ActionViewHelper)
104
+ ```
21
105
 
22
106
  ## Contributing
23
107
 
@@ -25,4 +109,4 @@ And then execute:
25
109
  2. Create your feature branch (`git checkout -b my-new-feature`)
26
110
  3. Commit your changes (`git commit -am 'Add some feature'`)
27
111
  4. Push to the branch (`git push origin my-new-feature`)
28
- 5. Create new Pull Request
112
+ 5. Create new Pull Request
@@ -1,3 +1,3 @@
1
1
  module OffsitePaymentsPay2go
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: offsite_payments_pay2go
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - hothero
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2019-05-23 00:00:00.000000000 Z
13
+ date: 2019-11-13 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: money