react-code-dataset / wp-calypso /client /jetpack-cloud /sections /partner-portal /payment-methods /stored-payment-method-api.ts
react-code-dataset / wp-calypso /client /jetpack-cloud /sections /partner-portal /payment-methods /stored-payment-method-api.ts
Download wp-calypso/client/jetpack-cloud/sections/partner-portal/payment-methods/stored-payment-method-api.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 880 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/jetpack-cloud/sections/partner-portal/payment-methods/stored-payment-method-api.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/jetpack-cloud/sections/partner-portal/payment-methods/stored-payment-method-api.ts
-
curl -L -o stored-payment-method-api.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/jetpack-cloud/sections/partner-portal/payment-methods/stored-payment-method-api.ts
880 Bytes
| import { recordTracksEvent } from 'calypso/lib/analytics/tracks'; | |
| import { wpcomJetpackLicensing as wpcomJpl } from 'calypso/lib/wp'; | |
| interface Params { | |
| token: string; | |
| useAsPrimaryPaymentMethod: boolean; | |
| stripeSetupIntentId: string; | |
| } | |
| export async function saveCreditCard( { | |
| token, | |
| useAsPrimaryPaymentMethod, | |
| stripeSetupIntentId, | |
| }: Params ): Promise< unknown > { | |
| const response = await wpcomJpl.req.post( | |
| { | |
| apiNamespace: 'wpcom/v2', | |
| path: '/jetpack-licensing/stripe/payment-method', | |
| }, | |
| { | |
| payment_method_id: token, | |
| use_as_primary_payment_method: useAsPrimaryPaymentMethod, | |
| stripe_setup_intent_id: stripeSetupIntentId, | |
| } | |
| ); | |
| if ( response.error ) { | |
| recordTracksEvent( 'calypso_partner_portal_add_new_credit_card_error' ); | |
| throw new Error( response ); | |
| } | |
| recordTracksEvent( 'calypso_partner_portal_add_new_credit_card' ); | |
| return response; | |
| } | |