easy_pay_u_latam 0.1.22 → 0.1.23
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 +9 -0
- data/app/assets/javascripts/easy_pay_u_latam/subscriptions/controllers/Subscriptions.js +27 -28
- data/app/controllers/easy_pay_u_latam/api/v1/pay_u_additional_charges_controller.rb +30 -0
- data/app/controllers/easy_pay_u_latam/api/v1/pay_u_subscriptions_controller.rb +8 -9
- data/app/models/easy_pay_u_latam/payu_payment.rb +42 -0
- data/config/routes.rb +1 -0
- data/lib/easy_pay_u_latam.rb +1 -0
- data/lib/easy_pay_u_latam/r_api/additional_charge.rb +42 -0
- data/lib/easy_pay_u_latam/r_api/subscription.rb +1 -1
- data/lib/easy_pay_u_latam/version.rb +1 -1
- metadata +18 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a7488eb02bd73a2e0a9e1985adeb73b08a077dc2fec24f84e8d1c6cefdc0f09f
|
4
|
+
data.tar.gz: 1037ea884d71536c6d3f1f589b1fd234aff545113b4321747d443d3560cf8441
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 690b7e42e7763aa14aa38a2cb8b19a5fdce8acccdc4f6e6c030527fc4ef42967ebb412743ea5ff9dc58d30ab04f3d2cdb52498b1918d71a16a97c38f9ecf8526
|
7
|
+
data.tar.gz: 66907a1086e3c0828a9e454349b1c64067d08f63b5acf841a737d5eb218e02d63f7493516daedb4cd7ba45c39ab81de1a68b1077d7162120c0820b076b4cabf4
|
data/README.md
CHANGED
@@ -68,6 +68,15 @@ EasyPayULatam.configure do |config|
|
|
68
68
|
#Pay U will consume a Web Service and it can not be in localhost, you most use something like ngrok
|
69
69
|
config.test_root_url = "ROOT URL FOR TESTING"
|
70
70
|
config.currency_precision = 2 #By default is 0 for colombian peso
|
71
|
+
config.testing = true #Set false in production
|
72
|
+
end
|
73
|
+
|
74
|
+
# This keys are different, the recursive API use other keys
|
75
|
+
EasyPayULatam::RApi.configure do |config|
|
76
|
+
config.api_login = 'YOUR KEY'
|
77
|
+
config.api_key = 'YOUR KEY'
|
78
|
+
config.account_id = 'YOUR PAY U ACCOUNT ID'
|
79
|
+
config.sandbox = true #Set false in production
|
71
80
|
end
|
72
81
|
```
|
73
82
|
|
@@ -56,27 +56,27 @@
|
|
56
56
|
}, 100);
|
57
57
|
|
58
58
|
$('#new-credit-card-modal').on('shown.bs.modal', function () {
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
59
|
+
if (self.create_subscription_after_new_card == true){
|
60
|
+
swal({
|
61
|
+
title: 'Confirmación',
|
62
|
+
text: "Cargaremos a tu tarjeta principal mensualmente el valor del plan hasta que canceles la subscripción.",
|
63
|
+
type: 'info',
|
64
|
+
showCancelButton: true,
|
65
|
+
confirmButtonColor: '#3085d6',
|
66
|
+
cancelButtonColor: '#d33',
|
67
|
+
confirmButtonText: 'Si, continuar',
|
68
|
+
cancelButtonText: "Cancelar"
|
69
|
+
}).then((result) => {
|
70
|
+
if (result) {
|
71
|
+
$scope.$evalAsync(function(){
|
72
|
+
('#new-credit-card-modal').modal("show");
|
73
|
+
});
|
74
|
+
}
|
75
|
+
else{
|
76
|
+
self.create_subscription_after_new_card = false;
|
77
|
+
}
|
78
|
+
});
|
79
|
+
}
|
80
80
|
})
|
81
81
|
}
|
82
82
|
|
@@ -127,10 +127,6 @@
|
|
127
127
|
$http.get("/easy_pay_u_latam/api/v1/pay_u_cards.json", {params: params}).then(
|
128
128
|
function(res, status){
|
129
129
|
self.cards = res.data.cards;
|
130
|
-
//Si el usuario seleccinó un plan se crea la subscripción automaticamente
|
131
|
-
if (self.create_subscription_after_new_card == true){
|
132
|
-
self.CreateSubscription();
|
133
|
-
}
|
134
130
|
},
|
135
131
|
function(res, status){
|
136
132
|
}
|
@@ -165,7 +161,10 @@
|
|
165
161
|
$("#new-credit-card-modal").modal("hide");
|
166
162
|
swal("¡Excelente!", "¡La tarjeta de crédito creada con éxito!", "success");
|
167
163
|
|
168
|
-
|
164
|
+
//Si el usuario seleccinó un plan se crea la subscripción automaticamente
|
165
|
+
if (self.create_subscription_after_new_card == true){
|
166
|
+
self.CreateSubscription();
|
167
|
+
}
|
169
168
|
},
|
170
169
|
function(res, status){
|
171
170
|
self.card_loading = false;
|
@@ -326,8 +325,8 @@
|
|
326
325
|
self.subscription_loading = false;
|
327
326
|
//Mirar si se muestra alerta y se fuerza un refresh
|
328
327
|
//O recirbir respuesta json y actualizar variables necesarias desde el API
|
329
|
-
swal("Información", "Estamos procesando tu pago
|
330
|
-
|
328
|
+
swal("Información", "Estamos procesando tu pago", "success");
|
329
|
+
window.location.reload();
|
331
330
|
},
|
332
331
|
function(res, status){
|
333
332
|
self.subscription_loading = false;
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module EasyPayULatam
|
2
|
+
class Api::V1::PayUAdditionalChargesController < ApiController
|
3
|
+
|
4
|
+
acts_as_token_authentication_handler_for User
|
5
|
+
|
6
|
+
def create
|
7
|
+
|
8
|
+
addcharge = current_user.last_payment.add_charge(params)
|
9
|
+
|
10
|
+
unless addcharge.response.blank?
|
11
|
+
render status: 200, json: {message: "ok"}
|
12
|
+
else
|
13
|
+
msg = addcharge.error["errorList"].blank? ? addcharge.error["description"] : addcharge.error["errorList"].to_sentence
|
14
|
+
render status: 411, json: {message: msg }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def destroy
|
19
|
+
|
20
|
+
if current_user.last_payments.count > 0
|
21
|
+
current_user.last_payment.remove_charge(params[:charge_id])
|
22
|
+
|
23
|
+
render status: 200, json: {message: "¡Cargo extra cancelado correctamente, tu plan estará activo por el periodo que ya habías pagado!"}
|
24
|
+
else
|
25
|
+
render status: 411, json: {message: "No tienes cargos extra para cancelar"}
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -4,15 +4,14 @@ 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
|
-
|
15
|
-
# end
|
7
|
+
client = RApi::Client.new current_user.pay_u_costumer_id
|
8
|
+
subs = RApi::Subscription.new client
|
9
|
+
|
10
|
+
unless subs.response["recurringBillList"].blank?
|
11
|
+
render status: 200, json: {subscriptions: current_user.all_payments.first(30), subscriptions_api: subs.response["recurringBillList"].last(30)}
|
12
|
+
else
|
13
|
+
render status: 200, json: {subscriptions: [], subscriptions_api: []}
|
14
|
+
end
|
16
15
|
end
|
17
16
|
|
18
17
|
def create
|
@@ -18,5 +18,47 @@ module EasyPayULatam
|
|
18
18
|
self.status == PENDING
|
19
19
|
end
|
20
20
|
|
21
|
+
def add_charge(params)
|
22
|
+
@payUConfig = EasyPayULatam.configuration
|
23
|
+
|
24
|
+
client = RApi::Client.new current_user.pay_u_costumer_id
|
25
|
+
addcharge = RApi::AdditionalCharge.new client, self.reference_recurring_payment
|
26
|
+
addcharge.params = {
|
27
|
+
"description": params[:description],
|
28
|
+
"additionalValues": {
|
29
|
+
{
|
30
|
+
"name": "ITEM_VALUE",
|
31
|
+
"value": params[:value],
|
32
|
+
"currency": "COP"
|
33
|
+
},
|
34
|
+
{
|
35
|
+
"name": "ITEM_TAX",
|
36
|
+
"value": "0",
|
37
|
+
"currency": "COP"
|
38
|
+
},
|
39
|
+
{
|
40
|
+
"name": "ITEM_TAX_RETURN_BASE",
|
41
|
+
"value": "0",
|
42
|
+
"currency": "COP"
|
43
|
+
}
|
44
|
+
}
|
45
|
+
}
|
46
|
+
|
47
|
+
addcharge.create!
|
48
|
+
|
49
|
+
addcharge
|
50
|
+
end
|
51
|
+
|
52
|
+
def remove_charge(id)
|
53
|
+
@payUConfig = EasyPayULatam.configuration
|
54
|
+
|
55
|
+
client = RApi::Client.new current_user.pay_u_costumer_id
|
56
|
+
addcharge = RApi::AdditionalCharge.new client, self.reference_recurring_payment
|
57
|
+
|
58
|
+
addcharge.delete id
|
59
|
+
|
60
|
+
addcharge
|
61
|
+
end
|
62
|
+
|
21
63
|
end
|
22
64
|
end
|
data/config/routes.rb
CHANGED
@@ -14,6 +14,7 @@ EasyPayULatam::Engine.routes.draw do
|
|
14
14
|
resources :pay_u_clients, only: [:create]
|
15
15
|
resources :pay_u_plans, only: [:index]
|
16
16
|
resources :pay_u_subscriptions, only: [:index, :show, :create, :update, :destroy]
|
17
|
+
resources :pay_u_additional_charges, only: [:create, :destroy]
|
17
18
|
end
|
18
19
|
end
|
19
20
|
|
data/lib/easy_pay_u_latam.rb
CHANGED
@@ -0,0 +1,42 @@
|
|
1
|
+
module EasyPayULatam
|
2
|
+
module RApi
|
3
|
+
class AdditionalCharge < Request
|
4
|
+
attr_reader :url, :plan, :customer, :card, :sub_id
|
5
|
+
attr_accessor :resource, :params
|
6
|
+
|
7
|
+
def initialize(customer, sub_id)
|
8
|
+
@customer = customer
|
9
|
+
@sub_id = sub_id
|
10
|
+
@customer = customer.response if !customer.nil?
|
11
|
+
# @callback_url = callback_url
|
12
|
+
@params = {}
|
13
|
+
return if @customer.nil?
|
14
|
+
# load("")
|
15
|
+
end
|
16
|
+
|
17
|
+
def create_url
|
18
|
+
@url = RApi.base_url + "/rest/v4.9/subscriptions/#{@sub_id}/recurringBillItems}"
|
19
|
+
end
|
20
|
+
|
21
|
+
def url
|
22
|
+
@url = RApi.base_url + "/rest/v4.9/recurringBillItems/"
|
23
|
+
end
|
24
|
+
|
25
|
+
def create!
|
26
|
+
create_url
|
27
|
+
super
|
28
|
+
end
|
29
|
+
|
30
|
+
def load(id)
|
31
|
+
url
|
32
|
+
super
|
33
|
+
end
|
34
|
+
|
35
|
+
def delete(id)
|
36
|
+
url
|
37
|
+
super
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
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.23
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- DEVPENGUIN
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-09-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rails-assets-sweetalert2
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: sweet-alert2-rails
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -146,6 +160,7 @@ files:
|
|
146
160
|
- app/assets/stylesheets/easy_pay_u_latam/styles.css
|
147
161
|
- app/assets/stylesheets/easy_pay_u_latam/subscriptions/application.scss
|
148
162
|
- app/assets/stylesheets/easy_pay_u_latam/subscriptions/card.css
|
163
|
+
- app/controllers/easy_pay_u_latam/api/v1/pay_u_additional_charges_controller.rb
|
149
164
|
- app/controllers/easy_pay_u_latam/api/v1/pay_u_cards_controller.rb
|
150
165
|
- app/controllers/easy_pay_u_latam/api/v1/pay_u_clients_controller.rb
|
151
166
|
- app/controllers/easy_pay_u_latam/api/v1/pay_u_payments_controller.rb
|
@@ -184,6 +199,7 @@ files:
|
|
184
199
|
- lib/easy_pay_u_latam/Configuration.rb
|
185
200
|
- lib/easy_pay_u_latam/engine.rb
|
186
201
|
- lib/easy_pay_u_latam/r_api.rb
|
202
|
+
- lib/easy_pay_u_latam/r_api/additional_charge.rb
|
187
203
|
- lib/easy_pay_u_latam/r_api/card.rb
|
188
204
|
- lib/easy_pay_u_latam/r_api/client.rb
|
189
205
|
- lib/easy_pay_u_latam/r_api/invoice.rb
|