Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

typescript initialize stripe api, connect stripe with OAuth and creating Direct Charges in Stripe.

const client = new stripe(`${process.env.STRIPE_SECRET_KEY}`, {
  apiVersion: '2020-08-27',
});

export const Stripe = {
  connect: async (code: string) => {
    const response = await client.oauth.token({
      grant_type: 'authorization_code',
      code,
    });

    return response;
  },
  charge: async (amount: number, source: string, stripeAccount: string) => {
    const res = await client.charges.create(
      {
        amount,
        currency: 'usd',
        source,
        application_fee_amount: Math.round(amount * 0.05),
      },
      {
        stripe_account: stripeAccount,
      }
    );

    if (res.status !== 'succeeded') {
      throw new Error('failed to create charge with Stripe');
    }
  },
};
Comment

PREVIOUS NEXT
Code Example
Typescript :: minikube arguments --cpus 
Typescript :: google sheets app script get last cell has value with empty cells 
Typescript :: how to make the score add on while its in a loop in python 
Typescript :: how to delete a struct in a arra of strcts c 
Typescript :: firebase angular assets not showing 
Typescript :: how to execute the same test case for multiple time using testng? 
Typescript :: ts Adapter pattern 
Typescript :: typescript different types support 
Typescript :: return type depends on input typescript 
Typescript :: typescript Empty Types 
Typescript :: positional arguments dart 
Typescript :: typescript reduce initial value type 
Typescript :: sap abap check file exists on application server tcode 
Typescript :: get list of property values from list of objects swift 
Typescript :: send tcp packets to kubernetes node 
Typescript :: calculate north south east west using magnetic sensor 
Typescript :: como agregarle un rango a mat-datapicker 
Typescript :: are remote objects and distributed objects the same 
Typescript :: typescript list 
Typescript :: real time charts in flutter 
Typescript :: fwrite() expects parameter 2 to be string, array given 
Typescript :: how to setup netflix workflow worker 
Cpp :: c++ get file content 
Cpp :: std logic vhdl 
Cpp :: is javascript for websites only 
Cpp :: maximum in vector 
Cpp :: c++ custom comparator for elements in set 
Cpp :: eosio multi index clear 
Cpp :: qimage transformed 
Cpp :: c++ execution time 
ADD CONTENT
Topic
Content
Source link
Name
1+3 =