Commit 6ebd772e by Nilu

move stripe reference to company from company user

parent bee8281b
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
<column name="post_code" type="String" nullable="true" length="10"/> <column name="post_code" type="String" nullable="true" length="10"/>
<column name="city" type="String" nullable="true" length="100"/> <column name="city" type="String" nullable="true" length="100"/>
<column name="has_client_support" type="Boolean" nullable="true"/> <column name="has_client_support" type="Boolean" nullable="true"/>
<column name="stripe_reference" type="String" nullable="true" length="100"/>
<column name="stripe_subscription" type="String" nullable="true" length="100"/>
<column name="added_by_user_id" type="Long" length="11" nullable="false"/> <column name="added_by_user_id" type="Long" length="11" nullable="false"/>
</NODE> </NODE>
......
...@@ -18,8 +18,6 @@ ...@@ -18,8 +18,6 @@
<column name="verification_key" type="String" nullable="true" length="10"/> <column name="verification_key" type="String" nullable="true" length="10"/>
<column name="is_account_verified" type="Boolean" nullable="true"/> <column name="is_account_verified" type="Boolean" nullable="true"/>
<column name="is_email_changed" type="Boolean" nullable="true"/> <column name="is_email_changed" type="Boolean" nullable="true"/>
<column name="stripe_reference" type="String" nullable="true" length="100"/>
<column name="stripe_subscription" type="String" nullable="true" length="100"/>
<column name="user_id" type="Long" length="11" nullable="true"/> <column name="user_id" type="Long" length="11" nullable="true"/>
<column name="company_id" type="Long" length="11" nullable="true"/> <column name="company_id" type="Long" length="11" nullable="true"/>
</NODE> </NODE>
......
...@@ -19,6 +19,8 @@ CREATE TABLE tl_company ( ...@@ -19,6 +19,8 @@ CREATE TABLE tl_company (
post_code varchar(10) NULL, post_code varchar(10) NULL,
city varchar(100) NULL, city varchar(100) NULL,
has_client_support char(1) NULL, has_client_support char(1) NULL,
stripe_reference varchar(100) NULL,
stripe_subscription varchar(100) NULL,
added_by_user_id numeric(12) NOT NULL added_by_user_id numeric(12) NOT NULL
); );
......
...@@ -17,8 +17,6 @@ CREATE TABLE oneit_sec_user_extension ( ...@@ -17,8 +17,6 @@ CREATE TABLE oneit_sec_user_extension (
verification_key varchar(10) NULL, verification_key varchar(10) NULL,
is_account_verified char(1) NULL, is_account_verified char(1) NULL,
is_email_changed char(1) NULL, is_email_changed char(1) NULL,
stripe_reference varchar(100) NULL,
stripe_subscription varchar(100) NULL,
user_id numeric(12) NULL, user_id numeric(12) NULL,
company_id numeric(12) NULL company_id numeric(12) NULL
); );
......
...@@ -20,6 +20,8 @@ CREATE TABLE tl_company ( ...@@ -20,6 +20,8 @@ CREATE TABLE tl_company (
post_code varchar2(10) NULL, post_code varchar2(10) NULL,
city varchar2(100) NULL, city varchar2(100) NULL,
has_client_support char(1) NULL, has_client_support char(1) NULL,
stripe_reference varchar2(100) NULL,
stripe_subscription varchar2(100) NULL,
added_by_user_id number(12) NOT NULL added_by_user_id number(12) NOT NULL
); );
......
...@@ -18,8 +18,6 @@ CREATE TABLE oneit_sec_user_extension ( ...@@ -18,8 +18,6 @@ CREATE TABLE oneit_sec_user_extension (
verification_key varchar2(10) NULL, verification_key varchar2(10) NULL,
is_account_verified char(1) NULL, is_account_verified char(1) NULL,
is_email_changed char(1) NULL, is_email_changed char(1) NULL,
stripe_reference varchar2(100) NULL,
stripe_subscription varchar2(100) NULL,
user_id number(12) NULL, user_id number(12) NULL,
company_id number(12) NULL company_id number(12) NULL
); );
......
...@@ -20,6 +20,8 @@ CREATE TABLE tl_company ( ...@@ -20,6 +20,8 @@ CREATE TABLE tl_company (
post_code varchar(10) NULL, post_code varchar(10) NULL,
city varchar(100) NULL, city varchar(100) NULL,
has_client_support char(1) NULL, has_client_support char(1) NULL,
stripe_reference varchar(100) NULL,
stripe_subscription varchar(100) NULL,
added_by_user_id numeric(12) NOT NULL added_by_user_id numeric(12) NOT NULL
); );
......
...@@ -18,8 +18,6 @@ CREATE TABLE oneit_sec_user_extension ( ...@@ -18,8 +18,6 @@ CREATE TABLE oneit_sec_user_extension (
verification_key varchar(10) NULL, verification_key varchar(10) NULL,
is_account_verified char(1) NULL, is_account_verified char(1) NULL,
is_email_changed char(1) NULL, is_email_changed char(1) NULL,
stripe_reference varchar(100) NULL,
stripe_subscription varchar(100) NULL,
user_id numeric(12) NULL, user_id numeric(12) NULL,
company_id numeric(12) NULL company_id numeric(12) NULL
); );
......
...@@ -118,10 +118,10 @@ public class SendCompanyUserInvitesFP extends SaveFP ...@@ -118,10 +118,10 @@ public class SendCompanyUserInvitesFP extends SaveFP
// Need to handle properly when plan and billing screens are added // Need to handle properly when plan and billing screens are added
StripeUtils.createCustomer(companyUser); StripeUtils.createCustomer(companyUser);
LogMgr.log(LOG, LogLevel.PROCESSING1,"Created customer in Stripe, customer reference ", companyUser.getStripeReference()); LogMgr.log(LOG, LogLevel.PROCESSING1,"Created customer in Stripe, customer reference ", company.getStripeReference());
StripeUtils.subscribeCustomer(companyUser); StripeUtils.subscribeCustomer(company);
LogMgr.log(LOG, LogLevel.PROCESSING1,"Subscribed customer to default plan in Stripe, subscription reference ", companyUser.getStripeSubscription()); LogMgr.log(LOG, LogLevel.PROCESSING1,"Subscribed customer to default plan in Stripe, subscription reference ", company.getStripeSubscription());
//process user invitations //process user invitations
......
...@@ -20,18 +20,20 @@ ...@@ -20,18 +20,20 @@
<TABLE name="tl_company" tablePrefix="object"> <TABLE name="tl_company" tablePrefix="object">
<ATTRIB name="CompanyName" type="String" dbcol="company_name" mandatory="true" length="100" /> <ATTRIB name="CompanyName" type="String" dbcol="company_name" mandatory="true" length="100" />
<ATTRIB name="CompanyLogo" type="BinaryContent" dbcol="company_logo" mandatory="false" binaryHandler="loggedin" attribHelper="BLOBAttributeHelper" attribHelperInstance="BLOBAttributeHelper.INSTANCE" /> <ATTRIB name="CompanyLogo" type="BinaryContent" dbcol="company_logo" mandatory="false" binaryHandler="loggedin" attribHelper="BLOBAttributeHelper" attribHelperInstance="BLOBAttributeHelper.INSTANCE" />
<ATTRIB name="HiringTeamType" type="HiringTeamType" dbcol="hiring_team_type" mandatory="false" attribHelper="EnumeratedAttributeHelper"/> <ATTRIB name="HiringTeamType" type="HiringTeamType" dbcol="hiring_team_type" mandatory="false" attribHelper="EnumeratedAttributeHelper"/>
<ATTRIB name="Industry" type="Industry" dbcol="industry" mandatory="false" attribHelper="EnumeratedAttributeHelper"/> <ATTRIB name="Industry" type="Industry" dbcol="industry" mandatory="false" attribHelper="EnumeratedAttributeHelper"/>
<ATTRIB name="TimeZone" type="TimeZone" dbcol="time_zone" mandatory="false" attribHelper="EnumeratedAttributeHelper"/> <ATTRIB name="TimeZone" type="TimeZone" dbcol="time_zone" mandatory="false" attribHelper="EnumeratedAttributeHelper"/>
<ATTRIB name="IsVerified" type="Boolean" dbcol="is_verified" defaultValue="Boolean.FALSE"/> <ATTRIB name="IsVerified" type="Boolean" dbcol="is_verified" defaultValue="Boolean.FALSE"/>
<ATTRIB name="State" type="State" dbcol="state" mandatory="false" defaultValue="State.WA" attribHelper="EnumeratedAttributeHelper"/> <ATTRIB name="State" type="State" dbcol="state" mandatory="false" defaultValue="State.WA" attribHelper="EnumeratedAttributeHelper"/>
<ATTRIB name="Country" type="Countries" dbcol="country" mandatory="false" defaultValue="Countries.AU" attribHelper="EnumeratedAttributeHelper"/> <ATTRIB name="Country" type="Countries" dbcol="country" mandatory="false" defaultValue="Countries.AU" attribHelper="EnumeratedAttributeHelper"/>
<ATTRIB name="PostCode" type="String" dbcol="post_code" mandatory="false" length="10"/> <ATTRIB name="PostCode" type="String" dbcol="post_code" mandatory="false" length="10"/>
<ATTRIB name="City" type="String" dbcol="city" mandatory="false" length="100"/> <ATTRIB name="City" type="String" dbcol="city" mandatory="false" length="100"/>
<ATTRIB name="HasClientSupport" type="Boolean" dbcol="has_client_support" mandatory="false" defaultValue="Boolean.FALSE"/> <ATTRIB name="HasClientSupport" type="Boolean" dbcol="has_client_support" mandatory="false" defaultValue="Boolean.FALSE"/>
<ATTRIB name="StripeReference" type="String" dbcol="stripe_reference" length="100"/>
<ATTRIB name="StripeSubscription" type="String" dbcol="stripe_subscription" length="100"/>
<SINGLEREFERENCE name="AddedByUser" type="CompanyUser" dbcol="added_by_user_id" mandatory="true"/> <SINGLEREFERENCE name="AddedByUser" type="CompanyUser" dbcol="added_by_user_id" mandatory="true"/>
</TABLE> </TABLE>
......
...@@ -22,8 +22,6 @@ ...@@ -22,8 +22,6 @@
<ATTRIB name="VerificationKey" type="String" dbcol="verification_key" length="10"/> <ATTRIB name="VerificationKey" type="String" dbcol="verification_key" length="10"/>
<ATTRIB name="IsAccountVerified" type="Boolean" dbcol="is_account_verified" defaultValue="Boolean.FALSE"/> <ATTRIB name="IsAccountVerified" type="Boolean" dbcol="is_account_verified" defaultValue="Boolean.FALSE"/>
<ATTRIB name="IsEmailChanged" type="Boolean" dbcol="is_email_changed" defaultValue="Boolean.FALSE"/> <ATTRIB name="IsEmailChanged" type="Boolean" dbcol="is_email_changed" defaultValue="Boolean.FALSE"/>
<ATTRIB name="StripeReference" type="String" dbcol="stripe_reference" length="100"/>
<ATTRIB name="StripeSubscription" type="String" dbcol="stripe_subscription" length="100"/>
<SINGLEREFERENCE name="User" type="SecUser" dbcol="user_id" backreferenceName="Extensions" inSuper='TRUE'/> <SINGLEREFERENCE name="User" type="SecUser" dbcol="user_id" backreferenceName="Extensions" inSuper='TRUE'/>
<SINGLEREFERENCE name="Company" type="Company" dbcol="company_id" backreferenceName="Users"/> <SINGLEREFERENCE name="Company" type="Company" dbcol="company_id" backreferenceName="Users"/>
......
...@@ -21,6 +21,7 @@ import oneit.objstore.StorageException; ...@@ -21,6 +21,7 @@ import oneit.objstore.StorageException;
import oneit.security.SecUser; import oneit.security.SecUser;
import oneit.utils.DateDiff; import oneit.utils.DateDiff;
import oneit.utils.parsers.FieldException; import oneit.utils.parsers.FieldException;
import performa.orm.Company;
import performa.orm.CompanyUser; import performa.orm.CompanyUser;
...@@ -41,15 +42,16 @@ public class StripeUtils ...@@ -41,15 +42,16 @@ public class StripeUtils
{ {
try try
{ {
Company company = companyUser.getCompany();
SecUser secUser = companyUser.getUser(); SecUser secUser = companyUser.getUser();
Map<String, Object> customerParams = new HashMap<>(); Map<String, Object> customerParams = new HashMap<>();
customerParams.put("description", companyUser.getCompany()); customerParams.put("description", company);
customerParams.put("email", secUser.getEmail()); customerParams.put("email", secUser.getEmail());
Customer customer = Customer.create(customerParams); Customer customer = Customer.create(customerParams);
companyUser.setStripeReference(customer.getId()); company.setStripeReference(customer.getId());
} }
catch (StorageException | AuthenticationException | InvalidRequestException | APIConnectionException | CardException | APIException ex) catch (StorageException | AuthenticationException | InvalidRequestException | APIConnectionException | CardException | APIException ex)
...@@ -59,7 +61,7 @@ public class StripeUtils ...@@ -59,7 +61,7 @@ public class StripeUtils
} }
public static void subscribeCustomer(CompanyUser companyUser) throws FieldException public static void subscribeCustomer(Company company) throws FieldException
{ {
try try
{ {
...@@ -76,12 +78,12 @@ public class StripeUtils ...@@ -76,12 +78,12 @@ public class StripeUtils
Map<String, Object> params = new HashMap<>(); Map<String, Object> params = new HashMap<>();
params.put("items", items); params.put("items", items);
params.put("coupon", STRIPE_COUPON_ID); params.put("coupon", STRIPE_COUPON_ID);
params.put("customer", companyUser.getStripeReference()); params.put("customer", company.getStripeReference());
params.put("trial_end", trialExpiry.getTime() / 1000L); params.put("trial_end", trialExpiry.getTime() / 1000L);
Subscription subscription = Subscription.create(params); Subscription subscription = Subscription.create(params);
companyUser.setStripeSubscription(subscription.getId()); company.setStripeSubscription(subscription.getId());
} }
catch (StorageException | AuthenticationException | InvalidRequestException | APIConnectionException | CardException | APIException ex) catch (StorageException | AuthenticationException | InvalidRequestException | APIConnectionException | CardException | APIException ex)
{ {
......
<?xml version="1.0" encoding="UTF-8"?>
<!-- @AutoRun -->
<OBJECTS name="" xmlns:oneit="http://www.1iT.com.au">
<NODE name="Script" factory="Vector">
<NODE name="DDL" factory="Participant" class="oneit.sql.transfer.RedefineTableOperation">
<tableName factory="String">tl_company</tableName>
<column name="stripe_reference" type="String" nullable="true" length="100"/>
<column name="stripe_subscription" type="String" nullable="true" length="100"/>
</NODE>
</NODE>
</OBJECTS>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment