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

feat: Adjust AWS payment settings #2400

Merged
merged 5 commits into from
Jul 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.20 on 2023-07-07 14:03

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('organisations', '0041_merge_20230621_0946'),
]

operations = [
migrations.AlterField(
model_name='subscription',
name='payment_method',
field=models.CharField(blank=True, choices=[('CHARGEBEE', 'Chargebee'), ('XERO', 'Xero'), ('AWS_MARKETPLACE', 'AWS Marketplace')], max_length=20, null=True),
),
]
2 changes: 2 additions & 0 deletions api/organisations/subscriptions/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@

CHARGEBEE = "CHARGEBEE"
XERO = "XERO"
AWS_MARKETPLACE = "AWS_MARKETPLACE"
SUBSCRIPTION_PAYMENT_METHODS = [
(CHARGEBEE, "Chargebee"),
(XERO, "Xero"),
(AWS_MARKETPLACE, "AWS Marketplace"),
]

FREE_PLAN_SUBSCRIPTION_METADATA = BaseSubscriptionMetadata(
Expand Down
3 changes: 3 additions & 0 deletions frontend/common/stores/account-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,9 @@ const store = Object.assign({}, BaseStore, {
getOrganisations() {
return store.model && store.model.organisations
},
getPaymentMethod() {
return store.organisation?.subscription?.payment_method
},
getPlans() {
if (!store.model) return []
return _.filter(
Expand Down
18 changes: 17 additions & 1 deletion frontend/web/components/modals/Payment.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import makeAsyncScriptLoader from 'react-async-script'
import _data from 'common/data/base/_data'
import ConfigProvider from 'common/providers/ConfigProvider'
import Constants from 'common/constants'
import InfoMessage from '../InfoMessage';

const PaymentButton = (props) => {
const activeSubscription = AccountStore.getOrganisationPlan(
AccountStore.getOrganisation().id,
)

if (
Utils.getFlagsmithHasFeature('upgrade_subscription') &&
activeSubscription
Expand Down Expand Up @@ -67,7 +69,21 @@ const PaymentModal = class extends Component {
}
render() {
const viewOnly = this.props.viewOnly

const isAWS = AccountStore.getPaymentMethod() === 'AWS_MARKETPLACE'
if (isAWS) {
return (
<InfoMessage>
Customers with AWS Marketplace subscriptions will need to{' '}
<a
href='https://www.flagsmith.com/contact-us'
target='_blank'
rel='noreferrer'
>
contact us
</a>
</InfoMessage>
)
}
return (
<div className='app-container container'>
<AccountProvider onSave={this.onSave} onRemove={this.onRemove}>
Expand Down
8 changes: 6 additions & 2 deletions frontend/web/components/pages/OrganisationSettingsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,15 +287,19 @@ const OrganisationSettingsPage = class extends Component {
}) => {
const { max_seats } = subscriptionMeta ||
organisation.subscription || { max_seats: 1 }
const isAWS =
AccountStore.getPaymentMethod() === 'AWS_MARKETPLACE'
const { chargebee_email } = subscriptionMeta || {}
const autoSeats = Utils.getPlansPermission('AUTO_SEATS')
const autoSeats =
!isAWS && Utils.getPlansPermission('AUTO_SEATS')
const usedSeats =
paymentsEnabled && organisation.num_seats >= max_seats
const overSeats =
paymentsEnabled && organisation.num_seats > max_seats
const needsUpgradeForAdditionalSeats =
(overSeats && (!verifySeatsLimit || !autoSeats)) ||
(!autoSeats && usedSeats)

return (
<div>
<Tabs
Expand Down Expand Up @@ -353,7 +357,7 @@ const OrganisationSettingsPage = class extends Component {
{organisation.id}
</p>
</div>
{paymentsEnabled && (
{paymentsEnabled && !isAWS && (
<div className='plan plan--current flex-row m-t-2'>
<div className='plan__prefix'>
<img
Expand Down