justifi 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 3c34231d16ea73027351523d6309369021705f687926de6467fd4e81d1ff122f
4
+ data.tar.gz: 8c0009bd8453cf885113b081c3527ce6f074c08b0ba7086ba82348d89f8ce09e
5
+ SHA512:
6
+ metadata.gz: ce6dc69cbc087eaa57536791686380791ba816ef7acebad501ad5f6133567dd37c1475ef0ada32d666282f1d556dae668950fd3806297392b95e42703d6d1c61
7
+ data.tar.gz: fff1e3c1f3d49da9dd15a248f43ee1f2330860a7ab0d492bdfd223f1ce80d77c1ea4088511bc577f7ca761c99aeaafd60377ee19bdcb9e97c71716cf2ca76d4c
data/.env.template ADDED
@@ -0,0 +1,2 @@
1
+ CLIENT_ID=some_client
2
+ CLIENT_SECRET=some_client_secret
@@ -0,0 +1,48 @@
1
+ <!--
2
+ Describe the rationale and use case for this pull request. Provide any
3
+ background, examples, and images that provide further information to accurately
4
+ describe what it is that you are adding to the repo. Add subsections as
5
+ necessary to organize and feel free to link and reference other PRs as
6
+ necessary, but also include them in the links section below as a quick
7
+ reference.
8
+
9
+ **Guidelines:**
10
+
11
+ * Keep Pull Request titles short and to the point, ideally under 72 characters
12
+ * Provide as much context/info in the description as necessary to get the
13
+ reviewer up to the same domain knowledge level as yourself
14
+ * Keep code changes as short as possible and implementing a single
15
+ feature/fix/refactoring, when possible
16
+ -->
17
+
18
+ Type of Change
19
+ --------------
20
+
21
+ * [ ] Bug fix (non-breaking change which fixes an issue)
22
+ * [ ] New feature (non-breaking change which adds functionality)
23
+ * [ ] Breaking change (would cause existing functionality to not work as expected)
24
+ * [ ] This change requires a documentation update
25
+ * [ ] This change is in scope for PCI
26
+ * [ ] This requires approval from UX
27
+ * [ ] This requires approval from Marketing
28
+
29
+
30
+ Links
31
+ -----
32
+
33
+ <!--
34
+ **Examples**
35
+
36
+ * http://documentation.for/library/that/I/am/adding
37
+ * [relevant issue or pull_request](#123)
38
+ -->
39
+
40
+
41
+ Steps for Testing/QA
42
+ --------------------
43
+
44
+ <!--
45
+ If there are any manual steps that you would like the reviewer(s) to take to
46
+ verify your changes, please describe in detail the steps to reproduce the
47
+ features added by the pull request, or the bug before and after the change.
48
+ -->
@@ -0,0 +1,92 @@
1
+ name: 📦 Build and Release
2
+
3
+ on:
4
+ push:
5
+ paths:
6
+ - lib/justifi/version.rb
7
+ workflow_dispatch:
8
+
9
+ jobs:
10
+ run_tests:
11
+ name: 📋 Verify
12
+ uses: justifi-tech/justifi-ruby/.github/workflows/verify.yml@main
13
+ if: github.ref == 'refs/heads/main'
14
+ secrets:
15
+ CLIENT_STAGING_ID: ${{secrets.CLIENT_STAGING_ID }}
16
+ CLIENT_SECRET_STAGING: ${{secrets.CLIENT_SECRET_STAGING }}
17
+ API_STAGING_BASE_URL: ${{secrets.API_STAGING_BASE_URL}}
18
+ ENVIRONMENT: ${{secrets.ENVIRONMENT}}
19
+
20
+ build_and_release:
21
+ strategy:
22
+ matrix:
23
+ include:
24
+ - api_key: JUSTIFI_MACHINA_RUBYGEMS_API_KEY
25
+ bearer: false
26
+ gem_host: https://rubygems.org
27
+ pkg_host_name: rubygems.org
28
+ - api_key: JUSTIFI_MACHINA_GITHUB_TOKEN
29
+ bearer: true
30
+ gem_host: https://rubygems.pkg.github.com/${{ github.repository_owner }}
31
+ pkg_host_name: pkg.github.com
32
+
33
+ name: 📦 Package and Release on ${{ matrix.pkg_host_name }}
34
+ needs: run_tests
35
+ if: github.ref == 'refs/heads/main'
36
+
37
+ runs-on: ubuntu-latest
38
+
39
+ steps:
40
+ - name: Build API_KEY value
41
+ id: api_key
42
+ run: |
43
+ echo "::set-output name=value::${{ matrix.bearer && 'Bearer ' || '' }}${{ secrets[matrix.api_key] }}"
44
+
45
+ - name: Checkout
46
+ uses: actions/checkout@v3
47
+
48
+ - name: Setup Ruby and install gems
49
+ uses: ruby/setup-ruby@v1
50
+ with:
51
+ bundler-cache: true
52
+ ruby-version: 2.6
53
+ rubygems: 3.2.32 # Required for GEM_HOST_API_KEY to work (delete if we use Ruby 3)
54
+
55
+ # The `computed` value here is to solve for `-pre` style tags.
56
+ # `raw_value` is what comes directly from the VERSION value, and
57
+ # `computed` is what `Gem::Version` will output
58
+ - name: Fetch Gem Version
59
+ id: gem_version
60
+ run: |
61
+ ruby -r ./lib/justifi/version.rb -e '
62
+ puts "::set-output name=raw_value::#{Justifi::VERSION}"
63
+ puts "::set-output name=computed::#{Gem::Version.new(Justifi::VERSION)}"
64
+ '
65
+
66
+ # Combination of bundler's release steps and the steps here:
67
+ #
68
+ # https://github.com/rickstaa/action-create-tag/blob/main/entrypoint.sh
69
+ #
70
+ - name: Tag Release
71
+ id: git_tag
72
+ if: matrix.gem_host == 'https://rubygems.org' # only do this step 1 time
73
+ env:
74
+ TAG: v${{ steps.gem_version.outputs.raw_value }}
75
+ VERSION: ${{ steps.gem_version.outputs.raw_value }}
76
+ run: |
77
+ git config user.name "JustiFi Machina"
78
+ git config user.email "justifi.machina@justifi.ai"
79
+ git tag -a "${TAG}" -m "Version ${VERSION}" "${GITHUB_SHA}"
80
+ git remote set-url origin "https://justifi-machina:${{ secrets.JUSTIFI_MACHINA_GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git"
81
+ git push origin refs/tags/${TAG}
82
+
83
+ - name: Build gem
84
+ run: gem build justifi.gemspec
85
+
86
+ - name: Publish gem to GitHub packages
87
+ env:
88
+ GEM_HOST_API_KEY: ${{ steps.api_key.outputs.value }}
89
+ RUBYGEMS_HOST: ${{ matrix.gem_host }}
90
+ VERSION: ${{ steps.gem_version.outputs.computed }}
91
+ run: |
92
+ gem push --host ${RUBYGEMS_HOST} justifi-${VERSION}.gem
@@ -0,0 +1,46 @@
1
+ name: Generate Coverage
2
+ on:
3
+ push:
4
+ branches:
5
+ - main
6
+
7
+ jobs:
8
+ generate_coverage:
9
+ name: Generate Coverage
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - name: Checkout code
13
+ uses: actions/checkout@v2
14
+
15
+ - name: Setup Ruby and install gems
16
+ uses: ruby/setup-ruby@v1
17
+ with:
18
+ bundler-cache: true
19
+ ruby-version: 2.6
20
+
21
+ - name: Run tests
22
+ env:
23
+ CLIENT_ID: ${{secrets.CLIENT_STAGING_ID }}
24
+ CLIENT_SECRET: ${{secrets.CLIENT_SECRET_STAGING }}
25
+ API_STAGING_BASE_URL: ${{secrets.API_STAGING_BASE_URL}}
26
+ ENVIRONMENT: ${{secrets.ENVIRONMENT}}
27
+ run: bundle exec rspec
28
+
29
+ - name: Deploy coverage to S3
30
+ uses: zdurham/s3-upload-github-action@master
31
+ with:
32
+ args: --acl public-read
33
+ env:
34
+ FILE: "coverage/coverage_badge_total.svg"
35
+ S3_BUCKET: ${{ secrets.AWS_STAGING_BUCKET_NAME }}
36
+ S3_KEY: "coverage_badge_total.svg"
37
+ AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID_STAGING }}
38
+ AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY_STAGING }}
39
+ AWS_REGION: "us-east-1"
40
+
41
+ - name: Change coverage_badge_total.svg Cache-Control
42
+ run: |
43
+ aws configure set aws_access_key_id ${{ secrets.AWS_ACCESS_KEY_ID_STAGING }}
44
+ aws configure set aws_secret_access_key ${{ secrets.AWS_SECRET_ACCESS_KEY_STAGING }}
45
+ aws configure set default.region "us-east-1"
46
+ aws s3 cp s3://${{ secrets.AWS_STAGING_BUCKET_NAME }}/coverage_badge_total.svg s3://${{ secrets.AWS_STAGING_BUCKET_NAME }}/coverage_badge_total.svg --metadata-directive REPLACE --cache-control "max-age=0" --acl public-read --content-type "image/svg+xml"
@@ -0,0 +1,51 @@
1
+ name: verify
2
+ on:
3
+ push:
4
+ branches:
5
+ - main
6
+ pull_request:
7
+ branches:
8
+ - main
9
+ workflow_call:
10
+ secrets:
11
+ CLIENT_STAGING_ID: {required: true}
12
+ CLIENT_SECRET_STAGING: {required: true}
13
+ API_STAGING_BASE_URL: {required: true}
14
+ ENVIRONMENT: {required: true}
15
+
16
+ jobs:
17
+ linters:
18
+ name: Linters
19
+ runs-on: ubuntu-latest
20
+ steps:
21
+ - name: Checkout code
22
+ uses: actions/checkout@v2
23
+ - name: Setup Ruby and install gems
24
+ uses: ruby/setup-ruby@v1
25
+ with:
26
+ bundler-cache: true
27
+ ruby-version: 2.6
28
+ - name: Run linters
29
+ run: |
30
+ bundle exec rubocop
31
+
32
+ tests:
33
+ name: Tests
34
+ runs-on: ubuntu-latest
35
+ steps:
36
+ - name: Checkout code
37
+ uses: actions/checkout@v2
38
+
39
+ - name: Setup Ruby and install gems
40
+ uses: ruby/setup-ruby@v1
41
+ with:
42
+ bundler-cache: true
43
+ ruby-version: 2.6
44
+
45
+ - name: Run tests
46
+ env:
47
+ CLIENT_ID: ${{secrets.CLIENT_STAGING_ID }}
48
+ CLIENT_SECRET: ${{secrets.CLIENT_SECRET_STAGING }}
49
+ API_STAGING_BASE_URL: ${{secrets.API_STAGING_BASE_URL}}
50
+ ENVIRONMENT: ${{secrets.ENVIRONMENT}}
51
+ run: bundle exec rspec
data/.gitignore ADDED
@@ -0,0 +1,15 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ examples/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
13
+ .env
14
+ .byebug_history
15
+ .DS_STORE
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,12 @@
1
+ require: standard
2
+
3
+ inherit_gem:
4
+ standard: config/base.yml
5
+
6
+ AllCops:
7
+ Exclude:
8
+ - "vendor/**/*"
9
+ - "bin/*"
10
+ - "db/schema.rb"
11
+ - "tmp/**/*"
12
+
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at jmatheus.vaz@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,92 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ justifi (0.5.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ addressable (2.8.0)
10
+ public_suffix (>= 2.0.2, < 5.0)
11
+ ast (2.4.2)
12
+ byebug (11.1.3)
13
+ crack (0.4.5)
14
+ rexml
15
+ diff-lcs (1.5.0)
16
+ docile (1.4.0)
17
+ dotenv (2.7.6)
18
+ hashdiff (1.0.1)
19
+ parallel (1.22.1)
20
+ parser (3.1.2.0)
21
+ ast (~> 2.4.1)
22
+ public_suffix (4.0.7)
23
+ rainbow (3.1.1)
24
+ rake (13.0.6)
25
+ regexp_parser (2.3.0)
26
+ repo-small-badge (0.2.7)
27
+ victor (~> 0.2.8)
28
+ rexml (3.2.5)
29
+ rspec (3.11.0)
30
+ rspec-core (~> 3.11.0)
31
+ rspec-expectations (~> 3.11.0)
32
+ rspec-mocks (~> 3.11.0)
33
+ rspec-core (3.11.0)
34
+ rspec-support (~> 3.11.0)
35
+ rspec-expectations (3.11.0)
36
+ diff-lcs (>= 1.2.0, < 2.0)
37
+ rspec-support (~> 3.11.0)
38
+ rspec-mocks (3.11.1)
39
+ diff-lcs (>= 1.2.0, < 2.0)
40
+ rspec-support (~> 3.11.0)
41
+ rspec-support (3.11.0)
42
+ rubocop (1.27.0)
43
+ parallel (~> 1.10)
44
+ parser (>= 3.1.0.0)
45
+ rainbow (>= 2.2.2, < 4.0)
46
+ regexp_parser (>= 1.8, < 3.0)
47
+ rexml
48
+ rubocop-ast (>= 1.16.0, < 2.0)
49
+ ruby-progressbar (~> 1.7)
50
+ unicode-display_width (>= 1.4.0, < 3.0)
51
+ rubocop-ast (1.17.0)
52
+ parser (>= 3.1.1.0)
53
+ rubocop-performance (1.13.3)
54
+ rubocop (>= 1.7.0, < 2.0)
55
+ rubocop-ast (>= 0.4.0)
56
+ ruby-progressbar (1.11.0)
57
+ simplecov (0.21.2)
58
+ docile (~> 1.1)
59
+ simplecov-html (~> 0.11)
60
+ simplecov_json_formatter (~> 0.1)
61
+ simplecov-html (0.12.3)
62
+ simplecov-small-badge (0.2.4)
63
+ repo-small-badge (~> 0.2.7)
64
+ simplecov (~> 0.17)
65
+ simplecov_json_formatter (0.1.4)
66
+ standard (1.10.0)
67
+ rubocop (= 1.27.0)
68
+ rubocop-performance (= 1.13.3)
69
+ unicode-display_width (2.1.0)
70
+ victor (0.2.8)
71
+ webmock (3.14.0)
72
+ addressable (>= 2.8.0)
73
+ crack (>= 0.3.2)
74
+ hashdiff (>= 0.4.0, < 2.0.0)
75
+
76
+ PLATFORMS
77
+ ruby
78
+
79
+ DEPENDENCIES
80
+ byebug
81
+ dotenv
82
+ justifi!
83
+ rake (~> 13.0)
84
+ rspec (~> 3.0)
85
+ rubocop
86
+ simplecov
87
+ simplecov-small-badge
88
+ standard
89
+ webmock (>= 3.8.0)
90
+
91
+ BUNDLED WITH
92
+ 2.2.3
data/README.md ADDED
@@ -0,0 +1,227 @@
1
+ # JustiFi Ruby ![Coverage](https://justifi-gem-assets.s3.us-east-2.amazonaws.com/coverage_badge_total.svg)
2
+
3
+ The JustiFi gem provides a simple way to access JustiFi API for apps written in Ruby language.
4
+ It includes a pre-defined set of modules and classes that are essentially wrapped versions of our API resources.
5
+
6
+ ## Installation
7
+
8
+ From the command line:
9
+ ```bash
10
+ gem install justifi --version "0.4.0" --source "https://rubygems.pkg.github.com/justifi-tech"
11
+ ```
12
+ OR
13
+
14
+ Add these lines to your application's Gemfile:
15
+
16
+ ```ruby
17
+ source "https://rubygems.pkg.github.com/justifi-tech" do
18
+ gem "justifi", "0.4.0"
19
+ end
20
+ ```
21
+ And then execute:
22
+
23
+ $ bundle install
24
+
25
+
26
+ ## Setup
27
+
28
+ The gem needs to be configured with your `client_id` and `client_secret` in order to access JustiFi API resources.
29
+
30
+ Set `Justifi.client_id` and `Justifi.client_secret`:
31
+
32
+ ```ruby
33
+ require 'justifi'
34
+
35
+ Justifi.client_id = 'live_13...'
36
+ Justifi.client_secret = 'live_TDYj_wdd...'
37
+ ```
38
+
39
+ OR just use the `Justifi.setup` method to set all at once:
40
+
41
+
42
+ ```ruby
43
+ require 'justifi'
44
+
45
+ # setup
46
+ Justifi.setup(client_id: ENV["JUSTIFI_CLIENT_ID"],
47
+ client_secret: ENV["JUSTIFI_CLIENT_SECRET"])
48
+ ```
49
+
50
+
51
+ ## Create Payment
52
+
53
+ There are two ways to create a payment:
54
+
55
+ 1. Create with tokenized payment method:
56
+
57
+ ```ruby
58
+ payment_params = {
59
+ amount: 1000,
60
+ currency: "usd",
61
+ capture_strategy: "automatic",
62
+ email: "example@example.com",
63
+ description: "Charging $10 on Example.com",
64
+ payment_method: {
65
+ token: "#{tokenized_payment_method_id}"
66
+ }
67
+ }
68
+
69
+ Justifi::Payment.create(params: payment_params)
70
+ ```
71
+
72
+ 2. Create with full payment params:
73
+
74
+ ```ruby
75
+ payment_params = {
76
+ amount: 1000,
77
+ currency: "usd",
78
+ capture_strategy: "automatic",
79
+ email: "example@example.com",
80
+ description: "Charging $10 on Example.com",
81
+ payment_method: {
82
+ card: {
83
+ name: "JustiFi Tester",
84
+ number: "4242424242424242",
85
+ verification: "123",
86
+ month: "3",
87
+ year: "2040",
88
+ address_postal_code: "55555"
89
+ }
90
+ }
91
+ }
92
+
93
+ Justifi::Payment.create(params: payment_params)
94
+ ```
95
+
96
+ ## Idempotency Key
97
+
98
+ You can use your own idempotency-key when creating payments.
99
+
100
+ ```ruby
101
+ payment_params = {
102
+ amount: 1000,
103
+ currency: "usd",
104
+ capture_strategy: "automatic",
105
+ email: "example@example.com",
106
+ description: "Charging $10 on Example.com",
107
+ payment_method: {
108
+ card: {
109
+ name: "JustiFi Tester",
110
+ number: "4242424242424242",
111
+ verification: "123",
112
+ month: "3",
113
+ year: "2040",
114
+ address_postal_code: "55555"
115
+ }
116
+ }
117
+ }
118
+
119
+ Justifi::Payment.create(params: payment_params, idempotency_key: "my_idempotency_key")
120
+ ```
121
+
122
+ IMPORTANT: The gem will generate an idempotency key in case you don't want to use your own.
123
+
124
+ ## Create Payment Refund
125
+
126
+ In order to create a refund, you will need an amount, a payment_id ( `py_2aBBouk...` ).
127
+
128
+ ```ruby
129
+ payment_params = {
130
+ amount: 1000,
131
+ currency: "usd",
132
+ capture_strategy: "automatic",
133
+ email: "example@example.com",
134
+ description: "Charging $10 on Example.com",
135
+ payment_method: {
136
+ card: {
137
+ name: "JustiFi Tester",
138
+ number: "4242424242424242",
139
+ verification: "123",
140
+ month: "3",
141
+ year: "2040",
142
+ address_postal_code: "55555"
143
+ }
144
+ }
145
+ }
146
+
147
+ payment_id = Justifi::Payment.create(params: payment_params).data[:id] # get the payment id
148
+ reason = ['duplicate', 'fraudulent', 'customer_request'] # optional: one of these
149
+ amount = 1000
150
+
151
+ Justifi::Payment.create_refund( amount: 1000, reason: reason, payment_id: payment_id )
152
+ ```
153
+
154
+ ## Listing Resources
155
+
156
+ All top-level API resources have support for bulk fetches via `array` API methods.
157
+ JustiFi uses cursor based pagination which supports `limit`, `before_cursor` and `after_cursor`.
158
+ Each response will have a `page_info` object that contains the `has_next` and `has_previous` fields,
159
+ you can find more information about this on [JustiFi's Developer Portal](https://developer.justifi.ai/#section/Pagination).
160
+
161
+ ### List Payments
162
+
163
+ ```ruby
164
+ payments = Justifi::Payment.list
165
+
166
+ # pagination with end_cursor
167
+
168
+ query_params = {
169
+ limit: 15,
170
+ after_cursor: payments.data[:page_info][:end_cursor],
171
+ }
172
+
173
+ payments = Justifi::Payment.list(params: query_params)
174
+ ```
175
+
176
+
177
+ ### List Refunds
178
+
179
+ ```ruby
180
+ refunds = Justifi::Refund.list
181
+
182
+ # pagination
183
+ refunds = refunds.next_page
184
+ refunds = refunds.previous_page
185
+ ```
186
+
187
+
188
+ ## Get resource by id
189
+
190
+ ```ruby
191
+ payment = Justifi::Payment.get(payment_id: 'py_xyz')
192
+ refund = Justifi::Refund.get(refund_id: 're_xyz')
193
+ ```
194
+
195
+ ## Seller Account
196
+
197
+ You can make requests using the `Seller-Account` header in order to process resources as a seller-account.
198
+
199
+ ```ruby
200
+ seller_account_id = "acc_xyzs"
201
+ Justifi::PaymentIntent.create(params: payment_intent_params, seller_account_id: seller_account_id)
202
+ ```
203
+
204
+ Any API resource using the `seller_account_id` variable will include the `Seller-Account` header and be
205
+ processed as the seller account.
206
+
207
+ ## Contributing
208
+
209
+ ### Release a new version of the gem
210
+
211
+ Follow the steps below to make a release:
212
+
213
+ 1. Increment the version number in `lib/justifi/version.rb`
214
+ 2. Run `bundle`
215
+ 3. Commit the following file changes to your branch
216
+ - `Gemfile.lock`
217
+ - `lib/justifi/version.rb`
218
+ 4. Create and Merge your PR to `main`
219
+
220
+ After this, the `.github/workflows/build_and_release.yml` will tag and release
221
+ the gem to github packages.
222
+
223
+
224
+ ## Code of Conduct
225
+
226
+ Everyone interacting in the JustApi project's codebases, issue trackers, chat
227
+ rooms and mailing lists is expected to follow the [code of conduct][].