Skip to content

Commit f4fa8f0

Browse files
committed
Add partner validation documentation
1 parent 17f03b1 commit f4fa8f0

2 files changed

Lines changed: 66 additions & 4 deletions

File tree

docs/flows/crypto-offramp.mdx

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ The crypto off-ramp flow allows a user to sell cryptocurrency and convert it int
2323
- `displayName` (_optional_): Partner name to be displayed to the user.
2424
- `fee` (_optional_): An object configuring the partner fee to be charged.
2525
- `percentage`: Percentage of the total source amount (the maximum allowed value is "5").
26+
- `validation` (_optional_): Custom request validation parameters.
27+
- `device`: (_optional_): Device parameters to validate.
28+
- `alg` (_optional_): Algorithm used to hash the fields. In case no algorithm is set, we'll be assumed that `sha256` was used.
29+
- `fields` (_optional_): Fields that have been hashed.
30+
- `hash` (_optional_): Result of hashing the fields appended in the given order, without any extra characters or whitespaces, using the given algorithm.
31+
- `ip` (_optional_): User IP on partner's side that we should validate remains the same.
32+
- `ipVersion` (_optional_): Version of IP value used on the hash.
33+
- `user-agent` (_optional_): User agent used on partner's side that we should validate remains the same.
2634
- `refund` (_optional_): An object configuring the refund details. The asset and network of the refund will be the same as the source asset and network.
2735
- `address`: Address to which the refund will be sent.
2836
- `tag` (_optional_): Tag of the crypto transaction, used to complement the `address`.
@@ -83,6 +91,12 @@ We recommend that you use `XRP` for testing purposes when integrating Topper sin
8391
"displayName": "ACME",
8492
"fee": {
8593
"percentage": "1"
94+
},
95+
validation: {
96+
device:{
97+
ip:'1.2.3.4',
98+
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)'
99+
}
86100
}
87101
},
88102
"refund": {
@@ -118,6 +132,23 @@ We recommend that you use `XRP` for testing purposes when integrating Topper sin
118132
</TabItem>
119133
</Tabs>
120134

135+
### Custom partner validation
136+
137+
To increase customer security we support an extra layer of validations that can be customizable by our partners. This layer includes validations from customer's device, like IP and user agent, that we ensure is the same as the one provided by you. In case of any mismatch, the user request to initiate a widget session will fail.
138+
We accept this validation parameters as a plain string or as an hashed string. If you send us hashed parameters, we'll fetch the same parameters we receive from the user request, hash them and compare if both hashes are equal.
139+
If you plan on using hashed validation, please check the example below to see how you should hash your data.
140+
141+
```js
142+
import { createHash } from 'node:crypto';
143+
144+
await createHash('sha256')
145+
.update('1.2.3.4')
146+
.digest('hex');
147+
```
148+
149+
:::note
150+
When validating user IP, if the IP versions mismatch, validation will be partially (plain string validation) or entirely (hashed validation) skipped.
151+
121152
## Events
122153

123154
Full information about the available events and their associated payloads can be found on the [events page](../events/crypto-offramp.mdx).

docs/flows/crypto-onramp.mdx

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,22 @@ The crypto on-ramp flow allows a user to add funds from a credit or debit card t
1515
<TabItem label="Schema" value="schema" default>
1616

1717
- `partner` (_optional_): Partner object.
18+
- `continueUrl` (_optional_): URL to redirect the user to after the order is placed.
19+
- `continueUrlTarget` (_optional_): In which tab should the `continueUrl` be opened.
1820
- `displayName` (_optional_): Partner name to be displayed to the user.
1921
- `fee` (_optional_): An object configuring the partner fee to be charged.
2022
- `percentage`: Percentage of the total source amount (the maximum allowed value is "5").
21-
- `continueUrl` (_optional_): URL to redirect the user to after the order is placed.
22-
- `continueUrlTarget` (_optional_): In which tab should the `continueUrl` be opened.
2323
- `new-tab`: Open in a new tab.
2424
- `same-tab`: Open in the same tab or iframe (default).
2525
- `parent-tab`: Useful only in an iframe: open in the tab that contains the iframe.
26+
- `validation` (_optional_): Custom request validation parameters.
27+
- `device`: (_optional_): Device parameters to validate.
28+
- `alg` (_optional_): Algorithm used to hash the fields. In case no algorithm is set, we'll be assumed that `sha256` was used.
29+
- `fields` (_optional_): Fields that have been hashed.
30+
- `hash` (_optional_): Result of hashing the fields appended in the given order, without any extra characters or whitespaces, using the given algorithm.
31+
- `ip` (_optional_): User IP on partner's side that we should validate remains the same.
32+
- `ipVersion` (_optional_): Version of IP value used on the hash.
33+
- `user-agent` (_optional_): User agent used on partner's side that we should validate remains the same.
2634
- `partnerFee` (_deprecated_): Use `partner.fee` instead.
2735
- `simulation` (_optional_): Simulation object.
2836
- `country` (_optional_): Country to use during simulations, in alpha-2 code format; It will be ignored after the user is authenticated and the user's country will be used.
@@ -71,12 +79,18 @@ We recommend that you use `XRP` for testing purposes when integrating Topper sin
7179
"sub": "b9fe022b-f436-49e1-bb89-6f2e8eabf336",
7280
// highlight-start
7381
"partner": {
82+
"continueUrl": "https://example.com",
83+
"continueUrlTarget": "new-tab",
7484
"displayName": "ACME",
7585
"fee": {
7686
"percentage": "1"
7787
},
78-
"continueUrl": "https://example.com",
79-
"continueUrlTarget": "new-tab"
88+
validation: {
89+
device:{
90+
ip:'1.2.3.4',
91+
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)'
92+
}
93+
}
8094
},
8195
"simulation": {
8296
"country": "US"
@@ -109,6 +123,23 @@ We recommend that you use `XRP` for testing purposes when integrating Topper sin
109123
</TabItem>
110124
</Tabs>
111125

126+
### Custom partner validation
127+
128+
To increase customer security we support an extra layer of validations that can be customizable by our partners. This layer includes validations from customer's device, like IP and user agent, that we ensure is the same as the one provided by you. In case of any mismatch, the user request to initiate a widget session will fail.
129+
We accept this validation parameters as a plain string or as an hashed string. If you send us hashed parameters, we'll fetch the same parameters we receive from the user request, hash them and compare if both hashes are equal.
130+
If you plan on using hashed validation, please check the example below to see how you should hash your data.
131+
132+
```js
133+
import { createHash } from 'node:crypto';
134+
135+
await createHash('sha256')
136+
.update('1.2.3.4')
137+
.digest('hex');
138+
```
139+
140+
:::note
141+
When validating user IP, if the IP versions mismatch, validation will be partially (plain string validation) or entirely (hashed validation) skipped.
142+
112143
### Recipient edit mode
113144

114145
<Tabs>

0 commit comments

Comments
 (0)