Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stripe Connect and Multi-Shop Checkout #2682

Merged
merged 62 commits into from
Aug 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
b355e5e
Add new show/hideForShopTypes setting to the registry
spencern Jul 30, 2017
c76caa5
Add provides marketplaceMerchantSettings reactionApp
spencern Jul 31, 2017
c6c491b
update provides shopSettings loop to use template instead of name for…
spencern Jul 31, 2017
b394dec
add shopAppSwitch helper for showing plugin/app enable switch
spencern Jul 31, 2017
6a58318
Init merchant stripe connect settings
spencern Jul 31, 2017
3fdc173
Unify payments-stripe-connect and payments-stripe plugins
spencern Jul 31, 2017
c44a2a9
getPackageSettingsWithOptions method
spencern Jul 31, 2017
7440f93
WIP Stripe Connect Integration
spencern Jul 31, 2017
debcc25
Create new shops with account address if it exists
spencern Jul 31, 2017
274cdff
Guard shopType in reactionApps
spencern Jul 31, 2017
f9086bc
WIP - Authorize stripe connect. Save connect credentials on merchant'…
spencern Aug 1, 2017
5554816
Direct users to stripe dashboard to check earnings if they have alrea…
spencern Aug 1, 2017
a4600f2
Update Reaction.marketplace helper
spencern Aug 2, 2017
0d7b3c3
Update tax rate calculator to be multi-shop aware
spencern Aug 2, 2017
f7acd11
Update cart and cartItem schemas to support taxes on each item and ta…
spencern Aug 2, 2017
bce643e
add reaction-taxes to the default package list for merchant shops
spencern Aug 2, 2017
22380e6
Add marketplace needed cart transforms.
spencern Aug 2, 2017
d1a9487
Fixes for updated taxes methods.
spencern Aug 2, 2017
dec3b54
check if merchant's have a stripe account better
spencern Aug 2, 2017
87c9843
WIP Experimental stripe connect multi-payment method
spencern Aug 2, 2017
492d843
Check to make sure that we haven't authorized this merchant yet.
spencern Aug 3, 2017
b67bbb8
Successfully charge on behalf of a connected account
spencern Aug 3, 2017
ccf4b35
Merge commit 'b99eebc20b78dc335c883b185081aa1aa0457730' into spencer-…
spencern Aug 4, 2017
5b8fdda
Edits to make stripe marketplace method work from checkout
spencern Aug 7, 2017
614e160
Update stripe/createCharges to create a "Payment" object for each cha…
spencern Aug 8, 2017
d33915f
[WIP] use call createCharges from client
spencern Aug 8, 2017
22a27c9
Update getApiKey in stripeapi to use primaryShop's stripe acct
spencern Aug 8, 2017
d0263ca
update payments schema to store shopId
spencern Aug 8, 2017
351af20
[HACK] Don't check for refunds when sending order notifications
spencern Aug 8, 2017
7716f44
[WIP] Start working on figuring out stripe connect refunds
spencern Aug 8, 2017
6d3f73b
Cleanup
spencern Aug 8, 2017
ae2812c
Update cart/submitPayment to work with multiple payments
spencern Aug 8, 2017
459ddb1
Update stripe/createCharges to respect request to "authorize" instead…
spencern Aug 8, 2017
9a69e81
Place order with stripe/createCharges and handle order creation on se…
spencern Aug 8, 2017
5805ac2
Client side validation and confirm that all stripe client safe errors…
spencern Aug 8, 2017
81d4eab
Send `card_error`s back to the client, throw on all other errors. Per…
spencern Aug 8, 2017
db95b27
Updates to cart and stripe payment methods to support multi-payments …
spencern Aug 10, 2017
b60c6a0
Properly charge primary shop and permit order splitting between prima…
spencern Aug 11, 2017
352aecd
remove comments
spencern Aug 11, 2017
6f54bce
Make standard taxes work with stripe connect / marketplace checkout.
spencern Aug 15, 2017
3f1f300
enable all tests
spencern Aug 15, 2017
8074356
Demo application fee for stripe connect accounts
spencern Aug 15, 2017
b382ead
Fix issues in cart transforms
spencern Aug 15, 2017
3fb8697
Adjust packages publications so that we have primary shop routes avai…
spencern Aug 15, 2017
f377f59
Don't refresh active shop package publication if active shop is prima…
spencern Aug 15, 2017
4455928
Remove comments
spencern Aug 15, 2017
4715723
Merge branch 'marketplace' into spencer-stripe-connect-merchant-signup
spencern Aug 15, 2017
ba68a39
Merge branch 'marketplace' into spencer-stripe-connect-merchant-signup
spencern Aug 16, 2017
fdf72e1
Fix issue where order would fail if no taxes are enabled for any shop
spencern Aug 17, 2017
e3714db
Update error handling to follow Reaction convention
spencern Aug 18, 2017
9fe8877
Fix issue where shop not having tax data would cause checkout to fail
spencern Aug 18, 2017
7cd3118
Export stripe methods
spencern Aug 18, 2017
5eea68d
Initial tests for updated Stripe package that supports connect
spencern Aug 21, 2017
a948a18
Remove old lib stripe api that's no longer used
spencern Aug 21, 2017
a96f590
Add nock to package.json
spencern Aug 21, 2017
3f02534
Stub stripe package fetching for marketplace shops in stripe createCh…
spencern Aug 21, 2017
f6ca006
Fix stripe create charges test
spencern Aug 21, 2017
ee3a42c
Revert unfinished experimental updates to stripe/refunds/list
spencern Aug 21, 2017
9d697c2
export stripe connect methods
spencern Aug 21, 2017
c36d24e
Merge branch 'marketplace' into spencer-stripe-connect-merchant-signup
spencern Aug 21, 2017
696cb1e
cast invoice values to numbers before updating cart billing
spencern Aug 22, 2017
0e0f650
Merge branch 'marketplace' into spencer-stripe-connect-merchant-signup
brent-hoover Aug 22, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion client/modules/core/helpers/apps.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Template } from "meteor/templating";
import { Meteor } from "meteor/meteor";
import { Roles } from "meteor/alanning:roles";
import { Reaction } from "/client/api";
import { Packages } from "/lib/collections";
import { Packages, Shops } from "/lib/collections";


/**
Expand Down Expand Up @@ -49,6 +49,7 @@ export function Apps(optionHash) {
let key;
const reactionApps = [];
let options = {};
let shopType;

// allow for object or option.hash
if (optionHash) {
Expand All @@ -64,6 +65,13 @@ export function Apps(optionHash) {
options.shopId = Reaction.getShopId();
}

// Get the shop to determine shopType
const shop = Shops.findOne({ _id: options.shopId });
if (shop) {
shopType = shop.shopType;
}


// remove audience permissions for owner (still needed here for older/legacy calls)
if (Reaction.hasOwnerAccess() && options.audience) {
delete options.audience;
Expand Down Expand Up @@ -130,6 +138,20 @@ export function Apps(optionHash) {
delete itemFilter.audience;
}

// Check that shopType matches showForShopType if option is present
if (item.showForShopTypes &&
Array.isArray(item.showForShopTypes) &&
item.showForShopTypes.indexOf(shopType) === -1) {
return false;
}

// Check that shopType does not match hideForShopType if option is present
if (item.hideForShopTypes &&
Array.isArray(item.hideForShopTypes) &&
item.hideForShopTypes.indexOf(shopType) !== -1) {
return false;
}

return _.isMatch(item, itemFilter);
});

Expand Down
10 changes: 8 additions & 2 deletions client/modules/core/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@ export default {

init() {
Tracker.autorun(() => {
// marketplaceSettings come over on the PrimarySHopPackages subscription
// marketplaceSettings come over on the PrimaryShopPackages subscription
if (this.Subscriptions.PrimaryShopPackages.ready()) {
if (!this.marketplace._ready) {
const marketplacePkgSettings = this.getMarketplaceSettings();
if (marketplacePkgSettings && marketplacePkgSettings.public) {
marketplacePkgSettings._ready = true;
this.marketplace._ready = true;
this.marketplace = marketplacePkgSettings.public;
this.marketplace.enabled = true;
}
}
}
Expand Down Expand Up @@ -487,6 +488,11 @@ export default {
return Packages.findOne(query);
},

getPackageSettingsWithOptions(options) {
const query = options;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we set this variable to options and then just return it, do we actually need it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did that just to make it clear what the options object was, but we don't really need it.

return Packages.findOne(query);
},

allowGuestCheckout() {
let allowGuest = false;
const settings = this.getShopSettings();
Expand Down
19 changes: 10 additions & 9 deletions client/modules/core/subscriptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,14 @@ Subscriptions.PrimaryShop = Subscriptions.Manager.subscribe("PrimaryShop");
// Additional shop subscriptions
Subscriptions.MerchantShops = Subscriptions.Manager.subscribe("MerchantShops");

// Init Packages sub so we have a "ready" state
// This Packages subscription is used for the Active shop's packages
// // Init sub here so we have a "ready" state
Subscriptions.Packages = Subscriptions.Manager.subscribe("Packages");

// This packages subscription is used for the Primary Shop's packages
// The Packages publication defaults to returning the primaryShopId's packages,
// so this subscription shouldn't ever need to be changed
// TODO: Consider how to handle routes for several shops which are all active at once
Subscriptions.PrimaryShopPackages = Subscriptions.Manager.subscribe("Packages");

Subscriptions.Tags = Subscriptions.Manager.subscribe("Tags");
Expand Down Expand Up @@ -82,14 +88,9 @@ Tracker.autorun(() => {

Tracker.autorun(() => {
// Reload Packages sub if shopId changes
if (Reaction.getShopId()) {
// We have a persistent subscription to the primary shop's packages,
// so don't refresh sub if we're updating to primaryShopId sub
if (Reaction.getShopId() && Reaction.getShopId() !== Reaction.getPrimaryShopId()) {
Subscriptions.Packages = Subscriptions.Manager.subscribe("Packages", Reaction.getShopId());
}
});

Tracker.autorun(() => {
// Reload Packages sub if primaryShopId changes
if (Reaction.getPrimaryShopId()) {
Subscriptions.PrimaryShopPackages = Subscriptions.Manager.subscribe("Packages", Reaction.getPrimaryShopId());
}
});
3 changes: 3 additions & 0 deletions imports/plugins/core/checkout/client/methods/cart.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import { Cart } from "/lib/collections";
// Client Cart Methods
// Stubs with matching server methods.
Meteor.methods({
// Not used for stripe connect integration
// Under consideration for deprecation and migrating other payment Packages
// to payments-stripe style methods
"cart/submitPayment": function (paymentMethod) {
check(paymentMethod, Reaction.Schemas.PaymentMethod);
const checkoutCart = Cart.findOne({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,20 +114,22 @@
<div class="panel-heading panel-heading-flex">
<div class="panel-title">
<a
href="#collapsable-{{name}}"
aria-controls="collapsable-{{name}}"
href="#collapsable-{{template}}"
aria-controls="collapsable-{{template}}"
role="button"
data-toggle="collapse"
data-parent="#shopSettingsAccordian">
<i class="{{icon}}"></i>
<span data-i18n="{{i18nKeyLabel}}">{{label}}</span>
</a>
</div>
{{#if showAppSwitch}}
<div class="panel-controls">
<input class="checkbox-switch" type="checkbox" name="enabled" data-id={{packageId}} data-key="{{settingsKey}}" {{checked enabled}}>
</div>
{{/if}}
</div>
<div id="collapsable-{{name}}" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapsable-{{name}}">
<div id="collapsable-{{template}}" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapsable-{{template}}">
<div class="panel-body {{shown enabled}}">
{{> Template.dynamic template=template data=.}}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,15 @@ Template.shopSettings.helpers({
_id: Reaction.getShopId()
}).addressBook;
return address[0];
},
showAppSwitch() {
if (Reaction.getMarketplaceSettings()) {
// if marketplace is enabled, only the primary shop can switch apps on and off.
return Reaction.getShopId() === Reaction.getPrimaryShopId();
}

// If marketplace is disabled, every shop can switch apps
return true;
}
});

Expand Down
Loading