payify 0.1.17 → 0.1.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +80 -18
  3. data/lib/payify/version.rb +1 -1
  4. metadata +20 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d2a72ee40f171a59366aafdae3a4a164350a4f6abce4722eea01d8b81ead5d4d
4
- data.tar.gz: b250cfb7c1692d82208d532313a44cded79e43a21d91f0a66c796794e4b742d9
3
+ metadata.gz: 70ae7f58afc3e60048eb7fd0805544c7ba63998c515eb27ee32596d5a655a093
4
+ data.tar.gz: 54d8895cfb775340d9e4a582bb5129ec13597cd755fc055f063067a7c5fd3755
5
5
  SHA512:
6
- metadata.gz: fb80e767f463c6ea8967b980ae76ac23b5d3f89d084cc2f4bc216ca387498bdeac5b6a09cf5d243177583d11a3d012439ac78704dfaac281bf375bdf3ee9f98f
7
- data.tar.gz: e830d91f014df3ad9c143be2127a4ec52f9a435db3969e0b9cf9eba228d34941d39709c7c28189a7989120cce901c42070a051f888ee51cb76ca875ad7e88f9e
6
+ metadata.gz: 69995924741921bd60e5687bdc45093267ae5269530e24a3d63219de930819d0f810066edfedb2f5a76bfeb81b0c6405bb563a04f236fa09cd36bd5543136996
7
+ data.tar.gz: 78ca6aebe7be93be3cb78732710d0ebd09b4ba4edf1340663b2de9873dc5263c8807d65d12466a44bf3e354785de8e197c6694faebd17863fa0ab18d879956a8
data/README.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Payify
2
2
 
3
+ <span>[![Gem Version](https://img.shields.io/gem/v/payify.svg?label=payify&colorA=D30001&colorB=DF3B3C)](https://rubygems.org/gems/payify)</span> <span>
4
+ [![ruby](https://img.shields.io/badge/ruby-2.6+%20*-ruby.svg?colorA=D30001&colorB=DF3B3C)](https://github.com/andrewdsilva/payify)</span> <span>
5
+ ![Rubocop Status](https://img.shields.io/badge/rubocop-passing-rubocop.svg?colorA=1f7a1f&colorB=2aa22a)</span> <span>
6
+ [![MIT license](https://img.shields.io/badge/license-MIT-mit.svg?colorA=1f7a1f&colorB=2aa22a)](http://opensource.org/licenses/MIT)</span> <span>
7
+ ![Downloads](https://img.shields.io/gem/dt/payify.svg?colorA=004d99&colorB=0073e6)</span>
8
+
3
9
  PayifyRails is a Ruby gem that simplifies payment integration into Ruby on Rails projects. It allows to easily add payment functionality to your models. For example, by applying the HasPaymentConcern to a reservation model, you can manage the payment process for reservations seamlessly.
4
10
 
5
11
  ![Screenshot](./app/assets/images/payify/screenshot.png)
@@ -16,34 +22,44 @@ And then execute:
16
22
 
17
23
  ```
18
24
  bundle install
25
+
26
+ rails payify_engine:install:migrations
19
27
  ```
20
28
 
21
29
  ## Features ✅
22
30
 
23
- - Includes a Payment model
24
- - Provides concerns to easily add a payment system to your model
25
- - Enables payment with Stripe
26
- - Offers a payment form to integrate into your application
27
- - Allows payment status to be checked via an api route
28
- - Allows configuration of payment (currency, VAT)
29
- - Provides a user interface for payment processing
30
- - Enables management of payment status (pending, paid)
31
+ - Easily create a payment using your models (e.g., from a reservation)
32
+ - Set up payment with Stripe in just 2 minutes
33
+ - Add a payment form to an existing page in your application
34
+ - You can configure the currency and tax rates (VAT)
35
+ - You can track the status of your payments (pending, paid)
36
+ - You can check the payment status through the API
31
37
 
32
38
  ## Configuration
33
39
 
34
- For now, Payify uses Stripe as the payment gateway. You can configure the currency using an initializer.
40
+ You can configure the currency using an initializer.
35
41
 
36
42
  ```ruby
37
43
  # initializers/payify.rb
38
44
  Payify.setup do |config|
39
45
  config.currency = "usd"
40
- config.default_tax_rates_id = "eur"
46
+ config.default_tax_rates_id = "txr_1234567890"
41
47
  end
42
48
  ```
43
49
 
50
+ ### Tax rates
51
+
44
52
  To handle VAT or different tax rates on your payments, you need to create tax rates on Stripe and define the default_tax_rates_id or, alternatively, define the tax_rates_id method on your payment-related models. Leave it empty if you don't manage any taxes.
45
53
 
46
- You can set your Stripe API credentials using environment variables. (Secret key, Publishable key)
54
+ To create a tax rate on Stripe, follow these steps:
55
+
56
+ 1. Go to the "Products" menu in your Stripe account.
57
+ 2. Navigate to the "Tax Rates" tab.
58
+ 3. Click on the "New" button located at the top right corner.
59
+
60
+ ### API key
61
+
62
+ You need to set your Stripe API credentials using environment variables. (Secret key, Publishable key)
47
63
 
48
64
  ```ruby
49
65
  # .env
@@ -53,11 +69,13 @@ STRIPE_PUBLISHABLE_KEY="..."
53
69
 
54
70
  ## Usage
55
71
 
72
+ ### Add the functionality to your model
73
+
56
74
  To enable payment functionality for a model, simply include the HasPayment concern:
57
75
 
58
76
  ```ruby
59
77
  class Reservation < ApplicationRecord
60
- include Payify::HasPaymentConcern
78
+ include ::Payify::HasPaymentConcern
61
79
 
62
80
  def amount_to_pay
63
81
  self.price
@@ -70,23 +88,50 @@ class Reservation < ApplicationRecord
70
88
  end
71
89
  ```
72
90
 
91
+ ### Create a payment
92
+
73
93
  When you want to request a payment for a model on which you added the concern, you just need to call the create_payment method.
74
94
 
95
+ Then you can find the id of the new pending payment with payment.id.
96
+
75
97
  ```ruby
76
98
  reservation_1.create_payment
99
+ reservation_1.payment.id # new payment id
77
100
  ```
78
101
 
79
- Then you can find the id of the new pending payment with payment.id.
102
+ You can use the `after_save` event on your model to automatically create the payment. Here's an example of how you can implement it:
80
103
 
81
104
  ```ruby
82
- reservation_1.payment.id
105
+ class Booking < ApplicationRecord
106
+ include ::Payify::HasPaymentConcern
107
+
108
+ after_save :create_payment
109
+
110
+ def amount_to_pay
111
+ total_ttc
112
+ end
113
+ end
83
114
  ```
84
115
 
85
- Now you just have to redirect the user to `/payments/:id/new` or include the payment form in your page.
116
+ ### Include the routes
117
+
118
+ To be able to use the routes of Payify, you need to add the following line to your `config/routes.rb` file:
119
+
120
+ ```ruby
121
+ mount Payify::Engine => '/payify', as: 'payify'
122
+ ```
123
+
124
+ ### Request a payment
125
+
126
+ To allow the user to make a payment, you have two options:
127
+
128
+ 1. Redirect the user to the payment form: You can redirect the user to the payment form using the URL `/payify/payments/:id/new`, where `:id` represents the payment id.
129
+
130
+ 2. Include the payment form on your page:
86
131
 
87
132
  ```ruby
88
133
  # reservation/show.html.erb
89
- <%= render "payify/payments/form", payment: @payment %>
134
+ <%= render "payify/payments/form", payment: @object.payment %>
90
135
  ```
91
136
 
92
137
  After completing the payment process, the user will be redirected to:
@@ -95,6 +140,8 @@ After completing the payment process, the user will be redirected to:
95
140
  /payments/:id/complete
96
141
  ```
97
142
 
143
+ ### Verify the payment
144
+
98
145
  The application will then verify the payment status with Stripe. You can do it manually calling the following method:
99
146
 
100
147
  ```ruby
@@ -119,7 +166,22 @@ To customize the page that displays the payment status, you can create the follo
119
166
  <% end %>
120
167
  ```
121
168
 
122
- ## API
169
+ ### Override the controller
170
+
171
+ If you want to override the `PaymentsController`, create the following file:
172
+
173
+ ```ruby
174
+ # app/controllers/payify/payments_controller.rb
175
+ module Payify
176
+ class PaymentsController < ApplicationController
177
+ include ::Payify::PaymentsControllerConcern
178
+
179
+ ...
180
+ end
181
+ end
182
+ ```
183
+
184
+ ### Using the API
123
185
 
124
186
  If you prefer using the Payify API, after creating the payment object, you can initialize a new Stripe payment by making a request to: `/payments/:id/new.json`
125
187
 
@@ -131,7 +193,7 @@ After making the payment, you can make a request to the following endpoint to up
131
193
  /payments/:id/complete.json
132
194
  ```
133
195
 
134
- ## Status
196
+ ### Status
135
197
 
136
198
  You can access the payment status using `@payment.status`. The possible statuses are:
137
199
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Payify
4
- VERSION = "0.1.17"
4
+ VERSION = "0.1.18"
5
5
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: payify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.17
4
+ version: 0.1.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Lopez
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-06-22 00:00:00.000000000 Z
11
+ date: 2023-07-14 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: active_model_serializers
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.10.13
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.10.13
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: dotenv-rails
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -106,7 +120,7 @@ homepage: https://github.com/andrewdsilva/payify
106
120
  licenses:
107
121
  - MIT
108
122
  metadata: {}
109
- post_install_message:
123
+ post_install_message:
110
124
  rdoc_options: []
111
125
  require_paths:
112
126
  - lib
@@ -121,8 +135,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
135
  - !ruby/object:Gem::Version
122
136
  version: '0'
123
137
  requirements: []
124
- rubygems_version: 3.4.14
125
- signing_key:
138
+ rubygems_version: 3.1.6
139
+ signing_key:
126
140
  specification_version: 4
127
141
  summary: Payment integration for Ruby on Rails projects.
128
142
  test_files: []