easy_pay_u_latam 0.1.23 → 0.1.26

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a7488eb02bd73a2e0a9e1985adeb73b08a077dc2fec24f84e8d1c6cefdc0f09f
4
- data.tar.gz: 1037ea884d71536c6d3f1f589b1fd234aff545113b4321747d443d3560cf8441
3
+ metadata.gz: e0400eae8836ba7b7594aebab078c58d12d50f67226f4260f3d2c8b329a6d8d9
4
+ data.tar.gz: 1a4dd65dd66fc34d3bb1e2832f9917394fdc82b1b328ddaaa5706fdfad9a73bf
5
5
  SHA512:
6
- metadata.gz: 690b7e42e7763aa14aa38a2cb8b19a5fdce8acccdc4f6e6c030527fc4ef42967ebb412743ea5ff9dc58d30ab04f3d2cdb52498b1918d71a16a97c38f9ecf8526
7
- data.tar.gz: 66907a1086e3c0828a9e454349b1c64067d08f63b5acf841a737d5eb218e02d63f7493516daedb4cd7ba45c39ab81de1a68b1077d7162120c0820b076b4cabf4
6
+ metadata.gz: fd3e4a6246d847bb4273d50193f654a4fef31ec0f1f57ba4f437f7889b6855e35ddc626727b5d3aa95ac06a2efecff2f786eff318378dbea717417c6b6b4f802
7
+ data.tar.gz: ad8e4a43b3eca88da922a82c2af20b58cd30dce19dfae069d00c48f46129155600471123abcb4fa2d9e4204fa377a84d65021ee5945b464bec7ee409afc3219c
data/README.md CHANGED
@@ -35,7 +35,7 @@ $ rails g migration AddPayUFieldsToUsers payu_default_card:string payu_customer_
35
35
 
36
36
  Only run this when recurrent payments are ON, extra fields for recurrent payments on payments table, you must run the following migration.
37
37
  ```bash
38
- $ rails g migration AddRecurrentPaymentsToEasyPayULatamPayuPayments payu_plan_id:string payu_plan_code:string payu_customer_id:string payu_subscription_id:string trial_days:integer payu_credit_card_token:string
38
+ $ rails g migration AddRecurrentPaymentsToEasyPayULatamPayuPayments payu_plan_id:string payu_plan_code:string payu_customer_id:string payu_subscription_id:string trial_days:integer payu_credit_card_token:string additional_charges_data:string
39
39
  ```
40
40
 
41
41
  If you want to keep a reference to plans, before this you must have created a plan model on your project, you can run the following migration (User only when recurrent payments are ON).
@@ -76,7 +76,8 @@ EasyPayULatam::RApi.configure do |config|
76
76
  config.api_login = 'YOUR KEY'
77
77
  config.api_key = 'YOUR KEY'
78
78
  config.account_id = 'YOUR PAY U ACCOUNT ID'
79
- config.sandbox = true #Set false in production
79
+ config.sandbox = true #Set false in production
80
+ config.api_version = "v4.3"
80
81
  end
81
82
  ```
82
83
 
@@ -24,31 +24,44 @@ module EasyPayULatam
24
24
  client = RApi::Client.new current_user.pay_u_costumer_id
25
25
  addcharge = RApi::AdditionalCharge.new client, self.reference_recurring_payment
26
26
  addcharge.params = {
27
- "description": params[:description],
28
- "additionalValues": {
27
+ "description" => params[:description],
28
+ "additionalValues" => [
29
29
  {
30
- "name": "ITEM_VALUE",
31
- "value": params[:value],
32
- "currency": "COP"
30
+ "name" => "ITEM_VALUE",
31
+ "value" => params[:value],
32
+ "currency" => "COP"
33
33
  },
34
34
  {
35
- "name": "ITEM_TAX",
36
- "value": "0",
37
- "currency": "COP"
35
+ "name" => "ITEM_TAX",
36
+ "value" => "0",
37
+ "currency" => "COP"
38
38
  },
39
39
  {
40
- "name": "ITEM_TAX_RETURN_BASE",
41
- "value": "0",
42
- "currency": "COP"
40
+ "name" => "ITEM_TAX_RETURN_BASE",
41
+ "value" => "0",
42
+ "currency" => "COP"
43
43
  }
44
- }
44
+ ]
45
45
  }
46
46
 
47
47
  addcharge.create!
48
48
 
49
+ unless addcharge.response["id"].blank?
50
+ self.additional_charges_data = "#{self.additional_charges_data}|#{addcharge.response["id"]}·#{Date.today}"
51
+ end
52
+
49
53
  addcharge
50
54
  end
51
55
 
56
+ def get_additional_charges
57
+ charges = []
58
+ self.additional_charges_data.split("|").each do |charge|
59
+ data = charge.split("·")
60
+ charges.push({id: data[0], date: data[1]})
61
+ end
62
+ charges
63
+ end
64
+
52
65
  def remove_charge(id)
53
66
  @payUConfig = EasyPayULatam.configuration
54
67
 
@@ -3,7 +3,7 @@ module EasyPayULatam
3
3
  class << self
4
4
  require "base64"
5
5
  # NOTA: definir si dejar estos campos como accessors
6
- attr_accessor :api_login, :api_key, :account_id, :sandbox
6
+ attr_accessor :api_login, :api_key, :account_id, :sandbox, :api_version
7
7
  attr_reader :base_url
8
8
 
9
9
  # recibe un bloque inicializador de variables de configuración de payu como la
@@ -34,6 +34,7 @@ module EasyPayULatam
34
34
  # config.api_key = '4Vj8eK4rloUd272L48hsrarnUA'
35
35
  # config.account_id = '512321'
36
36
  # config.sandbox = true
37
+ # config.api_version = "v4.3"
37
38
  # end
38
39
 
39
40
  # production
@@ -42,6 +43,7 @@ module EasyPayULatam
42
43
  # config.api_key = 'ZNl7g0L2H54Y9ZVn51keXS2l07'
43
44
  # config.account_id = '762507'
44
45
  # config.sandbox = false
46
+ # config.api_version = "v4.3"
45
47
  # end
46
48
 
47
49
  end
@@ -15,11 +15,11 @@ module EasyPayULatam
15
15
  end
16
16
 
17
17
  def create_url
18
- @url = RApi.base_url + "/rest/v4.9/subscriptions/#{@sub_id}/recurringBillItems}"
18
+ @url = RApi.base_url + "/rest/#{RApi.api_version}/subscriptions/#{@sub_id}/recurringBillItems}"
19
19
  end
20
20
 
21
21
  def url
22
- @url = RApi.base_url + "/rest/v4.9/recurringBillItems/"
22
+ @url = RApi.base_url + "/rest/#{RApi.api_version}/recurringBillItems/"
23
23
  end
24
24
 
25
25
  def create!
@@ -21,13 +21,13 @@ module EasyPayULatam
21
21
 
22
22
  # llena la variable local y super con la url de este recurso
23
23
  def url
24
- @url ||= RApi.base_url + "/rest/v4.9/creditCards/"
24
+ @url ||= RApi.base_url + "/rest/#{RApi.api_version}/creditCards/"
25
25
  end
26
26
 
27
27
  # el recurso de tarjeta necesita en algunos casos alterar la URL para incluir información
28
28
  # del customer, por eso se crea este metodo con la url necesario
29
29
  def customer_url
30
- @url = RApi.base_url + "/rest/v4.9/customers/#{@customer['id']}/creditCards/"
30
+ @url = RApi.base_url + "/rest/#{RApi.api_version}/customers/#{@customer['id']}/creditCards/"
31
31
  end
32
32
 
33
33
  # se sobreescribe el metodo crear de request
@@ -15,7 +15,7 @@ module EasyPayULatam
15
15
 
16
16
  # url base
17
17
  def url
18
- @url = RApi.base_url + '/rest/v4.9/customers/'
18
+ @url = RApi.base_url + "/rest/#{RApi.api_version}/customers/"
19
19
  end
20
20
 
21
21
  private
@@ -34,7 +34,7 @@ module PayuLatam
34
34
  end
35
35
 
36
36
  def url
37
- @url = PayuLatam.base_url + '/rest/v4.9/recurringBill'
37
+ @url = PayuLatam.base_url + "/rest/#{RApi.api_version}/recurringBill"
38
38
  end
39
39
 
40
40
  def customer_url
@@ -50,4 +50,4 @@ module PayuLatam
50
50
  @url = url "?customerId=#{@id}&dateBegin=#{@dateBegin}&dateFinal=#{@dateFinal}"
51
51
  end
52
52
  end
53
- end
53
+ end
@@ -28,7 +28,7 @@ module EasyPayULatam
28
28
  end
29
29
 
30
30
  def url
31
- @url = RApi.base_url + '/rest/v4.9/plans/'
31
+ @url = RApi.base_url + "/rest/#{RApi.api_version}/plans/"
32
32
  end
33
33
 
34
34
  private
@@ -14,11 +14,11 @@ module EasyPayULatam
14
14
  end
15
15
 
16
16
  def invoice_url
17
- @url = RApi.base_url + "/rest/v4.9/recurringBill?customerId=#{@customer['id']}"
17
+ @url = RApi.base_url + "/rest/#{RApi.api_version}/recurringBill?customerId=#{@customer['id']}"
18
18
  end
19
19
 
20
20
  def url
21
- @url = RApi.base_url + '/rest/v4.9/subscriptions/'
21
+ @url = RApi.base_url + "/rest/#{RApi.api_version}/subscriptions/"
22
22
  end
23
23
 
24
24
  def create!
@@ -1,3 +1,3 @@
1
1
  module EasyPayULatam
2
- VERSION = '0.1.23'
2
+ VERSION = '0.1.26'
3
3
  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.23
4
+ version: 0.1.26
5
5
  platform: ruby
6
6
  authors:
7
7
  - DEVPENGUIN
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-15 00:00:00.000000000 Z
11
+ date: 2020-09-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails