Because this would introduce
needless complications in the example code, I don??™t show the code for how to do this. In any case, all
stores have their own needs for this functionality, so you??™ll have to let your own demands decide which system
to choose.
In a regular Rails application, you??™d probably use one of the several libraries for handling payments that
exist for Ruby. One of the best is called Active Merchant, which according to its web site supports many gateways
for payment systems of all different kinds.Work is also going on to tie it into various shipping gateways,
such as FedEx, USPS, UPS, and Canada Post. By using something like this, you can offer much of the functionality
needed for a shop, without needing to implement much of the structures behind.
Of course, because we??™re talking about JRuby on Rails, all the APIs that are published for handling payments
through Java will work fine for such a solution. In fact, you can probably count on the provider of the
service to already have a way of handling requests from Java clients. In this case, you??™re home free. Integrating
the Java library through JRuby is almost always easy. You can also wrap the code in a Ruby class that
makes the API less cumbersome. This is often interesting, because most payment APIs in Java use XML at
one point or another.
A new Java Specification Request (JSR) is underway as I write this. It??™s JSR 182, and it??™s called JPay. Its
purpose is to allow open source implementations of payment gateways to provide the resources underneath
while still going through an open and standardized API.
Pages:
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170