-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an cvv field to test upsert operation
- Loading branch information
1 parent
fe919c3
commit 4af9294
Showing
5 changed files
with
110 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { defaultStyles } from "./styles"; | ||
|
||
export async function initUpsertSkyflow( | ||
vaultId, | ||
vaultUrl, | ||
baseUrl, | ||
apiKey, | ||
signal, | ||
customStyles = {} | ||
) { | ||
const skyflow = await Skyflow.init({ | ||
vaultID: vaultId, | ||
vaultURL: vaultUrl, | ||
getBearerToken: async () => { | ||
// Pass the signal to the fetch call | ||
const response = await fetch(`${baseUrl}/api/v1/vault-token/`, { | ||
method: 'GET', | ||
headers: { | ||
'Authorization': `Token ${apiKey}`, | ||
}, | ||
signal: signal, | ||
}); | ||
|
||
if (response.ok) { | ||
const responseBody = await response.json(); | ||
return responseBody.token; | ||
} else { | ||
throw new Error('Failed to retrieve bearer token'); | ||
} | ||
}, | ||
options: { | ||
logLevel: Skyflow.LogLevel.ERROR, | ||
env: Skyflow.Env.DEV, | ||
}, | ||
}); | ||
|
||
const cvvCollectContainer = await skyflow.container( | ||
Skyflow.ContainerType.COLLECT | ||
); | ||
|
||
// Custom styles for collect elements. | ||
var collectStylesOptions = Object.keys(customStyles).length === 0 ? defaultStyles : customStyles | ||
|
||
const cvvElementUpsert = await cvvCollectContainer.create({ | ||
table: "cards", | ||
column: "cvv", | ||
...collectStylesOptions, | ||
label: 'Upsert CVV', | ||
placeholder: collectStylesOptions.placeholders?.cvvPlaceholder, | ||
type: Skyflow.ElementType.CVV, | ||
skyflowID: 'd8ad3825-848b-4150-b077-c849b14031c8', | ||
}); | ||
|
||
await mountElements( | ||
cvvElementUpsert, | ||
) | ||
|
||
return cvvCollectContainer | ||
} | ||
|
||
async function mountElements( | ||
cvvElementUpsert, | ||
) { | ||
cvvElementUpsert.mount("#collectCvvUpsert"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters