Paycargo
Paycargo is a ruby gem client library to talk with Paycargo API. Paycargo wraps the Paycargos’s REST API and follows Ruby convention.
Quik start
Install via Rubygems
gem install paycargo
Or add to your application’s Gemfile:
gem 'paycargo'
And then execute:
bundle install
Access the library in Ruby:
require 'paycargo'
Making requests
Initialize client to make requets:
client = Paycargo::Client.new(token: "JWT TOKEN")
client.transactions.list()
Consuming resources
Most methods return a Resource
object which provides dot notation and [] access for fields returned in the API response.
User
This resource allows you to send user credentials, if login success you receive a JWT token as a response for sending future requests to this API. Token validity time is 8 hours.
client.users.login(username: 'username', password: 'password')
This resource allows you to retrieve user information. You need to pass a valid user id so as JWT token. Only users of your account (or your branches if you are a headquarter) are retrievable.
client.user.retreive(userId: 272360)
Retrieve a list of permissions for the selected user. Endpoint requires to pass a valid user id parameter.
client.users.permissions(272360)
Transactions
Get all Transactions for a client.
client.transactions.list()
Get a transaction by id
client.transactions.retreive(473943)
Get transaction by number
client.transactions.by_number(number: 9292323, vendorID: 279366)
Get transactions history
client.transactions.history(476296)
Create Transaction
client.transactions.create(
vendorId: 279546,
type: 'Other',
subcategory: 'I-432188',
number: '929-83294551',
departureDate: '2018-04-01',
arrivalDate: '2018-04-24',
total: 100,
direction: 'Outbound',
paymentDueDate: '2018-04-24',
hasArrived: 'Y',
shipperRefNumber: 'tdfgfdgfd'
)
Approve a Transaction
client.transactions.apporve(489479, paymentType: 'OVERNIGHT')
Batch Approves a list of transactions, for the same Vendor. Available payment methods: OVERNIGHT, PREPAID.
client.transactions.batch_approve(batchPaymentType: 'OVERNIGHT', transactionIds: '515168,515169')
Puting a transaction to proof
client.transactions.proof(500744)
Get transactions fees
client.transactions.fees(
paymentType: 'OVERNIGHT',
transactionId: 123456,
numberOfTransactions: 2,
payerId: 123456,
vendorId: 123456,
total: 70
)
-
paymentType
: payment type for transaction: OVERNIGHT, PREPAID, CREDITCARD, PAYCARGO_CREDIT. -
transactionId
: transaction id if exists. -
numberOfTransactions
: number of transaction. Used to define if batch flat fee can be applied. -
payerID
: payer ID -
vendorID
: vendor ID -
total
: total amount used to calculate fees for PAYCARGO_CREDIT and CREDITCARD payment type.
Void Transaction
client.transactions.void(483212)
Payer
Get Funds Availability
client.payer.funds(281783)
This endpoint retrieves the following data, per payer, per payment method:
- get funds availability
- get funds limit
Vendor
Get all vendors
client.vendors.list()
Get vendor by id
client.vendors.retreive(279824)
Reports
Get Payer ACH Report
client.reports.payer(
startDate: '10/01/2020',
endDate: '11/01/2020',
client_id: 284347,
report_action_name: 'getACHReconciliation',
type: 'SHIPPER',
accountName: 'all'
)
-
fleet_id
: Account fleet id ( payerId) -
startDate
: Start Date in MM/DD/YYYY format -
endDate
: End Date in MM/DD/YYYY format -
client_id
: Account client id -
report_action_name
: PayCargo report type name, for ACH report : getACHReconciliation -
type
: Account type : SHIPPER or CARRIER -
accountName
: Account name of branch if any. Apply “all” to get data from branches for HQ -
fleetLimit
: fleet_id -
providerLimit
: provier_id
Development
After checking out the repo, run bin/setup
to install dependencies. Then, run rake spec
to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
and then run bundle exec rake release
which will create a git tag for the version, push git commits and the created tag, and push the gem
file to rubygems.org.
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/lepepe/paycargo.
License
The gem is available as open source under the terms of the MIT License.