unlock_paypal 0.1.0 → 0.2.0
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 942f31b8d6f7f37a5fb9d72f83127ff5e3875f79
|
4
|
+
data.tar.gz: 59220b5d737980dd78ae88d53fdfb04d3b65675f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 712e0a5c8d1bde5f24f058a2aa923677ddda74e20379988f245a78d44826a1d7f3ca83116178cdfdeaeb340cefc6d071d6e33374dc0462753af68112402e4f60
|
7
|
+
data.tar.gz: a957aa23d77006c31e81337f92a73d7dfada2c45bd936fd459ac44b27e79074ad9180046aa5ffd37f33ddc2dc0a278f254aa45b448291ced195551d6195c5a40
|
@@ -34,70 +34,57 @@ class UnlockPaypal::ContributionsController < ::ApplicationController
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def edit
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
37
|
+
authorize @contribution
|
38
|
+
@initiative = @contribution.initiative
|
39
|
+
@gateways = @initiative.gateways.without_state(:draft).order(:ordering)
|
40
|
+
paypal = PayPal::Recurring.new({token: params[:token]}.merge(@contribution.paypal_auth))
|
41
|
+
details = paypal.checkout_details
|
42
|
+
@contribution.gateway_data = {} unless @contribution.gateway_data
|
43
|
+
@contribution.gateway_data["token"] = params[:token]
|
44
|
+
@contribution.gateway_data["PayerID"] = params[:PayerID]
|
45
|
+
@contribution.gateway_data["checkout_status"] = details.status
|
46
|
+
@contribution.gateway_data["email"] = details.email
|
47
|
+
@contribution.gateway_data["payer_status"] = details.payer_status
|
48
|
+
@contribution.gateway_data["payer_status"] = details.payer_status
|
49
|
+
@contribution.gateway_data["first_name"] = details.first_name
|
50
|
+
@contribution.gateway_data["last_name"] = details.last_name
|
51
|
+
@contribution.gateway_data["country"] = details.country
|
52
|
+
@contribution.gateway_data["currency"] = details.currency
|
53
|
+
@contribution.gateway_data["amount"] = details.amount
|
54
|
+
@contribution.gateway_data["description"] = details.description
|
55
|
+
@contribution.gateway_data["ipn_url"] = details.ipn_url
|
56
|
+
@contribution.gateway_data["agreed"] = details.agreed?
|
57
|
+
@contribution.save!
|
58
|
+
paypal = PayPal::Recurring.new({
|
59
|
+
token: params[:token],
|
60
|
+
payer_id: params[:PayerID],
|
61
|
+
description: details.description,
|
62
|
+
amount: details.amount,
|
63
|
+
currency: details.currency
|
64
|
+
}.merge(@contribution.paypal_auth))
|
65
|
+
payment = paypal.request_payment
|
66
|
+
if payment.approved? && payment.completed?
|
67
|
+
recurring = PayPal::Recurring.new({
|
68
|
+
ipn_url: details.ipn_url,
|
69
|
+
description: details.description,
|
70
|
+
amount: details.amount,
|
71
|
+
currency: details.currency,
|
72
|
+
frequency: 1,
|
60
73
|
token: params[:token],
|
74
|
+
period: :monthly,
|
61
75
|
payer_id: params[:PayerID],
|
62
|
-
|
63
|
-
|
64
|
-
|
76
|
+
start_at: Time.now,
|
77
|
+
failed: 3,
|
78
|
+
outstanding: :next_billing
|
65
79
|
}.merge(@contribution.paypal_auth))
|
66
|
-
|
67
|
-
if
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
token: params[:token],
|
75
|
-
period: :monthly,
|
76
|
-
payer_id: params[:PayerID],
|
77
|
-
start_at: Time.now,
|
78
|
-
failed: 3,
|
79
|
-
outstanding: :next_billing
|
80
|
-
}.merge(@contribution.paypal_auth))
|
81
|
-
profile = recurring.create_recurring_profile
|
82
|
-
if profile.valid? && profile.profile_id.present? && profile.status == "ActiveProfile"
|
83
|
-
profile_data = {}
|
84
|
-
profile_data["profile_id"] = profile.profile_id
|
85
|
-
profile_data["profile_status"] = profile.status
|
86
|
-
@contribution.update gateway_data: @contribution.gateway_data.merge(profile_data)
|
87
|
-
@contribution.activate!
|
88
|
-
return redirect_to initiative_contribution_path(@initiative.id, @contribution)
|
89
|
-
else
|
90
|
-
if payment.errors.size > 0
|
91
|
-
payment.errors.each do |error|
|
92
|
-
error[:messages].each do |message|
|
93
|
-
@contribution.errors.add(:base, "#{error[:code]} #{message} (PayPal)")
|
94
|
-
end
|
95
|
-
end
|
96
|
-
else
|
97
|
-
@contribution.errors.add(:base, "Ooops. Ocorreu um erro ao ativar seu perfil recorrente no PayPal.")
|
98
|
-
end
|
99
|
-
return render '/initiatives/contributions/new'
|
100
|
-
end
|
80
|
+
profile = recurring.create_recurring_profile
|
81
|
+
if profile.valid? && profile.profile_id.present? && profile.status == "ActiveProfile"
|
82
|
+
profile_data = {}
|
83
|
+
profile_data["profile_id"] = profile.profile_id
|
84
|
+
profile_data["profile_status"] = profile.status
|
85
|
+
@contribution.update gateway_data: @contribution.gateway_data.merge(profile_data)
|
86
|
+
@contribution.activate!
|
87
|
+
return redirect_to initiative_contribution_path(@initiative.id, @contribution)
|
101
88
|
else
|
102
89
|
if payment.errors.size > 0
|
103
90
|
payment.errors.each do |error|
|
@@ -106,10 +93,21 @@ class UnlockPaypal::ContributionsController < ::ApplicationController
|
|
106
93
|
end
|
107
94
|
end
|
108
95
|
else
|
109
|
-
@contribution.errors.add(:base, "Ooops. Ocorreu um erro ao
|
96
|
+
@contribution.errors.add(:base, "Ooops. Ocorreu um erro ao ativar seu perfil recorrente no PayPal.")
|
110
97
|
end
|
111
98
|
return render '/initiatives/contributions/new'
|
112
99
|
end
|
100
|
+
else
|
101
|
+
if payment.errors.size > 0
|
102
|
+
payment.errors.each do |error|
|
103
|
+
error[:messages].each do |message|
|
104
|
+
@contribution.errors.add(:base, "#{error[:code]} #{message} (PayPal)")
|
105
|
+
end
|
106
|
+
end
|
107
|
+
else
|
108
|
+
@contribution.errors.add(:base, "Ooops. Ocorreu um erro ao processar seu pagamento no PayPal.")
|
109
|
+
end
|
110
|
+
return render '/initiatives/contributions/new'
|
113
111
|
end
|
114
112
|
end
|
115
113
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unlock_paypal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Weinmann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-11-
|
11
|
+
date: 2014-11-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
33
|
+
version: 0.2.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.
|
40
|
+
version: 0.2.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: paypal-recurring
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|