2024-10-23 15:24:52 +02:00
import OnboardingHeader from '../../ReusableComponents/OnboardingHeader.js' ;
2024-10-23 08:56:47 +02:00
import { _ _ , sprintf } from '@wordpress/i18n' ;
import { Button , TextControl } from '@wordpress/components' ;
2024-10-23 15:24:52 +02:00
import PaymentMethodIcons from '../../ReusableComponents/PaymentMethodIcons' ;
import SettingsToggleBlock from '../../ReusableComponents/SettingsToggleBlock' ;
import Separator from '../../ReusableComponents/Separator' ;
2024-10-23 16:31:00 +02:00
import { useOnboardingDetails } from '../../../data' ;
2024-10-24 16:58:03 +02:00
import DataStoreControl from '../../ReusableComponents/DataStoreControl' ;
2024-10-23 08:56:47 +02:00
2024-10-24 06:35:48 +02:00
const StepWelcome = ( { setStep , currentStep } ) => {
2024-10-23 08:56:47 +02:00
return (
< div className = "ppcp-r-page-welcome" >
< OnboardingHeader
title = { _ _ (
'Welcome to PayPal Payments' ,
'woocommerce-paypal-payments'
) }
description = { _ _ (
'Your all-in-one checkout solution with PayPal, Venmo, Pay Later, all major credit/debit cards, Apple Pay, Google Pay, and more.' ,
'woocommerce-paypal-payments'
) }
/ >
< div className = "ppcp-r-inner-container" >
< PaymentMethodIcons icons = "all" / >
< WelcomeFeatures / >
< Button
className = "ppcp-r-button-activate-paypal"
variant = "primary"
2024-10-24 06:35:48 +02:00
onClick = { ( ) => setStep ( currentStep + 1 ) }
2024-10-23 08:56:47 +02:00
>
{ _ _ (
'Activate PayPal Payments' ,
'woocommerce-paypal-payments'
) }
< / B u t t o n >
< Separator
className = "ppcp-r-page-welcome-or-separator"
text = { _ _ ( 'or' , 'woocommerce-paypal-payments' ) }
/ >
< WelcomeForm / >
< / d i v >
< / d i v >
) ;
} ;
const WelcomeFeatures = ( ) => {
return (
< div className = "ppcp-r-welcome-features" >
< div className = "ppcp-r-welcome-features__col" >
< span > { _ _ ( 'Deposits' , 'woocommerce-paypal-payments' ) } < / s p a n >
< p > { _ _ ( 'Instant' , 'woocommerce-paypal-payments' ) } < / p >
< / d i v >
< div className = "ppcp-r-welcome-features__col" >
< span >
{ _ _ ( 'Payment Capture' , 'woocommerce-paypal-payments' ) }
< / s p a n >
< p >
{ _ _ (
'Authorize only or Capture' ,
'woocommerce-paypal-payments'
) }
< / p >
< / d i v >
< div className = "ppcp-r-welcome-features__col" >
< span >
{ _ _ (
'Recurring payments' ,
'woocommerce-paypal-payments'
) }
< / s p a n >
< p > { _ _ ( 'Supported' , 'woocommerce-paypal-payments' ) } < / p >
< / d i v >
< / d i v >
) ;
} ;
const WelcomeForm = ( ) => {
2024-10-23 16:31:00 +02:00
const {
isSandboxMode ,
setSandboxMode ,
isManualConnectionMode ,
setManualConnectionMode ,
2024-10-23 18:17:08 +02:00
clientId ,
setClientId ,
clientSecret ,
setClientSecret ,
2024-10-23 16:31:00 +02:00
} = useOnboardingDetails ( ) ;
2024-10-23 08:56:47 +02:00
const advancedUsersDescription = sprintf (
// translators: %s: Link to PayPal REST application guide
_ _ (
'For advanced users: Connect a custom PayPal REST app for full control over your integration. For more information on creating a PayPal REST application, <a href="%s">click here</a>.' ,
'woocommerce-paypal-payments'
) ,
'#'
) ;
return (
< >
< SettingsToggleBlock
label = { _ _ (
'Enable Sandbox Mode' ,
'woocommerce-paypal-payments'
) }
description = { _ _ (
'Activate Sandbox mode to safely test PayPal with sample data. Once your store is ready to go live, you can easily switch to your production account.' ,
'woocommerce-paypal-payments'
) }
2024-10-23 16:31:00 +02:00
isToggled = { ! ! isSandboxMode }
setToggled = { setSandboxMode }
2024-10-23 08:56:47 +02:00
>
< Button variant = "secondary" >
{ _ _ ( 'Connect Account' , 'woocommerce-paypal-payments' ) }
< / B u t t o n >
< / S e t t i n g s T o g g l e B l o c k >
< Separator className = "ppcp-r-page-welcome-mode-separator" / >
< SettingsToggleBlock
label = { _ _ (
'Manually Connect - TODO missing link' ,
'woocommerce-paypal-payments'
) }
description = { advancedUsersDescription }
2024-10-23 16:31:00 +02:00
isToggled = { ! ! isManualConnectionMode }
setToggled = { setManualConnectionMode }
2024-10-23 08:56:47 +02:00
>
2024-10-24 16:58:03 +02:00
< DataStoreControl
control = { TextControl }
2024-10-23 08:56:47 +02:00
label = { _ _ (
'Sandbox Client ID' ,
'woocommerce-paypal-payments'
) }
2024-10-24 16:58:03 +02:00
value = { clientId }
onChange = { setClientId }
/ >
< DataStoreControl
control = { TextControl }
2024-10-23 08:56:47 +02:00
label = { _ _ (
'Sandbox Secret Key' ,
'woocommerce-paypal-payments'
) }
2024-10-24 16:58:03 +02:00
value = { clientSecret }
onChange = { setClientSecret }
2024-10-23 08:56:47 +02:00
type = "password"
2024-10-24 16:58:03 +02:00
/ >
2024-10-23 08:56:47 +02:00
< Button variant = "secondary" >
{ _ _ ( 'Connect Account' , 'woocommerce-paypal-payments' ) }
< / B u t t o n >
< / S e t t i n g s T o g g l e B l o c k >
< / >
) ;
} ;
export default StepWelcome ;