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

Feature: Add support for integrating Blink Payment with the Donor Dashboard #7632

Merged
merged 9 commits into from
Dec 2, 2024
5 changes: 4 additions & 1 deletion src/DonorDashboards/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,9 @@ public function getLoaderTemplatePath()
/**
* Enqueue assets for front-end donor dashboards
*
* @unreleased Add action to allow enqueueing additional assets.
* @since 2.11.0 Set script translations.
* @since 2.10.0
* @since 2.11.0 Set script translations.
*
* @return void
*/
Expand Down Expand Up @@ -175,6 +176,8 @@ public function loadAssets()
[],
null
);

do_action('give_donor_dashboard_enqueued_assets');
pauloiankoski marked this conversation as resolved.
Show resolved Hide resolved
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ import SubscriptionCancelModal from '../subscription-cancel-modal';
*/
const normalizeAmount = (float, decimals) => Number.parseFloat(float).toFixed(decimals);

/**
* @unreleased Add support for hiding amount controls via filter
*/
const SubscriptionManager = ({id, subscription}) => {
const gatewayRef = useRef();
const [isPauseModalOpen, setIsPauseModalOpen] = useState(false);
Expand All @@ -37,6 +40,11 @@ const SubscriptionManager = ({id, subscription}) => {

const subscriptionStatus = subscription.payment.status?.id || subscription.payment.status.label.toLowerCase();

const showAmountControls = wp.hooks.applyFilters(
'give_donor_dashboard_subscription_manager_show_amount_controls',
true,
subscription
);
jonwaldstein marked this conversation as resolved.
Show resolved Hide resolved
const showPausingControls =
subscription.gateway.can_pause && !['Quarterly', 'Yearly'].includes(subscription.payment.frequency);

Expand Down Expand Up @@ -95,14 +103,16 @@ const SubscriptionManager = ({id, subscription}) => {

return (
<div className={'give-donor-dashboard__subscription-manager'}>
<AmountControl
currency={subscription.payment.currency}
options={options}
max={max}
min={min}
value={amount}
onChange={setAmount}
/>
{showAmountControls && (
<AmountControl
currency={subscription.payment.currency}
options={options}
max={max}
min={min}
value={amount}
onChange={setAmount}
/>
)}
<PaymentMethodControl
jonwaldstein marked this conversation as resolved.
Show resolved Hide resolved
forwardedRef={gatewayRef}
label={__('Payment Method', 'give')}
Expand Down Expand Up @@ -135,7 +145,11 @@ const SubscriptionManager = ({id, subscription}) => {
</>
)}

<Button disabled={subscriptionStatus !== 'active'} classnames={subscriptionStatus !== 'active' && 'disabled'} onClick={handleUpdate}>
<Button
disabled={subscriptionStatus !== 'active'}
classnames={subscriptionStatus !== 'active' && 'disabled'}
onClick={handleUpdate}
>
{updated ? (
<Fragment>
{__('Updated', 'give')} <FontAwesomeIcon icon="check" fixedWidth />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import React from 'react';

import AuthorizeControl from './authorize-control';
import SquareControl from './square-control';
import StripeControl from './stripe-control';
import CardControl from './card-control';

import './style.scss';

/**
* @unreleased Add controller for Blink payment method.
*/
const PaymentMethodControl = (props) => {
switch (props.gateway.id) {
case 'stripe':
Expand All @@ -23,6 +28,11 @@ const PaymentMethodControl = (props) => {
case 'paypalpro': {
return <CardControl {...props} />;
}
case 'blink': {
// Donor Dashboard currently loads its own version of React so we need to pass it to the component
const Element = wp.hooks.applyFilters('give_donor_dashboard_blink_payment_method_control', null, props);
return Element && <Element {...props} React={React} />;
}
default: {
return null;
}
Expand Down
Loading