Skip to content

Commit

Permalink
change company to individual
Browse files Browse the repository at this point in the history
  • Loading branch information
whybtech committed Jul 26, 2023
1 parent 2dd8392 commit 5f16cc3
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -303,16 +303,17 @@ class StripeSdkModule(reactContext: ReactApplicationContext) : ReactContextBaseJ

private fun createTokenFromAccount(params: ReadableMap, promise: Promise) {
val businessType = getValOr(params, "businessType", null)
if (businessType != "Company") {
promise.resolve(createError(CreateTokenErrorType.Failed.toString(), "businessType currently only accepts the Company account type"))
if (businessType != "Individual") {
promise.resolve(createError(CreateTokenErrorType.Failed.toString(), "businessType currently only accepts the Individual account type"))
return
}

val companyData = getMapOrNull(params, "company")
val individualData = getMapOrNull(params, "individual")
val accountParams = AccountParams.create(
tosShownAndAccepted = getBooleanOrFalse(params, "tosShownAndAccepted"),
company = AccountParams.BusinessTypeParams.Company.Builder()
.setPhone(getValOr(companyData, "phone", null))
company = AccountParams.BusinessTypeParams.Individual.Builder()
.setEmail(getValOr(individualData, "email", null))
.setPhone(getValOr(individualData, "phone", null))
.build()
)
CoroutineScope(Dispatchers.IO).launch {
Expand Down
6 changes: 2 additions & 4 deletions example/src/screens/CreateTokenScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,8 @@ function buildTestTokenParams(type: Token.Type): Token.CreateParams {
case 'Account':
return {
type: 'Account',
businessType: 'Company',
company: {
phone: '00000000'
},
businessType: 'Individual',
individual: {},
tosShownAndAccepted: true,
};
default:
Expand Down
12 changes: 7 additions & 5 deletions ios/StripeSdk.swift
Original file line number Diff line number Diff line change
Expand Up @@ -685,18 +685,20 @@ class StripeSdk: RCTEventEmitter, STPBankSelectionViewControllerDelegate, UIAdap
rejecter reject: @escaping RCTPromiseRejectBlock
) -> Void {
let businessType = params["businessType"] as? String
if (businessType != "Company") {
resolve(Errors.createError(ErrorType.Failed, "businessType currently only accepts the Company account type."))
if (businessType != "Individual") {
resolve(Errors.createError(ErrorType.Failed, "businessType currently only accepts the Individual account type."))
return
}

let tosShownAndAccepted = params["tosShownAndAccepted"] as? Bool ?? false
let phone = params["phone"] as? String
let email = params["email"] as? String

let connectAccountCompanyParams = STPConnectAccountCompanyParams()
connectAccountCompanyParams.phone = phone
let connectAccountIndividualParams = STPConnectAccountIndividualParams()
connectAccountIndividualParams.phone = phone
connectAccountIndividualParams.email = email

guard let accountParams = STPConnectAccountParams(tosShownAndAccepted: tosShownAndAccepted, company: connectAccountCompanyParams) else {
guard let accountParams = STPConnectAccountParams(tosShownAndAccepted: tosShownAndAccepted, company: connectAccountIndividualParams) else {
resolve(Errors.createError(ErrorType.Failed, "tosShownAndAccepted parameter must be true"))
return
}
Expand Down
5 changes: 3 additions & 2 deletions src/types/Token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,11 @@ export type AccountBusinessType = 'Company' | 'Individual';
export type CreateAccountTokenParams = {
type: 'Account';
businessType: AccountBusinessType;
company?: AccountCompany;
individual?: AccountIndividual;
tosShownAndAccepted?: boolean;
};

export type AccountCompany = {
export type AccountIndividual = {
phone?: string;
email?: string;
}

0 comments on commit 5f16cc3

Please sign in to comment.