Socket
Book a DemoInstallSign in
Socket

paypal-masspay

Package Overview
Dependencies
Maintainers
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

paypal-masspay

1.1.0
bundlerRubygems
Version published
Maintainers
2
Created
Source

Paypal::Masspay

Paypal::Masspay is a Ruby library that uses PayPals MassPay API to send Mass Payments.

The MassPay API provides a SOAP and NVP (Name-Value Pair) interface, however this library uses the NVP interface exclusively.

You can read more about PayPals MassPay API at the following link: PayPal MassPay API Documentationn

A introduction about PayPals NVP interface in general can be found here: PayPal NVP API Overview

Usage

In a nutshell the Paypal::Masspay library lets you send multiple payments at once using the following schema:

Paypal::Masspay::Configuration.configure do |config|
  config.environment  = :production
  config.username     = 'your_paypal_username'
  config.password     = 'your_paypal_password'
  config.signature    = 'your_paypal_signature'
end

masspay = Paypal::Masspay.new(:currency  => 'USD') do |bucket|
    bucket.add_recipient(Paypal::Masspay::Recipient.new(:recipient_email => 'chunky@example.com', :amount => 10.00, :unique_id => 1234, :note => 'hello'))
    bucket.add_recipient(Paypal::Masspay::Recipient.new(:recipient_email => 'bacon@example.com', :amount => 2.95, :unique_id => 222))
end

masspay.deliver

It also supports being used like this:

Paypal::Masspay::Configuration.configure do |config|
  config.environment  = :production
  config.username     = 'your_paypal_username'
  config.password     = 'your_paypal_password'
  config.signature    = 'your_paypal_signature'
end

recipients = [
  Paypal::Masspay::Recipient.new(
    :recipient_email => 'chunky@example.com',
    :amount          => 10.00,
    :unique_id       => 1234,
    :note            => 'hello'),
  Paypal::Masspay::Recipient.new(
    :recipient_email => 'bacon@example.com',
    :amount          => 2.95,
    :unique_id       => 222)
 ]

masspay = Paypal::Masspay.new(:currency => 'USD', :recipients => recipients)

masspay.deliver

This sends a post request to the PayPal NVP API endpoint containing the following data:

USER=your_paypal_username&
PWD=your_paypal_password&
SIGNATURE=your_paypal_signature&
VERSION=2.3&
METHOD=MassPay&
RECEIVERTYPE=EmailAddress&
L_EMAIL0=chunky@example.com&
L_AMT0=10.00&
L_UNIQUEID0=1234&
L_NOTE0=hello&
L_EMAIL1=bacon@example.com&
L_AMT1=2.95&
L_UNIQUEID1=222&
CURRENCYCODE=USD

You are also able to check whether or not the request was successfully sent to paypal, and can check any returned error/warnings using the following code:

masspay.successful? # ===> true/false

masspay.errors                  # ===> [ <Paypal::Masspay::Error>, <Paypal::Masspay::Error>, ... ]
masspay.errors[0].methods       # ===> [ :code, :short_message, :long_message, :severity ]
masspay.errors[0].code          # ===> 10000
masspay.errors[0].short_message # ===> "insufficient funds"

FAQs

Package last updated on 09 Sep 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.