Skip to content

Instantly share code, notes, and snippets.

@SimonHoiberg
Created June 19, 2020 14:55
Show Gist options
  • Save SimonHoiberg/8b15f6dcc77ff2c0c471dfdd68abe908 to your computer and use it in GitHub Desktop.
Save SimonHoiberg/8b15f6dcc77ff2c0c471dfdd68abe908 to your computer and use it in GitHub Desktop.
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