import{ Stripe, GooglePayEventsEnum }from'@capacitor-community/stripe';(async()=>{// Check to be able to use Google Pay on deviceconst isAvailable = Stripe.isGooglePayAvailable().catch(()=>undefined);if(isAvailable ===undefined){// disable to use GooglePayreturn;}})();
このメソッドは resolve(): void か reject('Not implemented on Device.') を返却します。
(async()=>{// Connect to your backend endpoint, and get paymentIntent.const{ paymentIntent }=awaitthis.http.post<{
paymentIntent:string;}>(environment.api +'payment-sheet',{}).pipe(first()).toPromise(Promise);// Prepare GooglePayawait Stripe.createGooglePay({
paymentIntentClientSecret: paymentIntent,// Web only. Google Pay on Android App doesn't need
paymentSummaryItems:[{
label:'Product Name',
amount:1099.00}],
merchantIdentifier:'merchant.com.getcapacitor.stripe',
countryCode:'US',
currency:'USD',});})();
import{ Stripe, GooglePayEventsEnum }from'@capacitor-community/stripe';(async()=>{// Check to be able to use Google Pay on deviceconst isAvailable = Stripe.isGooglePayAvailable().catch(()=>undefined);if(isAvailable ===undefined){// disable to use Google Payreturn;}
Stripe.addListener(GooglePayEventsEnum.Completed,()=>{console.log('GooglePayEventsEnum.Completed');});// Connect to your backend endpoint, and get paymentIntent.const{ paymentIntent }=awaitthis.http.post<{
paymentIntent:string;}>(environment.api +'payment-sheet',{}).pipe(first()).toPromise(Promise);// Prepare Google Payawait Stripe.createGooglePay({
paymentIntentClientSecret: paymentIntent,// Web only. Google Pay on Android App doesn't need
paymentSummaryItems:[{
label:'Product Name',
amount:1099.00}],
merchantIdentifier:'merchant.com.getcapacitor.stripe',
countryCode:'US',
currency:'USD',});// Present Google Payconst result =await Stripe.presentGooglePay();if(result.paymentResult === GooglePayEventsEnum.Completed){// Happy path}})();