core_merchant 0.1.0 → 0.2.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 +4 -4
- data/LICENSE.txt +1 -1
- data/README.md +76 -28
- data/lib/core_merchant/version.rb +1 -1
- data/lib/generators/core_merchant/install_generator.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e3770d6e4ff989b5f5e8ec48d7fb909b472b7c43b0f19fe7de933903a7d6c2ec
|
4
|
+
data.tar.gz: 7f4ab1681347258d44ca2bcc072ffc1f95f609153153d976406a0120ff1c4f11
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e72653b6788186e5e567e5a773510877d33e8b5880a09ecbd4c65c3ae9d06b9614553797fc9c1563f343925b6707abc9db278360a5000843f66f118c0e19502
|
7
|
+
data.tar.gz: ae2d68559f60e8da03e82e63613698a98da071f216e703a8dcfab80839f486abc0881936f390299ebc010ec62d29a2b355e46bdaf82ec9c998c4f3a1c0d9e9bd
|
data/LICENSE.txt
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
The MIT License (MIT)
|
2
2
|
|
3
|
-
Copyright (c) 2024 Seyithan
|
3
|
+
Copyright (c) 2024 Seyithan Teymur (https://seyithan.me)
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
data/README.md
CHANGED
@@ -1,39 +1,87 @@
|
|
1
1
|
# CoreMerchant
|
2
2
|
|
3
|
-
|
3
|
+
> [!CAUTION]
|
4
|
+
> This gem is under development at pre-release stage
|
4
5
|
|
5
|
-
|
6
|
+
CoreMerchant is a library for customer, product, and subscription management in Rails applications. It's meant to be a starting point for building e-commerce and SaaS applications. It provides essential functionality for handling customers, products, and subscriptions. Does not include payment integrations.
|
6
7
|
|
7
|
-
|
8
|
+
## To-dos until 1.0.0 release
|
9
|
+
- [X] Add customer behavior
|
10
|
+
- [X] Add initializer generator
|
11
|
+
- [X] Add SubscriptionPlan model
|
12
|
+
- [ ] Add Subscription model
|
13
|
+
- [ ] Add subscription management service
|
14
|
+
- [ ] Add sidekiq jobs for subscription management
|
15
|
+
- [ ] Add Invoice model
|
16
|
+
- [ ] Add billing and invoicing service
|
8
17
|
|
9
18
|
## Installation
|
19
|
+
Add this line to your application's Gemfile:
|
20
|
+
```
|
21
|
+
gem 'core_merchant', '~> 0.1.0'
|
22
|
+
```
|
23
|
+
and run `bundle install`.
|
10
24
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
If bundler is not being used to manage dependencies, install the gem by executing:
|
16
|
-
|
17
|
-
$ gem install core_merchant
|
25
|
+
Alternatively, you can install the gem manually:
|
26
|
+
```
|
27
|
+
$ gem install core_merchant
|
28
|
+
```
|
18
29
|
|
19
30
|
## Usage
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
31
|
+
### Initialization
|
32
|
+
Run the generator to create the initializer file and the migrations:
|
33
|
+
```
|
34
|
+
$ rails generate core_merchant:install
|
35
|
+
```
|
36
|
+
This will create the following files:
|
37
|
+
- `config/initializers/core_merchant.rb` - Configuration file
|
38
|
+
- `db/migrate/xxxxxx_create_core_merchant_subscription_plans.rb` - Migration for subscription plans
|
39
|
+
|
40
|
+
You can then run the migrations:
|
41
|
+
```
|
42
|
+
$ rails db:migrate
|
43
|
+
```
|
44
|
+
|
45
|
+
### Configuration
|
46
|
+
The initializer file `config/initializers/core_merchant.rb` contains the following configuration options:
|
47
|
+
```ruby
|
48
|
+
config.customer_class
|
49
|
+
```
|
50
|
+
|
51
|
+
### The cusomer class
|
52
|
+
The customer class is the model that represents the customer in your application. For example, if you already have a `User` model that represents the users of your application, you can use it as the customer class in CoreMerchant. To do this, you need to set the `customer_class` configuration option in the initializer file:
|
53
|
+
```ruby
|
54
|
+
# config/initializers/core_merchant.rb
|
55
|
+
CoreMerchant.configure do |config|
|
56
|
+
config.customer_class = 'User'
|
57
|
+
end
|
58
|
+
```
|
59
|
+
|
60
|
+
You need to then include the `CoreMerchant::Customer` module in the customer class:
|
61
|
+
```ruby
|
62
|
+
# app/models/user.rb
|
63
|
+
class User < ApplicationRecord
|
64
|
+
include CoreMerchant::Customer
|
65
|
+
|
66
|
+
# ... the rest of your model code
|
67
|
+
end
|
68
|
+
```
|
69
|
+
|
70
|
+
## Models
|
71
|
+
### SubscriptionPlan
|
72
|
+
The `SubscriptionPlan` model represents a subscription plan in your application. It has the following attributes:
|
73
|
+
- `name_key`: A unique key for the subscription plan.
|
74
|
+
This key is used to identify the plan in the application,
|
75
|
+
as well as the translation key for the plan name through `core_merchant.subscription_plans`.
|
76
|
+
- `price_cents`: The price of the subscription plan in cents.
|
77
|
+
- `duration`: The duration of the subscription plan.
|
78
|
+
Consists of a number and a letter representing the time unit as day, week, month, or year.
|
79
|
+
For example, `1w` for 1 week, `3m` for 3 months, `1y` for 1 year.
|
80
|
+
- `introductory_price_cents`: The introductory price of the subscription plan in cents.
|
81
|
+
- `introductory_duration`: The duration of the introductory price of the subscription plan.
|
82
|
+
|
83
|
+
> [!NOTE]
|
84
|
+
> Other models and features are being developed and will be added in future releases.
|
28
85
|
|
29
86
|
## Contributing
|
30
|
-
|
31
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/core_merchant. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/core_merchant/blob/main/CODE_OF_CONDUCT.md).
|
32
|
-
|
33
|
-
## License
|
34
|
-
|
35
|
-
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
36
|
-
|
37
|
-
## Code of Conduct
|
38
|
-
|
39
|
-
Everyone interacting in the CoreMerchant project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/core_merchant/blob/main/CODE_OF_CONDUCT.md).
|
87
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/theseyithan/core_merchant
|
@@ -21,7 +21,7 @@ module CoreMerchant
|
|
21
21
|
def create_migration_file
|
22
22
|
timestamp = self.class.next_migration_number(nil)
|
23
23
|
migration_template "create_core_merchant_subscription_plans.rb",
|
24
|
-
"db/migrate
|
24
|
+
"db/migrate/create_core_merchant_subscription_plans.rb"
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|