easy_pay_u_latam 0.1.16 → 0.1.17
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/app/assets/javascripts/easy_pay_u_latam/subscriptions/controllers/Subscriptions.js +14 -1
- data/app/controllers/easy_pay_u_latam/api/v1/pay_u_cards_controller.rb +3 -2
- data/app/controllers/easy_pay_u_latam/api/v1/pay_u_subscriptions_controller.rb +60 -15
- data/app/views/easy_pay_u_latam/pay_u_payments/_dashboard.html.erb +1 -1
- data/app/views/easy_pay_u_latam/pay_u_payments/cards/_list.html.erb +3 -3
- data/app/views/easy_pay_u_latam/pay_u_payments/subscriptions/_actual.html.erb +17 -11
- data/app/views/easy_pay_u_latam/pay_u_payments/subscriptions/_list.html.erb +5 -5
- data/db/migrate/20170929211207_create_easy_pay_u_latam_payu_payments.rb +1 -1
- data/lib/easy_pay_u_latam/r_api/subscription.rb +1 -1
- data/lib/easy_pay_u_latam/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 92312a4faad16ed20b911633516d52cdf80d0aed11e76244c99a59d6d31a3ce6
|
4
|
+
data.tar.gz: b97b7aaac62e33efd4cb2c8eba3fd88909397c6fd80b3f79457bc2d47abaa03e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c96fb55e3e4b6cc9724213d52fb0351eafe7a559e3c75f2e2b4418b36bf501a7d2d24fa0d0a716936fe7dd2c399f09b0f2585d8b754a29ce80c346beec49bb0b
|
7
|
+
data.tar.gz: 3887f13d76debc527dc211c0375d57beb0e98445b263b5d55cf80965e55d0138d28a74ed10bef569f6d390a46b1ab0fc60e71b403608f7c9bfa91c12f049bad4
|
@@ -7,6 +7,8 @@
|
|
7
7
|
//Atributos de Planes
|
8
8
|
this.actual_plan = null;
|
9
9
|
this.selected_plan = null;
|
10
|
+
this.last_payment = null;
|
11
|
+
this.is_buyer = false;
|
10
12
|
this.plans = [];
|
11
13
|
|
12
14
|
//Atributos de Subscripciones
|
@@ -37,9 +39,13 @@
|
|
37
39
|
width: 500 //optional
|
38
40
|
};
|
39
41
|
|
40
|
-
this.init = function(uuid, token, plans){
|
42
|
+
this.init = function(uuid, token, plans, is_buyer, last_payment, actual_plan){
|
41
43
|
this.user_uuid = uuid;
|
42
44
|
this.user_token = token;
|
45
|
+
this.is_buyer = is_buyer;
|
46
|
+
this.last_payment = last_payment;
|
47
|
+
this.actual_plan = actual_plan;
|
48
|
+
|
43
49
|
this.ClearCard();
|
44
50
|
this.GetClient();
|
45
51
|
//No tengo ni idea porque me toco hacer eso pero sin el timeout simplemente el ng-repeat no renderiza plans
|
@@ -296,6 +302,7 @@
|
|
296
302
|
subscription: {
|
297
303
|
quantity: "1",
|
298
304
|
installments: "1",
|
305
|
+
immediatePayment: true,
|
299
306
|
trialDays: "15",
|
300
307
|
customer: {
|
301
308
|
id: "",
|
@@ -318,9 +325,12 @@
|
|
318
325
|
self.subscription_loading = false;
|
319
326
|
//Mirar si se muestra alerta y se fuerza un refresh
|
320
327
|
//O recirbir respuesta json y actualizar variables necesarias desde el API
|
328
|
+
swal("Información", "Estamos procesando tu pago", "success");
|
329
|
+
window.location.reload();
|
321
330
|
},
|
322
331
|
function(res, status){
|
323
332
|
self.subscription_loading = false;
|
333
|
+
swal("Información", res.data.message, "warning");
|
324
334
|
}
|
325
335
|
);
|
326
336
|
}
|
@@ -348,11 +358,14 @@
|
|
348
358
|
$http.delete("/easy_pay_u_latam/api/v1/pay_u_subscriptions/0000.json", {params: params}).then(
|
349
359
|
function(res, status){
|
350
360
|
self.subscription_loading = false;
|
361
|
+
swal("Información", res.data.message, "success");
|
362
|
+
window.location.reload();
|
351
363
|
//Mirar si se muestra alerta y se fuerza un refresh
|
352
364
|
//O recirbir respuesta json y actualizar variables necesarias desde el API
|
353
365
|
},
|
354
366
|
function(res, status){
|
355
367
|
self.subscription_loading = false;
|
368
|
+
swal("Información", res.data.message, "warning");
|
356
369
|
}
|
357
370
|
);
|
358
371
|
});
|
@@ -8,7 +8,7 @@ module EasyPayULatam
|
|
8
8
|
cards = RApi::Card.new client
|
9
9
|
unless cards.response["creditCardList"].blank?
|
10
10
|
if cards.response["creditCardList"].count == 1
|
11
|
-
if current_user.payu_default_card
|
11
|
+
if current_user.payu_default_card != cards.response["creditCardList"][0]["token"]
|
12
12
|
current_user.update_attribute :payu_default_card, cards.response["creditCardList"][0]["token"]
|
13
13
|
end
|
14
14
|
end
|
@@ -43,8 +43,9 @@ module EasyPayULatam
|
|
43
43
|
#validat si tiene subscripciones y actualizar subscricion
|
44
44
|
|
45
45
|
subs = RApi::Subscription.new client
|
46
|
+
|
46
47
|
unless subs.response.blank?
|
47
|
-
|
48
|
+
if !subs.response["creditCardList"].nil? && !subs.response["creditCardList"].empty?
|
48
49
|
res = subs.update({"creditCardToken": params[:id]})
|
49
50
|
|
50
51
|
unless subs.response.blank?
|
@@ -4,24 +4,35 @@ module EasyPayULatam
|
|
4
4
|
acts_as_token_authentication_handler_for User
|
5
5
|
|
6
6
|
def index
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
7
|
+
render status: 200, json: {subscriptions: current_user.all_payments.first(30)}
|
8
|
+
# client = RApi::Client.new current_user.pay_u_costumer_id
|
9
|
+
# subs = RApi::Subscription.new client
|
10
|
+
#
|
11
|
+
# unless subs.response["recurringBillList"].blank?
|
12
|
+
# render status: 200, json: {subscriptions: subs.response["recurringBillList"].last(30)}
|
13
|
+
# else
|
14
|
+
# render status: 200, json: {subscriptions: []}
|
15
|
+
# end
|
15
16
|
end
|
16
17
|
|
17
18
|
def create
|
19
|
+
@payUConfig = EasyPayULatam.configuration
|
20
|
+
generate_payment(params[:subscription][:plan][:planCode])
|
21
|
+
|
18
22
|
client = RApi::Client.new current_user.pay_u_costumer_id
|
19
23
|
subs = RApi::Subscription.new client
|
20
24
|
subs.params = params[:subscription].as_json
|
21
25
|
subs.params["customer"]["id"] = current_user.pay_u_costumer_id
|
22
26
|
subs.params["customer"]["creditCards"][0]["token"] = current_user.payu_default_card
|
27
|
+
|
28
|
+
if !current_user.last_payment.nil? && current_user.last_payment.end_date > Date.today
|
29
|
+
subs.params["trialDays"] = (current_user.last_payment.end_date - Date.today).to_i
|
30
|
+
end
|
31
|
+
|
32
|
+
subs.params["notifyUrl"] = "#{@payUConfig.get_root_url}/easy_pay_u_latam/api/v1/pay_u_payments/#{ @payu_payment.id}/confirmation.json?user_id=#{current_user.id}"
|
33
|
+
|
23
34
|
response = subs.create!
|
24
|
-
|
35
|
+
|
25
36
|
unless subs.response.blank?
|
26
37
|
render status: 200, json: {message: "ok"}
|
27
38
|
else
|
@@ -40,17 +51,51 @@ module EasyPayULatam
|
|
40
51
|
def destroy
|
41
52
|
client = RApi::Client.new current_user.pay_u_costumer_id
|
42
53
|
subs = RApi::Subscription.new client
|
43
|
-
unless subs.response.blank?
|
44
|
-
unless subs.response["creditCardList"].empty?
|
45
|
-
res = subs.delete params[:id]
|
46
54
|
|
47
|
-
|
48
|
-
|
49
|
-
|
55
|
+
if current_user.last_payments.count > 0
|
56
|
+
current_user.last_payments.each do |sub|
|
57
|
+
res = subs.delete sub.reference_recurring_payment
|
58
|
+
sub.update_attribute :response_message_pol, "CANCELLED BY USER"
|
59
|
+
sub.update_attribute :state_pol, "-1"
|
50
60
|
end
|
61
|
+
|
62
|
+
render status: 200, json: {message: "¡Subscripción cancelada correctamente, tu plan estará activo por el periodo que ya habías pagado!"}
|
51
63
|
else
|
52
64
|
render status: 411, json: {message: "No tienes subscripciones para cancelar"}
|
53
65
|
end
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
def generate_payment(plan_code)
|
70
|
+
plan = Plan.actives.find_by_payu_plan_code plan_code
|
71
|
+
# period_moths = 1 if plan.interval.downcase == "day"
|
72
|
+
period_moths = 1 if plan.interval.downcase == "month"
|
73
|
+
period_moths = 6 if plan.interval.downcase == "semester"
|
74
|
+
period_moths = 12 if plan.interval.downcase == "year"
|
75
|
+
|
76
|
+
current_user.update_attribute(:temp_plan_id, plan.id)
|
77
|
+
|
78
|
+
period = "del día" if plan.interval.downcase == "day"
|
79
|
+
period = "del año" if plan.interval.downcase == "year"
|
80
|
+
period = "del semestre" if plan.interval.downcase == "semester"
|
81
|
+
period = "del mes" if plan.interval.downcase == "month"
|
82
|
+
|
83
|
+
# end_date = Date.today + 1.day if plan.interval.downcase == "day"
|
84
|
+
end_date = Date.today + 1.month if plan.interval.downcase == "month"
|
85
|
+
end_date = Date.today + 6.months if plan.interval.downcase == "semester"
|
86
|
+
end_date = Date.today + 1.year if plan.interval.downcase == "year"
|
87
|
+
|
88
|
+
@payu_payment = EasyPayULatam::PayuPayment.create(
|
89
|
+
# amount: plan["value_month"],
|
90
|
+
amount: plan["value_#{plan.interval.downcase}"],
|
91
|
+
currency: "COP",
|
92
|
+
period: period_moths,
|
93
|
+
plan_id: plan.id,
|
94
|
+
user_id: current_user.id,
|
95
|
+
description: "Pago #{plan.name} #{period} UPICK",
|
96
|
+
start_date: Date.today,
|
97
|
+
end_date: end_date
|
98
|
+
)
|
54
99
|
end
|
55
100
|
end
|
56
101
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<%= stylesheet_link_tag "easy_pay_u_latam/subscriptions/application", media: "all" %>
|
2
2
|
<%= javascript_include_tag "easy_pay_u_latam/subscriptions/application" %>
|
3
3
|
<div id="easy_pay_u_latam">
|
4
|
-
<div ng-controller="SubscriptionsController as ssCtrl" ng-init="ssCtrl.init('<%= current_user.email %>', '<%= current_user.authentication_token %>', <%= Plan.actives.select(:id, :name, :value_month, :description, :payu_plan_code, :payu_plan_id).to_json%>)">
|
4
|
+
<div ng-controller="SubscriptionsController as ssCtrl" ng-init="ssCtrl.init('<%= current_user.email %>', '<%= current_user.authentication_token %>', <%= Plan.actives.select(:id, :name, :value_month, :description, :payu_plan_code, :payu_plan_id).to_json%>, <%= current_user.is_buyer?%>, <%= current_user.last_payment.to_json%>, <%= current_user.plan.to_json%>)">
|
5
5
|
<%= render "easy_pay_u_latam/pay_u_payments/subscriptions/none" %>
|
6
6
|
<%= render "easy_pay_u_latam/pay_u_payments/plans/list" %>
|
7
7
|
<%= render "easy_pay_u_latam/pay_u_payments/subscriptions/actual" %>
|
@@ -8,10 +8,10 @@
|
|
8
8
|
<%= render "easy_pay_u_latam/pay_u_payments/cards/form" %>
|
9
9
|
</div>
|
10
10
|
<div class="col-md-12">
|
11
|
-
<div class="alert alert-warning" ng-
|
11
|
+
<div class="alert alert-warning" ng-show="ssCtrl.cards.length == 0">
|
12
12
|
<strong>Información: </strong> No tienes medio de pagos creados, da click en <b>Nueva tarjeta</b> para crearlos.
|
13
13
|
</div>
|
14
|
-
<table class="table" ng-
|
14
|
+
<table class="table" ng-show="ssCtrl.cards.length > 0">
|
15
15
|
<tr>
|
16
16
|
<th>
|
17
17
|
Número de tajeta
|
@@ -38,7 +38,7 @@
|
|
38
38
|
{{card.type}}
|
39
39
|
</td>
|
40
40
|
<td class="text-center">
|
41
|
-
<button type="button" class="text-btn pull-right" ng-click="ssCtrl.DeleteCard(card)">
|
41
|
+
<button type="button" class="text-btn pull-right" ng-click="ssCtrl.DeleteCard(card)" ng-if="card.token != ssCtrl.user_default_card">
|
42
42
|
<i class="far fa-trash-alt"></i>
|
43
43
|
Eliminar
|
44
44
|
</button>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<div class="my-profile-info-text">
|
1
|
+
<div class="my-profile-info-text" ng-hide="ssCtrl.actual_plan == null">
|
2
2
|
<h2 class="h4">
|
3
3
|
<i class="fas fa-medal icon-full-blue"></i> Membresía y facturación
|
4
4
|
</h2>
|
@@ -7,23 +7,29 @@
|
|
7
7
|
<div class="col-md-8">
|
8
8
|
<p class="h6">
|
9
9
|
Plan actual:
|
10
|
-
<span ng-
|
10
|
+
<span ng-show="ssCtrl.subscription_loading != true">
|
11
11
|
{{ssCtrl.actual_plan.name}}
|
12
|
+
<small ng-show="ssCtrl.last_payment.state_pol == '4'">
|
13
|
+
(Renovación automática)
|
14
|
+
</small>
|
15
|
+
<small ng-show="ssCtrl.last_payment.state_pol == '-1'">
|
16
|
+
(Renovación manual)
|
17
|
+
</small>
|
12
18
|
</span>
|
13
|
-
<span ng-
|
19
|
+
<span ng-show="ssCtrl.subscription_loading == true">
|
14
20
|
<i class="fas fa-circle-notch fa-spin vertical-middle"></i>
|
15
21
|
</span>
|
16
22
|
</p>
|
17
23
|
<p class="h6">
|
18
|
-
Fecha de inicio:
|
24
|
+
Fecha de inicio: {{ssCtrl.last_payment.start_date}}
|
19
25
|
</p>
|
20
26
|
<p class="h6">
|
21
|
-
Fecha de corte:
|
27
|
+
Fecha de corte: {{ssCtrl.last_payment.end_date}}
|
22
28
|
</p>
|
23
|
-
<p class="h6">
|
24
|
-
Medio de pago:
|
29
|
+
<p class="h6" ng-show="ssCtrl.last_payment.number_card != null">
|
30
|
+
Medio de pago: {{ssCtrl.last_payment.number_card}}
|
25
31
|
</p>
|
26
|
-
<p class="h6" ng-
|
32
|
+
<p class="h6" ng-show="ssCtrl.selected_plan != null">
|
27
33
|
<span class="label label-info" style="font-size: 14px;">
|
28
34
|
Nuevo plan seleccionado: {{ssCtrl.selected_plan.name}}
|
29
35
|
</span>
|
@@ -36,16 +42,16 @@
|
|
36
42
|
</div>
|
37
43
|
<div class="col-md-4">
|
38
44
|
<div class="btn-group-vertical">
|
39
|
-
<button type="button" class="btn secundary-btn pull-right" style="font-size: 16px; margin-right: 15px" ng-click="ssCtrl.ChangePlan();">
|
45
|
+
<!-- <button type="button" class="btn secundary-btn pull-right" style="font-size: 16px; margin-right: 15px" ng-click="ssCtrl.ChangePlan();">
|
40
46
|
<span>Cambiar plan</span>
|
41
|
-
</button>
|
47
|
+
</button> -->
|
42
48
|
<!-- <button type="button" class="btn secundary-btn pull-right" style="font-size: 16px; margin-right: 15px">
|
43
49
|
<span>Actualizar información de pagos</span>
|
44
50
|
</button>
|
45
51
|
<button type="button" class="btn secundary-btn pull-right" style="font-size: 16px; margin-right: 15px">
|
46
52
|
<span>Detalles de facturación</span>
|
47
53
|
</button> -->
|
48
|
-
<button type="button" class="btn secundary-btn pull-right" style="font-size: 16px; margin-right: 15px" ng-
|
54
|
+
<button type="button" class="btn secundary-btn pull-right" style="font-size: 16px; margin-right: 15px" ng-show="ssCtrl.actual_plan != null" ng-click="ssCtrl.DeleteSubscription();">
|
49
55
|
<span>Cancelar membresía</span>
|
50
56
|
</button>
|
51
57
|
</div>
|
@@ -5,10 +5,10 @@
|
|
5
5
|
<br/>
|
6
6
|
<div class="row">
|
7
7
|
<div class="col-md-12">
|
8
|
-
<div class="alert alert-warning" ng-
|
8
|
+
<div class="alert alert-warning" ng-show="ssCtrl.subscriptions.length == 0">
|
9
9
|
<strong>Información: </strong> Aún no tienes facturas para mostrar.
|
10
10
|
</div>
|
11
|
-
<table class="table" ng-
|
11
|
+
<table class="table" ng-show="ssCtrl.subscriptions.length > 0">
|
12
12
|
<tr>
|
13
13
|
<th>
|
14
14
|
Orden Id
|
@@ -28,10 +28,10 @@
|
|
28
28
|
</tr>
|
29
29
|
<tr ng-repeat="sub in ssCtrl.subscriptions">
|
30
30
|
<td>
|
31
|
-
{{sub.
|
31
|
+
{{sub.reference_code}}
|
32
32
|
</td>
|
33
33
|
<td class="text-center">
|
34
|
-
{{sub.
|
34
|
+
{{sub.response_message_pol}}
|
35
35
|
</td>
|
36
36
|
<td class="text-right">
|
37
37
|
{{sub.amount | myCurrency}}
|
@@ -40,7 +40,7 @@
|
|
40
40
|
{{sub.currency}}
|
41
41
|
</td>
|
42
42
|
<td class="text-center">
|
43
|
-
{{
|
43
|
+
{{sub.created_at}}
|
44
44
|
</td>
|
45
45
|
</tr>
|
46
46
|
</table>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: easy_pay_u_latam
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- DEVPENGUIN
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-12-
|
11
|
+
date: 2018-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|