# MassPay API with Ruby On Rails PayPal AARRRGH

**URL:** <https://www.ruby-forum.com/t/masspay-api-with-ruby-on-rails-paypal-aarrrgh/78689>\
**Category:** Rails\
**Created:** [December 7, 2006, 9:31pm UTC](https://www.ruby-forum.com/t/masspay-api-with-ruby-on-rails-paypal-aarrrgh/78689 "2006-12-07T21:31:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![joep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/87869e/32.png) [@joep](https://www.ruby-forum.com/u/joep)\
**Post date:** [December 7, 2006, 9:31pm UTC](https://www.ruby-forum.com/t/masspay-api-with-ruby-on-rails-paypal-aarrrgh/78689/1 "2006-12-07T21:31:19Z")

</div>

Hey,

I’m trying to use Paypal to automatically pay customers, and I’ve heard  
MassPay API is a good thing to use. But I cannot find any examples of  
it for Ruby, nor do I know what steps to take to use it.

Does anyone have any information or experience with using MassPay API in  
RoR? Any help is much appreciated

---

<div class="post-metadata">

**Author:** ![joep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/87869e/32.png) [@joep](https://www.ruby-forum.com/u/joep)\
**Post date:** [December 8, 2006, 2:15am UTC](https://www.ruby-forum.com/t/masspay-api-with-ruby-on-rails-paypal-aarrrgh/78689/2 "2006-12-08T02:15:34Z")

</div>

Hello Joe,

2006/12/7, Joe P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> I’m trying to use Paypal to automatically pay customers, and I’ve heard  
> MassPay API is a good thing to use. But I cannot find any examples of  
> it for Ruby, nor do I know what steps to take to use it.
> 
> Does anyone have any information or experience with using MassPay API in  
> RoR? Any help is much appreciated

I don’t know what level of integration you are looking for. If your  
customer accepts a small amount of manual work, the only thing I did  
was to export a CSV file with the list of payments to make. Then, you  
need a human to upload this file, select a few items in a form, and  
submit.

The rest happens behind the scenes if you set your PayPal IPN URL  
correctly.

If you need more information, I can probably help out some more. I  
cannot share code, unfortunately, but I can guide you.

## Bye !

FranÃ§ois Beausoleil  
[http://blog.teksol.info/](http://blog.teksol.info/)  
[http://piston.rubyforge.org/](http://piston.rubyforge.org/)

---

<div class="post-metadata">

**Author:** ![joep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/87869e/32.png) [@joep](https://www.ruby-forum.com/u/joep)\
**Post date:** [December 8, 2006, 3:54pm UTC](https://www.ruby-forum.com/t/masspay-api-with-ruby-on-rails-paypal-aarrrgh/78689/3 "2006-12-08T15:54:30Z")

</div>

FranÃ§ois Beausoleil wrote:

> Hello Joe,
> 
> 2006/12/7, Joe P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):
> 
> > I’m trying to use Paypal to automatically pay customers, and I’ve heard  
> > MassPay API is a good thing to use. But I cannot find any examples of  
> > it for Ruby, nor do I know what steps to take to use it.
> > 
> > Does anyone have any information or experience with using MassPay API in  
> > RoR? Any help is much appreciated
> 
> I don’t know what level of integration you are looking for. If your  
> customer accepts a small amount of manual work, the only thing I did  
> was to export a CSV file with the list of payments to make. Then, you  
> need a human to upload this file, select a few items in a form, and  
> submit.
> 
> The rest happens behind the scenes if you set your PayPal IPN URL  
> correctly.
> 
> If you need more information, I can probably help out some more. I  
> cannot share code, unfortunately, but I can guide you.
> 
> ## Bye !
> 
> FranÃ§ois Beausoleil  
> [http://blog.teksol.info/](http://blog.teksol.info/)  
> [http://piston.rubyforge.org/](http://piston.rubyforge.org/)

Hi Francois,

I’m trying to completely automate it. Is it possible to do this with  
the MassPay API? I’ve also heard that Paypal is working on something  
called SendMoney API, but it’s not completed yet.

Joe

---

<div class="post-metadata">

**Author:** ![joep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/87869e/32.png) [@joep](https://www.ruby-forum.com/u/joep)\
**Post date:** [December 12, 2006, 4:28pm UTC](https://www.ruby-forum.com/t/masspay-api-with-ruby-on-rails-paypal-aarrrgh/78689/4 "2006-12-12T16:28:55Z")

</div>

Hey, thanks for that. I already actually bought that PDF last week; I’m  
still trying to get Ruby and Paypal working together.

I found this example, which has been pretty helpful.  
[http://www.pranavbihari.com/articles/2005/12/02/testing-paypal-web-services-with-ruby-soap4r](http://www.pranavbihari.com/articles/2005/12/02/testing-paypal-web-services-with-ruby-soap4r)

I’m still getting some errors when I try to run the test.rb, but I’m  
pretty sure they are caused by where my files are.

---

<div class="post-metadata">

**Author:** ![joep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/87869e/32.png) [@joep](https://www.ruby-forum.com/u/joep)\
**Post date:** [December 11, 2006, 3:43pm UTC](https://www.ruby-forum.com/t/masspay-api-with-ruby-on-rails-paypal-aarrrgh/78689/5 "2006-12-11T15:43:39Z")

</div>

On 12/8/06, Joe P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I’m trying to completely automate it. Is it possible to do this with  
> the MassPay API?  
> I haven’t done a MassPay integration, but I did go through the  
> DoDirectPayment one. If you look in the PayPal wsdl it referrs to the  
> MassPayRequestType, MassPayItem, and MassPayResponseType.

[https://www.paypal.com/IntegrationCenter/ic\_api-reference.html](https://www.paypal.com/IntegrationCenter/ic_api-reference.html)

For Ruby, you can download the xml and xsd files and use soap4r to  
generate related ruby classes. From those classes you can figure out  
what the message really needs to look like. It takes a bit of  
research to figure out that a MassPayRequest contains a  
MassPayRequestType, and the MassPayRequestType has to have one or more  
MassPayRequestItemType’s (but not more than 250).

Once you get that bit sorted out, you can just create the client,  
create a tree of Ruby classes that are all related, and send it off to  
PayPal. They should send you back a response for each request. One  
interesting gotcha: A single request must include items that are of  
the same currency.

Be sure to use a recent snapshot of soap4r and http-access2. Also, be  
sure to _install_ them in your ruby install directory, not just drop  
to them in the /vendor

For an example of how to go through the process for DoExpressPayment, you can check out my Friday at http://pragmaticprogrammer.com/titles/jfpaypal/index.html

The other route would be to figure out how to create the XML yourself  
and just do it. This would reduce your dependancies on other  
libraries. The ActiveMerchant integration for PayPal does this  
approach with DoExpressPayment, and it makes for a more simple  
solution.

[http://home.leetsoft.com/am](http://home.leetsoft.com/am)

To get the actual XML that is sent/received, you might try using the  
Java or PHP libraries.

## Let us know what you find, Joe

“For a new software system, the requirements will not be completely  
known until after the users have used it.” Humphrey’s Requirements  
Uncertainty Principle.
