Skip to content

Commit c666955

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

2 files changed

Lines changed: 67 additions & 4 deletions

File tree

docs/flows/crypto-offramp.mdx

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,15 @@ 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+
- `ip` (_optional_): User IP on partner's side that we should validate remains the same.
29+
- `user-agent` (_optional_): User agent used on partner's side that we should validate remains the same.
30+
- `encrypted` (_optional_): Encrypted parameters to validate.
31+
- `alg` (_optional_): Algorithm used to hash the fields. In case no algorithm is set, we'll be assumed that `sha256` was used.
32+
- `fields`: Fields that have been hashed.
33+
- `hash`: Result of hashing the fields appended in the given order, without any extra characters or whitespaces, using the given algorithm.
34+
- `ipVersion` (_optional_): Version of IP value used on the hash.
2635
- `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.
2736
- `address`: Address to which the refund will be sent.
2837
- `tag` (_optional_): Tag of the crypto transaction, used to complement the `address`.
@@ -83,6 +92,12 @@ We recommend that you use `XRP` for testing purposes when integrating Topper sin
8392
"displayName": "ACME",
8493
"fee": {
8594
"percentage": "1"
95+
},
96+
validation: {
97+
device:{
98+
ip:'1.2.3.4',
99+
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)'
100+
}
86101
}
87102
},
88103
"refund": {
@@ -118,6 +133,23 @@ We recommend that you use `XRP` for testing purposes when integrating Topper sin
118133
</TabItem>
119134
</Tabs>
120135

136+
### Custom partner validation
137+
138+
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.
139+
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.
140+
If you plan on using hashed validation, please check the example below to see how you should hash your data.
141+
142+
```js
143+
import { createHash } from 'node:crypto';
144+
145+
await createHash('sha256')
146+
.update('1.2.3.4')
147+
.digest('hex');
148+
```
149+
150+
:::note
151+
When validating user IP, if the IP versions mismatch, validation will be partially (plain string validation) or entirely (hashed validation) skipped.
152+
121153
## Events
122154

123155
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,23 @@ 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+
- `ip` (_optional_): User IP on partner's side that we should validate remains the same.
29+
- `user-agent` (_optional_): User agent used on partner's side that we should validate remains the same.
30+
- `encrypted` (_optional_): Encrypted parameters to validate.
31+
- `alg` (_optional_): Algorithm used to hash the fields. In case no algorithm is set, we'll be assumed that `sha256` was used.
32+
- `fields`: Fields that have been hashed.
33+
- `hash`: Result of hashing the fields appended in the given order, without any extra characters or whitespaces, using the given algorithm.
34+
- `ipVersion` (_optional_): Version of IP value used on the hash.
2635
- `partnerFee` (_deprecated_): Use `partner.fee` instead.
2736
- `simulation` (_optional_): Simulation object.
2837
- `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 +80,18 @@ We recommend that you use `XRP` for testing purposes when integrating Topper sin
7180
"sub": "b9fe022b-f436-49e1-bb89-6f2e8eabf336",
7281
// highlight-start
7382
"partner": {
83+
"continueUrl": "https://example.com",
84+
"continueUrlTarget": "new-tab",
7485
"displayName": "ACME",
7586
"fee": {
7687
"percentage": "1"
7788
},
78-
"continueUrl": "https://example.com",
79-
"continueUrlTarget": "new-tab"
89+
validation: {
90+
device:{
91+
ip:'1.2.3.4',
92+
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)'
93+
}
94+
}
8095
},
8196
"simulation": {
8297
"country": "US"
@@ -109,6 +124,22 @@ We recommend that you use `XRP` for testing purposes when integrating Topper sin
109124
</TabItem>
110125
</Tabs>
111126

127+
### Custom partner validation
128+
129+
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.
130+
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.
131+
If you plan on using hashed validation, please check the example below to see how you should hash your data.
132+
133+
```js
134+
import { createHash } from 'node:crypto';
135+
136+
await createHash('sha256')
137+
.update('1.2.3.4')
138+
.digest('hex');
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)