unacms / una

UNA Community Management System
https://unacms.com
MIT License
265 stars 153 forks source link

Payments: single transaction mode for multiple purchases from different vendors #2992

Closed AlexTr closed 3 years ago

AlexTr commented 4 years ago

Add setting in payment module to enable "single transaction mode for multiple purchases from different vendors" (or it maybe it's better to implement it as separate Payment module instead of setting in existing module).

It has many benefits:

In this mode we need to pass vendor ID for every purchased product, so we'll be able to track whom item is sold. When vendor's product is purchases, vendor receives credits according to specified credits conversion rate. Later vendor can exchange received credits to real money using different exchange rate or using the same rate but with some commission deducted.

Master user payment tools need to be updated to include sub-vendor ID field. Vendors payment tools will have limited functionality in this mode, most tools should be read-only, however variant where vendor adds transaction without affecting any balance can be also considered.

Some things to take into account:

AntonLV commented 4 years ago

It would be better to update currently available Payments app that it can be used in two modes:

  1. Multi-shopping carts (currently available).
  2. Single shopping cart.

Some things to take into account:

  1. The very first version can be created without Credits' based payouts to vendors. Site owner can organize the payouts manually or so.
  2. In 'single transaction mode' we cannot use Stripe and/or ChargeBee because they require to create plans (products) on their end. So, we need to: 2.1. Develop our own 'Time Tracking' mechanism which will track subscriptions and initialize payments when it's needed. 2.2. Update Credits to allow subscription payments which will use newly developed 'Time Tracking' mechanism. 2.3. Integrate PayPal subscriptions and PayPal Mass Payments. Read more about up to date PayPal API here: https://developer.paypal.com/docs/checkout/integrate/
AntonLV commented 3 years ago

Execute during the next update:

ALTER TABLE `bx_payment_subscriptions` ADD `status` varchar(32) NOT NULL default 'unpaid';
UPDATE `bx_payment_subscriptions` SET `status`='active' WHERE `paid` <> 0;
ALTER TABLE `bx_payment_subscriptions` DROP `paid`;
ALTER TABLE `bx_payment_subscriptions_deleted` ADD `status` varchar(32) NOT NULL default 'unpaid';
UPDATE `bx_payment_subscriptions_deleted` SET `status`='active' WHERE `paid` <> 0;
ALTER TABLE `bx_payment_subscriptions_deleted` DROP `paid`;