Created
June 19, 2020 14:55
-
-
Save SimonHoiberg/8b15f6dcc77ff2c0c471dfdd68abe908 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
class StripeManager { | |
... | |
public static async retreivePaymentInfo(paymentMethodID: string) { | |
try { | |
const request = await fetch( | |
'https://your-endpoint/stripe/retrieve-payment-method', | |
{ | |
method: 'POST', | |
body: JSON.stringify({ | |
paymentMethodID, | |
}), | |
} | |
); | |
const result = await request.json(); | |
return { | |
type: result.card.brand, | |
digits: result.card.last4, | |
}; | |
} catch (error) { | |
console.error(error); | |
return null; | |
} | |
} | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment