Skip to content

Commit

Permalink
Allow picklist types for number fields in Stripe (#683)
Browse files Browse the repository at this point in the history
  • Loading branch information
mbianco-stripe authored Aug 29, 2022
1 parent 2d310f5 commit 176df2c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
1 change: 0 additions & 1 deletion sfdx/force-app/main/default/classes/utilities.cls
Original file line number Diff line number Diff line change
Expand Up @@ -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<Setup_Connection_Data__mdt> setupConfigList = getStripeConnectionKey();
if(setupConfigList.isEmpty()) {
/* This error should only be thrown in a scratch org when unmangaed key is deployed to
Expand Down
16 changes: 11 additions & 5 deletions sfdx/force-app/main/default/lwc/dataMappingStep/dataMappingStep.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' )
Expand Down Expand Up @@ -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');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down

0 comments on commit 176df2c

Please sign in to comment.