> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/zkp2p/zkp2p-contracts/llms.txt
> Use this file to discover all available pages before exploring further.

# Payment Methods

> Work with payment method configurations and provider hashes

The `@zkp2p/contracts-v2/paymentMethods` module provides unified payment method configurations including payment method hashes, supported currencies, and provider hashes from on-chain deployments.

## Import Payment Methods

Import payment method configurations for a specific network:

```typescript theme={null}
import { base } from '@zkp2p/contracts-v2/paymentMethods';

// Access specific payment method
const venmoConfig = base.methods.venmo;
console.log('Payment Method Hash:', venmoConfig.paymentMethodHash);
console.log('Supported Currencies:', venmoConfig.currencies);
```

## Network-Specific Payment Methods

<CodeGroup>
  ```typescript Base Mainnet theme={null}
  import { base } from '@zkp2p/contracts-v2/paymentMethods';

  // Access payment methods
  const venmo = base.methods.venmo;
  const revolut = base.methods.revolut;
  const wise = base.methods.wise;
  const cashapp = base.methods.cashapp;

  console.log('Network:', base.network);
  console.log('Chain ID:', base.chainId);
  ```

  ```typescript Base Sepolia (Testnet) theme={null}
  import { baseSepolia } from '@zkp2p/contracts-v2/paymentMethods';

  const venmo = baseSepolia.methods.venmo;
  console.log('Venmo hash:', venmo.paymentMethodHash);
  ```
</CodeGroup>

## Payment Method Configuration

Each payment method contains:

```typescript theme={null}
interface PaymentMethodConfig {
  paymentMethodHash: string;        // Keccak256 hash of payment method name
  currencies: string[];             // Array of supported currency hashes
  timestampBuffer: number;          // Buffer time in seconds
  providerHashes: string[];         // Array of provider email domain hashes
}
```

## Available Payment Methods

### Venmo

```typescript theme={null}
import { base } from '@zkp2p/contracts-v2/paymentMethods';

const venmoConfig = base.methods.venmo;
console.log(venmoConfig);
// {
//   paymentMethodHash: "0x9026...",
//   currencies: ["0xc4ae..."], // USD
//   timestampBuffer: 30,
//   providerHashes: ["0x..."]
// }
```

<Info>
  Venmo only supports USD currency and is available in the United States.
</Info>

### Revolut

```typescript theme={null}
import { base } from '@zkp2p/contracts-v2/paymentMethods';

const revolutConfig = base.methods.revolut;
console.log('Supported currencies:', revolutConfig.currencies.length);
// 24 currencies supported
```

<Info>
  Revolut supports 24+ currencies including USD, EUR, GBP, AUD, CAD, and more.
</Info>

### Cash App

```typescript theme={null}
import { base } from '@zkp2p/contracts-v2/paymentMethods';

const cashappConfig = base.methods.cashapp;
console.log(cashappConfig.paymentMethodHash);
// "0x10940ee67cfb3c6c064569ec92c0ee934cd7afa18dd2ca2d6a2254fcb009c17d"
```

### Wise

```typescript theme={null}
import { base } from '@zkp2p/contracts-v2/paymentMethods';

const wiseConfig = base.methods.wise;
console.log('Currencies:', wiseConfig.currencies.length);
// Multiple currencies supported
```

## Working with Payment Method Hashes

### Get Payment Method Hash

```typescript theme={null}
import { base } from '@zkp2p/contracts-v2/paymentMethods';

function getPaymentMethodHash(methodName: string): string | undefined {
  return base.methods[methodName]?.paymentMethodHash;
}

const venmoHash = getPaymentMethodHash('venmo');
// "0x90262a3db0edd0be2369c6b28f9e8511ec0bac7136cefbada0880602f87e7268"
```

### Check Currency Support

```typescript theme={null}
import { base } from '@zkp2p/contracts-v2/paymentMethods';
import { Currency } from '@zkp2p/contracts-v2/utils/protocolUtils';

function supportsCurrency(
  methodName: string, 
  currencyHash: string
): boolean {
  const method = base.methods[methodName];
  return method?.currencies.includes(currencyHash) ?? false;
}

// Check if Venmo supports USD
const venmoSupportsUSD = supportsCurrency('venmo', Currency.USD);
console.log('Venmo supports USD:', venmoSupportsUSD); // true

// Check if Venmo supports EUR
const venmoSupportsEUR = supportsCurrency('venmo', Currency.EUR);
console.log('Venmo supports EUR:', venmoSupportsEUR); // false
```

### Verify Provider Hash

```typescript theme={null}
import { base } from '@zkp2p/contracts-v2/paymentMethods';

function hasProviderHash(
  methodName: string,
  providerHash: string
): boolean {
  const method = base.methods[methodName];
  return method?.providerHashes.includes(providerHash) ?? false;
}

const providerHash = "0x...";
const isValid = hasProviderHash('venmo', providerHash);
```

## Helper Functions

### Get All Payment Methods

```typescript theme={null}
import { base } from '@zkp2p/contracts-v2/paymentMethods';

function getAllPaymentMethods() {
  return Object.keys(base.methods);
}

const methods = getAllPaymentMethods();
console.log('Available methods:', methods);
// ["venmo", "revolut", "cashapp", "wise", ...]
```

### Find Methods by Currency

```typescript theme={null}
import { base } from '@zkp2p/contracts-v2/paymentMethods';
import { Currency } from '@zkp2p/contracts-v2/utils/protocolUtils';

function findMethodsByCurrency(currencyHash: string): string[] {
  return Object.entries(base.methods)
    .filter(([_, config]) => config.currencies.includes(currencyHash))
    .map(([name]) => name);
}

const usdMethods = findMethodsByCurrency(Currency.USD);
console.log('USD payment methods:', usdMethods);
// ["venmo", "revolut", "cashapp", "wise", ...]
```

## Using in Smart Contract Calls

### Signal Intent with Payment Method

```typescript theme={null}
import { ethers } from 'ethers';
import { base as addresses } from '@zkp2p/contracts-v2/addresses';
import { Orchestrator } from '@zkp2p/contracts-v2/abis/base';
import { base as paymentMethods } from '@zkp2p/contracts-v2/paymentMethods';
import { Currency } from '@zkp2p/contracts-v2/utils/protocolUtils';

const provider = new ethers.providers.Web3Provider(window.ethereum);
const signer = provider.getSigner();

const orchestrator = new ethers.Contract(
  addresses.Orchestrator,
  Orchestrator,
  signer
);

// Get payment method hash for Venmo
const venmoHash = paymentMethods.methods.venmo.paymentMethodHash;

const tx = await orchestrator.signalIntent(
  depositId,
  amount,
  to,
  venmoHash,           // Payment method hash
  Currency.USD,        // Currency hash
  priceLimit,
  paymentIdentifier,
  encryptedPaymentDetails
);

await tx.wait();
```

## Type Definitions

```typescript theme={null}
interface PaymentMethodConfig {
  paymentMethodHash: string;
  currencies: string[];
  timestampBuffer: number;
  providerHashes: string[];
}

interface NetworkPaymentMethods {
  network: string;
  chainId?: number | string;
  generatedAt: string;
  methods: Record<string, PaymentMethodConfig>;
}
```

## Direct JSON Import

For bundle size optimization:

```typescript theme={null}
import basePaymentMethods from '@zkp2p/contracts-v2/paymentMethods/base.json';

console.log(basePaymentMethods.methods.venmo);
```

## Next Steps

<CardGroup cols={2}>
  <Card title="Utilities" icon="wrench" href="/sdk/utilities">
    Use protocol utility functions
  </Card>

  <Card title="Constants" icon="hashtag" href="/sdk/constants">
    Access protocol constants
  </Card>
</CardGroup>
