Skip to content

Commit bccd9a6

Browse files
zangetsouuandregoncalvesdev
authored andcommitted
Add partner validation documentation
1 parent 1d90c6c commit bccd9a6

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`.
@@ -86,6 +94,12 @@ We recommend that you use `XRP` for testing purposes when integrating Topper sin
8694
"displayName": "ACME",
8795
"fee": {
8896
"percentage": "1"
97+
},
98+
validation: {
99+
device:{
100+
ip:'1.2.3.4',
101+
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)'
102+
}
89103
}
90104
},
91105
"refund": {
@@ -121,6 +135,23 @@ We recommend that you use `XRP` for testing purposes when integrating Topper sin
121135
</TabItem>
122136
</Tabs>
123137

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

126157
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
- `reusableKYC` (_optional_): An object to provide a KYC shareable token.
2836
- `provider` (_required_): Provider that issued the shareable token.
@@ -74,12 +82,18 @@ We recommend that you use `XRP` for testing purposes when integrating Topper sin
7482
"sub": "b9fe022b-f436-49e1-bb89-6f2e8eabf336",
7583
// highlight-start
7684
"partner": {
85+
"continueUrl": "https://example.com",
86+
"continueUrlTarget": "new-tab",
7787
"displayName": "ACME",
7888
"fee": {
7989
"percentage": "1"
8090
},
81-
"continueUrl": "https://example.com",
82-
"continueUrlTarget": "new-tab"
91+
validation: {
92+
device:{
93+
ip:'1.2.3.4',
94+
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)'
95+
}
96+
}
8397
},
8498
"simulation": {
8599
"country": "US"
@@ -112,6 +126,23 @@ We recommend that you use `XRP` for testing purposes when integrating Topper sin
112126
</TabItem>
113127
</Tabs>
114128

129+
### Custom partner validation
130+
131+
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.
132+
We accept this validation parameters as plain strings 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.
133+
If you plan on using hashed validation, please check the example below to see how you should hash your data.
134+
135+
```js
136+
import { createHash } from 'node:crypto';
137+
138+
await createHash('sha256')
139+
.update('1.2.3.4')
140+
.digest('hex');
141+
```
142+
143+
:::note
144+
When validating user IP, if the IP versions mismatch, validation will be partially (plain string validation) or entirely (hashed validation) skipped.
145+
115146
### Recipient edit mode
116147

117148
<Tabs>

0 commit comments

Comments
 (0)