conekta-tiempometa 2.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +24 -0
  3. data/.rspec +1 -0
  4. data/CHANGELOG.md +124 -0
  5. data/Dockerfile +44 -0
  6. data/Gemfile +13 -0
  7. data/LICENSE.txt +22 -0
  8. data/README.md +182 -0
  9. data/Rakefile +1 -0
  10. data/conekta.gemspec +29 -0
  11. data/lib/conekta/address.rb +5 -0
  12. data/lib/conekta/card.rb +21 -0
  13. data/lib/conekta/charge.rb +25 -0
  14. data/lib/conekta/conekta_object.rb +109 -0
  15. data/lib/conekta/customer.rb +82 -0
  16. data/lib/conekta/customer_info.rb +5 -0
  17. data/lib/conekta/destination.rb +17 -0
  18. data/lib/conekta/details.rb +5 -0
  19. data/lib/conekta/discount_line.rb +19 -0
  20. data/lib/conekta/error.rb +99 -0
  21. data/lib/conekta/error_details.rb +14 -0
  22. data/lib/conekta/event.rb +9 -0
  23. data/lib/conekta/line_item.rb +21 -0
  24. data/lib/conekta/list.rb +59 -0
  25. data/lib/conekta/log.rb +10 -0
  26. data/lib/conekta/method.rb +4 -0
  27. data/lib/conekta/operations/create.rb +19 -0
  28. data/lib/conekta/operations/create_member.rb +40 -0
  29. data/lib/conekta/operations/custom_action.rb +13 -0
  30. data/lib/conekta/operations/delete.rb +45 -0
  31. data/lib/conekta/operations/find.rb +21 -0
  32. data/lib/conekta/operations/update.rb +11 -0
  33. data/lib/conekta/operations/where.rb +30 -0
  34. data/lib/conekta/order.rb +87 -0
  35. data/lib/conekta/payee.rb +66 -0
  36. data/lib/conekta/payment_method.rb +4 -0
  37. data/lib/conekta/payment_source.rb +17 -0
  38. data/lib/conekta/payout.rb +7 -0
  39. data/lib/conekta/payout_method.rb +17 -0
  40. data/lib/conekta/plan.rb +16 -0
  41. data/lib/conekta/refund.rb +6 -0
  42. data/lib/conekta/requestor.rb +80 -0
  43. data/lib/conekta/resource.rb +54 -0
  44. data/lib/conekta/return.rb +12 -0
  45. data/lib/conekta/shipping_contact.rb +19 -0
  46. data/lib/conekta/shipping_line.rb +20 -0
  47. data/lib/conekta/subscription.rb +25 -0
  48. data/lib/conekta/tax_line.rb +19 -0
  49. data/lib/conekta/token.rb +8 -0
  50. data/lib/conekta/transfer.rb +7 -0
  51. data/lib/conekta/util.rb +136 -0
  52. data/lib/conekta/version.rb +3 -0
  53. data/lib/conekta/webhook.rb +12 -0
  54. data/lib/conekta/webhook_log.rb +4 -0
  55. data/lib/conekta.rb +101 -0
  56. data/lib/ssl_data/ca_bundle.crt +3955 -0
  57. data/locales/en.yml +9 -0
  58. data/locales/es.yml +10 -0
  59. data/readme_files/banner.png +0 -0
  60. data/readme_files/conekta-badge.png +0 -0
  61. data/readme_files/ruby-badge.png +0 -0
  62. data/spec/conekta/1.0.0/.DS_Store +0 -0
  63. data/spec/conekta/1.0.0/card_spec.rb +40 -0
  64. data/spec/conekta/1.0.0/charge_spec.rb +152 -0
  65. data/spec/conekta/1.0.0/customer_spec.rb +147 -0
  66. data/spec/conekta/1.0.0/error_spec.rb +69 -0
  67. data/spec/conekta/1.0.0/event_spec.rb +26 -0
  68. data/spec/conekta/1.0.0/log_spec.rb +20 -0
  69. data/spec/conekta/1.0.0/payout_spec.rb +60 -0
  70. data/spec/conekta/1.0.0/plan_spec.rb +53 -0
  71. data/spec/conekta/1.0.0/token_spec.rb +5 -0
  72. data/spec/conekta/1.0.0/webhook_spec.rb +36 -0
  73. data/spec/conekta/2.0.0/customer_spec.rb +77 -0
  74. data/spec/conekta/2.0.0/discount_line_spec.rb +49 -0
  75. data/spec/conekta/2.0.0/error_spec.rb +61 -0
  76. data/spec/conekta/2.0.0/line_item_spec.rb +53 -0
  77. data/spec/conekta/2.0.0/list_spec.rb +29 -0
  78. data/spec/conekta/2.0.0/order_spec.rb +291 -0
  79. data/spec/conekta/2.0.0/payee_spec.rb +55 -0
  80. data/spec/conekta/2.0.0/shipping_contact_spec.rb +60 -0
  81. data/spec/conekta/2.0.0/shipping_line_spec.rb +53 -0
  82. data/spec/conekta/2.0.0/source_spec.rb +31 -0
  83. data/spec/conekta/2.0.0/tax_line_spec.rb +44 -0
  84. data/spec/conekta/2.0.0/transfer_spec.rb +59 -0
  85. data/spec/conekta_spec.rb +29 -0
  86. data/spec/spec_helper.rb +14 -0
  87. data/spec/support/fixtures/orders.json +1127 -0
  88. data/spec/support/shared_context.rb +49 -0
  89. metadata +229 -0
@@ -0,0 +1,53 @@
1
+ require 'spec_helper'
2
+
3
+ describe Conekta::ShippingLine do
4
+ include_context "API 2.0.0"
5
+ include_context "order"
6
+
7
+ let(:shipping_lines) do
8
+ [
9
+ {
10
+ description: "Free Shipping",
11
+ amount: 0,
12
+ tracking_number: "TRACK123",
13
+ carrier: "USPS",
14
+ method: "Train",
15
+ },
16
+ {
17
+ description: "Otro Shipping",
18
+ amount: 40,
19
+ tracking_number: "TRACK124",
20
+ carrier: "USPS",
21
+ method: "Train",
22
+ }
23
+ ]
24
+ end
25
+
26
+ let(:order) do
27
+ Conekta::Order.create(order_data.merge(shipping_lines: shipping_lines))
28
+ end
29
+
30
+ let(:shipping_line) { order.shipping_lines.first }
31
+
32
+ context "deleting shipping lines" do
33
+ it "successful shipping line delete" do
34
+ shipping_line.delete
35
+
36
+ expect(shipping_line.deleted).to eq(true)
37
+ end
38
+ end
39
+
40
+ context "updating shipping lines" do
41
+ it "successful shipping line update" do
42
+ shipping_line.update(method: "Air")
43
+
44
+ expect(shipping_line._method).to eq("Air")
45
+ end
46
+
47
+ it "unsuccessful shipping line update" do
48
+ expect {
49
+ shipping_line.update(amount: -1)
50
+ }.to raise_error(Conekta::ParameterValidationError)
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+
3
+ describe Conekta::PaymentSource do
4
+ include_context "API 2.0.0"
5
+ include_context "customer"
6
+
7
+ let(:customer) { Conekta::Customer.create(customer_data) }
8
+ let(:payment_source) { customer.payment_sources.first }
9
+
10
+ context "deleting payment_sources" do
11
+ it "successful source delete" do
12
+ payment_source.delete
13
+
14
+ expect(payment_source.deleted).to eq(true)
15
+ end
16
+ end
17
+
18
+ context "updating payment_sources" do
19
+ it "successful payment_source update" do
20
+ payment_source.update(exp_month: 12)
21
+
22
+ expect(payment_source.exp_month).to eq("12")
23
+ end
24
+
25
+ it "unsuccessful payment_source update" do
26
+ expect {
27
+ payment_source.update(token_id: "tok_test_visa_4241")
28
+ }.to raise_error(Conekta::ParameterValidationError)
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,44 @@
1
+ require 'spec_helper'
2
+
3
+ describe Conekta::TaxLine do
4
+ include_context "API 2.0.0"
5
+ include_context "order"
6
+
7
+ let(:tax_lines) do
8
+ [
9
+ {
10
+ description: "IVA",
11
+ amount: 600
12
+ },
13
+ {
14
+ description: "ISR",
15
+ amount: 100
16
+ }
17
+ ]
18
+ end
19
+
20
+ let(:order) { Conekta::Order.create(order_data.merge(tax_lines: tax_lines)) }
21
+ let(:tax_line) { order.tax_lines.first }
22
+
23
+ context "deleting tax lines" do
24
+ it "successful tax line delete" do
25
+ tax_line.delete
26
+
27
+ expect(tax_line.deleted).to eq(true)
28
+ end
29
+ end
30
+
31
+ context "updating tax lines" do
32
+ it "successful tax line update" do
33
+ tax_line.update(amount: 50)
34
+
35
+ expect(tax_line.amount).to eq(50)
36
+ end
37
+
38
+ it "unsuccessful tax line update" do
39
+ expect {
40
+ tax_line.update(amount: -1)
41
+ }.to raise_error(Conekta::Error)
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,59 @@
1
+ require 'spec_helper'
2
+
3
+ describe Conekta::Payout do
4
+ include_context "API 2.0.0"
5
+
6
+ let(:payee_attributes) do
7
+ {
8
+ name: "John Doe", email: "j_d@radcorp.com", phone: "555555555",
9
+ billing_address:{
10
+ company_name: 'Rad Corp',
11
+ tax_id: 'tax121212abc',
12
+ street1: 'Guadalupe 73',
13
+ street2: 'Despacho 32',
14
+ street3: 'Condesa',
15
+ city: 'Cuauhtemoc',
16
+ state: 'DF',
17
+ country: 'MX',
18
+ zip: '06100'
19
+ }
20
+ }
21
+ end
22
+
23
+ let(:bank_attributes) do
24
+ {
25
+ type: "bank_account",
26
+ account_number: '072225008217746674',
27
+ account_holder_name: 'J D - Radcorp'
28
+ }
29
+ end
30
+
31
+ describe 'an instance' do
32
+ before do
33
+ payee = Conekta::Payee.create(payee_attributes)
34
+ payout_method = payee.create_destination(bank_attributes)
35
+
36
+ @payee = Conekta::Payee.find(payee.id)
37
+ end
38
+
39
+ it 'is created successfully' do
40
+ payout = Conekta::Transfer.create(
41
+ amount: 5000, currency: "MXN", payee: @payee.id
42
+ )
43
+ expect(payout).to be_a(Conekta::Transfer)
44
+ end
45
+
46
+ it 'can be retrieved by :id' do
47
+ transaction = Conekta::Transfer.create(
48
+ amount: 5000, currency: "MXN", payee: @payee.id
49
+ )
50
+ # refetch payout
51
+ payout = Conekta::Transfer.find(transaction.id)
52
+ expect(payout).to be_a(Conekta::Transfer)
53
+ end
54
+
55
+ it 'has a :method attribute' do
56
+ expect(@payee.destinations.first).to be_a(Conekta::Destination)
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+
3
+ describe Conekta do
4
+ describe ".config" do
5
+ it "sets the api key initializer style" do
6
+ Conekta.config { |c| c.api_key = "abc" }
7
+
8
+ expect(Conekta.api_key).to eq("abc")
9
+ end
10
+
11
+ it "sets the api version initializer style" do
12
+ Conekta.config { |c| c.api_version = "1.0" }
13
+
14
+ expect(Conekta.api_version).to eq("1.0")
15
+ end
16
+
17
+ it "sets the api locale initializer style" do
18
+ Conekta.config { |c| c.locale = "es" }
19
+
20
+ expect(Conekta.locale).to eq("es")
21
+ end
22
+
23
+ it "sets the plugin initializer style" do
24
+ Conekta.config { |c| c.plugin = "spree" }
25
+
26
+ expect(Conekta.plugin).to eq("spree")
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,14 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'rspec'
4
+ require 'pry'
5
+ require 'conekta'
6
+ require 'byebug'
7
+
8
+ # Requires supporting files with custom matchers and macros, etc,
9
+ # in ./support/ and its subdirectories.
10
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
11
+
12
+ RSpec.configure do |config|
13
+ config.before(:all) { Conekta.api_key = 'key_ZLy4aP2szht1HqzkCezDEA' }
14
+ end