-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2167 from reactioncommerce/spencer-799-marketplac…
…e-stripe-connect [Marketplace] Spencer 799 marketplace stripe connect
- Loading branch information
Showing
58 changed files
with
1,009 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -347,3 +347,11 @@ | |
right: 0px; | ||
} | ||
} | ||
|
||
.product-grid-badges { | ||
.badge { | ||
position: absolute; | ||
top: 0px; | ||
right: 0px; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
...ded/marketplace/client/templates/stripeConnectSignupButton/stripeConnectSignupButton.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<template name="stripeConnectSignupButton"> | ||
<button | ||
class="btn {{classes}}" | ||
data-event-category="marketplace" | ||
data-event-action="button-click-stripe-signup" | ||
data-event-label="Stripe Connect Signup button click" | ||
data-event-value="clicked" | ||
data-i18n="marketplace.stripeConnectSignup">Start Accepting Payments</button> | ||
</template> |
47 changes: 47 additions & 0 deletions
47
...luded/marketplace/client/templates/stripeConnectSignupButton/stripeConnectSignupButton.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { Meteor } from "meteor/meteor"; | ||
import { Reaction } from "/lib/api"; | ||
|
||
// TODO: This button should be a React component. | ||
|
||
Template.stripeConnectSignupButton.onCreated(function () { | ||
this.autorun(() => { | ||
// TODO: this should probably be managed by a subscription? | ||
// Seems inefficient to do it at the button component level | ||
Meteor.subscribe("SellerShops"); | ||
}); | ||
}); | ||
|
||
// Button | ||
Template.stripeConnectSignupButton.helpers({ | ||
/** | ||
* Give it a size and style | ||
* @return {String} The classes | ||
*/ | ||
classes() { | ||
const classes = [ | ||
(this.type || "btn-info"), | ||
(this.size || "") | ||
]; | ||
|
||
return classes.join(" "); | ||
} | ||
}); | ||
|
||
Template.stripeConnectSignupButton.events({ | ||
"click [data-event-action='button-click-stripe-signup']": function () { | ||
const sellerShop = Reaction.getSellerShop(); | ||
|
||
const email = sellerShop.emails[0].address; | ||
const country = sellerShop.addressBook[0].country; | ||
const phoneNumber = sellerShop.addressBook[0].phone; | ||
const businessName = sellerShop.addressBook[0].company; | ||
const streetAddress = sellerShop.addressBook[0].address1; | ||
const city = sellerShop.addressBook[0].city; | ||
const state = sellerShop.addressBook[0].state; | ||
const zip = sellerShop.addressBook[0].postal; | ||
|
||
const autofillParams = `&stripe_user[email]=${email}&stripe_user[country]=${country}&stripe_user[phone_number]=${phoneNumber}&stripe_user[business_name]=${businessName}&stripe_user[street_address]=${streetAddress}&stripe_user[city]=${city}&stripe_user[state]=${state}&stripe_user[zip]=${zip}`; // eslint-disable-line max-len | ||
// TODO: Should client_id be hardcoded in here? | ||
window.location.href = "https://connect.stripe.com/oauth/authorize?response_type=code&client_id=ca_32D88BD1qLklliziD7gYQvctJIhWBSQ7&scope=read_write" + autofillParams; | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
imports/plugins/included/payments-stripe-connect/client/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import "./settings/settings"; |
65 changes: 65 additions & 0 deletions
65
imports/plugins/included/payments-stripe-connect/client/settings/settings.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<template name="stripeConnectSettings"> | ||
{{#unless packageData.settings.api_key}} | ||
<div class="alert alert-info"> | ||
<span data-i18n="admin.paymentSettings.stripeConnectSettingsDescription">Don't have a Stripe Connect API Client ID?</span> | ||
<a href="https://dashboard.stripe.com/account/apikeys" target="_blank"> | ||
<span data-i18n="admin.paymentSettings.stripeConnectSettingsGetItHere">Get it here.</span> | ||
</a> | ||
</div> | ||
{{/unless}} | ||
<div> | ||
{{#autoForm collection=Collections.Packages schema=StripeConnectPackageConfig doc=packageData type="update" id="stripe-connect-update-form"}} | ||
{{>afQuickField name='settings.api_key'}} | ||
{{>afQuickField name='settings.transactionFee.enabled'}} | ||
{{>afQuickField name='settings.transactionFee.percentage'}} | ||
<button type="submit" class="btn btn-primary pull-right"><span data-i18n="app.saveChanges">Save Changes</span></button> | ||
{{/autoForm}} | ||
</div> | ||
|
||
</template> | ||
|
||
|
||
<template name="stripeConnect"> | ||
<div class="container-fluid-sm flex"> | ||
<div class="flex-item"> | ||
<div class="panel panel-default"> | ||
<div class="panel-heading"> | ||
<div class="panel-title">Stripe Connect Checkout</div> | ||
</div> | ||
<div class="list-group"> | ||
<div class="list-group-item"> | ||
{{#if packageData.settings.api_key}} | ||
<span>API Client ID: <button type="button" class="btn btn-link" data-event-action="showStripeConnectSettings">**********</button></span> | ||
{{else}} | ||
<span>API Client ID: <button type="button" class="btn btn-link" data-event-action="showStripeConnectSettings">Configure Now</button></span> | ||
{{/if}} | ||
</div> | ||
</div> | ||
<div class="panel-footer"> | ||
<div class="left"></div> | ||
<div class="right"> | ||
|
||
<div class="panel-footer-item"> | ||
{{#if packageData.settings.api_key}} | ||
<i class="fa fa-check-circle fa-2x text-success"></i> | ||
{{else}} | ||
<i class="fa fa-minus-circle fa-2x text-muted"></i> | ||
{{/if}} | ||
</div> | ||
|
||
<div class="panel-footer-item"> | ||
<button class="btn btn-default" data-event-action="showStripeConnectSettings"> | ||
<i class="fa fa-gear"></i> | ||
</button> | ||
</div> | ||
|
||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<template name="stripeConnectRedirect"> | ||
<span data-i18n=“admin.redirect.stripeConnectWaitingNote>Will auto redirect in a couple seconds or click here.</span> | ||
</template> |
43 changes: 43 additions & 0 deletions
43
imports/plugins/included/payments-stripe-connect/client/settings/settings.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { Template } from "meteor/templating"; | ||
import { Reaction, i18next, Router } from "/client/api"; | ||
import { Packages } from "/lib/collections"; | ||
import { StripeConnectPackageConfig } from "../../lib/collections/schemas"; | ||
|
||
import "./settings.html"; | ||
|
||
Template.stripeConnectSettings.helpers({ | ||
StripeConnectPackageConfig() { | ||
return StripeConnectPackageConfig; | ||
}, | ||
packageData() { | ||
return Packages.findOne({ | ||
name: "reaction-stripe-connect", | ||
shopId: Reaction.getShopId() | ||
}); | ||
} | ||
}); | ||
|
||
AutoForm.hooks({ | ||
"stripe-connect-update-form": { | ||
onSuccess: function () { | ||
return Alerts.toast(i18next.t("admin.settings.saveSuccess"), "success"); | ||
}, | ||
onError: function () { | ||
return Alerts.toast(`${i18next.t("admin.settings.saveFailed")} ${error}`, "error"); | ||
} | ||
} | ||
}); | ||
|
||
Template.stripeConnectRedirect.onCreated(function () { | ||
// TODO: Verify that this works and define steps to reproduce. | ||
// grab stripe connects oauth values and redirect the user | ||
const authCode = Router.getQueryParam("code"); | ||
|
||
Meteor.call("stripeConnect/saveSellerParams", Reaction.getSellerShopId(), authCode, function (err) { | ||
if (err) { | ||
// TODO: i18n here | ||
Alerts.toast("There was an error with saving your seller params from stripe."); | ||
} | ||
Reaction.Router.go("/"); | ||
}); | ||
}); |
1 change: 1 addition & 0 deletions
1
imports/plugins/included/payments-stripe-connect/lib/collections/schemas/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./stripe-connect"; |
24 changes: 24 additions & 0 deletions
24
imports/plugins/included/payments-stripe-connect/lib/collections/schemas/stripe-connect.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { SimpleSchema } from "meteor/aldeed:simple-schema"; | ||
import { PackageConfig } from "/lib/collections/schemas/registry"; | ||
|
||
export const StripeConnectPackageConfig = new SimpleSchema([ | ||
PackageConfig, { | ||
"settings.mode": { | ||
type: Boolean, | ||
defaultValue: false | ||
}, | ||
"settings.api_key": { | ||
type: String, | ||
label: "API Client ID" | ||
}, | ||
"settings.transactionFee.enabled": { | ||
type: Boolean, | ||
label: "Enable Fee" | ||
}, | ||
"settings.transactionFee.percentage": { | ||
type: Number, | ||
label: "Fee Percentage", | ||
decimal: true | ||
} | ||
} | ||
]); |
43 changes: 43 additions & 0 deletions
43
imports/plugins/included/payments-stripe-connect/register.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* eslint camelcase: 0 */ | ||
import { Reaction } from "/server/api"; | ||
|
||
Reaction.registerPackage({ | ||
label: "Stripe Connect", | ||
name: "reaction-stripe-connect", | ||
icon: "fa fa-cc-stripe", | ||
autoEnable: true, | ||
settings: { | ||
"mode": false, | ||
"api_key": "", | ||
"reaction-stripe-connect": { | ||
enabled: false | ||
}, | ||
"stripe-redirect-url": "stripe-connect-redirect", | ||
"transactionFee": { | ||
enabled: false, | ||
percentage: 0 | ||
} | ||
}, | ||
registry: [ | ||
// Settings panel | ||
{ | ||
label: "Stripe Connect", | ||
provides: "paymentSettings", | ||
container: "dashboard", | ||
template: "stripeConnectSettings" | ||
}, | ||
|
||
// Payment form for checkout | ||
{ | ||
template: "stripePaymentForm", | ||
provides: "paymentMethod", | ||
icon: "fa fa-cc-stripe" | ||
}, | ||
|
||
// Redirect for Stripe Connect Sign-In | ||
{ | ||
template: "stripeConnectRedirect", | ||
route: "/stripe-connect-redirect" | ||
} | ||
] | ||
}); |
24 changes: 24 additions & 0 deletions
24
imports/plugins/included/payments-stripe-connect/server/i18n/ar.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
[{ | ||
"language": "Arabic", | ||
"i18n": "ar", | ||
"ns": "reaction-stripe-connect", | ||
"translation": { | ||
"reaction-payments": { | ||
"admin": { | ||
"shortcut": { | ||
"stripeConnectLabel": "Stripe Connect" | ||
}, | ||
"dashboard": { | ||
"stripeConnectLabel": "Stripe Connect", | ||
"stripeConnectDescription": "المدفوعات شريط" | ||
}, | ||
"paymentSettings": { | ||
"stripeConnectLabel": "Stripe Connect", | ||
"stripeConnectSettingsLabel": "Stripe Connect", | ||
"stripeConnectSettingsDescription": "لم يكن لديك معرف العميل الشريط API؟", | ||
"stripeConnectSettingsGetItHere": "أحضره هنا" | ||
} | ||
} | ||
} | ||
} | ||
}] |
24 changes: 24 additions & 0 deletions
24
imports/plugins/included/payments-stripe-connect/server/i18n/bg.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
[{ | ||
"language": "Bulgarian", | ||
"i18n": "bg", | ||
"ns": "reaction-stripeConnect", | ||
"translation": { | ||
"reaction-payments": { | ||
"admin": { | ||
"shortcut": { | ||
"stripeConnectLabel": "Stripe Connect" | ||
}, | ||
"dashboard": { | ||
"stripeConnectLabel": "Stripe Connect", | ||
"stripeConnectDescription": "плащания Stripe Connect" | ||
}, | ||
"paymentSettings": { | ||
"stripeConnectLabel": "Stripe Connect", | ||
"stripeConnectSettingsLabel": "Stripe Connect", | ||
"stripeConnectSettingsDescription": "Не трябва Stripe Connect API Client ID а?", | ||
"stripeConnectSettingsGetItHere": "Вземете го от тук" | ||
} | ||
} | ||
} | ||
} | ||
}] |
Oops, something went wrong.