Skip to content

Commit 3901805

Browse files
authored
Add preferredProvider in buyWithFiat (#4546)
1 parent 285321b commit 3901805

File tree

6 files changed

+21
-0
lines changed

6 files changed

+21
-0
lines changed

.changeset/yellow-donkeys-tie.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"thirdweb": patch
3+
---
4+
5+
Add preferredProvider to buyWithFiat

packages/thirdweb/src/pay/buyWithFiat/getQuote.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { ThirdwebClient } from "../../client/client.js";
22
import { getClientFetch } from "../../utils/fetch.js";
3+
import type { FiatProvider } from "../utils/commonTypes.js";
34
import { getPayBuyWithFiatQuoteEndpoint } from "../utils/definitions.js";
45

56
/**
@@ -82,6 +83,13 @@ export type GetBuyWithFiatQuoteParams = {
8283
* If erc20, will onramp native token + erc20
8384
*/
8485
toGasAmountWei?: string;
86+
87+
/**
88+
* Optional parameter to specify the preferred onramp provider.
89+
*
90+
* By default, we choose a recommended provider based on the location of the user, KYC status, and currency.
91+
*/
92+
preferredProvider?: FiatProvider;
8593
};
8694

8795
/**
@@ -303,6 +311,7 @@ export async function getBuyWithFiatQuote(
303311
purchaseData: params.purchaseData,
304312
fromAddress: params.fromAddress,
305313
toGasAmountWei: params.toGasAmountWei,
314+
preferredProvider: params.preferredProvider,
306315
}),
307316
});
308317

packages/thirdweb/src/pay/utils/commonTypes.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,5 @@ export type PayOnChainTransactionDetails = {
1616
completedAt?: string; // ISO DATE
1717
explorerLink?: string;
1818
};
19+
20+
export type FiatProvider = "STRIPE" | "TRANSAK" | "KADO";

packages/thirdweb/src/react/core/hooks/connection/ConnectButtonProps.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type { Chain } from "../../../../chains/types.js";
22
import type { ThirdwebClient } from "../../../../client/client.js";
33
import type { BuyWithCryptoStatus } from "../../../../pay/buyWithCrypto/getStatus.js";
44
import type { BuyWithFiatStatus } from "../../../../pay/buyWithFiat/getStatus.js";
5+
import type { FiatProvider } from "../../../../pay/utils/commonTypes.js";
56
import type { PreparedTransaction } from "../../../../transaction/prepare-transaction.js";
67
import type { Prettify } from "../../../../utils/type-utils.js";
78
import type { Account, Wallet } from "../../../../wallets/interfaces/wallet.js";
@@ -86,6 +87,7 @@ export type PayUIOptions = Prettify<
8687
prefillSource?: {
8788
currency?: "USD" | "CAD" | "GBP" | "EUR" | "JPY";
8889
};
90+
preferredProvider?: FiatProvider;
8991
}
9092
| false;
9193

packages/thirdweb/src/react/core/hooks/transaction/useSendTransaction.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { Chain } from "../../../../chains/types.js";
33
import { getGasPrice } from "../../../../gas/get-gas-price.js";
44
import type { BuyWithCryptoStatus } from "../../../../pay/buyWithCrypto/getStatus.js";
55
import type { BuyWithFiatStatus } from "../../../../pay/buyWithFiat/getStatus.js";
6+
import type { FiatProvider } from "../../../../pay/utils/commonTypes.js";
67
import { estimateGasCost } from "../../../../transaction/actions/estimate-gas-cost.js";
78
import type { GaslessOptions } from "../../../../transaction/actions/gasless/types.js";
89
import { sendTransaction } from "../../../../transaction/actions/send-transaction.js";
@@ -58,6 +59,7 @@ export type SendTransactionPayModalConfig =
5859
currency?: "USD" | "CAD" | "GBP" | "EUR" | "JPY";
5960
};
6061
testMode?: boolean;
62+
preferredProvider?: FiatProvider;
6163
};
6264
purchaseData?: object;
6365
/**

packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1352,6 +1352,7 @@ function FiatScreenContent(props: {
13521352
isTestMode: buyWithFiatOptions?.testMode,
13531353
purchaseData: props.payOptions.purchaseData,
13541354
fromAddress: payer.account.address,
1355+
preferredProvider: buyWithFiatOptions?.preferredProvider,
13551356
}
13561357
: undefined,
13571358
);

0 commit comments

Comments
 (0)