Created
November 25, 2025 20:48
-
-
Save Dari4sho/755a0f9795ed98b1ac5dc504284fc39e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| import Stripe from 'stripe' // ^19.1.0 | |
| /** | |
| * Example function to upload image and update stripe account logo. | |
| * Call this function. | |
| */ | |
| const doTheThing = async () => { | |
| // Get buffer from real file - this is just an example | |
| const buffer = Buffer.from([]) | |
| const stripeAccountId = 'acct_1SX79GBYNFuMerau' | |
| // Upload image to stripe | |
| const file = await uploadImage({ | |
| stripeAccountId, | |
| buffer: buffer, | |
| contentType: 'image/png', | |
| }) | |
| // Update account with new logo | |
| updateAccount({ | |
| stripeAccountId, | |
| logoId: file.id, | |
| }) | |
| } | |
| /** | |
| * Function to upload file to stripe account (connected account) | |
| */ | |
| const uploadImage = async (params: { stripeAccountId: string, buffer: Buffer<ArrayBufferLike>; contentType: string }) => { | |
| const { stripeAccountId, buffer, contentType } = params | |
| return stripe.files.create( | |
| { | |
| file: { | |
| data: buffer, // bytes of file | |
| name: '1764102230314-b20cc10f-7feb-4f1e-876d-744eff7bb55d-fff.png', | |
| type: contentType || 'application/octet-stream', | |
| }, | |
| purpose: 'business_logo', | |
| }, | |
| { | |
| stripeAccount: stripeAccountId, | |
| } | |
| ) | |
| } | |
| /** | |
| * Function to update stripe account with new logo | |
| */ | |
| const updateAccount = async (params: { stripeAccountId: string, logoId: string }) => { | |
| const { stripeAccountId, logoId } = params | |
| return stripe.accounts.update(stripeAccountId, { | |
| settings: { | |
| branding: { | |
| icon: logoId, | |
| logo: logoId, | |
| }, | |
| }, | |
| }) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment