From 176df2cc50a11ad2d0b7d72f7d4af55677a269ee Mon Sep 17 00:00:00 2001 From: mbianco-stripe <45374579+mbianco-stripe@users.noreply.github.com> Date: Mon, 29 Aug 2022 12:14:12 -0700 Subject: [PATCH] Allow picklist types for number fields in Stripe (#683) --- .../force-app/main/default/classes/utilities.cls | 1 - .../lwc/dataMappingStep/dataMappingStep.js | 16 +++++++++++----- .../systemConnectionsStep.js | 12 +++++++++--- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/sfdx/force-app/main/default/classes/utilities.cls b/sfdx/force-app/main/default/classes/utilities.cls index e8caa740ce..bfeb4309f0 100644 --- a/sfdx/force-app/main/default/classes/utilities.cls +++ b/sfdx/force-app/main/default/classes/utilities.cls @@ -194,7 +194,6 @@ public with sharing class utilities { // generates package level key and sends to ruby. Named `salesforce_organization_key` on the ruby side public static void generatePackageKey(Stripe_Connection__c stripeConnectRec) { - List setupConfigList = getStripeConnectionKey(); if(setupConfigList.isEmpty()) { /* This error should only be thrown in a scratch org when unmangaed key is deployed to diff --git a/sfdx/force-app/main/default/lwc/dataMappingStep/dataMappingStep.js b/sfdx/force-app/main/default/lwc/dataMappingStep/dataMappingStep.js index 0895782e72..6784bda952 100644 --- a/sfdx/force-app/main/default/lwc/dataMappingStep/dataMappingStep.js +++ b/sfdx/force-app/main/default/lwc/dataMappingStep/dataMappingStep.js @@ -416,12 +416,17 @@ export default class DataMappingStep extends LightningElement { if (!this.stripeObjectField.type) { return; } - var fieldType = this.stripeObjectField.type.toLowerCase() - //has to be a copy to force a rerender - let modifiedFieldOptions = JSON.parse(JSON.stringify(this.sfFieldOptions)) - switch(fieldType) { + + const stripeFieldType = this.stripeObjectField.type.toLowerCase() + + // has to be a copy to force a rerender + const modifiedFieldOptions = JSON.parse(JSON.stringify(this.sfFieldOptions)) + + // TODO this whole switch statement is a mess and is confusing, need to clean this up + switch(stripeFieldType) { case 'integer' || 'decimal' || 'number': - this.sfFieldOptions = modifiedFieldOptions.filter(fieldOptions => fieldOptions.type === 'double' ||fieldOptions.type === 'reference'); + // NOTE `string` was specifically added as an acceptable value because of the payment terms mapping + this.sfFieldOptions = modifiedFieldOptions.filter(fieldOptions => fieldOptions.type === 'double' || fieldOptions.type === 'reference' || fieldOptions.type == 'picklist'); return; case 'timestamp': this.sfFieldOptions = modifiedFieldOptions.filter(fieldOptions => fieldOptions.type.includes('date') || fieldOptions.type === 'reference' ) @@ -652,6 +657,7 @@ export default class DataMappingStep extends LightningElement { isConnectedCallback: isConnectedCallback, ObjectApiName: ObjectName }); + const picklistValueResponseData = JSON.parse(getPicklistValues); if(picklistValueResponseData.error) { this.showToast(picklistValueResponseData.error, 'error', 'sticky'); diff --git a/sfdx/force-app/main/default/lwc/systemConnectionsStep/systemConnectionsStep.js b/sfdx/force-app/main/default/lwc/systemConnectionsStep/systemConnectionsStep.js index 7a96a7ffc3..142ef6ead9 100644 --- a/sfdx/force-app/main/default/lwc/systemConnectionsStep/systemConnectionsStep.js +++ b/sfdx/force-app/main/default/lwc/systemConnectionsStep/systemConnectionsStep.js @@ -19,15 +19,21 @@ export default class SystemConnectionsStep extends LightningElement { stripeConnectedAppCallback() { this.validateConnectionStatus(true, ''); this.postMessageListener = (event) => { - if (event.origin === this.rubyBaseURI && event.data === 'stripeConnectionSuccessful') { + if(event.origin !== this.rubyBaseURI) { + console.log("bad post message origin") + return + } + + if (event.data === 'stripeConnectionSuccessful') { this.validateConnectionStatus(false, 'salesforce'); - } else if (event.origin === this.rubyBaseURI && event.data === 'salesforceConnectionSuccessful') { + } else if (event.data === 'salesforceConnectionSuccessful') { this.connectWindow.close(); this.validateConnectionStatus(false, 'stripe'); } else { - + console.log("bad postmessage data") } } + window.addEventListener("message", this.postMessageListener.bind(this)); }