Skip to content

Commit

Permalink
Add success-redirect field to 1.1 spec
Browse files Browse the repository at this point in the history
  • Loading branch information
mcintyre94 committed Feb 27, 2023
1 parent d791c24 commit 8717cdd
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions SPEC1.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ A standard URL protocol for requesting native SOL transfers, SPL Token transfers

These URLs may be encoded in QR codes or NFC tags, or sent between users and applications to request payment and compose transactions.

Applications should ensure that a transaction has been confirmed and is valid before they release goods or services being sold, or grant access to objects or events.
Applications should ensure that a transaction has been confirmed and is valid before they release goods or services being sold, or grant access to objects or events.

Mobile wallets should register to handle the URL scheme to provide a seamless yet secure experience when Solana Pay URLs are encountered in the environment.

Expand All @@ -29,6 +29,7 @@ solana:<recipient>
&label=<label>
&message=<message>
&memo=<memo>
&success-redirect=<success-redirect>
```

The request is non-interactive because the parameters in the URL are used by a wallet to directly compose a transaction.
Expand Down Expand Up @@ -78,6 +79,12 @@ The wallet must [URL-decode](https://developer.mozilla.org/en-US/docs/Web/JavaSc

If the field is provided, the wallet must include a `MemoProgram` instruction as the second to last instruction of the transaction, immediately before the SOL or SPL Token transfer instruction, to avoid ambiguity with other instructions in the transaction.

### Success Redirect

A single `success-redirect` field is allowed as an optional query parameter. The value must be a conditionally [URL-encoded](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent) absolute HTTPS or solana URL.

The wallet must [URL-decode](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURIComponent) the value. If it is a HTTPS URL then the wallet should display the decoded value to the user. If the transaction is completed successfully and it is a HTTPS URL then the wallet should redirect the user to the URL. If the transaction is completed successfully and it is a solana URL then the wallet should treat it as a new Solana Pay request. If the transaction is not completed successfully then the wallet should not use the URL.

### Examples

##### URL describing a transfer request for 1 SOL.
Expand All @@ -95,6 +102,11 @@ solana:mvines9iiHiQTysrwkJjGf2gb9Ex9jXJX8ns3qwf2kN?amount=0.01&spl-token=EPjFWdd
solana:mvines9iiHiQTysrwkJjGf2gb9Ex9jXJX8ns3qwf2kN&label=Michael
```

##### URL describing a transfer request for 1 SOL with a success redirect
```
solana:mvines9iiHiQTysrwkJjGf2gb9Ex9jXJX8ns3qwf2kN?amount=1&label=Michael&message=Thanks%20for%20all%20the%20fish&memo=OrderId12345&success-redirect=https://example.com
```

## Specification: Transaction Request

A Solana Pay transaction request URL describes an interactive request for any Solana transaction.
Expand Down Expand Up @@ -187,10 +199,20 @@ The `<message>` value must be a UTF-8 string that describes the nature of the tr

For example, this might be the name of an item being purchased, a discount applied to the purchase, or a thank you note. The wallet should display the value to the user.

The application may also include an optional `successRedirect` field in the response body:

```json
{"successRedirect":"<success-redirect>","transaction":"<transaction>"}
```

The `success-redirect` field must be a conditionally [URL-encoded](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent) absolute HTTPS or solana URL.

The wallet must [URL-decode](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURIComponent) the value. If it is a HTTPS URL then the wallet should display the decoded value to the user. If the transaction is completed successfully and it is a HTTPS URL then the wallet should redirect the user to the URL. If the transaction is completed successfully and it is a solana URL then the wallet should treat it as a new Solana Pay request. If the transaction is not completed successfully then the wallet should not use the URL.

The wallet and application should allow additional fields in the request body and response body, which may be added by future specification.

#### Error Handling
If the application responds with an HTTP [client](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#client_error_responses) or [server](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#server_error_responses) error in response to the POST or PUT operations, the wallet must consider the entire transaction request as failed.
If the application responds with an HTTP [client](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#client_error_responses) or [server](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#server_error_responses) error in response to the POST or PUT operations, the wallet must consider the entire transaction request as failed.

Client and server errors may optionally be accompanied by a JSON body containing a UTF-8 string `message` field describing the nature of the error:
```json
Expand Down

0 comments on commit 8717cdd

Please sign in to comment.