Skip to content

Commit

Permalink
Merge branch 'main' of github.com:pay-rails/pay
Browse files Browse the repository at this point in the history
  • Loading branch information
excid3 committed May 16, 2024
2 parents 39b4cab + 3f860ad commit 49e9f58
Show file tree
Hide file tree
Showing 19 changed files with 182 additions and 78 deletions.
3 changes: 3 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Make sure RUBY_VERSION matches the Ruby version in .ruby-version
ARG RUBY_VERSION=3.3.1
FROM ghcr.io/rails/devcontainer/images/ruby:$RUBY_VERSION
58 changes: 58 additions & 0 deletions .devcontainer/compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
services:
rails-app:
build:
context: ..
dockerfile: .devcontainer/Dockerfile

volumes:
- ../..:/workspaces:cached

# Overrides default command so things don't shut down after the process ends.
command: sleep infinity

networks:
- default

# Uncomment the next line to use a non-root user for all processes.
# user: vscode

# Use "forwardPorts" in **devcontainer.json** to forward an app port locally.
# (Adding the "ports" property to this file will not forward from a Codespace.)
ports:
- 45678:45678
depends_on:
- selenium
- mysql
- postgres

selenium:
image: seleniarm/standalone-chromium
restart: unless-stopped
networks:
- default

mysql:
image: mysql/mysql-server:8.0
restart: unless-stopped
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: 'true'
MYSQL_ROOT_HOST: "%"
volumes:
- mysql-data:/var/lib/mysql
networks:
- default

postgres:
image: postgres:16.1
restart: unless-stopped
networks:
- default
volumes:
- postgres-data:/var/lib/postgresql/data
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres

volumes:
mysql-data:
postgres-data:
37 changes: 37 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/ruby
{
"name": "pay_gem",
"dockerComposeFile": "compose.yaml",
"service": "rails-app",
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",

// Features to add to the dev container. More info: https://containers.dev/features.
"features": {
"ghcr.io/devcontainers/features/github-cli:1": {},
"ghcr.io/rails/devcontainer/features/activestorage": {},
"ghcr.io/rails/devcontainer/features/mysql-client": {},
"ghcr.io/rails/devcontainer/features/postgres-client": {}
},

"containerEnv": {
"CAPYBARA_SERVER_PORT": "45678",
"SELENIUM_HOST": "selenium",
"DATABASE_URL": "sqlite3:test.sqlite3"
// "DATABASE_URL": "postgresql://postgres:postgres@postgres:5432/test"
// "DATABASE_URL": "mysql2://root@mysql:3306/test"
},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": [3000, 3306, 5432, 6379],

// Configure tool-specific properties.
// "customizations": {},

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root",


// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "bin/setup"
}
6 changes: 3 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ gem "vcr"
gem "webmock"

gem "braintree", ">= 2.92.0"
gem "stripe", "~> 10.11"
gem "paddle", "~> 2.1"
gem "stripe", "~> 11.0"
gem "paddle", "~> 2.2"

gem "receipts"
gem "prawn"

# Test against different databases
gem "pg"
gem "mysql2"
gem "sqlite3", "~> 1.7.2"
gem "sqlite3", "~> 2.0.1"

# Used for the dummy Rails app integration
gem "puma"
Expand Down
26 changes: 13 additions & 13 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,9 @@ GEM
marcel (1.0.4)
matrix (0.4.2)
mini_mime (1.1.5)
mini_portile2 (2.8.5)
mini_portile2 (2.8.6)
minitest (5.22.3)
mocha (2.1.0)
mocha (2.2.0)
ruby2_keywords (>= 0.0.5)
mutex_m (0.2.0)
mysql2 (0.5.6)
Expand All @@ -161,18 +161,18 @@ GEM
net-smtp (0.5.0)
net-protocol
nio4r (2.7.1)
nokogiri (1.16.3)
nokogiri (1.16.5)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
nokogiri (1.16.3-x86_64-darwin)
nokogiri (1.16.5-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.16.3-x86_64-linux)
nokogiri (1.16.5-x86_64-linux)
racc (~> 1.4)
overcommit (0.63.0)
childprocess (>= 0.6.3, < 6)
iniparse (~> 1.4)
rexml (~> 3.2)
paddle (2.1.3)
paddle (2.2.0)
faraday (~> 2.0)
parallel (1.24.0)
parser (3.3.0.5)
Expand Down Expand Up @@ -265,10 +265,10 @@ GEM
actionpack (>= 5.2)
activesupport (>= 5.2)
sprockets (>= 3.0.0)
sqlite3 (1.7.3)
sqlite3 (2.0.1)
mini_portile2 (~> 2.8.0)
sqlite3 (1.7.3-x86_64-darwin)
sqlite3 (1.7.3-x86_64-linux)
sqlite3 (2.0.1-x86_64-darwin)
sqlite3 (2.0.1-x86_64-linux-gnu)
standard (1.35.1)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.0)
Expand All @@ -284,7 +284,7 @@ GEM
stimulus-rails (1.3.3)
railties (>= 6.0.0)
stringio (3.1.0)
stripe (10.14.0)
stripe (11.2.0)
thor (1.3.1)
timeout (0.4.1)
ttfunk (1.8.0)
Expand Down Expand Up @@ -329,17 +329,17 @@ DEPENDENCIES
net-pop
net-smtp
overcommit
paddle (~> 2.1)
paddle (~> 2.2)
pay!
pg
prawn
puma
receipts
sprockets-rails
sqlite3 (~> 1.7.2)
sqlite3 (~> 2.0.1)
standard
stimulus-rails
stripe (~> 10.11)
stripe (~> 11.0)
turbo-rails
vcr
web-console
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ Want to add a new payment provider? Contributions are welcome.

If you have an issue you'd like to submit, please do so using the issue tracker in GitHub. In order for us to help you in the best way possible, please be as detailed as you can.

For those using devcontainers, if you want to test the application with different databases:
1. Uncomment the `DATABASE_URL` corresponding to the database type you wish to use in the `.devcontainer/devcontainer.json` file.
2. Rebuild the devcontainer, which will configure the application to use the selected database for your development environment.

If you'd like to open a PR please make sure the following things pass:

```ruby
Expand Down
14 changes: 14 additions & 0 deletions docs/4_payment_methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,20 @@ You can also add a payment method without making it the default.
@user.payment_processor.add_payment_method(params[:payment_method_token], default: false)
```

## Importing Payment Methods

### Paddle Billing

If a Paymment Method doesn't exist in Pay, then you can use the following method to create it from Paddle Billing:

It takes a `Pay::Customer` and a Paddle Transaction ID as arguments.

```ruby
Pay::PaddleBilling::PaymentMethod.sync_from_transaction pay_customer: @user.payment_processor, transaction: "txn_abc123"
```

If a Payment Method already exists with the token, then it will be updated with the latest details from Paddle.

## Next

See [Charges](5_charges.md)
Expand Down
4 changes: 2 additions & 2 deletions gemfiles/rails_6_1.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ gem "mocha"
gem "vcr"
gem "webmock"
gem "braintree", ">= 2.92.0"
gem "stripe", "~> 10.11"
gem "stripe", "~> 11.0"
gem "paddle", "~> 2.1"
gem "receipts"
gem "prawn", git: "https://github.com/prawnpdf/prawn.git"
gem "prawn"
gem "pg"
gem "mysql2"
gem "sqlite3", "~> 1.7.2"
Expand Down
20 changes: 8 additions & 12 deletions gemfiles/rails_6_1.gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
GIT
remote: https://github.com/prawnpdf/prawn.git
revision: ce374035905ef7691ddfa2dc015f4ea734d1f737
specs:
prawn (2.5.0)
matrix (~> 0.4)
pdf-core (~> 0.10.0)
ttfunk (~> 1.8)

GIT
remote: https://github.com/thoughtbot/appraisal.git
revision: f5e31c48a1dda036a2c13663fad1b657a0953f5d
Expand Down Expand Up @@ -165,6 +156,10 @@ GEM
racc
pdf-core (0.10.0)
pg (1.5.6)
prawn (2.5.0)
matrix (~> 0.4)
pdf-core (~> 0.10.0)
ttfunk (~> 1.8)
prawn-table (0.2.2)
prawn (>= 1.3.0, < 3.0.0)
public_suffix (5.0.4)
Expand Down Expand Up @@ -251,7 +246,7 @@ GEM
rubocop-performance (~> 1.20.2)
stimulus-rails (1.3.3)
railties (>= 6.0.0)
stripe (10.14.0)
stripe (11.2.0)
thor (1.3.1)
timeout (0.4.1)
ttfunk (1.8.0)
Expand Down Expand Up @@ -282,6 +277,7 @@ GEM
PLATFORMS
arm64-darwin-21
arm64-darwin-22
arm64-darwin-23
x86_64-darwin-20
x86_64-darwin-21
x86_64-darwin-22
Expand All @@ -301,15 +297,15 @@ DEPENDENCIES
paddle (~> 2.1)
pay!
pg
prawn!
prawn
puma
rails (~> 6.1.0)
receipts
sprockets-rails
sqlite3 (~> 1.7.2)
standard
stimulus-rails
stripe (~> 10.11)
stripe (~> 11.0)
turbo-rails
vcr
web-console
Expand Down
4 changes: 2 additions & 2 deletions gemfiles/rails_7.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ gem "mocha"
gem "vcr"
gem "webmock"
gem "braintree", ">= 2.92.0"
gem "stripe", "~> 10.11"
gem "stripe", "~> 11.0"
gem "paddle", "~> 2.1"
gem "receipts"
gem "prawn", git: "https://github.com/prawnpdf/prawn.git"
gem "prawn"
gem "pg"
gem "mysql2"
gem "sqlite3", "~> 1.7.2"
Expand Down
20 changes: 8 additions & 12 deletions gemfiles/rails_7.gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
GIT
remote: https://github.com/prawnpdf/prawn.git
revision: ce374035905ef7691ddfa2dc015f4ea734d1f737
specs:
prawn (2.5.0)
matrix (~> 0.4)
pdf-core (~> 0.10.0)
ttfunk (~> 1.8)

GIT
remote: https://github.com/thoughtbot/appraisal.git
revision: f5e31c48a1dda036a2c13663fad1b657a0953f5d
Expand Down Expand Up @@ -171,6 +162,10 @@ GEM
racc
pdf-core (0.10.0)
pg (1.5.6)
prawn (2.5.0)
matrix (~> 0.4)
pdf-core (~> 0.10.0)
ttfunk (~> 1.8)
prawn-table (0.2.2)
prawn (>= 1.3.0, < 3.0.0)
public_suffix (5.0.4)
Expand Down Expand Up @@ -257,7 +252,7 @@ GEM
rubocop-performance (~> 1.20.2)
stimulus-rails (1.3.3)
railties (>= 6.0.0)
stripe (10.14.0)
stripe (11.2.0)
thor (1.3.1)
timeout (0.4.1)
ttfunk (1.8.0)
Expand Down Expand Up @@ -288,6 +283,7 @@ GEM
PLATFORMS
arm64-darwin-21
arm64-darwin-22
arm64-darwin-23
x86_64-darwin-20
x86_64-darwin-21
x86_64-darwin-22
Expand All @@ -307,15 +303,15 @@ DEPENDENCIES
paddle (~> 2.1)
pay!
pg
prawn!
prawn
puma
rails (~> 7.0.0)
receipts
sprockets-rails
sqlite3 (~> 1.7.2)
standard
stimulus-rails
stripe (~> 10.11)
stripe (~> 11.0)
turbo-rails
vcr
web-console
Expand Down
4 changes: 2 additions & 2 deletions gemfiles/rails_7_1.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ gem "mocha"
gem "vcr"
gem "webmock"
gem "braintree", ">= 2.92.0"
gem "stripe", "~> 10.11"
gem "stripe", "~> 11.0"
gem "paddle", "~> 2.1"
gem "receipts"
gem "prawn", git: "https://github.com/prawnpdf/prawn.git"
gem "prawn"
gem "pg"
gem "mysql2"
gem "sqlite3", "~> 1.7.2"
Expand Down
Loading

0 comments on commit 49e9f58

Please sign in to comment.