@bigbinary/neeto-payments-frontend 1.3.8 → 1.3.10
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 +271 -283
- package/app/javascript/src/translations/en.json +17 -3
- package/dist/index.cjs.js +192 -31
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +196 -36
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,258 +1,40 @@
|
|
|
1
1
|
# neeto-payments-nano
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
neetoPayments is the library that manages payments across neeto products.
|
|
2
|
+
The `neeto-payments-nano` manages payments across neeto products. The nano exports the `@bigbinary/neeto-payments-frontend` NPM package and `neeto-payments-engine` Rails engine for development.
|
|
3
|
+
|
|
4
|
+
# Contents
|
|
5
|
+
1. [Development with Host Application](#development-with-host-application)
|
|
6
|
+
- [Engine](#engine)
|
|
7
|
+
- [Installation](#installation)
|
|
8
|
+
- [Usage](#usage)
|
|
9
|
+
- [Frontend package](#frontend-package)
|
|
10
|
+
- [Installation](#installation-1)
|
|
11
|
+
- [Components](#components)
|
|
12
|
+
- [Hooks](#hooks)
|
|
13
|
+
- [Functions](#functions)
|
|
14
|
+
2. [Instructions for Publishing](#instructions-for-publishing)
|
|
15
|
+
|
|
16
|
+
# Development with Host Application
|
|
17
|
+
## Engine
|
|
18
|
+
The engine is used to manage payments across neeto products.
|
|
21
19
|
|
|
22
20
|
### Installation
|
|
21
|
+
1. Add this line to your application's Gemfile:
|
|
22
|
+
```ruby
|
|
23
|
+
source "NEETO_GEM_SERVER_URL" do
|
|
24
|
+
# ..existing gems
|
|
23
25
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
the below command:
|
|
27
|
-
|
|
28
|
-
```zsh
|
|
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
|
|
26
|
+
gem 'neeto-payments-engine'
|
|
27
|
+
end
|
|
30
28
|
```
|
|
31
|
-
|
|
32
|
-
2. Now install the latest **neetoPayments** package using the below command:
|
|
33
|
-
|
|
29
|
+
2. And then execute:
|
|
34
30
|
```zsh
|
|
35
|
-
|
|
31
|
+
bundle install
|
|
32
|
+
```
|
|
33
|
+
3. Add this line to your application's `config/routes.rb` file:
|
|
34
|
+
```ruby
|
|
35
|
+
mount NeetoPaymentsEngine::Engine, at: '/payments'
|
|
36
36
|
```
|
|
37
|
-
|
|
38
|
-
### Usage
|
|
39
|
-
|
|
40
|
-
neeto-payments-frontend exports:
|
|
41
|
-
|
|
42
|
-
- `Dashboard` component
|
|
43
|
-
- `buildStripeTransactionLink()` function
|
|
44
|
-
- `useStripePromise()` hook
|
|
45
|
-
|
|
46
|
-
#### 1. `Dashboard` component
|
|
47
|
-
|
|
48
|
-
##### Props
|
|
49
|
-
|
|
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.
|
|
54
|
-
|
|
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.
|
|
58
|
-
|
|
59
|
-
3. **searchProps**: To specify the properties of the search bar in `Dashboard`.
|
|
60
|
-
|
|
61
|
-
4. **tabs**: To specify the tabs to be displayed in the payments dashboard. It
|
|
62
|
-
is an optional parameter.
|
|
63
|
-
|
|
64
|
-
5. **headerProps**: To specify the props to be passed to the neetoUI `Header`
|
|
65
|
-
component used in the `Dashboard`.
|
|
66
|
-
|
|
67
|
-
**More about `payableEntityColumns`**
|
|
68
|
-
|
|
69
|
-
Here is an example of `payableEntityColumns` prop:
|
|
70
|
-
|
|
71
|
-
```js
|
|
72
|
-
const payableEntityColumns = [
|
|
73
|
-
{
|
|
74
|
-
title: t("entity.meeting"),
|
|
75
|
-
dataIndex: "payable",
|
|
76
|
-
key: "meeting",
|
|
77
|
-
ellipsis: true,
|
|
78
|
-
width: 150,
|
|
79
|
-
render: renderMeeting,
|
|
80
|
-
isFilterable: true,
|
|
81
|
-
filterProps: {
|
|
82
|
-
key: "meeting",
|
|
83
|
-
label: "Meeting",
|
|
84
|
-
node: "bookings:payable.meeting.name",
|
|
85
|
-
type: "multi_option",
|
|
86
|
-
model: "Meeting",
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
title: t("common.host"),
|
|
91
|
-
dataIndex: ["payable", "host"],
|
|
92
|
-
key: "host",
|
|
93
|
-
ellipsis: true,
|
|
94
|
-
width: 150,
|
|
95
|
-
isFilterable: true,
|
|
96
|
-
filterProps: {
|
|
97
|
-
key: "host",
|
|
98
|
-
label: "Host",
|
|
99
|
-
node: "bookings:payable.user.first_name,last_name",
|
|
100
|
-
model: "User",
|
|
101
|
-
type: "multi_option",
|
|
102
|
-
},
|
|
103
|
-
},
|
|
104
|
-
];
|
|
105
|
-
```
|
|
106
|
-
|
|
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
|
|
110
|
-
[NeetoUI docs](https://neeto-ui.neeto.com/?path=/docs/components-table--default).
|
|
111
|
-
|
|
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.
|
|
115
|
-
|
|
116
|
-
> :memo: **Note:** The data about the payable entity is in the format
|
|
117
|
-
> `{ payable: {...} }`. So the `dataIndex` key must be used accordingly. Refer
|
|
118
|
-
> the example above.
|
|
119
|
-
|
|
120
|
-
> In the case of columns with filter type as `single_option` or `multi_option`,
|
|
121
|
-
> `values` key can be passed along with `filterProps`.
|
|
122
|
-
|
|
123
|
-
**More about `searchProps` prop**
|
|
124
|
-
|
|
125
|
-
Here is an example of `searchProps` prop:
|
|
126
|
-
|
|
127
|
-
```js
|
|
128
|
-
const searchProps = {
|
|
129
|
-
key: "keyword",
|
|
130
|
-
node: "bookings:payable.meeting.name,bookings:payable.user.first_name,last_name,bookings:payable.name",
|
|
131
|
-
model: "Meeting,User,Booking",
|
|
132
|
-
placeholder: "Search by meeting name, user name or booking name",
|
|
133
|
-
};
|
|
134
|
-
```
|
|
135
|
-
|
|
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.
|
|
140
|
-
|
|
141
|
-
To know more about the working of `node` and `model` keys, refer the
|
|
142
|
-
[`neeto-filters-frontend` documentation](https://github.com/bigbinary/neeto-filters-frontend/blob/main/README.md).
|
|
143
|
-
|
|
144
|
-
**More about `tabs` prop**
|
|
145
|
-
|
|
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.
|
|
149
|
-
|
|
150
|
-
#### 2. `buildStripeTransactionLink` function
|
|
151
|
-
|
|
152
|
-
This function is used to generate the stripe transaction link from a payment
|
|
153
|
-
identifier.
|
|
154
|
-
|
|
155
|
-
The arguments are:
|
|
156
|
-
|
|
157
|
-
1. `identifier`: The payment identifier
|
|
158
|
-
2. `isLive`: Specifying whether or not the environment is live. It defaults to
|
|
159
|
-
`true`.
|
|
160
|
-
|
|
161
|
-
Example usage
|
|
162
|
-
|
|
163
|
-
```js
|
|
164
|
-
const transactionLink = buildStripeTransactionLink(
|
|
165
|
-
"pi_3MqWX92fKivMPpZ11EPmOBBR",
|
|
166
|
-
false
|
|
167
|
-
);
|
|
168
|
-
```
|
|
169
|
-
|
|
170
|
-
#### 3. `useStripePromise` hook
|
|
171
|
-
|
|
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`.
|
|
175
|
-
|
|
176
|
-
> :memo: **Note:** `STRIPE_PUBLISHABLE_KEY` environment variable must be present
|
|
177
|
-
> for this hook to work.
|
|
178
|
-
|
|
179
|
-
Example usage
|
|
180
|
-
|
|
181
|
-
```js
|
|
182
|
-
const stripeAccountIdentifier = "acct_1Mtqtz2e5McIywz4";
|
|
183
|
-
const stripePromise = useStripePromise(stripeAccountIdentifier);
|
|
184
|
-
...
|
|
185
|
-
<Elements stripe={stripePromise}>
|
|
186
|
-
<CardElement />
|
|
187
|
-
</Elements>
|
|
188
|
-
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
#### 4. `PaymentKindRestrictionAlert` component
|
|
192
|
-
|
|
193
|
-
##### Props
|
|
194
|
-
|
|
195
|
-
1. **isOpen**: To specify whether the Stripe connect restriction alert should be
|
|
196
|
-
opened or closed.
|
|
197
|
-
|
|
198
|
-
2. **paymentKind**: To specify the type of Stripe payment kind for rendering
|
|
199
|
-
related content to alert either as "standard" or "platform". If Stripe
|
|
200
|
-
Standard is connected the alert shall forbid Stripe Platform connect and vice
|
|
201
|
-
versa.
|
|
202
|
-
|
|
203
|
-
3. **onClose**: Handler function that is triggered when the disconnect button is
|
|
204
|
-
clicked.
|
|
205
|
-
|
|
206
|
-
Example usage
|
|
207
|
-
|
|
208
|
-
```js
|
|
209
|
-
<PaymentKindRestrictionAlert
|
|
210
|
-
isOpen={isStripePlatformConnectedAlertOpen}
|
|
211
|
-
paymentKind="standard"
|
|
212
|
-
onClose={() => setIsStripePlatformConnectedAlertOpen(false)}
|
|
213
|
-
/>
|
|
214
|
-
```
|
|
215
|
-
|
|
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
37
|
4. Configure the following environment variables.
|
|
255
|
-
|
|
256
38
|
```yaml
|
|
257
39
|
APP_URL=#Application URL
|
|
258
40
|
STRIPE_PUBLISHABLE_KEY='pk_test_fnFiGXjRkMXnLkueiNKJidGU00V83aRC0V'
|
|
@@ -262,9 +44,7 @@ possible for Indian business Stripe accounts.
|
|
|
262
44
|
NB: Replace `APP_URL` environment variable value with the host application's
|
|
263
45
|
base URL without a trailing slash for example: `https://app.neetocal.net`.
|
|
264
46
|
Stripe environment variables values are `test` mode keys.
|
|
265
|
-
|
|
266
47
|
5. Run the following command to subscribe Stripe webhooks events.
|
|
267
|
-
|
|
268
48
|
```shell
|
|
269
49
|
bundle exec rails neeto_payments_engine:stripe:webhooks:subscribe
|
|
270
50
|
```
|
|
@@ -287,9 +67,7 @@ possible for Indian business Stripe accounts.
|
|
|
287
67
|
]
|
|
288
68
|
```
|
|
289
69
|
- Add the returned environment variable and its value.
|
|
290
|
-
|
|
291
70
|
6. Add the following secret values to `config/secrets.yml`.
|
|
292
|
-
|
|
293
71
|
```yaml
|
|
294
72
|
host: <%= ENV['APP_URL'] || ENV['HEROKU_APP_URL'] %>
|
|
295
73
|
stripe:
|
|
@@ -298,21 +76,17 @@ possible for Indian business Stripe accounts.
|
|
|
298
76
|
webhooks:
|
|
299
77
|
secret: <%= ENV['STRIPE_WEBHOOK_SECRET'] %>
|
|
300
78
|
```
|
|
301
|
-
|
|
302
79
|
7. Add the following line to application's
|
|
303
80
|
`config/initializer/neeto_payments_engine.rb` file. Replace the
|
|
304
81
|
`holdable_class` value with a model name where you want to associate your
|
|
305
82
|
Stripe account in the host application.
|
|
306
|
-
|
|
307
83
|
```ruby
|
|
308
|
-
|
|
84
|
+
NeetoPaymentsEngine.holdable_class = "Organization"
|
|
309
85
|
```
|
|
310
|
-
|
|
311
86
|
8. Add the following association to the model you defined as holdable_class in
|
|
312
|
-
step
|
|
313
|
-
|
|
87
|
+
step 7.
|
|
314
88
|
```ruby
|
|
315
|
-
|
|
89
|
+
has_one :stripe_integration, class_name: "::NeetoPaymentsEngine::Stripe::Account", foreign_key: :holdable_id
|
|
316
90
|
```
|
|
317
91
|
|
|
318
92
|
9. Add the following association to the chargeable model. The chargeable model
|
|
@@ -320,47 +94,261 @@ possible for Indian business Stripe accounts.
|
|
|
320
94
|
For example `Meeting` model in `neetoCal` where meeting service is a
|
|
321
95
|
chargeable one.
|
|
322
96
|
```ruby
|
|
323
|
-
|
|
97
|
+
has_one :charge, as: :chargeable, class_name: "::NeetoPaymentsEngine::Stripe::Charge", dependent: :destroy
|
|
324
98
|
```
|
|
325
99
|
10. Add the following association to the payable model.
|
|
326
|
-
|
|
327
100
|
```ruby
|
|
328
|
-
|
|
101
|
+
has_one :payment, as: :payable, class_name: "::NeetoPaymentsEngine::Stripe::Transaction", dependent: :destroy
|
|
329
102
|
```
|
|
330
|
-
|
|
331
103
|
11. Add the following queue to your sidekiq config file `config/sidekiq.yml`
|
|
332
104
|
```yaml
|
|
333
105
|
queues:
|
|
334
106
|
- payment # For neeto-payments-engine
|
|
335
107
|
```
|
|
336
108
|
|
|
337
|
-
###
|
|
338
|
-
|
|
339
|
-
1.
|
|
340
|
-
copy of neetoPayments' engine):
|
|
109
|
+
### Usage
|
|
110
|
+
You can learn more about setup and usage here:
|
|
111
|
+
1. [Services](/docs/engine/services.md)
|
|
341
112
|
|
|
342
|
-
|
|
343
|
-
|
|
113
|
+
## Frontend package
|
|
114
|
+
### Installation
|
|
115
|
+
1. Install the latest `neeto-payments-frontend` package using the below command:
|
|
116
|
+
```zsh
|
|
117
|
+
yarn add @bigbinary/neeto-payments-frontend
|
|
118
|
+
```
|
|
119
|
+
2. `neeto-payments-frontend` has a few peer dependencies that are required for the proper functioning of the package. Install all the peer dependencies using the below command:
|
|
120
|
+
```zsh
|
|
121
|
+
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
|
|
344
122
|
```
|
|
345
123
|
|
|
346
|
-
|
|
124
|
+
### Components
|
|
125
|
+
#### 1. `Dashboard` ([source code](https://github.com/bigbinary/neeto-payments-nano/blob/42ad8330442696b102d8555930162d75cf94931e/app/javascript/src/components/Dashboard/index.jsx))
|
|
347
126
|
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
127
|
+
**Props**
|
|
128
|
+
- `holdableId`: To specify the ID of the entity that holds the stripe
|
|
129
|
+
account. This is an optional prop. If the value is not specified, the current
|
|
130
|
+
organization ID is taken as the default value while querying for
|
|
131
|
+
transactions.
|
|
132
|
+
- `payableEntityColumns`: To specify the columns from the payable entity
|
|
133
|
+
which need to be additionally displayed. It is an optional prop that defaults
|
|
134
|
+
to `[]` if not specified.
|
|
135
|
+
- `tabs`: To specify the tabs to be displayed in the payments dashboard. It
|
|
136
|
+
is an optional parameter.
|
|
137
|
+
- `headerProps`: To specify the props to be passed to the neetoUI `Header`
|
|
138
|
+
component used in the `Dashboard`.
|
|
351
139
|
|
|
352
|
-
|
|
353
|
-
|
|
140
|
+
**Configuration**
|
|
141
|
+
- Refer to the [Dashboard](/docs/frontend/dashboard.md) section for detailed information on the available configurations for the `Dashboard` component.
|
|
142
|
+
|
|
143
|
+
**Usage**
|
|
144
|
+
```jsx
|
|
145
|
+
import React, { useState } from "react";
|
|
146
|
+
import { Dashboard } from "@bigbinary/neeto-payments-frontend";
|
|
147
|
+
|
|
148
|
+
const App = () => {
|
|
149
|
+
const headerProps = {
|
|
150
|
+
className: "w-80",
|
|
151
|
+
// Your header properties
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
return (
|
|
155
|
+
<Dashboard
|
|
156
|
+
tabs={["all", "successful"]}
|
|
157
|
+
headerProps={headerProps}
|
|
158
|
+
/>
|
|
159
|
+
);
|
|
160
|
+
};
|
|
354
161
|
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
```
|
|
162
|
+
export default App;
|
|
163
|
+
```
|
|
358
164
|
|
|
359
|
-
|
|
165
|
+
#### 2. `PaymentKindRestrictionAlert` ([source code](https://github.com/bigbinary/neeto-payments-nano/blob/42ad8330442696b102d8555930162d75cf94931e/app/javascript/src/components/Stripe/Connect/PaymentKindRestrictionAlert/index.jsx))
|
|
166
|
+
|
|
167
|
+
**Props**
|
|
168
|
+
- `isOpen`: To specify whether the Stripe connect restriction alert should be
|
|
169
|
+
opened or closed.
|
|
170
|
+
- `paymentKind`: To specify the type of Stripe payment kind for rendering
|
|
171
|
+
related content to alert either as "standard" or "platform". If Stripe
|
|
172
|
+
Standard is connected the alert shall forbid Stripe Platform connect and vice
|
|
173
|
+
versa.
|
|
174
|
+
- `onClose`: Handler function that is triggered when the disconnect button is
|
|
175
|
+
clicked.
|
|
360
176
|
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
177
|
+
**Usage**
|
|
178
|
+
```jsx
|
|
179
|
+
import React, { useState } from "react";
|
|
180
|
+
import { PaymentKindRestrictionAlert } from "@bigbinary/neeto-payments-frontend";
|
|
181
|
+
|
|
182
|
+
const App = () => {
|
|
183
|
+
const [isStripePlatformConnectedAlertOpen, setIsStripePlatformConnectedAlertOpen] = useState(false);
|
|
184
|
+
|
|
185
|
+
return (
|
|
186
|
+
<PaymentKindRestrictionAlert
|
|
187
|
+
isOpen={isStripePlatformConnectedAlertOpen}
|
|
188
|
+
paymentKind="standard"
|
|
189
|
+
onClose={() => setIsStripePlatformConnectedAlertOpen(false)}
|
|
190
|
+
/>
|
|
191
|
+
);
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
export default App;
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
#### 3. `SquareCard` ([source code](https://github.com/bigbinary/neeto-payments-nano/blob/42ad8330442696b102d8555930162d75cf94931e/app/javascript/src/components/SquareCard/index.jsx))
|
|
198
|
+
|
|
199
|
+
**Props**
|
|
200
|
+
- `card`: The Square card instance.
|
|
201
|
+
- `setCard`: Function to set the Square card instance.
|
|
202
|
+
|
|
203
|
+
**Optional Props**
|
|
204
|
+
- `onChange`: Event handler function triggered on Square card events.
|
|
205
|
+
- `id`: ID of the container element for the Square card. Defaults to `square-card-container`.
|
|
206
|
+
- `options`: Configuration options for the Square card. Defaults to `{}`.
|
|
207
|
+
- `disabled`: Disables pointer events if set to `true`. Defaults to `false`.
|
|
208
|
+
|
|
209
|
+
**Usage**
|
|
210
|
+
```jsx
|
|
211
|
+
import React, { useState } from "react";
|
|
212
|
+
import { SquareCard } from "@bigbinary/neeto-payments-frontend";
|
|
213
|
+
|
|
214
|
+
const App = () => {
|
|
215
|
+
const [squareCard, setSquareCard] = useState(null);
|
|
216
|
+
const handleCardChange = event => {
|
|
217
|
+
// Handle Square card events
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
return (
|
|
221
|
+
<SquareCard
|
|
222
|
+
card={squareCard}
|
|
223
|
+
setCard={setSquareCard}
|
|
224
|
+
onChange={handleCardChange}
|
|
225
|
+
disabled={false}
|
|
226
|
+
/>
|
|
227
|
+
);
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
export default App;
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
#### 4. `PayoutsDashboard` ([source code](https://github.com/bigbinary/neeto-payments-nano/blob/42ad8330442696b102d8555930162d75cf94931e/app/javascript/src/components/PayoutsDashboard/index.jsx))
|
|
234
|
+
|
|
235
|
+
**Props**
|
|
236
|
+
- `payoutsPageRoute`: The route for the payouts page.
|
|
237
|
+
- `isPlatformEnabled`: Indicates whether the platform is enabled or not.
|
|
238
|
+
|
|
239
|
+
**Usage**
|
|
240
|
+
```jsx
|
|
241
|
+
import React from "react";
|
|
242
|
+
import { PayoutsDashboard } from "@bigbinary/neeto-payments-frontend";
|
|
243
|
+
|
|
244
|
+
const App = () => {
|
|
245
|
+
return (
|
|
246
|
+
<PayoutsDashboard
|
|
247
|
+
isPlatformEnabled
|
|
248
|
+
payoutsPageRoute={routes.admin.payment.stripePayouts.show}
|
|
249
|
+
/>
|
|
250
|
+
);
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
export default App;
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
#### 5. `SquareDashboard` ([source code](https://github.com/bigbinary/neeto-payments-nano/blob/42ad8330442696b102d8555930162d75cf94931e/app/javascript/src/components/SquareDashboard/index.jsx))
|
|
257
|
+
|
|
258
|
+
**Props**
|
|
259
|
+
- `searchProps`: To specify the search props to be passed to the neetoUI `Header`
|
|
260
|
+
component used in the `Dashboard`.
|
|
261
|
+
|
|
262
|
+
**Optional Props**
|
|
263
|
+
- `holdableId`: To specify the ID of the entity that holds the stripe
|
|
264
|
+
account. If the value is not specified, the current
|
|
265
|
+
organization ID is taken as the default value while querying for
|
|
266
|
+
transactions.
|
|
267
|
+
- `payableEntityColumns`: To specify the columns from the payable entity
|
|
268
|
+
which need to be additionally displayed. Defaults to `[]`.
|
|
269
|
+
- `kind`: To specify the type of payment. Defaults to `squarePayment`.
|
|
270
|
+
- `headerProps`: To specify the props to be passed to the neetoUI `Header`
|
|
271
|
+
component used in the `Dashboard`. Defaults to `{}`.
|
|
272
|
+
|
|
273
|
+
**Usage**
|
|
274
|
+
```jsx
|
|
275
|
+
import React from "react";
|
|
276
|
+
import { SquareDashboard } from "@bigbinary/neeto-payments-frontend";
|
|
277
|
+
|
|
278
|
+
const App = () => {
|
|
279
|
+
const searchProps = {
|
|
280
|
+
placeholder: "Search...",
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
const headerProps = {
|
|
284
|
+
className: "w-80",
|
|
285
|
+
// Your header properties
|
|
286
|
+
};
|
|
287
|
+
return (
|
|
288
|
+
<SquareDashboard
|
|
289
|
+
searchProps={searchProps}
|
|
290
|
+
headerProps={headerProps}
|
|
291
|
+
kind="squarePayment"
|
|
292
|
+
payableEntityColumns=[]
|
|
293
|
+
/>
|
|
294
|
+
);
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
export default App;
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
### Hooks
|
|
301
|
+
#### 1. `useStripePromise` ([source code](https://github.com/bigbinary/neeto-payments-nano/blob/42ad8330442696b102d8555930162d75cf94931e/app/javascript/src/hooks/useStripePromise.js))
|
|
302
|
+
|
|
303
|
+
- This hook is used to generate the `stripePromise` object to be passed to the
|
|
304
|
+
stripe `<Elements>` context. The `useStripePromise` hook takes a stripe account
|
|
305
|
+
identifier as input and returns a `Promise`.
|
|
306
|
+
- Usage in [neetoForm](https://github.com/bigbinary/neeto-form-web/blob/f84ad909628b7ce3497cbb6f9a1da8631121a167/app/javascript/src/components/Form/Design/Preview/index.jsx#L39).
|
|
307
|
+
|
|
308
|
+
> :memo: **Note:** `STRIPE_PUBLISHABLE_KEY` environment variable must be present
|
|
309
|
+
> for this hook to work.
|
|
310
|
+
|
|
311
|
+
**Usage**
|
|
312
|
+
```jsx
|
|
313
|
+
const stripeAccountIdentifier = "acct_1Mtqtz2e5McIywz4";
|
|
314
|
+
const stripePromise = useStripePromise(stripeAccountIdentifier);
|
|
315
|
+
...
|
|
316
|
+
<Elements stripe={stripePromise}>
|
|
317
|
+
<CardElement />
|
|
318
|
+
</Elements>
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
#### 2. `useSquareCard` ([source code](https://github.com/bigbinary/neeto-payments-nano/blob/42ad8330442696b102d8555930162d75cf94931e/app/javascript/src/hooks/useSquareCard.js))
|
|
322
|
+
|
|
323
|
+
- This hook manages the state and functionality related to the Square card instance, providing methods for setting the card, accessing the current card instance, and tokenizing the card.
|
|
324
|
+
- Usage in [neetoInvoice](https://github.com/bigbinary/neeto-payments-nano/blob/42ad8330442696b102d8555930162d75cf94931e/app/javascript/src/hooks/useSquareCard.js).
|
|
325
|
+
|
|
326
|
+
**Returns**
|
|
327
|
+
- `card`: The Square card instance.
|
|
328
|
+
- `setCard`: Function to set the Square card instance.
|
|
329
|
+
- `tokenizeCard`: Asynchronous function to tokenize the Square card instance. It returns a Promise that resolves to the tokenized card. If no card instance is found, a warning is logged, and an empty string is returned. If tokenization is successful, the token is returned. In case of errors during tokenization, an error is logged, and an empty string is returned.
|
|
330
|
+
|
|
331
|
+
**Usage**
|
|
332
|
+
```jsx
|
|
333
|
+
const { card, setCard, tokenizeCard } = useSquareCard();
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
### Functions
|
|
337
|
+
#### 1. `buildStripeTransactionLink` ([source code](https://github.com/bigbinary/neeto-payments-nano/blob/42ad8330442696b102d8555930162d75cf94931e/app/javascript/src/utils/index.js#L3))
|
|
338
|
+
|
|
339
|
+
- This function is used to generate the stripe transaction link from payment identifier.
|
|
340
|
+
|
|
341
|
+
**Parameters**
|
|
342
|
+
1. `identifier`: The payment identifier.
|
|
343
|
+
2. `isLive`: Specifying whether or not the environment is live. It defaults to `true`.
|
|
344
|
+
|
|
345
|
+
**Usage**
|
|
346
|
+
```jsx
|
|
347
|
+
const transactionLink = buildStripeTransactionLink(
|
|
348
|
+
"pi_3MqWX92fKivMPpZ11EPmOBBR",
|
|
349
|
+
false
|
|
350
|
+
);
|
|
351
|
+
```
|
|
364
352
|
|
|
365
|
-
|
|
366
|
-
|
|
353
|
+
# Instructions for Publishing
|
|
354
|
+
Consult the [building and releasing packages](https://neeto-engineering.neetokb.com/articles/building-and-releasing-packages) guide for details on how to publish.
|
|
@@ -49,7 +49,8 @@
|
|
|
49
49
|
"continue": "Continue",
|
|
50
50
|
"connect": "Connect",
|
|
51
51
|
"configure": "Configure",
|
|
52
|
-
"finish": "Finish"
|
|
52
|
+
"finish": "Finish",
|
|
53
|
+
"pay": "Pay"
|
|
53
54
|
},
|
|
54
55
|
"alert": {
|
|
55
56
|
"stripe": {
|
|
@@ -85,6 +86,10 @@
|
|
|
85
86
|
"refundWithStatus": "There are no {{status}} refunds.",
|
|
86
87
|
"account": "There are no standard accounts.",
|
|
87
88
|
"accountWithStatus": "There are no {{status}} standard accounts.",
|
|
89
|
+
"squarePayment": "There are no payments.",
|
|
90
|
+
"squarePaymentWithStatus": "There are no {{status}} payments.",
|
|
91
|
+
"squareRefund": "There are no refunds.",
|
|
92
|
+
"squareRefundWithStatus": "There are no {{status}} refunds.",
|
|
88
93
|
"payouts": {
|
|
89
94
|
"all": "There are no payouts to show.",
|
|
90
95
|
"paid": "There are no paid payouts.",
|
|
@@ -126,7 +131,8 @@
|
|
|
126
131
|
"successful": "successful",
|
|
127
132
|
"refunded": "refunded",
|
|
128
133
|
"pending": "pending",
|
|
129
|
-
"initiated": "initiated"
|
|
134
|
+
"initiated": "initiated",
|
|
135
|
+
"requires_action": "requires action"
|
|
130
136
|
},
|
|
131
137
|
"payment": {
|
|
132
138
|
"completed": "completed",
|
|
@@ -148,7 +154,8 @@
|
|
|
148
154
|
"declined": "This payment failed because the issuing bank declined it",
|
|
149
155
|
"initiated": "The customer has not entered their payment method.",
|
|
150
156
|
"pending": "Transaction has been authorized, but the funds have not been captured yet",
|
|
151
|
-
"refunded": "Transaction has been refunded"
|
|
157
|
+
"refunded": "Transaction has been refunded",
|
|
158
|
+
"requires_action": "The process requires further action from the customer to complete"
|
|
152
159
|
},
|
|
153
160
|
"refund": {
|
|
154
161
|
"successful": "The refund has been successfully processed",
|
|
@@ -223,8 +230,12 @@
|
|
|
223
230
|
"refundWithStatus_other": "{{count}} {{status}} refunds",
|
|
224
231
|
"squarePayment": "{{count}} payment",
|
|
225
232
|
"squarePayment_other": "{{count}} payments",
|
|
233
|
+
"squarePaymentWithStatus": "{{count}} {{status}} payment",
|
|
234
|
+
"squarePaymentWithStatus_other": "{{count}} {{status}} payments",
|
|
226
235
|
"squareRefund": "{{count}} refund",
|
|
227
236
|
"squareRefund_other": "{{count}} refunds",
|
|
237
|
+
"squareRefundWithStatus": "{{count}} {{status}} refund",
|
|
238
|
+
"squareRefundWithStatus_other": "{{count}} {{status}} refunds",
|
|
228
239
|
"account": "{{count}} standard account",
|
|
229
240
|
"account_other": "{{count}} standard accounts",
|
|
230
241
|
"accountWithStatus": "{{count}} {{status}} standard account",
|
|
@@ -281,6 +292,9 @@
|
|
|
281
292
|
"validations": {
|
|
282
293
|
"countryRequired": "Country is required",
|
|
283
294
|
"invalidUrl": "Enter a valid URL"
|
|
295
|
+
},
|
|
296
|
+
"razorpay": {
|
|
297
|
+
"loadError": "Failed to load Razropay!!"
|
|
284
298
|
}
|
|
285
299
|
}
|
|
286
300
|
}
|