### Install asdf on Linux using Git Source: https://github.com/activemerchant/active_merchant/wiki/New-to-Ruby? Clone the asdf repository to install the version manager on Linux. ```bash git clone https://github.com/asdf-vm/asdf.git ~/.asdf cd ~/.asdf git checkout "$(git describe --abbrev=0 --tags)" ``` -------------------------------- ### Install Dependencies and Run Tests Source: https://github.com/activemerchant/active_merchant/wiki/Testing-Your-Gateway Installs project dependencies and runs local or remote tests. Remote tests require valid credentials in `test/fixtures.yml`. ```bash $ bundle install $ bundle exec rake test:local #Runs `test:units` and `rubocop`. All these tests should pass. $ bundle exec rake test:remote #Will not pass without updating test/fixtures.yml with credentials ``` -------------------------------- ### Install asdf on macOS using Homebrew Source: https://github.com/activemerchant/active_merchant/wiki/New-to-Ruby? Use Homebrew to install the asdf version manager on macOS. ```bash brew install asdf ``` -------------------------------- ### Example Commit Messages for New Gateway Source: https://github.com/activemerchant/active_merchant/wiki/Submitting-Your-Gateway Organize your commits logically when developing a new gateway. This example shows a potential commit history for a new gateway. ```bash MyNewGateway: generate new gateway; test successful purchase MyNewGateway: add authorize, capture, and scrub actions, plus assoc. tests MyNewGateway: add 3DS options, plus assoc. tests MyNewGateway: add testing for different card types ``` -------------------------------- ### Install and Reshim Ruby with asdf Source: https://github.com/activemerchant/active_merchant/wiki/New-to-Ruby? Install the Ruby version specified in `.ruby-version` and update asdf's shims. Run these commands from your Active Merchant directory. ```bash asdf install asdf reshim ``` -------------------------------- ### Install Dependencies and Run Tests Source: https://github.com/activemerchant/active_merchant/wiki/New-to-Ruby? Install Active Merchant's gem dependencies using Bundler and execute the local test suite, which includes unit tests and RuboCop linting. Ensure you are in the Active Merchant directory. ```bash gem install bundler bundle install bundle exec rake test:local ``` -------------------------------- ### Install Active Merchant with RubyGems Source: https://github.com/activemerchant/active_merchant/blob/master/README.md Install the Active Merchant gem using the RubyGems package manager. ```console gem install activemerchant ``` -------------------------------- ### Example 3DS2 Options in Gateway Purchase Call Source: https://github.com/activemerchant/active_merchant/wiki/Standardized-3DS-Fields Demonstrates how to pass standardized 3DS2-specific options within the `three_d_secure` hash during a gateway's `purchase` call. Ensure all required fields for the specific gateway are included. ```ruby gateway.purchase( 100, credit_card, three_d_secure: { version: '2.1.0', eci: '02', cavv: 'jJ81HADVRtXfCBATEp01CJUAAAA=', ds_transaction_id: '97267598-FAE6-48F2-8083-C23433990FBC', acs_transaction_id: '13c701a3-5a88-4c45-89e9-ef65e50a8bf9', xid: '00000000000000000501', cavv_algorithm: '1', directory_response_status: 'Y', authentication_response_status: 'Y', three_ds_server_trans_id: '24f701e3-9a85-4d45-89e9-af67e70d8fg8' } ) ``` -------------------------------- ### Example Pull Request Commit Message Source: https://github.com/activemerchant/active_merchant/wiki/Submitting-Your-Gateway An example of a filled-out pull request commit message, demonstrating how to summarize the gateway integration and report test results. ```markdown AwesomesauceGateway: Integration of new Awesomesauce Gateway Integrate new AwesomesauceGateway with the following methods: authorize, verify, capture, refund, etc. Test Summary Local: 4650 tests, 73149 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Unit: 71 tests, 372 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 94 tests, 361 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed ``` -------------------------------- ### Add Ruby Plugin with asdf Source: https://github.com/activemerchant/active_merchant/wiki/New-to-Ruby? Install the Ruby plugin for asdf, a tool for managing multiple Ruby versions. Run this command in your home directory. ```bash asdf plugin add ruby ``` -------------------------------- ### Add asdf to Linux shell configuration Source: https://github.com/activemerchant/active_merchant/wiki/New-to-Ruby? Add the asdf executable path to your .bashrc file for Linux installations. ```bash . $HOME/.asdf/asdf.sh ``` -------------------------------- ### View Git Remotes Source: https://github.com/activemerchant/active_merchant/wiki/New-to-Ruby? Verify that both 'origin' (your fork) and 'upstream' (original repository) remotes are correctly set up. ```bash git remote -v ``` -------------------------------- ### Configure asdf for Version Files Source: https://github.com/activemerchant/active_merchant/wiki/New-to-Ruby? Enable asdf to recognize and use local `.ruby-version` files for managing Ruby versions per project. Append this line to your ~/.asdfrc file. ```bash echo 'legacy_version_file = yes' >> ~/.asdfrc ``` -------------------------------- ### Make a Purchase with TrustCommerce Gateway Source: https://github.com/activemerchant/active_merchant/blob/master/README.md Demonstrates how to make a purchase using a credit card with the TrustCommerce gateway. Ensure amounts are in cents and credit card details are validated before processing. ```ruby require 'active_merchant' # Use the TrustCommerce test servers ActiveMerchant::Billing::Base.mode = :test gateway = ActiveMerchant::Billing::TrustCommerceGateway.new( :login => 'TestMerchant', :password => 'password') # ActiveMerchant accepts all amounts as Integer values in cents amount = 1000 # $10.00 # The card verification value is also known as CVV2, CVC2, or CID credit_card = ActiveMerchant::Billing::CreditCard.new( :first_name => 'Bob', :last_name => 'Bobsen', :number => '4242424242424242', :month => '8', :year => Time.now.year+1, :verification_value => '000') # Validating the card automatically detects the card type if credit_card.validate.empty? # Capture $10 from the credit card response = gateway.purchase(amount, credit_card) if response.success? puts "Successfully charged $#{sprintf("%.2f", amount / 100)} to the credit card #{credit_card.display_number}" else raise StandardError, response.message end end ``` -------------------------------- ### Create and Push New Gateway Branch Source: https://github.com/activemerchant/active_merchant/wiki/Submitting-Your-Gateway Use these Git commands to create a new branch for your gateway, add your files, commit your changes, and push the branch to your forked repository. ```bash git checkout -b add_my_new_gateway git add [filename(s)] git commit -m "MyNewGateway: generate new gateway" git push origin add_my_new_gateway ``` -------------------------------- ### Perform a Purchase with a Gateway Source: https://github.com/activemerchant/active_merchant/blob/master/GettingStarted.md Instantiate a gateway and perform a purchase operation. Amounts are in cents. ```ruby gateway = SomeGateway.new # Amounts are always specified in cents, so $10.00 is 1000 cents response = gateway.purchase(1000, credit_card) ``` -------------------------------- ### Run Local Gateway Tests Source: https://github.com/activemerchant/active_merchant/wiki/Submitting-Your-Gateway Execute local tests for your gateway after rebasing to ensure all changes are compatible and passing. ```bash bundle exec rake test:local ruby -Itest test/unit/gateways/my_new_gateway_test.rb ruby -Itest test/remote/gateways/remote_my_new_gateway_test.rb ``` -------------------------------- ### Set Project Ruby Version Source: https://github.com/activemerchant/active_merchant/wiki/New-to-Ruby? Create a `.ruby-version` file in your Active Merchant project directory to specify the desired Ruby version (e.g., 2.5.7). ```bash echo '2.5.7' > .ruby-version ``` -------------------------------- ### Create a Credit Card Object Source: https://github.com/activemerchant/active_merchant/blob/master/GettingStarted.md Instantiate a CreditCard object with explicit details for processing. ```ruby credit_card = ActiveMerchant::Billing::CreditCard.new( :first_name => 'Steve', :last_name => 'Smith', :month => '9', :year => '2022', :brand => 'visa', :number => '4242424242424242', :verification_value => '424') ``` -------------------------------- ### Add Upstream Remote Source: https://github.com/activemerchant/active_merchant/wiki/New-to-Ruby? Add the original Active Merchant repository as an 'upstream' remote to sync your fork. Navigate into your cloned directory first. ```bash git remote add upstream https://github.com/activemerchant/active_merchant.git ``` -------------------------------- ### Run Specific Test Suite Source: https://github.com/activemerchant/active_merchant/wiki/Testing-Your-Gateway Executes a specific unit or remote test suite by providing the test file path. ```bash $ bundle exec rake test:units TEST=test/unit/gateways/nab_transact_test.rb $ bundle exec rake test:remote TEST=test/remote/gateways/remote_nab_transact_test.rb ``` -------------------------------- ### Update Local Fork Source: https://github.com/activemerchant/active_merchant/wiki/New-to-Ruby? Keep your local Active Merchant copy synchronized with the official repository. Ensure you are in your Active Merchant directory. ```bash git checkout master git pull upstream master ``` -------------------------------- ### Create a Credit Card Object from Parameters Source: https://github.com/activemerchant/active_merchant/blob/master/GettingStarted.md Instantiate a CreditCard object using parameters typically received from a web form (e.g., in a Rails controller). ```ruby credit_card = ActiveMerchant::Billing::CreditCard.new(params[:credit_card]) ``` -------------------------------- ### Verify Current Ruby Version Source: https://github.com/activemerchant/active_merchant/wiki/New-to-Ruby? Check the currently active Ruby version for your project. The output should confirm the version you intended to set (e.g., ruby 2.5.7). ```bash asdf current ``` -------------------------------- ### Store, Unstore, and Update API Definitions Source: https://github.com/activemerchant/active_merchant/wiki/Patterns-&-Standards Defines methods for tokenizing payment methods. `store` tokenizes a payment method, `unstore` removes a token, and `update` modifies the payment method associated with a token. ```ruby def store(payment_method, options={}) #=> Response def unstore(token, options={}) #=> Response def update(token, payment_method, options={}) #=> Response ``` -------------------------------- ### Authorize, Capture, and Void API Definitions Source: https://github.com/activemerchant/active_merchant/wiki/Patterns-&-Standards Defines the `authorize`, `capture`, and `void` methods. `authorize` and `capture` are required for authorizing funds and subsequent settlement, while `void` cancels an authorization. ```ruby def authorize(amount, payment_method, options={}) #=> Response def capture(amount, identifier, options={}) #=> Response def void(identifier, options={}) #=> Response ``` -------------------------------- ### Clone Active Merchant Fork Source: https://github.com/activemerchant/active_merchant/wiki/New-to-Ruby? Clone your forked Active Merchant repository to your local machine. Replace YOUR-GITHUB-USERNAME with your actual GitHub username. ```bash git clone https://github.com/YOUR-GITHUB-USERNAME/active_merchant ``` -------------------------------- ### Purchase API Definition Source: https://github.com/activemerchant/active_merchant/wiki/Patterns-&-Standards Defines the `purchase` method, which is the minimum required API for a gateway. It handles authorization and settlement in a single call or as chained authorize and capture calls. ```ruby def purchase(amount, payment_method, options={}) #=> Response ``` -------------------------------- ### Verify API Definition Source: https://github.com/activemerchant/active_merchant/wiki/Patterns-&-Standards Defines the `verify` method for checking the validity of a payment instrument, typically implemented as a zero-dollar authorization or an authorize followed by a void. ```ruby def verify(payment_method, options={}) #=> Response ``` -------------------------------- ### Credit API Definition Source: https://github.com/activemerchant/active_merchant/wiki/Patterns-&-Standards Defines the `credit` method for putting funds directly onto a supported payment method. ```ruby def credit(amount, payment_method, options={}) #=> Response ``` -------------------------------- ### Capture HTTP Request and Response Source: https://github.com/activemerchant/active_merchant/wiki/Testing-Your-Gateway Captures the raw HTTP request and response details for a specific test case by setting the `DEBUG_ACTIVE_MERCHANT` environment variable. This is useful for debugging and creating unit tests. ```bash $ DEBUG_ACTIVE_MERCHANT=true ruby -Itest test/remote/gateways/remote_nab_transact_test.rb -n test_successful_purchase <- "POST /test/xmlapi/payment... <- " "HTTP/1.1 200 OK\r\n" -> "Content-Type: text/xml;charset=ISO-8859-1\r\n" -> "Content-Length: 954\r\n" ... ``` -------------------------------- ### Run Specific Test Case Source: https://github.com/activemerchant/active_merchant/wiki/Testing-Your-Gateway Executes a single test case within a remote test file using the `-n` flag. ```bash $ ruby -Itest test/remote/gateways/remote_nab_transact_test.rb -n test_successful_purchase ``` -------------------------------- ### Refund API Definition Source: https://github.com/activemerchant/active_merchant/wiki/Patterns-&-Standards Defines the `refund` method for canceling settlement or returning funds for a prior purchase or capture. ```ruby def refund(amount, identifier, options={}) #=> Response ``` -------------------------------- ### Add asdf to macOS Catalina or newer shell configuration Source: https://github.com/activemerchant/active_merchant/wiki/New-to-Ruby? Add the asdf executable path to your .zshrc file for macOS Catalina or newer. ```bash . /usr/local/opt/asdf/asdf.sh ``` -------------------------------- ### Pull Request Commit Message Template Source: https://github.com/activemerchant/active_merchant/wiki/Submitting-Your-Gateway Use this template for your commit message when submitting a pull request for a new gateway. It includes sections for a short summary, full description, and test results. ```markdown # Short Summary: ##################### # ^^^ Line above intentionally left blank # Full Description: ########################## # Successful Test Summary ``` -------------------------------- ### Squash Commits with Interactive Rebase Source: https://github.com/activemerchant/active_merchant/wiki/Submitting-Your-Gateway Use interactive rebase to squash all commits on your branch into a single commit before pushing. This step is not necessary if your branch already has only one commit. ```bash git rebase -i master ``` -------------------------------- ### Rebase Branch with Upstream Master Source: https://github.com/activemerchant/active_merchant/wiki/Submitting-Your-Gateway Update your local master branch, then rebase your gateway branch onto the upstream master to incorporate the latest changes from the official repository. ```bash git checkout master git pull upstream master git checkout add_my_new_gateway git rebase upstream/master ``` -------------------------------- ### Push Updated Branch to Fork Source: https://github.com/activemerchant/active_merchant/wiki/Submitting-Your-Gateway After rebasing and squashing your commits, push the updated branch to your forked repository to notify maintainers of the changes. ```bash git push origin add_my_new_gateway ``` -------------------------------- ### Ruby Class Naming Convention Source: https://github.com/activemerchant/active_merchant/wiki/New-to-Ruby? Class names in Ruby should follow CamelCase convention. ```ruby Class MyNewGateway ``` -------------------------------- ### Ruby Variable and Method Naming Convention Source: https://github.com/activemerchant/active_merchant/wiki/New-to-Ruby? Variable and method names in Ruby should follow snake_case convention. ```ruby def my_important_method end ``` -------------------------------- ### Check Payment Response Status Source: https://github.com/activemerchant/active_merchant/blob/master/GettingStarted.md Examine the success or failure of a gateway operation using the response object. ```ruby if response.success? puts "Payment complete!" else puts "Payment failed: #{response.message}" end ``` -------------------------------- ### Add Active Merchant to Gemfile Source: https://github.com/activemerchant/active_merchant/blob/master/README.md Include Active Merchant as a dependency in your Ruby on Rails application's Gemfile. ```ruby gem 'activemerchant' ``` -------------------------------- ### CreditCard Attributes Source: https://github.com/activemerchant/active_merchant/wiki/Patterns-&-Standards Accesses common attributes of a CreditCard object for transaction processing. Ensure the CreditCard object is properly instantiated before accessing these attributes. ```ruby CreditCard.number CreditCard.first_name CreditCard.last_name CreditCard.verfication_value CreditCard.month CreditCard.year ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.