vindi-rails-engines 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: c338b9c48768fa14df28c2a9a80eebb9df434761f290ad13238ee2bd356eb69e
4
+ data.tar.gz: c0fc63e9050e804ca08128032937ef984f0f24ca02f742f8f436bc931b0e0961
5
+ SHA512:
6
+ metadata.gz: 291d5f38a07ddb1845bdf5e045095286a2b047653680d567c35ca0504de8de8ae6035a19018f7085e2d84b739edcfd81b19c8cc1b714c21cbac0bfe9bf4523a1
7
+ data.tar.gz: 90f00aeee250ac82f02a1ec835260219faf67f6dfbb3ad930517aa555a2db0fb0a638f94628b06a5da452295f3d9ae6408a8e5fa551c3b4fab0a74e86105c5bc
data/README.md ADDED
@@ -0,0 +1,37 @@
1
+ # Vindi Rails Engines
2
+
3
+ [Leia em Português (README.pt-BR.md)](./README.pt-BR.md)
4
+
5
+ An extension gem for the [vindi-rails](https://github.com/wesleyskap/vindi-rails) core SDK, providing mountable frontend checkouts, HTML views, and Stimulus JS credit card tokenization components using Vindi's public keys encryption.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'vindi-rails-engines'
13
+ ```
14
+
15
+ ## Features & Usage
16
+
17
+ ### 1. Checkout UI Setup
18
+ Copy Stimulus JS tokenization components and checkout form partial views to your application:
19
+ ```bash
20
+ bundle exec rails generate vindi:checkout
21
+ ```
22
+ This generates:
23
+ - Checkout view form partial (`app/views/vindi/checkout/_form.html.erb`)
24
+ - Stimulus controller (`app/javascript/controllers/vindi_checkout_controller.js`)
25
+
26
+ ### 2. Environment Setup
27
+ Configure your public key in your environment file:
28
+ ```bash
29
+ ENV["VINDI_PUBLIC_KEY"] = "YOUR_PUBLIC_KEY"
30
+ ```
31
+
32
+ ## Running Tests
33
+
34
+ To run the Minitest suite:
35
+ ```bash
36
+ bundle exec rake test
37
+ ```
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rails/generators"
4
+
5
+ module Vindi
6
+ module Generators
7
+ class CheckoutGenerator < ::Rails::Generators::Base
8
+ source_root File.expand_path("templates", __dir__)
9
+
10
+ desc "Copies Vindi checkout Stimulus JS and view templates to your Rails application."
11
+
12
+ def copy_checkout_templates
13
+ copy_file "_form.html.erb", "app/views/vindi/checkout/_form.html.erb"
14
+ copy_file "checkout_controller.js", "app/javascript/controllers/vindi_checkout_controller.js"
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,39 @@
1
+ <!-- Vindi PCI-Compliant Checkout Form -->
2
+ <%= form_with url: checkout_path, local: true, data: { controller: "vindi-checkout" } do |f| %>
3
+ <!-- Vindi Public Key configured in environment -->
4
+ <input type="hidden" id="vindi-public-key" value="<%= ENV['VINDI_PUBLIC_KEY'] %>" data-vindi-checkout-target="publicKey">
5
+
6
+ <div class="form-group">
7
+ <label for="card_holder">Cardholder Name</label>
8
+ <input type="text" id="card_holder" class="form-control" data-vindi-checkout-target="holderName" placeholder="JOHN DOE" required>
9
+ </div>
10
+
11
+ <div class="form-group">
12
+ <label for="card_number">Card Number</label>
13
+ <input type="text" id="card_number" class="form-control" data-vindi-checkout-target="cardNumber" placeholder="4111 1111 1111 1111" required>
14
+ </div>
15
+
16
+ <div class="form-row">
17
+ <div class="form-group col-md-6">
18
+ <label for="card_expiry">Expiration Date</label>
19
+ <input type="text" id="card_expiry" class="form-control" data-vindi-checkout-target="expiry" placeholder="MM/YYYY" required>
20
+ </div>
21
+
22
+ <div class="form-group col-md-6">
23
+ <label for="card_cvv">CVV</label>
24
+ <input type="password" id="card_cvv" class="form-control" data-vindi-checkout-target="cvv" placeholder="123" required>
25
+ </div>
26
+ </div>
27
+
28
+ <!-- Hidden field to store the encrypted card token returned by Vindi -->
29
+ <%= f.hidden_field :payment_profile_token, data: { vindi_checkout_target: "tokenInput" } %>
30
+
31
+ <div class="form-group mt-3">
32
+ <button type="submit" class="btn btn-primary btn-block" data-action="click->vindi-checkout#tokenizeCard">
33
+ Pay Securely
34
+ </button>
35
+ </div>
36
+ <% end %>
37
+
38
+ <!-- Load Vindi Tokenizer JS Library -->
39
+ <script src="https://sandbox-gp.vindi.com.br/assets/vindi.js"></script>
@@ -0,0 +1,29 @@
1
+ import { Controller } from "@hotwired/stimulus"
2
+
3
+ // Connects to data-controller="vindi-checkout"
4
+ export default class extends Controller {
5
+ static targets = [ "publicKey", "holderName", "cardNumber", "expiry", "cvv", "tokenInput" ]
6
+
7
+ tokenizeCard(event) {
8
+ event.preventDefault()
9
+
10
+ const vindi = new Vindi(this.publicKeyTarget.value)
11
+
12
+ const cardData = {
13
+ holder_name: this.holderNameTarget.value,
14
+ card_number: this.cardNumberTarget.value.replace(/\s+/g, ''),
15
+ card_expiration: this.expiryTarget.value,
16
+ card_cvv: this.cvvTarget.value
17
+ }
18
+
19
+ vindi.createToken(cardData)
20
+ .then((response) => {
21
+ // Set the token into the hidden field and submit the form
22
+ this.tokenInputTarget.value = response.token
23
+ this.element.submit()
24
+ })
25
+ .catch((error) => {
26
+ alert("Payment Error: " + error.message)
27
+ })
28
+ }
29
+ }
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Vindi
4
+ class Engine < ::Rails::Engine
5
+ isolate_namespace Vindi
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Vindi
4
+ module Engines
5
+ VERSION = "0.1.0"
6
+ end
7
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "vindi"
4
+ require_relative "vindi/engines/version"
5
+ require_relative "vindi/engines/engine" if defined?(Rails)
6
+
7
+ module Vindi
8
+ module Engines
9
+ class Error < StandardError; end
10
+ end
11
+ end
metadata ADDED
@@ -0,0 +1,109 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vindi-rails-engines
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Wesley Lima
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2026-06-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: vindi-rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 0.2.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 0.2.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: railties
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '6.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '6.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: minitest
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Encapsulates reusable front-end screens, checkout templates, and credit
70
+ card tokenization components.
71
+ email:
72
+ - wesleyskap@gmail.com
73
+ executables: []
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - README.md
78
+ - lib/generators/vindi/checkout_generator.rb
79
+ - lib/generators/vindi/templates/_form.html.erb
80
+ - lib/generators/vindi/templates/checkout_controller.js
81
+ - lib/vindi-rails-engines.rb
82
+ - lib/vindi/engines/engine.rb
83
+ - lib/vindi/engines/version.rb
84
+ homepage: https://github.com/wesleyskap/vindi-rails
85
+ licenses:
86
+ - MIT
87
+ metadata:
88
+ homepage_uri: https://github.com/wesleyskap/vindi-rails
89
+ source_code_uri: https://github.com/wesleyskap/vindi-rails
90
+ post_install_message:
91
+ rdoc_options: []
92
+ require_paths:
93
+ - lib
94
+ required_ruby_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: 3.0.0
99
+ required_rubygems_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ requirements: []
105
+ rubygems_version: 3.5.22
106
+ signing_key:
107
+ specification_version: 4
108
+ summary: Rails mountable UI Engines for Vindi checkout and payment screens.
109
+ test_files: []