2024-10-31 14:44:45 +01:00
import OnboardingHeader from '../../ReusableComponents/OnboardingHeader' ;
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-31 17:41:01 +01:00
import { useOnboardingStepWelcome , useManualConnect } from '../../../data' ;
2024-10-24 16:58:03 +02:00
import DataStoreControl from '../../ReusableComponents/DataStoreControl' ;
2024-11-05 13:49:38 +04:00
import BadgeBox from "../../ReusableComponents/BadgeBox" ;
2024-10-23 08:56:47 +02:00
2024-10-31 09:47:06 +02:00
const StepWelcome = ( { setStep , currentStep , setCompleted } ) => {
2024-10-23 08:56:47 +02:00
return (
2024-11-05 13:49:38 +04:00
< div className = "ppcp-r-page-welcome" >
< OnboardingHeader
title = { _ _ (
'Welcome to PayPal Payments' ,
'woocommerce-paypal-payments'
) }
description = { _ _ (
'Your all-in-one integration for PayPal checkout solutions that enable buyers to pay via PayPal, Pay Later, all major credit/debit cards, Apple Pay, Google Pay, and more.' ,
'woocommerce-paypal-payments'
) }
/ >
< div className = "ppcp-r-inner-container" >
< WelcomeFeatures / >
< PaymentMethodIcons icons = "all" / >
< p className = "ppcp-r-button__description" > { _ _ (
` Click the button below to be guided through connecting your existing PayPal account or creating a new one.You will be able to choose the payment options that are right for your store. ` ,
'woocommerce-paypal-payments'
) }
< / p >
< Button
className = "ppcp-r-button-activate-paypal"
variant = "primary"
onClick = { ( ) => setStep ( currentStep + 1 ) }
>
{ _ _ (
'Activate PayPal Payments' ,
'woocommerce-paypal-payments'
) }
< / B u t t o n >
< / d i v >
< Separator className = "ppcp-r-page-welcome-mode-separator" / >
< WelcomeDocs / >
< WelcomeForm setCompleted = { setCompleted } / >
< / d i v >
) ;
2024-10-23 08:56:47 +02:00
} ;
const WelcomeFeatures = ( ) => {
2024-11-05 13:49:38 +04:00
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" >
2024-10-23 08:56:47 +02:00
< span >
2024-11-05 13:49:38 +04:00
{ _ _ ( 'Payment Capture' , 'woocommerce-paypal-payments' ) }
2024-10-23 08:56:47 +02:00
< / s p a n >
2024-11-05 13:49:38 +04:00
< p >
{ _ _ (
'Authorize only or Capture' ,
'woocommerce-paypal-payments'
) }
< / p >
< / d i v >
< div className = "ppcp-r-welcome-features__col" >
2024-10-23 08:56:47 +02:00
< span >
2024-11-05 13:49:38 +04:00
{ _ _ (
'Recurring payments' ,
'woocommerce-paypal-payments'
) }
2024-10-23 08:56:47 +02:00
< / s p a n >
2024-11-05 13:49:38 +04:00
< p > { _ _ ( 'Supported' , 'woocommerce-paypal-payments' ) } < / p >
< / d i v >
< / d i v >
) ;
} ;
const WelcomeDocs = ( ) => {
return (
< div className = "ppcp-r-welcome-docs" >
< h2 className = "ppcp-r-welcome-docs__title" > { _ _ ( ` Want to know more about PayPal Payments? ` , 'woocommerce-paypal-payments' ) } < / h 2 >
< div className = "ppcp-r-welcome-docs__wrapper" >
< div className = "ppcp-r-welcome-docs__col" >
< BadgeBox
title = { _ _ ( 'PayPal Checkout' , 'woocommerce-paypal-payments' ) }
textBadge = { _ _ ( 'from 3.49% + $0.49 USD1' , 'woocommerce-paypal-payments' ) }
description = { _ _ (
'Our all-in-one checkout solution lets you offer PayPal, Venmo, Pay Later options, and more to help maximise conversion' ,
'woocommerce-paypal-payments'
) }
/ >
< BadgeBox title = { _ _ ( 'Included in PayPal Checkout' , 'woocommerce-paypal-payments' ) } / >
< BadgeBox
title = { _ _ ( 'Pay with PayPal' , 'woocommerce-paypal-payments' ) }
titleTag = 'h4'
imageBadge = { [ 'icon-button-paypal.svg' ] }
description = { sprintf (
// translators: %s: Link to PayPal REST application guide
_ _ (
'Our brand recognition helps give customers the confidence to buy. <a target="_blank" href="%s">Learn more</a>' ,
'woocommerce-paypal-payments'
) ,
'https://woocommerce.com/document/woocommerce-paypal-payments/#manual-credential-input '
) }
/ >
< Separator className = "ppcp-r-page-welcome-mode-separator" / >
< BadgeBox
title = { _ _ ( 'Pay Later' , 'woocommerce-paypal-payments' ) }
titleTag = 'h4'
imageBadge = { [ 'icon-payment-method-paypal-small.svg' ] }
description = { sprintf (
// translators: %s: Link to PayPal REST application guide
_ _ (
'Offer installment payment options and get paid upfront - at no extra cost to you. <a target="_blank" href="%s">Learn more</a>' ,
'woocommerce-paypal-payments'
) ,
'https://woocommerce.com/document/woocommerce-paypal-payments/#manual-credential-input '
) }
/ >
< Separator className = "ppcp-r-page-welcome-mode-separator" / >
< BadgeBox
title = { _ _ ( 'Venmo' , 'woocommerce-paypal-payments' ) }
titleTag = 'h4'
imageBadge = { [ 'icon-button-venmo.svg' ] }
description = { sprintf (
// translators: %s: Link to PayPal REST application guide
_ _ (
'Automatically offer Venmo checkout to millions of active users. <a target="_blank" href="%s">Learn more</a>' ,
'woocommerce-paypal-payments'
) ,
'https://woocommerce.com/document/woocommerce-paypal-payments/#manual-credential-input '
) }
/ >
< Separator className = "ppcp-r-page-welcome-mode-separator" / >
< BadgeBox
title = { _ _ ( 'Crypto' , 'woocommerce-paypal-payments' ) }
titleTag = 'h4'
imageBadge = { [ 'icon-payment-method-crypto.svg' ] }
description = { sprintf (
// translators: %s: Link to PayPal REST application guide
_ _ (
'Let customers checkout with Crypto while you get paid in cash. <a target="_blank" href="%s">Learn more</a>' ,
'woocommerce-paypal-payments'
) ,
'https://woocommerce.com/document/woocommerce-paypal-payments/#manual-credential-input '
) }
/ >
< / d i v >
< div className = "ppcp-r-welcome-docs__col" >
< BadgeBox
title = { _ _ ( 'Optional payment methods' , 'woocommerce-paypal-payments' ) }
description = { _ _ ( 'with additional application' , 'woocommerce-paypal-payments' ) }
/ >
< BadgeBox
title = { _ _ ( 'Custom Card Fields' , 'woocommerce-paypal-payments' ) }
titleTag = 'h4'
imageBadge = { [ 'icon-button-visa.svg' , 'icon-button-mastercard.svg' , 'icon-button-amex.svg' , 'icon-button-discover.svg' ] }
textBadge = { _ _ ( 'from 2.59% + $0.49 USD1' , 'woocommerce-paypal-payments' ) }
description = { sprintf (
// translators: %s: Link to PayPal REST application guide
_ _ (
'Style the credit card fields to match your own style. Includes advanced processing with risk management, 3D Secure, fraud protection options, and chargeback protection. <a target="_blank" href="%s">Learn more</a>' ,
'woocommerce-paypal-payments'
) ,
'https://woocommerce.com/document/woocommerce-paypal-payments/#manual-credential-input '
) }
/ >
< Separator className = "ppcp-r-page-welcome-mode-separator" / >
< BadgeBox
title = { _ _ ( 'Digital Wallets' , 'woocommerce-paypal-payments' ) }
titleTag = 'h4'
imageBadge = { [ 'icon-button-apple-pay.svg' , 'icon-button-google-pay.svg' ] }
textBadge = { _ _ ( 'from 2.59% + $0.49 USD1' , 'woocommerce-paypal-payments' ) }
description = { sprintf (
// translators: %s: Link to PayPal REST application guide
_ _ (
'Accept Apple Pay on eligible devices and Google Pay through mobile and web. <a target="_blank" href="%s">Learn more</a>' ,
'woocommerce-paypal-payments'
) ,
'https://woocommerce.com/document/woocommerce-paypal-payments/#manual-credential-input '
) }
/ >
< Separator className = "ppcp-r-page-welcome-mode-separator" / >
< BadgeBox
title = { _ _ ( 'Alternative Payment Methods' , 'woocommerce-paypal-payments' ) }
titleTag = 'h4'
imageBadge = { [ 'icon-button-sepa.svg' , 'icon-button-ideal.svg' , 'icon-button-blik.svg' , 'icon-button-bancontact.svg' ] }
textBadge = { _ _ ( 'from 3.49% + $0.49 USD1' , 'woocommerce-paypal-payments' ) }
description = { sprintf (
// translators: %s: Link to PayPal REST application guide
_ _ (
'Seamless payments for customers across the globe using their preferred payment methods. <a target="_blank" href="%s">Learn more</a>' ,
'woocommerce-paypal-payments'
) ,
'https://woocommerce.com/document/woocommerce-paypal-payments/#manual-credential-input '
) }
/ >
< Separator className = "ppcp-r-page-welcome-mode-separator" / >
< BadgeBox
title = { _ _ ( '' , 'woocommerce-paypal-payments' ) }
titleTag = 'h4'
imageBadge = { [ 'icon-payment-method-fastlane-small.svg' ] }
textBadge = { _ _ ( 'from 2.59% + $0.49 USD1' , 'woocommerce-paypal-payments' ) }
description = { sprintf (
// translators: %s: Link to PayPal REST application guide
_ _ (
'Speed up guest checkout with Fatslane. Link a customer\'s email address to their payment details. <a target="_blank" href="%s">Learn more</a>' ,
'woocommerce-paypal-payments'
) ,
'https://woocommerce.com/document/woocommerce-paypal-payments/#manual-credential-input '
) }
/ >
< / d i v >
< / d i v >
< / d i v >
) ;
2024-10-23 08:56:47 +02:00
} ;
2024-11-05 13:49:38 +04:00
const WelcomeForm = ( { setCompleted } ) => {
const {
isSandboxMode ,
setSandboxMode ,
isManualConnectionMode ,
setManualConnectionMode ,
clientId ,
setClientId ,
clientSecret ,
setClientSecret ,
} = useOnboardingStepWelcome ( ) ;
2024-10-23 16:31:00 +02:00
2024-11-05 13:49:38 +04:00
const { connectManual } = useManualConnect ( ) ;
2024-10-31 09:47:06 +02:00
2024-11-05 13:49:38 +04:00
const handleConnect = async ( ) => {
try {
const res = await connectManual (
clientId ,
clientSecret ,
isSandboxMode
) ;
if ( ! res . success ) {
throw new Error ( 'Request failed.' ) ;
}
2024-10-31 09:47:06 +02:00
2024-11-05 13:49:38 +04:00
setCompleted ( true ) ;
} catch ( exc ) {
console . error ( exc ) ;
alert ( 'Connection failed.' ) ;
}
} ;
2024-10-31 09:47:06 +02:00
2024-11-05 13:49:38 +04: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 target="_blank" href="%s">click here</a>.' ,
'woocommerce-paypal-payments'
) ,
'https://woocommerce.com/document/woocommerce-paypal-payments/#manual-credential-input '
) ;
2024-10-23 08:56:47 +02:00
2024-11-05 13:49:38 +04:00
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'
) }
isToggled = { ! ! isSandboxMode }
setToggled = { setSandboxMode }
>
< 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' ,
'woocommerce-paypal-payments'
) }
description = { advancedUsersDescription }
isToggled = { ! ! isManualConnectionMode }
setToggled = { setManualConnectionMode }
>
< DataStoreControl
control = { TextControl }
label = {
isSandboxMode
? _ _ (
'Sandbox Client ID' ,
'woocommerce-paypal-payments'
)
: _ _ (
'Live Client ID' ,
'woocommerce-paypal-payments'
)
}
value = { clientId }
onChange = { setClientId }
/ >
< DataStoreControl
control = { TextControl }
label = {
isSandboxMode
? _ _ (
'Sandbox Secret Key' ,
'woocommerce-paypal-payments'
)
: _ _ (
'Live Secret Key' ,
'woocommerce-paypal-payments'
)
}
value = { clientSecret }
onChange = { setClientSecret }
type = "password"
/ >
< Button variant = "secondary" onClick = { handleConnect } >
{ _ _ ( '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 >
< / >
) ;
2024-10-23 08:56:47 +02:00
} ;
export default StepWelcome ;