# Wallet Integration

This section describes how a wallet provider can support payment links in Stream**Pay** app. It shows how to parse the payment URL and create a transaction from it.

This guide walks through an **example** implementation for wallet providers. The purpose of this is to make it easy for wallets to implement the protocol correctly.

### 1. Set up StreamPay[​](https://docs.solanapay.com/#1-set-up-solana-pay) Wallet <a href="#id-1-set-up-solana-pay" id="id-1-set-up-solana-pay"></a>

Install the packages and import them in your code.

**npm**

```
npm install @stream-pay-wallet @stream/web3.js --save
```

**yarn**

```
yarn add @stream-pay-wallet @stream/web3.js
```

### 2. Parse payment request link[​](https://docs.solanapay.com/#2-parse-payment-request-link) <a href="#id-2-parse-payment-request-link" id="id-2-parse-payment-request-link"></a>

As a wallet provider, you will have to parse the received URL to extract the parameters. For more information on the URL format, please see the [specification](https://docs.solanapay.com/spec).

### 3. Create transaction[​](https://docs.solanapay.com/#3-create-transaction) <a href="#id-3-create-transaction" id="id-3-create-transaction"></a>

Use the `createTransaction` function to create a transaction with the parameters from the `parseURL` function with an additional `payer`.

The `payer` **should** be the public key of the current users' wallet.

<details>

<summary>Create transaction reference implementation</summary>

</details>

This transaction **should** represent the original intent of the payment request link. The example implementation walks through the steps on how to construct the transaction:

**Native STRM/SOL transfer**

1. Check that the payer and recipient accounts exist
2. Check the payer and recipient are valid native accounts
3. Check the payer has enough lamports for the transfer
4. Create an instruction to transfer native STRM or SOL
5. If references were included, add them to the instruction
6. If a memo was included, create an instruction for the memo program

**SPL token transfer**

1. Check that the payer and recipient accounts exist
2. Check the token provided is an initialized mint
3. Check the payer and recipient's Associated Token Account (ATA) exists
4. Check the payer has enough lamports for the transfer
5. Create an instruction to transfer SPL tokens
6. If references were included, add them to the instruction
7. If a memo was included, create an instruction for the memo program

### 4. Complete transaction[​](https://docs.solanapay.com/#4-complete-transaction) <a href="#id-4-complete-transaction" id="id-4-complete-transaction"></a>

With the transaction formed. The user must be prompted to approve the transaction.

The `label` and `message` **should** be shown to the user, as it gives added context to the user on the transaction.

<details>

<summary>Finally, use <code>sendAndConfirmTransaction</code> to complete the transaction.</summary>

\
\
\
Deep linking[​](https://docs.solanapay.com/#deep-linking)

</details>

### Deep linking

Wallet providers building for mobile or wearable devices are encouraged to register their app as a handler for the Stream**Pay** URL scheme`solana:`.

For example, when a payment request is presented as a QR code, the payer should ideally be able to read the code using the native scanning capability of their device and have the appropriate wallet open with the transaction prefilled.

URLs can be embedded in the environment in web pages, QR codes, NFC tags and potential new formats. To avoid inadvertent transfer of tokens, care must be taken when designing wallets to ensure that transactions cannot accidentally be triggered and sent.

\
\
\\
