@bigbinary/neeto-payments-frontend 1.3.1 → 1.3.3

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.
package/README.md CHANGED
@@ -1,13 +1,29 @@
1
- # @bigbinary/neeto-payments-frontend
1
+ # neeto-payments-nano
2
+
3
+ - [Engine and package installation](./docs/engine-and-package-installation.md)
4
+ - [Building and releasing](./docs/building-and-releasing.md)
5
+
6
+ ## Integrations
7
+
8
+ | Project | Integrated |
9
+ | :----------: | :----------------: |
10
+ | neetoCal | :white_check_mark: |
11
+ | neetoInvoice | :white_check_mark: |
12
+ | neetoCourse | :x: |
13
+ | neetoForm | :x: |
14
+
15
+ ## @bigbinary/neeto-payments-frontend
2
16
 
3
17
  ![npm](https://img.shields.io/npm/v/@bigbinary/neeto-payments-frontend?color=greenyellow)
4
18
  ![npm](https://img.shields.io/npm/dw/@bigbinary/neeto-payments-frontend?color=greenyellow)
5
19
 
6
20
  neetoPayments is the library that manages payments across neeto products.
7
21
 
8
- ## Installation
22
+ ### Installation
9
23
 
10
- 1. **neetoPayments** has a few peer dependencies that are required for the proper functioning of the package. Install all the peer dependencies using the below command:
24
+ 1. **neetoPayments** has a few peer dependencies that are required for the
25
+ proper functioning of the package. Install all the peer dependencies using
26
+ the below command:
11
27
 
12
28
  ```zsh
13
29
  yarn add @bigbinary/neeto-commons-frontend@2.0.54 @bigbinary/neeto-filters-frontend@2.8.1 @bigbinary/neeto-icons@1.9.22 @bigbinary/neeto-molecules@1.0.9 @bigbinary/neetoui@4.4.10 @honeybadger-io/js@5.1.1 @honeybadger-io/react@5.1.3 axios@1.3.4 classnames@2.3.2 formik@2.2.9 js-logger@1.6.1 mixpanel-browser@2.45.0 ramda@0.28.0 react-helmet@6.1.0 react-query@3.39.3 react-router-dom@5.3.4 react-toastify@8.2.0 yup@1.0.2
@@ -19,7 +35,7 @@ neetoPayments is the library that manages payments across neeto products.
19
35
  yarn add @bigbinary/neeto-payments-frontend
20
36
  ```
21
37
 
22
- ## Usage
38
+ ### Usage
23
39
 
24
40
  neeto-payments-frontend exports:
25
41
 
@@ -27,19 +43,26 @@ neeto-payments-frontend exports:
27
43
  - `buildStripeTransactionLink()` function
28
44
  - `useStripePromise()` hook
29
45
 
30
- ### 1. `Dashboard` component
46
+ #### 1. `Dashboard` component
31
47
 
32
- #### Props
48
+ ##### Props
33
49
 
34
- 1. **holdableId**: To specify the ID of the entity that holds the stripe account. This is an optional prop. If the value is not specified, the current organization ID is taken as the default value while querying for transactions.
50
+ 1. **holdableId**: To specify the ID of the entity that holds the stripe
51
+ account. This is an optional prop. If the value is not specified, the current
52
+ organization ID is taken as the default value while querying for
53
+ transactions.
35
54
 
36
- 2. **payableEntityColumns**: To specify the columns from the payable entity which need to be additionally displayed. It is an optional prop that defaults to `[]` if not specified.
55
+ 2. **payableEntityColumns**: To specify the columns from the payable entity
56
+ which need to be additionally displayed. It is an optional prop that defaults
57
+ to `[]` if not specified.
37
58
 
38
59
  3. **searchProps**: To specify the properties of the search bar in `Dashboard`.
39
60
 
40
- 4. **tabs**: To specify the tabs to be displayed in the payments dashboard. It is an optional parameter.
61
+ 4. **tabs**: To specify the tabs to be displayed in the payments dashboard. It
62
+ is an optional parameter.
41
63
 
42
- 5. **headerProps**: To specify the props to be passed to the neetoUI `Header` component used in the `Dashboard`.
64
+ 5. **headerProps**: To specify the props to be passed to the neetoUI `Header`
65
+ component used in the `Dashboard`.
43
66
 
44
67
  **More about `payableEntityColumns`**
45
68
 
@@ -81,15 +104,21 @@ const payableEntityColumns = [
81
104
  ];
82
105
  ```
83
106
 
84
- The `payableEntityColumns` is similar to `columnData` prop used in `Table` component in **NeetoUI**. The prop can be modified accordingly to customize the columns in the table. For more customizations, refer
107
+ The `payableEntityColumns` is similar to `columnData` prop used in `Table`
108
+ component in **NeetoUI**. The prop can be modified accordingly to customize the
109
+ columns in the table. For more customizations, refer
85
110
  [NeetoUI docs](https://neeto-ui.neeto.com/?path=/docs/components-table--default).
86
111
 
87
- The additional keys are `isFilterable` and `filterProps`. `filterProps` is used to build the list of columns to be represented in the filters pane. The `isFilterable` key must be `true` for `filterProps` to be considered.
112
+ The additional keys are `isFilterable` and `filterProps`. `filterProps` is used
113
+ to build the list of columns to be represented in the filters pane. The
114
+ `isFilterable` key must be `true` for `filterProps` to be considered.
88
115
 
89
116
  > :memo: **Note:** The data about the payable entity is in the format
90
- > `{ payable: {...} }`. So the `dataIndex` key must be used accordingly. Refer the example above.
117
+ > `{ payable: {...} }`. So the `dataIndex` key must be used accordingly. Refer
118
+ > the example above.
91
119
 
92
- > In the case of columns with filter type as `single_option` or `multi_option`, `values` key can be passed along with `filterProps`.
120
+ > In the case of columns with filter type as `single_option` or `multi_option`,
121
+ > `values` key can be passed along with `filterProps`.
93
122
 
94
123
  **More about `searchProps` prop**
95
124
 
@@ -104,24 +133,30 @@ const searchProps = {
104
133
  };
105
134
  ```
106
135
 
107
- This is passed to the `FiltersBar` and `FiltersPane` components from `neeto-filters-frontend`. This is similar to the `keyword` prop used in `neeto-filters-frontend` with an additional `placeholder` key which is used as the placeholder in the search bar.
136
+ This is passed to the `FiltersBar` and `FiltersPane` components from
137
+ `neeto-filters-frontend`. This is similar to the `keyword` prop used in
138
+ `neeto-filters-frontend` with an additional `placeholder` key which is used as
139
+ the placeholder in the search bar.
108
140
 
109
141
  To know more about the working of `node` and `model` keys, refer the
110
142
  [`neeto-filters-frontend` documentation](https://github.com/bigbinary/neeto-filters-frontend/blob/main/README.md).
111
143
 
112
144
  **More about `tabs` prop**
113
145
 
114
- `tabs` is an array of strings. It has default value as this: `["all", "successful", "pending", "declined", "refunded"]`.It should only be a subset of the array above. Preferably it shouldn't be an empty array.
115
-
146
+ `tabs` is an array of strings. It has default value as this:
147
+ `["all", "successful", "pending", "declined", "refunded"]`.It should only be a
148
+ subset of the array above. Preferably it shouldn't be an empty array.
116
149
 
117
- ### 2. `buildStripeTransactionLink` function
150
+ #### 2. `buildStripeTransactionLink` function
118
151
 
119
- This function is used to generate the stripe transaction link from a payment identifier.
152
+ This function is used to generate the stripe transaction link from a payment
153
+ identifier.
120
154
 
121
155
  The arguments are:
122
156
 
123
157
  1. `identifier`: The payment identifier
124
- 2. `isLive`: Specifying whether or not the environment is live. It defaults to `true`.
158
+ 2. `isLive`: Specifying whether or not the environment is live. It defaults to
159
+ `true`.
125
160
 
126
161
  Example usage
127
162
 
@@ -132,11 +167,14 @@ const transactionLink = buildStripeTransactionLink(
132
167
  );
133
168
  ```
134
169
 
135
- ### 3. `useStripePromise` hook
170
+ #### 3. `useStripePromise` hook
136
171
 
137
- This hook is used to generate the `stripePromise` object to be passed to the stripe `<Elements>` context. The `useStripePromise` hook takes a stripe account identifier as input and returns a `Promise`.
172
+ This hook is used to generate the `stripePromise` object to be passed to the
173
+ stripe `<Elements>` context. The `useStripePromise` hook takes a stripe account
174
+ identifier as input and returns a `Promise`.
138
175
 
139
- > :memo: **Note:** `STRIPE_PUBLISHABLE_KEY` environment variable must be present for this hook to work.
176
+ > :memo: **Note:** `STRIPE_PUBLISHABLE_KEY` environment variable must be present
177
+ > for this hook to work.
140
178
 
141
179
  Example usage
142
180
 
@@ -150,9 +188,9 @@ Example usage
150
188
 
151
189
  ```
152
190
 
153
- ### 4. `PaymentKindRestrictionAlert` component
191
+ #### 4. `PaymentKindRestrictionAlert` component
154
192
 
155
- #### Props
193
+ ##### Props
156
194
 
157
195
  1. **isOpen**: To specify whether the Stripe connect restriction alert should be
158
196
  opened or closed.
@@ -175,7 +213,154 @@ Example usage
175
213
  />
176
214
  ```
177
215
 
178
- ## Other References
216
+ ## neetoPaymentsEngine
217
+
218
+ neeto-payments-engine is a Rails engine that manages payment across the neeto
219
+ products. It offers the following features to the users.
220
+
221
+ - Integrate payment gateway account.
222
+ - To set a charge for a service.
223
+ - Collect the charge from End-User.
224
+ - Refund amount collected by value or percentage.
225
+
226
+ Currently, the engine only supports [Stripe](https://stripe.com) payment gateway
227
+ integration from the following countries _Australia, Austria, Belgium, Canada,
228
+ Cyprus, Estonia, Finland, France, Germany, Gibraltar, Greece, Iceland, India,
229
+ Italy, Latvia, Lithuania, Luxembourg, Malta, Netherlands, Portugal, Slovakia,
230
+ Slovenia, Spain, United Kingdom, United States_. International transfers are not
231
+ possible for Indian business Stripe accounts.
232
+
233
+ ### Installation
234
+
235
+ 1. Add this line to your application's Gemfile:
236
+
237
+ ```ruby
238
+ gem 'neeto-payments-engine', git: 'https://github.com/bigbinary/neeto-payments-engine.git', branch: 'stable'
239
+ ```
240
+
241
+ 2. And then execute:
242
+
243
+ ```shell
244
+ bundle install
245
+ ```
246
+
247
+ 3. Add this line to your application's `config/routes.rb` file (replace `at` to
248
+ your desired route):
249
+
250
+ ```ruby
251
+ mount NeetoPaymentsEngine::Engine, at: '/payments'
252
+ ```
253
+
254
+ 4. Configure the following environment variables.
255
+
256
+ ```yaml
257
+ APP_URL=#Application URL
258
+ STRIPE_PUBLISHABLE_KEY='pk_test_fnFiGXjRkMXnLkueiNKJidGU00V83aRC0V'
259
+ STRIPE_SECRET_KEY='sk_test_eyKnYYoSDcvojBAiFoDv3QJQ00z0yOlt89'
260
+ ```
261
+
262
+ NB: Replace `APP_URL` environment variable value with the host application's
263
+ base URL without a trailing slash for example: `https://app.neetocal.net`.
264
+ Stripe environment variables values are `test` mode keys.
265
+
266
+ 5. Run the following command to subscribe Stripe webhooks events.
267
+
268
+ ```shell
269
+ bundle exec rails neeto_payments_engine:stripe:webhooks:subscribe
270
+ ```
271
+
272
+ - After successful subscription, the above command will return the list of
273
+ events subscribed and the details of environment variable.
274
+ - Sample output
275
+ ```
276
+ *** Successfully subscribed for webhooks ***
277
+ Please add the following environment variable
278
+ STRIPE_WEBHOOK_SECRET='whsec_06LHs3IOmLOgEzXDm3otErje8I4Q15ME'
279
+ ==============================================
280
+ Subscribed events: [
281
+ "account.updated",
282
+ "payment_intent.payment_failed",
283
+ "payment_intent.processing",
284
+ "payment_intent.succeeded",
285
+ "charge.refund.updated",
286
+ "charge.refunded"
287
+ ]
288
+ ```
289
+ - Add the returned environment variable and its value.
290
+
291
+ 6. Add the following secret values to `config/secrets.yml`.
292
+
293
+ ```yaml
294
+ host: <%= ENV['APP_URL'] || ENV['HEROKU_APP_URL'] %>
295
+ stripe:
296
+ publishable_key: <%= ENV['STRIPE_PUBLISHABLE_KEY'] %>
297
+ secret_key: <%= ENV['STRIPE_SECRET_KEY'] %>
298
+ webhooks:
299
+ secret: <%= ENV['STRIPE_WEBHOOK_SECRET'] %>
300
+ ```
301
+
302
+ 7. Add the following line to application's
303
+ `config/initializer/neeto_payments_engine.rb` file. Replace the
304
+ `holdable_class` value with a model name where you want to associate your
305
+ Stripe account in the host application.
306
+
307
+ ```ruby
308
+ NeetoPaymentsEngine.holdable_class = "Organization"
309
+ ```
310
+
311
+ 8. Add the following association to the model you defined as holdable_class in
312
+ step 6.
313
+
314
+ ```ruby
315
+ has_one :stripe_integration, class_name: "::NeetoPaymentsEngine::Stripe::Account", foreign_key: :holdable_id
316
+ ```
317
+
318
+ 9. Add the following association to the chargeable model. The chargeable model
319
+ is the model in the host application which needs to charge for its service.
320
+ For example `Meeting` model in `neetoCal` where meeting service is a
321
+ chargeable one.
322
+ ```ruby
323
+ has_one :charge, as: :chargeable, class_name: "::NeetoPaymentsEngine::Stripe::Charge", dependent: :destroy
324
+ ```
325
+ 10. Add the following association to the payable model.
326
+
327
+ ```ruby
328
+ has_one :payment, as: :payable, class_name: "::NeetoPaymentsEngine::Stripe::Transaction", dependent: :destroy
329
+ ```
330
+
331
+ 11. Add the following queue to your sidekiq config file `config/sidekiq.yml`
332
+ ```yaml
333
+ queues:
334
+ - payment # For neeto-payments-engine
335
+ ```
336
+
337
+ ### Development
338
+
339
+ 1. Add this line to your application's Gemfile (replace the path to the local
340
+ copy of neetoPayments' engine):
341
+
342
+ ```ruby
343
+ gem 'neeto-payments-engine', path: '../neeto-payments-engine'
344
+ ```
345
+
346
+ 2. And then execute:
347
+
348
+ ```shell
349
+ bundle install
350
+ ```
351
+
352
+ 3. Add this line to your application's `config/routes.rb` file (replace `at` to
353
+ your desired route):
354
+
355
+ ```ruby
356
+ mount NeetoPaymentsEngine::Engine, at: '/payments'
357
+ ```
358
+
359
+ ### Usage
360
+
361
+ This engine can be used to integrate a payment gateway and to do payments to
362
+ your application. Currently, the engine only supports the Stripe payment
363
+ gateway.
179
364
 
180
- - [Development instructions](./docs/general/development-instructions.md)
181
- - [Building and releasing](./docs/general/building-and-releasing.md)
365
+ 1. [Stripe Integration](./docs/stripe_integration.md)
366
+ 2. [Stripe Payment](./docs/stripe_payment.md)