Skip to content

Commit

Permalink
feat: Adjust AWS payment settings (#2400)
Browse files Browse the repository at this point in the history
* Adjust AWS payment settings

* Lint

* Add enum and db migration for new payment method

* Add payment modal message

---------

Co-authored-by: Ben Rometsch <ben.rometsch@gmail.com>
  • Loading branch information
kyle-ssg and dabeeeenster committed Jul 14, 2023
1 parent a2bdb63 commit de4618d
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 3 deletions.
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

0 comments on commit de4618d

Please sign in to comment.