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-458 | Show an warning in stripe #205

Merged
merged 9 commits into from
Jan 30, 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' => '6131043b9611749a390c');
<?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' => '159a2d5abe36aadd2e23');
37 changes: 19 additions & 18 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 20 additions & 15 deletions src/components/Stripe.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Badge, Button, Title } from "@newfold/ui-component-library";
import { Alert, Badge, Button, Title, Link } from "@newfold/ui-component-library";
import { useEffect, useRef } from "@wordpress/element";
import { __ } from "@wordpress/i18n";
import classNames from "classnames";
Expand All @@ -11,20 +11,22 @@ import { ReactComponent as MasterCardBrand } from "../icons/brands/mastercard.sv
import { ReactComponent as StripeBrand } from "../icons/brands/stripe.svg";
import { ReactComponent as VisaBrand } from "../icons/brands/visa.svg";
import { ThirdPartyIntegration } from "./ThirdPartyIntegration";
import { RuntimeSdk } from "../sdk/runtime";

const Stripe = ({ notify }) => {
const buttonRef = useRef();
const isHttp = window.location.protocol === "http:";

useEffect(() => {
let button = false;
if (window?.yithStripePayments?.connectOnboarding) {
button = window.yithStripePayments.connectOnboarding(buttonRef.current, {
reloadOnClose: false,
});
}
return () => window?.yithStripePayments?.onboardingButton?.destroy();
})

return () => button && button.destroy();
});
const handleClick = () => {
if (!window?.yithStripePayments?.onboardingButton?.$button?.is(buttonRef.current)) {
window.yithStripePayments.onboardingButton = window.yithStripePayments.connectOnboarding(buttonRef.current, { reloadOnClose: false });
window.yithStripePayments.onboardingButton.onClick();
}
}

return (
<ThirdPartyIntegration
Expand All @@ -40,18 +42,21 @@ const Stripe = ({ notify }) => {
const isSetupComplete = integrationStatus?.complete;
let environment = integrationStatus?.details?.environment;


if ( ! environment ) {
if (!environment) {
environment = 'test' === window?.yithStripePayments?.env ? 'test' : 'live';
}

const isLive = environment === "live";
return (
<div className="nfd-border nfd-rounded-md nfd-p-6">
{isHttp && isLive && <Alert variant="warning" className="nfd-mb-6">
{__("A secure connection is required when running Stripe Payments in Live mode; plugin is currently enabled, but no gateway will be available until you secure connection to your site through a valid SSL certificate.\
If you already have a valid SSL certificate, please change the url in", "wp-module-ecommerce")} <Link href={RuntimeSdk.adminUrl('options-general.php')}> {__("settings", "wp-module-ecommerce")}</Link> {__("page", "wp-module-ecommerce")}.
</Alert>}
<div className="nfd-flex nfd-justify-between nfd-mb-8">
<StripeBrand />
{!isInstalling ? (
<>
{isSetupComplete ? (
{isSetupComplete && integrationStatus?.integration?.plugin?.status ? (
<Button
variant="secondary"
as="a"
Expand All @@ -62,11 +67,11 @@ const Stripe = ({ notify }) => {
) : (
<>
{!integrationStatus?.integration?.plugin?.status ? (
<Button onClick={onConnect}>
<Button onClick={onConnect} >
{__("Install", "wp-module-ecommerce")}
</Button>
) : (
<Button ref={buttonRef}>
<Button ref={buttonRef} disabled={isHttp && isLive} onClick={handleClick}>
{__("Connect", "wp-module-ecommerce")}
</Button>
)}
Expand Down
Loading