Problem

Handling payments to each store after the buyer has paid the total order amount to the website.
For each Marketplace order there are multiple per-store orders. The buyer can interact with the top-level Marketplace Order (which contains products from all stores), while each store sees it's one Store order (which contains products from the store). The buyer pays for all of the products from all stores at once. We need to come up with a solution for paying stores.

Proposed solutions

PayPal Delayed Chained Payment Method

We will need a new commerce payment method for PayPal Chained Payments (PayPal Adaptive payments).
More information:
https://www.x.com/developers/paypal/documentation-tools/adaptive-payment...

API Reference:
https://developer.paypal.com/webapps/developer/docs/classic/api/#ap

Pros

  • Handling payments gets easier - no credit management system is required in Drupal.
  • Easier to implement.

Cons

  • Chained payment method allows up to 5 parallel receivers in each transaction, so we will have problem with orders that have products from more than 5 stores in them.
  • PayPal takes fees off each payment to each store. If the marketplace plans to take fees too, the total amount of the fees gets large.
  • Buyers will be forced to use PayPal for their payments

Funds management system for marketplace stores

Fork commerce_funds and make it work with store entities.
Pros

  • More flexible and IMHO more elegant way for handling payments
  • It's more clear to the store owners what's happening, they'll be able to get their transaction history on the marketplace website.
  • The marketplace will be able to use any payment method to allow buyers pay for the products

Cons

  • Difficult and time consuming to implement
  • Maybe it's better if we don't treat Drupal as a bank - It's hard to make sure that everything is secure.

Let me know if you have any other ideas for handling the payments. Also, let me know your opinion about these two proposed solutions.

Comments

spchris’s picture

Check out WePay. People can create accounts attached to a larger marketplace allowing marketplace sites to send payments directly into the seller's subaccounts. They also allow the main account to take a percentage of each sale automatically.

The API seems to be much cleaner than PayPal's.

https://www.wepay.com/developer/platform/

farhadhf’s picture

@sp_chris, Thanks, but WePay doesn't work for our usecase. In this marketplace module, the customer adds products from different stores to her cart and then pays the cart total in one transaction. PayPal Chained Payment works, because it allows us to split and send the money paid by the customer to multiple destination accounts.
For example the customer has added products from store A, store B, and store C to her cart (totaling $100). She pays $100 in one transaction using PayPal Chained Payments, Marketplace gets $5, $30 goes to store A's PayPal account, $30 goes to store B's account and $35 goes to store C's account.

I couldn't find anything related to this kind of parallel payments in WePay's documents.

spchris’s picture

It supports it. You send each order to the WePay checkout/create API to create separate checkout ID's for each store and then send the customer to WePay to complete checkout for all of them as one transaction. There is also an API function to send a fee to the parent account (the site owner) automatically, removing the requirement for billing if the site needs this option.

This guy: http://www.alanpinnt.com/category/wepay/ has made several WePay plugins and may be of assistance. Personally I would like to see Paypal and WePay supported as I think only supporting one payment processor, especially PayPal, is a major risk to the site owner and merchants considering Paypal's history with locking funds.

--- EMAIL FROM WEPAY FOLLOWS ---

Dominic (WePay Support)

May 01 10:13 am (PDT)

Hi Christopher,

To answer your question, this is achievable with our API. You would need to create WePay accounts for your vendors to receive their portion of the funds. In your example, you would need to execute three separate checkouts on the back end using the /checkout/create call. This ensures your users will only need to enter their information once for the checkout.

Please let me know if you have further questions.

Best,
Dominic

ChristopherFriend

ChristopherFriend

May 01 06:53 am (PDT)

Hi,

I wanted to know if there is a way to send payments to multiple accounts
at once in the API.

An example:

1) User goes to an Etsy type marketplace and adds 3 products from three
different vendors into the cart
2) User goes through checkout and selects Wepay as the payment option
3) User pays, money for each cart goes into the merchant's Wepay account

Thanks,
Chris

Liliplanet’s picture

Wepay looks fabulous and love the clean interface. The major problem is that only US citizens can receive payments.

Paypal will be the more internationally viable option for our community.

spchris’s picture

I think we need to explore every payment method possible. I'm going to see if I can implement a Drupal Commerce Wepay plugin and then modify it to interface with the marketplace addon. I managed to make one for Prestashop, I just need to see if I still have the code floating around.

farhadhf’s picture

@chris, Thanks, That would be great!
I agree that we need to have more than one solution for the payments. I'll start working on the PayPal payment method tonight.

markwk’s picture

Amazing work. Just caught up with this issue and examined the demo and code structure. Great stuff.

From working on a marketplace project, my advice would be to implement a "funds structure" and then connect it to PayBack order method.

The advantage of this approach is that when people buy stuff from individual stores, we credit the stores themselves. Subsequently you can generate payback orders to then balance what was owed for what was bought. It also gives us a few stages to deduce any marketplace fees, coupons, etc.

farhadhf’s picture

Just found this: http://www.mangopay.com/features/for-marketplaces/

Seems like a good solution for marketplace payments. Any opinions?

@markwk, yes, I agree that it's more flexible (and probably better) approach, but it takes a lot of time and energy to develop... I don't have enough time to start working on it :(

Anonymous’s picture

I like the look of Mangopay - I haven't spotted that one before. Am signing up for a trial to see what it's like.

There's also Balanced Payments https://www.balancedpayments.com, but they are no good for me as US-only.

I've been looking at Stripe Connect as a possible solution - the store would need to register as a Stripe app, and each seller would need a connected stripe account but it looks quite a neat way of doing things. https://stripe.com/docs/connect#payments

stopshinal’s picture

I've been looking at Dwolla - and if you haven't checked it out yet you really should. It's getting incredible traction in the non-credit card world. Also - a new 16 million dollar investment may secure their place in the future world of non ACH payments.

It also provides a facilitator fee, so payments could be made directly to a store (without any need for escrow or a dwolla esque bank - everything is done within Drupal).

I know this isn't the credit card solution everyone is after - but Dwolla is rapidly expanding their API (and has some interesting user-creation calls) that I think will help lower the bar for entry.

At the end of the day - if you have a niche marketplace where users dont mind registering - this could be perfect. I specifically like their guest-checkout with the ability to pay without an account using your routing & account number.

ALSO the transaction fees are the best on the web. 25 cents if > 10$, free if under 10$.

markwk’s picture

My guess is that all of these payment methods could be made to work, but I doubt you'll satisfy anyone by establishing a hard requirement on a vendor-specific payment method. If one or two of you have a client willing to contribute some of the work back on drupal.org, then perhaps you can choose one option that works best for you and build it together. This approach will let you establish whatever additional payment code/api you'll need in a commerce marketplace and still focus on getting an end solution.

Admittedly, tough stuff though, especially once you *throw in* international requirements. Personally, I'd recommend Stripe...

farhadhf’s picture

Good news! I got a project to work on a commerce marketplace website. The client needs an on-site funds management system and he agreed to let me use the code in this module. So, we will have at least one solution for the payments in the next few weeks :)

stopshinal’s picture

That is wonderful! I have a few on the books for August - so perhaps we can tackle a few more then.

septianw’s picture

Just an idea from me.
Scenario 1 : How if there's an option to pay through deposit. just like a voucher, seller and buyer buy deposit or voucher from marketplace, and they using it to transaction on marketplace.

Scenario 2 : marketplace as a payment gateway. when buyer buy some goods to seller on marketplace they send the money to marketplace. Marketplace send confirmation to seller that buyer have been pay the bill so let the seller send the goods. buyer need to confirm that the goods was arrived so let the marketplace send the payment to seller.

farhadhf’s picture

@septianw, Scenario 1 will be possible after I've finished working on the funds management system. I'm not completely sure what you meant by Scenaria 2, but buyer confirmation for releasing payments is on my todo list.

pinkonomy’s picture

I am not sure if what I will say is out of scope,but keep an eye on this:
As we are interested in a marketplace,where everyone can have a different way of sending/accepting payments,it would be great if there was a universal way of payment.
This is what Mozilla is working on with the Web payments API.
Also,there is this company https://meritora.com/ which we can keep an eye on. http://cardnews.drupalgardens.com/content/new-payments-company-meritora
In this article,I can read about the Dwola company .
I hope the above make sense.
thanks

farhadhf’s picture

Just pushed the first version of the funds management module to Git. It's not yet complete, but it has the basic structure, Account and Transaction entities and an incomplete withdrawal submodule.
Account entity type has 2 bundles by default: user and commerce_store (yep, bundle name is the same as the entity type which owns the funds account)
Transaction has 3 bundles by default: Payment (for payments using a commerce payment method which will be developed later) , Transfer (for transfering funds between two funds accounts) and Deposit (for depositing funds from a bank or paypal into the funds account).

Withdraw module provides two entity types: Withdrawal Method and Withdraw Request. You will be able to create new Withdrawal Method bundles with whatever fields you want, the user will be able to create new one Withdrawal Method entity instance per bundle for configuring the methods. Then she'll be able to create Withdraw requests and select a withdrawal method of her choice for that request.
The withdraw module also creates a "Withdraw" Transaction bundle which is used to save the funds withdrawal transactions.

The funds account and transaction management module (commerce_marketplace_funds) is almost complete. Withdraw module (commerce_marketplace_funds_withdraw) just has a hook_schema() implemented.

Any help would be much appreciated - patches and ideas are welcome!

farhadhf’s picture

The commerce_marketplace_funds sub-module is ready! It should work fine, but I haven't done complete testing yet (Please test it and let me know the problems!). BTW, the code structure isn't great, it could probably be packaged in 3 separate modules, but for now, I'd like to have something working, we can fix the code structure later.

I haven't implemented withdrawal functionality yet. Deposit functionality is there, but the required rules are not created, you can do it yourself easily. Funds transfer functionality works, and there's a rule for creating Funds payments to store owners when someone buys something from their store. Also, the funds account feature is really flexible, any entity type can have a funds account associated with it (e.g nodes/taxonomy terms/whatever can have a funds account - so, for example, one can create a product display node for fundraising for an event , and associate a funds account with that node. Then she just has to create a bunch of rules to make it credit the node's funds account whenever someone pays for the product reference in that node! Go create a Drupal version of Kickstarter! :D)

pinkonomy’s picture

Thanks!!

robotjox’s picture

This looks great.
Could you perhaps provide a few steps on how to test this? I can see the store funds accounts on every shop but I am unable to get funds transfered to them.
Which rule should I edit?
Most importantly: When someone buys from several shops, how do I make sure that only the funds belonging to the right shop gets transfered to that shop and not the complete order total?

robotjox’s picture

oh, to answer my first question, the rule is of course "Make payments to stores", but I haven't been able to get it working just yet.

edit: this log entry may provide a hint: "Unable to get variable store_orders, it is not defined."

farhadhf’s picture

OK, there were a few problems with the deposit process. It's fixed now. Please test it! Clear the caches after updating the module code, if it still doesn't work, disable commerce_marketplace_funds and enable it again. If you still had problems with it, create a new issue and I'll look into it!

Thanks!

b3nji’s picture

This is great! Question: Are you planning to implement the PayPal Delayed Chained Payment Method as well? From a security perspective, I think the paypal method has some advantages over the funds transfer method.

riverole’s picture

Hello!

I have this module installed and I'm trying to get it working but I'm afraid I really don't understand exactly how it works. For the moment, I have created stores related to users, and have created products by these users (stores). I realized that when I create a new store, it's created a new account fund for the store. When I buy a product from this store (using a fake payment) I see that the counter of this fund is automatically increased with the value of the product. This is great, but I still don't understand where the payment is done to the store itself. I mean, how this funds are really transferred to a store's bank account? It's going to be automatic? If so, which method is going to be used to do this payments? Or maybe with the withdrawal funds the store will be able to withdraw these funds manually?

Thanks for all and sorry for being so dumb! :P

farhadhf’s picture

@riverole, no, It's not going to be automatic (at least not at this point). The commerce_marketplace_funds module contains an empty sub-module for handling withdrawal methods and requests, but it's not developed yet.
The module will introduce two new entity types: "Withdrawal method" and "Withdraw request". "Withdrawal method" bundles are created by the site administrator, while the actual "Withdrawal method" entity are created by the stores/users. So, "Funds account" owners will be able to create withdrawal method instances for configuring the methods (e.g. specifying their paypal account address, bitcoin address, bank account information, etc). Then they'll be able to create withdraw request and select one of the methods that they have configured. The requests should be handled by the site administrator(s), but I'm gonna provide an API to allow others develop modules for automating the withdrawal request handling process.

farhadhf’s picture

You can now take fees from funds (deposit, transfer and payment) transactions.
The fee value is configured via Rules, You can take a percentage or a flat rate. Fees are implemented using a new price component type which is added to the transaction amount by using "Apply fees to funds transaction" Rules action (the fee component amount is negative). I've broken the previously defined Rules action "Create a new Funds Transaction" into 3 new smaller actions to make this work and removed "Make deposit to funds account" action. Now, the actions don't save of the funds account and transaction entities themselves, you have to use "Save entity" Rules action to do that (See the rules mentioned below for an example).

Do a pull, clear the caches and revert "Create funds payment transaction for store order" component and "Complete deposit process" rule.

I just finished writing the code, I have not tested this yet!
Please test it and let me know if you see any problems!

Thanks!

giorgio79’s picture

nyleve101’s picture

Hello,

I have been looking at the following for possible payment solutions:

Balanced Payments- US, Canada and UK
Braintree Payments- US, Canada, Australia and Europe

@farhadhf would sponsorship of development for either of these payment methods be possible? Preferably Braintree so that more users can use it.

Please let me know.

Thanks,

Ev

farhadhf’s picture

Thanks to nyleve101 I'll be working on MangoPay integration starting next week.
Commerce Marketplace Funds management already works if you're OK with saving the funds account balance on Drupal database.

amittarkar’s picture

as described in this link, https://drupal.org/project/adaptive_payments, is following example possible?
Example: On a market place site, sender makes a payment for a product, Site owner (primary receiver) gets 10% and the balance is send to the stall owner. Or, as with the children party example above, the primary receiver can be the event organiser.
I mean is it possible for a site owner to set percentage for all seller accounts? I need this for commerce auction.

farhadhf’s picture

@amittarkar Yes, it is possible, but you'll need to write some custom code for integrating adaptive_payments with Commerce Marketplace.

amittarkar’s picture

Is that functionality of adaptive_payments is implemented over here? https://github.com/amitaibu/commerce-paypal-chained/blob/7.x-1.x/it

farhadhf’s picture

I've read commerce_paypal_chained's code before, and I've written a PayPal Chained Payment method for Commerce Payback. It is totally possible to use PayPal (delayed) Chained Payments for Commerce Marketplace, but I don't have the time to work on it right now. I'm making some architectural changes in Commerce Marketplace Funds module to make it possible to use it with different payment processors instead of just saving funds information in Drupal database. I will eventually write integration code for PayPal and Commerce Marketplace, but it won't be soon.

sketman’s picture

We are also building marketplace. We dont use this Farhadhf´s solution, but we are facing the problem of payments too.
Finally we decided to use Paypal Adaptive Payments - Parallel payments.

After having it almost finished and after having done a lot of tests, here are some my observations:

There are some caveats for sellers with Paypal´s requirements. These are mainly following:
- must have Paypal account
- account must be verified
- in order to being able using it effectively, requirement to upgrade it to Business type of account, otherwise there are limits for amounts processed.

For example we discovered, that if seller´s Paypal account hasnt been verified, Paypal wont allow to pay for order of that seller by credit card. After redirecting to Paypal payment page, you get displayed only option to pay by Paypal account or to create new Paypal account. No option, or form, for payment by credit cards. This is even worst, because if buyer has in his shopping cart items of 5 different sellers, this disables the payment by credit card for entire order, for products of all 5 sellers. Only because one of sellers dont have his Paypal account verified.
So now we are working on solution, that we will check if Paypal account email address entered by seller is verified or not. If not, some actions will be taken, we havent this decided yet.

So, if you are looking for easy and lightweight solution, enabling your sellers to start selling at your marketplace quickly, Paypal is not the way unfortunately.

The above is probably the biggest problem with Paypal from my point of view. Then, as Farhadhf mentioned in his first post, Paypal is expensive. I think it really is. But this is also very subjective, depending on focus of your marketplace. Fortunately, this is not that big issue for us, because we are not taking commisions at our marketplace.

Besides the above, the rest of experience is rather positive. It is a robust, reliable and it all works as expected. We found, that Paypal will process you payment for more that declared limit of 5 sellers. But we will not relly on this and we have limited the maximum sellers in shopping cart/order for 5.:)

Hope this helps.

farhadhf’s picture

@sketman Thanks for the insight! I'll absolutely take your comment into consideration for deciding whether to implement PayPal support or not (which is not implementing right now - PayPal is simply too expensive, and the limit 5 sellers will introduces some special cases that are difficult to handle with the current architecture!).

But for now:
We have MangoPay integration! Take a look: https://drupal.org/sandbox/farhadhf/2072127
It's fully functional, although not completely stable yet, and the code is not as clean as I would want, but it's getting better everyday! Please test it and let me know what you think, and report any bugs that you find on it's issue queue.

Thanks!

amittarkar’s picture

Dear farhadhf,
I read your post about 'Commerce Payback' so I followed the instructions at https://drupal.org/sandbox/farhadhf/1588182. but as per one instruction i couldn't find PayPal Adaptive Payments NVP SDK at
https://www.x.com/sites/default/files/PayPal_Platform_PHP_Nvp_SDK_0.zip link also please give me the exact link for 'commerce_paypal_simple module'. Please also let me know if there are any other alternatives for paypal delayed chain method, especially If there are two sellers i.e. the store owner and the site owner. I am very new to drupal but I shall take efforts to integrate paypal with your commerce marketplace if required.

farhadhf’s picture

@amittarkar, Please create an issue on the Commerce Payback issue queue :)

farhadhf’s picture

Issue summary: View changes

Fixed HTML error.

amittarkar’s picture

Dear farhadhf,
You have written a module for mangopay to handle store payments, but mangopay is available only for companies registered in europe. So Do you have other solutions available to use this module?

amittarkar’s picture

Dear farhadhf,
whenever you have time, please integrate paypal delayed chain with this marketplace for beginners like me.

shabirahmad’s picture

Hello All,

I have read all the documents, It was quite helpful. I have downloaded the module marketplace, I know it is not completed yet but still I would like to give it a go. There is no readme file attached can some one explain how it works?
PS: I am using market place with paypal adaptive methods, Is this possible with this module or with any other. Please suggests

Thanks

shabirahmad’s picture

Hello Farhad,

I would like to set up a simple market place along with adaptive paypal method. I have installed marketplace set of modules and cloned the sandbox module commerce_payback.
I am still not getting the flow. Can you guide me.

Thanks

kevinquillen’s picture

New to the thread, I posted this in Commerce Funds originally..

Basically, what I want to do is keep a separate container of money per user to act as a user balance / store credit.. ex., user receives part of an order that is bad, the store grants them credit back - I want it to be based on real money, like a 'credit order' with a credit line item. This drops into their user balance, and any new order has the credits applied before final payment is calculated. This flow basically is predicated on me treating my stores orders as invoices, which they basically are, and I wind up with a very accountable system.

It doesn't matter if all the automation isn't quite there, I just need the capability to store things properly, I can code the Rules and actions to get the business logic I am after.

So for me, I am not treating Drupal like a bank per-se, I am keeping a running customer balance that is not explicably linked to orders. The user never deposits funds, the application will automatically (based on some conditions) and then the system uses funds for them automatically on any following orders.

pinkonomy’s picture

Is there any thought/roadmap to using Paypal for payments?

glass.dimly’s picture

Version: » 7.x-1.0-beta2

I'm looking to build a US-based payment system. Unfortunately, MangoPay can't help me in that regard.

What's the progress or holdups on integrating Paypal Delay Chained payments? Anybody have any code or anything? Doesn't matter if it's ugly.

For me, I don't really have a need to do two different accounts per shopping cart. I could force each person to add only items from a single store.

Any solution like for that use-case?

I looked at Pay Leap http://www.payleap.com and they charge $19.95 per month per account, and also each payment to each account would incur a 29 cent fee on top of the 1.89-2.89% percentage. So it'd be us sending in separate transactions to them. Yuck.

Another thing that's important to me is being able to use a credit-card reader. Doesn't seem like there's a way to do this with Drupal Services or anything, huh? Using Drupal Services would mean it'd just populate the cart form with the proper information rather than dealing with the merchant. Anybody seen anything?

glass.dimly’s picture

Hey there folks,

Looks like there's an old D6 module that serves as an API for Paypal Chained Payments: https://drupal.org/project/adaptive_payments

Anybody know anything about it? I'm about to dig in. At a minimum some of the functions will be useful.

Peace,
Jeremy (glass.dimly)

amittarkar’s picture

@glass.dimly there is a separate issue for this regard https://drupal.org/node/2184455

glass.dimly’s picture

Note, for those interested in Stripe Connect integration, a separate issue exists here: https://drupal.org/node/2138171

shamil.f’s picture

@farhadhf, could you please inform us about the following:

1. What is the status of

"I'm making some architectural changes in Commerce Marketplace Funds module to make it possible to use it with different payment processors instead of just saving funds information in Drupal database"

? How can I install processors for marketplace funds?

2. My main question is, and I think everybody here would like to know, is there any working way to handle store payments right now apart from MangoPay? (since it works only for EU based companies).

3. How to setup marketplace funds and make it work in a real world website? Is it possible?

Thanks

amittarkar’s picture

If Chained payment method allows up to 5 parallel receivers in each transaction, Does mangopay handles more than 5 receiver? and what are the other advantages of mangpay over paypal chain method If any?

amittarkar’s picture

has anyone tried to integrate 'paypal masspay' with this module as over here 'https://www.drupal.org/node/326102' or over here 'https://www.drupal.org/project/mp_wallet'

kevinquillen’s picture

I am not sure if this is the appropriate thread, but are there methods to offload payments from orders to payments from customers? Like, a customer balance - abstracting what someone owes on an order, to what someone owes overall to the business.

pinkonomy’s picture

This sites ,which uses Drupal Ubercart marketplace,uses Paypal adaptive payments. http://www.cargoh.com/
Is this of any help?
thanks

pinkonomy’s picture

Could be also included Bitcoin as a payment method?E.g. using these modules https://www.drupal.org/project/cointools and https://www.drupal.org/project/commerce_bitcoin
thanks

ed523’s picture

I too would like to give sellers the option of accepting bitcoin but it doesn't seem like this is to the point where it can accept traditional central bank currencies. I'm a little confused as to whether or not Commerce Marketplace Funds management works or how it works with no payment gateways, not counting the for dev only mangopay sandbox project. If it's a matter of money perhaps we could talk about crowdfunding these developers? I guess it would need to be known how much was needed.

pinkonomy’s picture

Hi,
how Commerce marketplace could handle "Cash on delivery" for site owners?
Perhaps take a percentage of the product after using the Cash on delivery method?
If anyone has done this please post this here,thanks

Londova’s picture

Hi,
I have the same questions as @shamil.f in post #48.
- How can I install processors for marketplace funds?
- How to setup marketplace funds and make it work in a real world website?

@farhadhf, there were no any comment for more than 1 year.
I am VERY disappointed how Drupal team provides support and description for modules.
I spend 1 year searching the right solution for my problem, I contacted several times @farhadhf directly for a paid support. No any feed-back so far. I think Drupal is not the right platform for me.
VERY, VERY disappointed !!!

ed523’s picture

Drupal being open source and decentralized he may have made this module on his own and abandoned it when he found something that paid better (or at all). I ended up going with ubercart marketplace which works for d7 despite that version being in dev. the developer no longer does freelance but he will answer questions if you contact him directly. I don't know if it will work for your project. This developer should have noted on the page that this project was no longer in active development or supported if he intended to abandon it. Hopefully it's not a situation where he was unable to.