Shopping Cart API for any payment gateway? (PayPal at least required)

Brad Parks picture Brad Parks · Apr 25, 2012 · Viewed 7.2k times · Source

I'm trying to find a java based API that wraps up the details of processing a credit card transaction or purchase via PayPal at a minimum, and other gateways as a plus in an IPN fashion (ie no products required, just an invoice amount)

As a bit of a simplification, I think I should be able to do something like the following pseudocode:

shoppingApi.postTransaction("paypal", amount, currency, invoiceId, purchaseDescription)

and later on during a scheduled task or on notification from an IPN url:

completedPayments = shoppingApi.getUnprocessedCompletedPayments();
for (Payment payment: completedPayments)
{
  // my code to process a successful payment.
}

and then I'd process the purchases.

I know there's tons of shopping carts out there that do this, but from what I've seen, they all want you to put your products in their system, which doesn't work for me. My products are in a 3rd party system, and I just want to process a payment. That's all.

And no cart I know of exposes a simple API like the one I'm suggesting above. I don't care what payment type my users use, I just want to know if they completed it. I know that Shopify.com has a REST api that does something like this, but it's not IPN like (it wants your products in it's system).

Thanks in advance for any suggestions!

EDIT: I know of course that there'd be other statuses that I'd need to look at, like "pending", etc, but that'd simply be another simple API call, like shoppingApi.getPendingPayments(). If the API did the above 2 calls, I'd be pretty happy ;-)

EDIT 2: I'd prefer opensource, but am totally open to commercial if it's a flat fee, can be trialed to some extent, and is reasonably mature/respectable

EDIT 3 - MAJOR NOTE: I feel confident that such a library should exist. Whether or not it does is another question. So to be clear, I'd really like to see "yes, use this library" answers, not "NO", this can't be done, as I'm %99.999 sure it can be done ;-) Thanks in advance!

Answer

GingerHead picture GingerHead · May 3, 2012

I would say it's better to write your own api, because anything related to payment and purchase processes will cost you money to get. You need the following for your app to accomplish:

  1. You need a server that will communicate with PayPal (or DataTrans or any other payment systems)
  2. You need a database to capture all the payments transferred:

    • That have been settled
    • That have been payed but the settlement is not received yet
    • That still need to be payed
    • Installments done, finished, or yet to be done
  3. The server needs to be any web app (spring with hibernate etc) that has some security (acegi, spring)

  4. Every-time a user logs in and starts purchasing online you need to do a call to PayPal and get the response in a callback to the browser of the user
  5. Every time you have a settlement you save the needed data in the DB like user-id purchase-method owner card-number invoice-id PayPal -token

I hope this helps