Guide
How to use Pay in Capacitor
Using @capgo/capacitor-pay
Capacitor plugin to trigger native payment for iOS(Apple pay) and Android(Google Pay).
Install
bun add @capgo/capacitor-pay
bunx cap sync
bunx cap sync copies the plugin's native code into your native projects. Run it again after every plugin upgrade.
Import
import { Pay } from '@capgo/capacitor-pay';
API at a glance
| Method | Description |
|---|---|
isPayAvailable |
Checks whether native pay is available on the current platform. On iOS this evaluates Apple Pay, on Android it evaluates Google Pay. |
requestPayment |
Presents the native pay sheet for the current platform. Provide the Apple Pay configuration on iOS and the Google Pay configuration on Android. |
Examples
isPayAvailable()
Checks whether native pay is available on the current platform. On iOS this evaluates Apple Pay, on Android it evaluates Google Pay.
import { Pay } from '@capgo/capacitor-pay';
const result = await Pay.isPayAvailable();
console.log(result);
requestPayment()
Presents the native pay sheet for the current platform. Provide the Apple Pay configuration on iOS and the Google Pay configuration on Android.
import { Pay } from '@capgo/capacitor-pay';
const result = await Pay.requestPayment({
apple: {
merchantIdentifier: 'merchant-identifier-123',
countryCode: 'US',
currencyCode: 'USD',
paymentSummaryItems: [
{
label: 'Hello from Capacitor',
amount: 'amount',
},
],
supportedNetworks: ['AmEx'],
},
});
// The result holds sensitive values: use it without logging it.
Full reference
Keep going from Using @capgo/capacitor-pay
If you are using Using @capgo/capacitor-pay to plan payments and purchases, connect it with @capgo/capacitor-pay for the implementation detail in @capgo/capacitor-pay, Getting Started for the implementation detail in Getting Started, Capgo Pricing for the product workflow in Capgo Pricing, Payment system for the implementation detail in Payment system, and @capgo/native-purchases for the implementation detail in @capgo/native-purchases.