Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PRESS4-483 | Connect a payment process step is not working in BH Plugin Dashboard #221

Merged
merged 5 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build/index.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('lodash', 'moment', 'react', 'wp-api-fetch', 'wp-data', 'wp-date', 'wp-dom-ready', 'wp-element', 'wp-i18n', 'wp-url'), 'version' => '2594edd0d7eff5838e6c');
<?php return array('dependencies' => array('lodash', 'moment', 'react', 'wp-api-fetch', 'wp-data', 'wp-date', 'wp-dom-ready', 'wp-element', 'wp-i18n', 'wp-url'), 'version' => '64d8ebf708a365ec7d39');
253 changes: 133 additions & 120 deletions src/components/Paypal.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,137 +15,150 @@ import { ThirdPartyIntegration } from "./ThirdPartyIntegration";

const Paypal = ({ notify }) => {
useEffect(() => {
const ppButton = document.querySelector(".yith-btn-paypal");
window?.PAYPAL?.apps?.Signup?.loadScripts(document, "script");
window?.PAYPAL?.apps?.Signup?.render();
const ppButton = document.querySelector( ".yith-btn-paypal" );
if( ppButton ){
(function( d, s, id ) {
var js, ref = d.getElementsByTagName( s )[0];
if ( !d.getElementById( id ) ) {
js = d.createElement( s );
js.id = id;
js.async = true;
js.src = "https://www.paypal.com/webapps/merchantboarding/js/lib/lightbox/partner.js";
ref.parentNode.insertBefore( js, ref );
}
}( document, "script", "paypal-js" ));
window?.PAYPAL?.apps?.Signup?.loadScripts( document, "script" );
window?.PAYPAL?.apps?.Signup?.render();
}

return ()=>{
const panel = document.querySelector('#payment-details');
const panel = document.querySelector( '#payment-details' );
if( !panel && ppButton ){
ppButton.remove();
}
};
});
return (
<ThirdPartyIntegration
id="paypal"
title={__("Paypal", "wp-module-ecommerce")}
description={__(
"Online payments built for success. We help you do business in 200+ markets and 100+ currencies—even if your customers don't have PayPal.",
"wp-module-ecommerce"
)}
notify={notify}
>
{({ integrationStatus, onConnect, isInstalling }) => {
const isSetupComplete = integrationStatus?.complete;
const environment = integrationStatus?.details?.environment;
return (
<div className="nfd-border nfd-rounded-md nfd-p-6">
<div
className={classNames(
"max-[359px]:nfd-flex-col",
"min-[360px]:nfd-flex nfd-justify-between nfd-items-center min-[360px]:nfd-mb-8"
)}
>
<PaypalBrand />
{isInstalling ? (
<Button
variant="secondary"
isLoading
className={classNames(
"max-[359px]:nfd-my-2",
"min-[360px]:nfd-m-0"
)}
>
{__("Installing...", "wp-module-ecommerce")}
</Button>
) : isSetupComplete ? (
<Button
variant="secondary"
as="a"
href={integrationStatus?.integration?.plugin?.url}
className={classNames(
"max-[359px]:nfd-my-2",
"min-[360px]:nfd-m-0"
)}
>
{__("Manage", "wp-module-ecommerce")}
</Button>
) : typeof yith_ppwc_login !== "undefined" &&
!parseInt(yith_ppwc_login?.liveConnected) ? (
<Link
href={yith_ppwc_login.loginURL}
variant="primary"
className="nfd-button nfd-button--primary yith-btn-paypal nfd-text-white"
target="_blank"
data-paypal-onboard-complete="onboardedCallback"
data-paypal-button="PPLtBlue"
>
{__("Connect", "wp-module-ecommerce")}
</Link>
) : (
<Button
onClick={onConnect}
className={classNames(
"max-[359px]:nfd-my-2",
"min-[360px]:nfd-m-0"
)}
>
{__("Connect", "wp-module-ecommerce")}
</Button>
)}
</div>
{isSetupComplete && environment && (
<div className="nfd-flex nfd-gap-4 nfd-mt-4">
<span>{__("Environment:", "wp-module-ecommerce")}</span>
<Badge
size="large"
variant={environment === "sandbox" ? "upsell" : "plain"}
className={classNames(
"nfd-text-sm nfd-capitalize",
environment === "live" && "nfd-bg-[#178113] nfd-text-white"
)}
>
{environment}
</Badge>
</div>
)}
{!isSetupComplete && (
<div className="nfd-space-y-4 nfd-text-[#5B5B5B]">
<Title size="3">
{__("Provides flexible checkout options", "wp-module-ecommerce")}
</Title>
<ul className="nfd-pl-5 nfd-list-disc">
<li>{__("PayPal Buy Now Pay Later", "wp-module-ecommerce")}</li>
<li>{__("White-Labeling", "wp-module-ecommerce")}</li>
<li>
{__(
"Country-specific payment methods",
"wp-module-ecommerce"
<ThirdPartyIntegration
id="paypal"
title={__("Paypal", "wp-module-ecommerce")}
description={__(
"Online payments built for success. We help you do business in 200+ markets and 100+ currencies—even if your customers don't have PayPal.",
"wp-module-ecommerce"
)}
notify={notify}
>
{({ integrationStatus, onConnect, isInstalling }) => {
const isSetupComplete = integrationStatus?.complete;
const environment = integrationStatus?.details?.environment;
return (
<div className="nfd-border nfd-rounded-md nfd-p-6">
<div
className={classNames(
"max-[359px]:nfd-flex-col",
"min-[360px]:nfd-flex nfd-justify-between nfd-items-center min-[360px]:nfd-mb-8"
)}
</li>
</ul>
<Title size="3">
{__(
" Supports many popular payment methods",
"wp-module-ecommerce"
>
<PaypalBrand />
{isInstalling ? (
<Button
variant="secondary"
isLoading
className={classNames(
"max-[359px]:nfd-my-2",
"min-[360px]:nfd-m-0"
)}
>
{__("Installing...", "wp-module-ecommerce")}
</Button>
) : isSetupComplete ? (
<Button
variant="secondary"
as="a"
href={integrationStatus?.integration?.plugin?.url}
className={classNames(
"max-[359px]:nfd-my-2",
"min-[360px]:nfd-m-0"
)}
>
{__("Manage", "wp-module-ecommerce")}
</Button>
) : typeof yith_ppwc_login !== "undefined" &&
!parseInt(yith_ppwc_login?.liveConnected) ? (
<Link
href={yith_ppwc_login.loginURL}
variant="primary"
className="nfd-button nfd-button--primary yith-btn-paypal nfd-text-white"
target="_blank"
data-paypal-onboard-complete="onboardedCallback"
data-paypal-button="PPLtBlue"
>
{__("Connect", "wp-module-ecommerce")}
</Link>
) : (
<Button
onClick={onConnect}
className={classNames(
"max-[359px]:nfd-my-2",
"min-[360px]:nfd-m-0"
)}
>
{__("Connect", "wp-module-ecommerce")}
</Button>
)}
</Title>
<div className="nfd-flex nfd-items-end nfd-gap-2 nfd-flex-wrap">
<VisaBrand />
<MasterCardBrand />
<AmexBrand />
<DiscoverBrand />
<VenmoBrand />
<IdealBrand />
<GiroPayBrand />
<SofortBrand />
</div>
{isSetupComplete && environment && (
<div className="nfd-flex nfd-gap-4 nfd-mt-4">
<span>{__("Environment:", "wp-module-ecommerce")}</span>
<Badge
size="large"
variant={environment === "sandbox" ? "upsell" : "plain"}
className={classNames(
"nfd-text-sm nfd-capitalize",
environment === "live" && "nfd-bg-[#178113] nfd-text-white"
)}
>
{environment}
</Badge>
</div>
)}
{!isSetupComplete && (
<div className="nfd-space-y-4 nfd-text-[#5B5B5B]">
<Title size="3">
{__("Provides flexible checkout options", "wp-module-ecommerce")}
</Title>
<ul className="nfd-pl-5 nfd-list-disc">
<li>{__("PayPal Buy Now Pay Later", "wp-module-ecommerce")}</li>
<li>{__("White-Labeling", "wp-module-ecommerce")}</li>
<li>
{__(
"Country-specific payment methods",
"wp-module-ecommerce"
)}
</li>
</ul>
<Title size="3">
{__(
" Supports many popular payment methods",
"wp-module-ecommerce"
)}
</Title>
<div className="nfd-flex nfd-items-end nfd-gap-2 nfd-flex-wrap">
<VisaBrand />
<MasterCardBrand />
<AmexBrand />
<DiscoverBrand />
<VenmoBrand />
<IdealBrand />
<GiroPayBrand />
<SofortBrand />
</div>
</div>
)}
</div>
)}
</div>
);
}}
</ThirdPartyIntegration>
);
}}
</ThirdPartyIntegration>
);
};
export default Paypal;
25 changes: 14 additions & 11 deletions src/components/YITHPlugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,20 @@ export function YITHPlugins({ woo, wpModules }) {
{ refreshInterval: 10 * 1000, isPaused: () => !woo.isActive }
);
const [yithProducts, setYithProducts] = useState([]);
useEffect(async () => {
const data = await apiFetch({
url: NewfoldRuntime.createApiUrl("/newfold-marketplace/v1/marketplace"),
});
setYithProducts(
data?.products?.data.filter(
(product) =>
product.categories?.includes("eCommerce") &&
product.categories?.length === 1
)
);
useEffect( () => {
const fecthApi = async () => {
const data = await apiFetch({
url: NewfoldRuntime.createApiUrl("/newfold-marketplace/v1/marketplace"),
});
setYithProducts(
data?.products?.data.filter(
(product) =>
product.categories?.includes("eCommerce") &&
product.categories?.length === 1
)
);
}
fecthApi()
}, []);
if (!woo.isActive) {
return null;
Expand Down
Loading