The Cash App Pay Ruby library provides convenient access to the Cash App Pay API from applications written in the Ruby language. It includes a pre-defined set of classes for API resources.
The library also provides other features. For example:
- Easy configuration path for fast setup and use.
- Helpers for pagination.
- Built-in mechanisms for the serialization of parameters according to the expectations of Cash App Pay API.
See the Cash App Pay API docs.
You don't need this source code unless you want to modify the gem. If you just want to use the package, just run:
gem install cash_app_pay
If you want to build the gem from source:
gem build cash_app_pay.gemspec
then install the gem locally:
gem install cash_app_pay-*.gem
Run Ruby and require the gem
require 'cash_app_pay'
- Ruby 2.3+.
If you are installing via bundler, you should be sure to use the https rubygems source in your Gemfile, as any gems fetched over http could potentially be compromised in transit and alter the code of gems fetched securely over https:
source 'https://rubygems.org'
gem 'rails'
gem 'cash_app_pay'
The libaray needs to be configured with your account's client_id. Set CashAppPay.client_id
to its value:
require 'cash_app_pay'
CashAppPay.client_id = 'CAS...'
# create a Customer Request
CashAppPay::CustomerRequest.create({ idempotency_key: 'xyz_123_...', channel: 'IN_APP', ... })
# retrieve single Customer Request
CashAppPay::CustomerRequest.retrieve('GRR_123456789')
The libaray needs to be configured with your account's client_id as well as api_key, signature and region. Set CashAppPay.client_id
, CashAppPay.api_key
, CashAppPay.signature
and CashAppPay.region
:
require 'cash_app_pay'
CashAppPay.client_id = 'CAS...'
CashAppPay.region = '...'
CashAppPay.signature = '...'
CashAppPay.api_key = 'KEY_...'
# create a Customer Request
CashAppPay::Merchant.create({ idempotency_key: 'xyz_123_...', name: 'My merchant', ... })
# retrieve single Customer Request
CashAppPay::Merchant.retrieve('MMI_123456789s')
For apps that need to use multiple keys during the lifetime of a process it's possible to set a per-request:
require 'cash_app_pay'
CashAppPay::CustomerRequest.create(
{ idempotency_key: 'xyz_123_...', channel: 'IN_APP', ... },
{ api_key: 'CAS...' }
)
Run all tests:
bundle exec rake test
Run a single test suite:
bundle exec rake test TEST=test/cash_app_pay/resources/payment_test.rb
There is a sample project in Ruby On Rails at: