@@ -32,14 +32,10 @@ public function __construct() {
3232 $ this ->description = $ this ->get_option ('description ' );
3333 $ this ->enabled = $ this ->get_option ('enabled ' );
3434
35- // thirdweb specific settings
36- // Use .env value as default if WooCommerce setting is empty
37- $ env_client_id = thirdweb_wc_get_env ('THIRDWEB_CLIENT_ID ' , '' );
38- $ this ->client_id = $ this ->get_option ('client_id ' ) ?: $ env_client_id ;
35+ // thirdweb specific settings (no Client ID needed for iframe widget)
3936 $ this ->seller_wallet = $ this ->get_option ('seller_wallet ' );
4037 $ this ->chain_id = $ this ->get_option ('chain_id ' );
4138 $ this ->token_address = $ this ->get_option ('token_address ' );
42- $ this ->theme = $ this ->get_option ('theme ' );
4339
4440 // Save settings hook
4541 add_action ('woocommerce_update_options_payment_gateways_ ' . $ this ->id , [$ this , 'process_admin_options ' ]);
@@ -69,23 +65,10 @@ public function init_form_fields() {
6965 'description ' => __ ('Payment method description shown at checkout ' , 'thirdweb-wc ' ),
7066 'default ' => __ ('Pay securely with USDC, USDT or other stablecoins from any wallet. ' , 'thirdweb-wc ' ),
7167 ],
72- 'client_id ' => [
73- 'title ' => __ ('thirdweb Client ID ' , 'thirdweb-wc ' ),
74- 'type ' => 'text ' ,
75- 'description ' => sprintf (
76- __ ('Get your Client ID from <a href="%s" target="_blank">thirdweb Dashboard</a>. Create a new project if you haven \'t already. Can also be set via .env file for development. ' , 'thirdweb-wc ' ),
77- 'https://thirdweb.com/dashboard '
78- ),
79- 'default ' => thirdweb_wc_get_env ('THIRDWEB_CLIENT_ID ' , '' ),
80- 'placeholder ' => __ ('e.g., abc123def456... ' , 'thirdweb-wc ' ),
81- ],
8268 'seller_wallet ' => [
8369 'title ' => __ ('Seller Wallet Address ' , 'thirdweb-wc ' ),
8470 'type ' => 'text ' ,
85- 'description ' => sprintf (
86- __ ('Your project wallet address that will receive all payments. Get this from your <a href="%s" target="_blank">thirdweb project dashboard</a>. ' , 'thirdweb-wc ' ),
87- 'https://thirdweb.com/dashboard '
88- ),
71+ 'description ' => __ ('Your wallet address that will receive all payments. Use any Ethereum-compatible wallet (MetaMask, Coinbase Wallet, etc.). ' , 'thirdweb-wc ' ),
8972 'default ' => '' ,
9073 'placeholder ' => __ ('0x... ' , 'thirdweb-wc ' ),
9174 'custom_attributes ' => [
@@ -108,21 +91,10 @@ public function init_form_fields() {
10891 'token_address ' => [
10992 'title ' => __ ('Token Address (Optional) ' , 'thirdweb-wc ' ),
11093 'type ' => 'text ' ,
111- 'description ' => __ ('USDC/USDT contract address for the chain above. Make sure the token address matches your selected chain. Leave empty to accept the native token (ETH, MATIC, etc.) . Default is USDC on Base (chain 8453). ' , 'thirdweb-wc ' ),
94+ 'description ' => __ ('USDC/USDT contract address for the chain above. Make sure the token address matches your selected chain. Leave empty to accept any stablecoin . Default is USDC on Base (chain 8453). ' , 'thirdweb-wc ' ),
11295 'default ' => '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 ' , // USDC on Base
11396 'placeholder ' => __ ('0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 ' , 'thirdweb-wc ' ),
11497 ],
115- 'theme ' => [
116- 'title ' => __ ('Widget Theme ' , 'thirdweb-wc ' ),
117- 'type ' => 'select ' ,
118- 'description ' => __ ('Choose the color theme for the checkout widget. Light theme is recommended for most sites. ' , 'thirdweb-wc ' ),
119- 'default ' => 'light ' ,
120- 'desc_tip ' => true ,
121- 'options ' => [
122- 'light ' => __ ('Light ' , 'thirdweb-wc ' ),
123- 'dark ' => __ ('Dark ' , 'thirdweb-wc ' ),
124- ],
125- ],
12698 ];
12799 }
128100
@@ -134,15 +106,24 @@ public function payment_fields() {
134106 echo wpautop (wptexturize ($ this ->description ));
135107 }
136108
137- // Container for React to mount the CheckoutWidget
138- echo '<div id="thirdweb-checkout-widget"
139- data-client-id=" ' . esc_attr ($ this ->client_id ) . '"
140- data-seller=" ' . esc_attr ($ this ->seller_wallet ) . '"
141- data-chain-id=" ' . esc_attr ($ this ->chain_id ) . '"
142- data-token-address=" ' . esc_attr ($ this ->token_address ) . '"
143- data-amount=" ' . esc_attr (WC ()->cart ->get_total ('edit ' )) . '"
144- data-currency=" ' . esc_attr (get_woocommerce_currency ()) . '">
145- </div> ' ;
109+ // Container for iframe checkout widget (legacy checkout)
110+ $ amount = WC ()->cart ->get_total ('edit ' );
111+ $ params = [
112+ 'chain ' => $ this ->chain_id ,
113+ 'amount ' => $ amount ,
114+ 'seller ' => $ this ->seller_wallet ,
115+ ];
116+
117+ // Only add tokenAddress if provided
118+ if (!empty ($ this ->token_address )) {
119+ $ params ['tokenAddress ' ] = $ this ->token_address ;
120+ }
121+
122+ $ iframe_url = 'https://thirdweb.com/bridge/checkout-widget? ' . http_build_query ($ params );
123+
124+ echo '<div id="thirdweb-checkout-widget"> ' ;
125+ echo '<iframe src=" ' . esc_url ($ iframe_url ) . '" height="700px" width="100%" style="border: 0;" title="thirdweb Checkout Widget"></iframe> ' ;
126+ echo '</div> ' ;
146127
147128 // Hidden field to store transaction hash
148129 echo '<input type="hidden" name="thirdweb_tx_hash" id="thirdweb_tx_hash" value="" /> ' ;
@@ -199,8 +180,17 @@ public function process_payment($order_id) {
199180 * Verify transaction on-chain
200181 */
201182 private function verify_transaction ($ tx_hash , $ order ) {
202- // Use thirdweb RPC to verify the transaction
203- $ rpc_url = 'https:// ' . $ this ->chain_id . '.rpc.thirdweb.com/ ' . $ this ->client_id ;
183+ // Use public RPC endpoint to verify the transaction
184+ // No Client ID needed - using public RPC endpoints
185+ $ rpc_endpoints = [
186+ '1 ' => 'https://eth.llamarpc.com ' , // Ethereum
187+ '8453 ' => 'https://base.llamarpc.com ' , // Base
188+ '137 ' => 'https://polygon.llamarpc.com ' , // Polygon
189+ '42161 ' => 'https://arbitrum.llamarpc.com ' , // Arbitrum
190+ '10 ' => 'https://optimism.llamarpc.com ' , // Optimism
191+ ];
192+
193+ $ rpc_url = $ rpc_endpoints [$ this ->chain_id ] ?? 'https://eth.llamarpc.com ' ;
204194
205195 $ response = wp_remote_post ($ rpc_url , [
206196 'headers ' => ['Content-Type ' => 'application/json ' ],
@@ -210,10 +200,13 @@ private function verify_transaction($tx_hash, $order) {
210200 'params ' => [$ tx_hash ],
211201 'id ' => 1 ,
212202 ]),
203+ 'timeout ' => 10 ,
213204 ]);
214205
215206 if (is_wp_error ($ response )) {
216- return false ;
207+ // If RPC fails, still allow the order (transaction hash is recorded)
208+ // Admin can manually verify on block explorer
209+ return true ;
217210 }
218211
219212 $ body = json_decode (wp_remote_retrieve_body ($ response ), true );
@@ -233,13 +226,11 @@ private function verify_transaction($tx_hash, $order) {
233226 */
234227 public function get_frontend_config () {
235228 return [
236- 'clientId ' => $ this ->client_id ,
237229 'seller ' => $ this ->seller_wallet ,
238230 'chainId ' => (int ) $ this ->chain_id ,
239231 'tokenAddress ' => $ this ->token_address ,
240232 'title ' => $ this ->title ,
241233 'description ' => $ this ->description ,
242- 'theme ' => $ this ->theme ?: 'light ' ,
243234 ];
244235 }
245236}
0 commit comments