@churchapps/apphelper 0.12.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/donations/components/MultiGatewayDonationForm.d.ts.map +1 -1
- package/dist/donations/components/MultiGatewayDonationForm.js +88 -184
- package/dist/donations/components/MultiGatewayDonationForm.js.map +1 -1
- package/dist/donations/components/NonAuthDonation.d.ts.map +1 -1
- package/dist/donations/components/NonAuthDonation.js +16 -74
- package/dist/donations/components/NonAuthDonation.js.map +1 -1
- package/dist/donations/components/PaymentMethods.d.ts.map +1 -1
- package/dist/donations/components/PaymentMethods.js +33 -31
- package/dist/donations/components/PaymentMethods.js.map +1 -1
- package/dist/donations/components/RecurringDonations.js +6 -6
- package/dist/donations/components/RecurringDonations.js.map +1 -1
- package/dist/donations/helpers/DonationHelper.d.ts +2 -3
- package/dist/donations/helpers/DonationHelper.d.ts.map +1 -1
- package/dist/donations/helpers/DonationHelper.js +1 -4
- package/dist/donations/helpers/DonationHelper.js.map +1 -1
- package/dist/donations/helpers/DonationInterface.d.ts +1 -1
- package/dist/donations/helpers/DonationInterface.d.ts.map +1 -1
- package/dist/donations/helpers/PaymentMethod.d.ts +2 -2
- package/dist/donations/helpers/PaymentMethod.d.ts.map +1 -1
- package/dist/donations/helpers/StripePaymentMethod.d.ts +1 -1
- package/dist/donations/helpers/StripePaymentMethod.d.ts.map +1 -1
- package/dist/donations/index.d.ts +1 -0
- package/dist/donations/index.d.ts.map +1 -1
- package/dist/donations/index.js +1 -0
- package/dist/donations/index.js.map +1 -1
- package/dist/donations/providers/KingdomFundingProvider.d.ts +3 -0
- package/dist/donations/providers/KingdomFundingProvider.d.ts.map +1 -0
- package/dist/donations/providers/KingdomFundingProvider.js +86 -0
- package/dist/donations/providers/KingdomFundingProvider.js.map +1 -0
- package/dist/donations/providers/PayPalProvider.d.ts +3 -0
- package/dist/donations/providers/PayPalProvider.d.ts.map +1 -0
- package/dist/donations/providers/PayPalProvider.js +81 -0
- package/dist/donations/providers/PayPalProvider.js.map +1 -0
- package/dist/donations/providers/StripeProvider.d.ts +34 -0
- package/dist/donations/providers/StripeProvider.d.ts.map +1 -0
- package/dist/donations/providers/StripeProvider.js +74 -0
- package/dist/donations/providers/StripeProvider.js.map +1 -0
- package/dist/donations/providers/index.d.ts +3 -0
- package/dist/donations/providers/index.d.ts.map +1 -0
- package/dist/donations/providers/index.js +6 -0
- package/dist/donations/providers/index.js.map +1 -0
- package/dist/donations/providers/registry.d.ts +6 -0
- package/dist/donations/providers/registry.d.ts.map +1 -0
- package/dist/donations/providers/registry.js +36 -0
- package/dist/donations/providers/registry.js.map +1 -0
- package/dist/donations/providers/types.d.ts +113 -0
- package/dist/donations/providers/types.d.ts.map +1 -0
- package/dist/donations/providers/types.js +2 -0
- package/dist/donations/providers/types.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef, useImperativeHandle, useRef } from "react";
|
|
4
|
+
import { KingdomFundingTokenForm } from "../components/KingdomFundingTokenForm";
|
|
5
|
+
import { KingdomFundingNonAuthDonationInner } from "../components/KingdomFundingNonAuthDonationInner";
|
|
6
|
+
import { buildSavedMethodBody } from "./StripeProvider";
|
|
7
|
+
// Inline card entry for member donations — wraps the accept.blue hosted iframe
|
|
8
|
+
// and normalizes its nonce into the uniform PaymentToken.
|
|
9
|
+
const KingdomFundingMemberEntry = forwardRef(({ gateway }, ref) => {
|
|
10
|
+
const kfRef = useRef(null);
|
|
11
|
+
useImperativeHandle(ref, () => ({
|
|
12
|
+
tokenize: async () => {
|
|
13
|
+
if (!kfRef.current)
|
|
14
|
+
throw new Error("Card form not ready. Please wait and try again.");
|
|
15
|
+
const r = await kfRef.current.getNonce();
|
|
16
|
+
return { id: r.nonce, type: "card", brand: r.cardType, last4: r.last4, expMonth: r.expiryMonth, expYear: r.expiryYear };
|
|
17
|
+
}
|
|
18
|
+
}));
|
|
19
|
+
return (_jsx(KingdomFundingTokenForm, { ref: kfRef, tokenizationKey: gateway.publicKey || "", sandbox: gateway?.settings?.sandbox === true || gateway?.environment === "sandbox" }));
|
|
20
|
+
});
|
|
21
|
+
KingdomFundingMemberEntry.displayName = "KingdomFundingMemberEntry";
|
|
22
|
+
const KingdomFundingGuestForm = (props) => (_jsx(KingdomFundingNonAuthDonationInner, { churchId: props.churchId, mainContainerCssProps: props.mainContainerCssProps, showHeader: false, recaptchaSiteKey: props.recaptchaSiteKey, churchLogo: props?.churchLogo, paymentType: "card" }));
|
|
23
|
+
export const KingdomFundingProvider = {
|
|
24
|
+
key: "kingdomfunding",
|
|
25
|
+
descriptor: {
|
|
26
|
+
adminValue: "KingdomFunding",
|
|
27
|
+
label: "Kingdom Funding",
|
|
28
|
+
keyLabels: {
|
|
29
|
+
public: "settings.givingSettingsEdit.tokenizationKey",
|
|
30
|
+
private: "settings.givingSettingsEdit.sourceKey",
|
|
31
|
+
webhook: "settings.givingSettingsEdit.webhookKey"
|
|
32
|
+
},
|
|
33
|
+
feeFields: ["kf"],
|
|
34
|
+
currencies: [],
|
|
35
|
+
selectableInAdmin: true,
|
|
36
|
+
betaOnly: true,
|
|
37
|
+
setupInstructionsKey: "settings.givingSettingsEdit.kfSetup",
|
|
38
|
+
signupUrl: (church, user) => {
|
|
39
|
+
const fullName = ((user?.firstName || "") + " " + (user?.lastName || "")).trim();
|
|
40
|
+
const params = [
|
|
41
|
+
["sponsor", "b1"],
|
|
42
|
+
["email", user?.email],
|
|
43
|
+
["org", church?.name],
|
|
44
|
+
["full_name", fullName],
|
|
45
|
+
["phone", user?.contactInfo?.workPhone],
|
|
46
|
+
["address1", church?.address1],
|
|
47
|
+
["address2", church?.address2],
|
|
48
|
+
["state", church?.state],
|
|
49
|
+
["zip", church?.zip],
|
|
50
|
+
["country", church?.country]
|
|
51
|
+
];
|
|
52
|
+
return "https://kingdomfunding.org/begin-registration/?" + params.map(([k, v]) => k + "=" + encodeURIComponent(v || "")).join("&");
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
capabilities: { savedCard: true, savedBank: false, guestAch: false, memberNewCard: true, recurring: true, editRecurring: false },
|
|
56
|
+
MemberEntry: KingdomFundingMemberEntry,
|
|
57
|
+
buildChargeRequest: (ctx, token) => {
|
|
58
|
+
const endpoint = ctx.recurring ? "/donate/subscribe" : "/donate/charge";
|
|
59
|
+
if (token.saved)
|
|
60
|
+
return { endpoint, body: buildSavedMethodBody(ctx, token, "kingdomfunding") };
|
|
61
|
+
const body = {
|
|
62
|
+
provider: "kingdomfunding",
|
|
63
|
+
gatewayId: ctx.gatewayId,
|
|
64
|
+
churchId: ctx.churchId,
|
|
65
|
+
amount: ctx.amount,
|
|
66
|
+
funds: ctx.funds,
|
|
67
|
+
person: ctx.person,
|
|
68
|
+
notes: ctx.notes || "",
|
|
69
|
+
church: ctx.church,
|
|
70
|
+
saveCard: ctx.saveCard,
|
|
71
|
+
type: "card",
|
|
72
|
+
id: token.id,
|
|
73
|
+
cardBrand: token.brand,
|
|
74
|
+
cardLast4: token.last4,
|
|
75
|
+
expiry_month: token.expMonth,
|
|
76
|
+
expiry_year: token.expYear
|
|
77
|
+
};
|
|
78
|
+
if (ctx.recurring) {
|
|
79
|
+
body.billing_cycle_anchor = ctx.billingCycleAnchor;
|
|
80
|
+
body.interval = ctx.interval;
|
|
81
|
+
}
|
|
82
|
+
return { endpoint, body };
|
|
83
|
+
},
|
|
84
|
+
GuestForm: KingdomFundingGuestForm
|
|
85
|
+
};
|
|
86
|
+
//# sourceMappingURL=KingdomFundingProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KingdomFundingProvider.js","sourceRoot":"","sources":["../../../src/donations/providers/KingdomFundingProvider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAc,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,OAAO,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AE,EAAE,KAAK,CAAC,EAAE;YACZ,SAAS,EAAE,KAAK,CAAC,KAAK;YACtB,SAAS,EAAE,KAAK,CAAC,KAAK;YACtB,YAAY,EAAE,KAAK,CAAC,QAAQ;YAC5B,WAAW,EAAE,KAAK,CAAC,OAAO;SAC3B,CAAC;QACF,IAAI,GAAG,CAAC,SAAS,EAAE,CAAC;YAClB,IAAI,CAAC,oBAAoB,GAAG,GAAG,CAAC,kBAAkB,CAAC;YACnD,IAAI,CAAC,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC;QAC/B,CAAC;QACD,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC5B,CAAC;IAED,SAAS,EAAE,uBAAuB;CACnC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PayPalProvider.d.ts","sourceRoot":"","sources":["../../../src/donations/providers/PayPalProvider.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,eAAe,EAEhB,MAAM,SAAS,CAAC;AA0EjB,eAAO,MAAM,cAAc,EAAE,eAiC5B,CAAC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef, useImperativeHandle, useRef } from "react";
|
|
4
|
+
import { ApiHelper } from "@churchapps/helpers";
|
|
5
|
+
import { PayPalHostedFields } from "../components/PayPalHostedFields";
|
|
6
|
+
import { PayPalNonAuthDonationInner } from "../components/PayPalNonAuthDonationInner";
|
|
7
|
+
// Member PayPal entry — Hosted Fields create a server-side order at submit time,
|
|
8
|
+
// so it reads live amount/funds through getContext(). tokenize() returns the
|
|
9
|
+
// captured order id.
|
|
10
|
+
const PayPalMemberEntry = forwardRef(({ gateway, getContext }, ref) => {
|
|
11
|
+
const hostedRef = useRef(null);
|
|
12
|
+
useImperativeHandle(ref, () => ({
|
|
13
|
+
tokenize: async () => {
|
|
14
|
+
const payload = await hostedRef.current?.submit();
|
|
15
|
+
const orderId = payload?.orderId || payload?.id || "";
|
|
16
|
+
return { id: orderId, type: "paypal" };
|
|
17
|
+
}
|
|
18
|
+
}));
|
|
19
|
+
return (_jsx(PayPalHostedFields, { ref: hostedRef, clientId: gateway.publicKey || "", getClientToken: async () => {
|
|
20
|
+
try {
|
|
21
|
+
const ctx = getContext?.();
|
|
22
|
+
const resp = await ApiHelper.post("/donate/client-token", { churchId: ctx?.churchId || "", provider: "paypal", gatewayId: gateway.id }, "GivingApi");
|
|
23
|
+
const token = resp?.clientToken || resp?.token || resp?.result || resp;
|
|
24
|
+
return typeof token === "string" && token.length > 0 ? token : "";
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
return "";
|
|
28
|
+
}
|
|
29
|
+
}, createOrder: async () => {
|
|
30
|
+
try {
|
|
31
|
+
const ctx = getContext?.();
|
|
32
|
+
const resp = await ApiHelper.post("/donate/create-order", {
|
|
33
|
+
churchId: ctx?.churchId || "",
|
|
34
|
+
provider: "paypal",
|
|
35
|
+
gatewayId: gateway.id,
|
|
36
|
+
amount: ctx?.amount,
|
|
37
|
+
currency: (ctx?.currency || "USD").toUpperCase(),
|
|
38
|
+
funds: ctx?.funds || [],
|
|
39
|
+
notes: ctx?.notes || ""
|
|
40
|
+
}, "GivingApi");
|
|
41
|
+
return resp?.id || resp?.orderId || "";
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return "";
|
|
45
|
+
}
|
|
46
|
+
} }));
|
|
47
|
+
});
|
|
48
|
+
PayPalMemberEntry.displayName = "PayPalMemberEntry";
|
|
49
|
+
const PayPalGuestForm = (props) => (_jsx(PayPalNonAuthDonationInner, { churchId: props.churchId, mainContainerCssProps: props.mainContainerCssProps, showHeader: false, recaptchaSiteKey: props.recaptchaSiteKey, churchLogo: props?.churchLogo, paypalClientId: props.gateway?.publicKey || null, allowSingleGift: props.allowSingleGift, allowRecurring: props.allowRecurring, showFundSelector: props.showFundSelector, allowedFundIds: props.allowedFundIds, defaultFundId: props.defaultFundId }));
|
|
50
|
+
export const PayPalProvider = {
|
|
51
|
+
key: "paypal",
|
|
52
|
+
descriptor: {
|
|
53
|
+
adminValue: "Paypal",
|
|
54
|
+
label: "PayPal",
|
|
55
|
+
keyLabels: { public: "settings.givingSettingsEdit.clientId", private: "settings.givingSettingsEdit.clientSecret" },
|
|
56
|
+
feeFields: ["paypal"],
|
|
57
|
+
currencies: [],
|
|
58
|
+
selectableInAdmin: false,
|
|
59
|
+
setupInstructionsKey: "settings.givingSettingsEdit.paypalSetup",
|
|
60
|
+
signupUrl: () => "https://developer.paypal.com/"
|
|
61
|
+
},
|
|
62
|
+
// PayPal has no saved-method vault and no member subscribe path today; charges
|
|
63
|
+
// are one-time via captured orders.
|
|
64
|
+
capabilities: { savedCard: false, savedBank: false, guestAch: false, memberNewCard: false, recurring: false, editRecurring: false },
|
|
65
|
+
MemberEntry: PayPalMemberEntry,
|
|
66
|
+
buildChargeRequest: (ctx, token) => ({
|
|
67
|
+
endpoint: "/donate/charge",
|
|
68
|
+
body: {
|
|
69
|
+
provider: "paypal",
|
|
70
|
+
gatewayId: ctx.gatewayId,
|
|
71
|
+
id: token.id,
|
|
72
|
+
churchId: ctx.churchId,
|
|
73
|
+
amount: ctx.amount,
|
|
74
|
+
funds: ctx.funds,
|
|
75
|
+
person: ctx.person,
|
|
76
|
+
notes: ctx.notes || ""
|
|
77
|
+
}
|
|
78
|
+
}),
|
|
79
|
+
GuestForm: PayPalGuestForm
|
|
80
|
+
};
|
|
81
|
+
//# sourceMappingURL=PayPalProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PayPalProvider.js","sourceRoot":"","sources":["../../../src/donations/providers/PayPalProvider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAc,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAq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CAAC,KAAK,IAAI,EAAE;SACvB;KACF,CAAC;IAEF,SAAS,EAAE,eAAe;CAC3B,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { PaymentProvider, ChargeContext, PaymentToken } from "./types";
|
|
2
|
+
declare function buildSavedMethodBody(ctx: ChargeContext, token: PaymentToken, providerKey: string): {
|
|
3
|
+
id: string;
|
|
4
|
+
type: "card" | "paypal" | "bank";
|
|
5
|
+
provider: string;
|
|
6
|
+
customerId: string;
|
|
7
|
+
gatewayId: string;
|
|
8
|
+
person: {
|
|
9
|
+
id: string;
|
|
10
|
+
email: string;
|
|
11
|
+
name: string;
|
|
12
|
+
};
|
|
13
|
+
amount: number;
|
|
14
|
+
funds: {
|
|
15
|
+
id: string;
|
|
16
|
+
amount: number;
|
|
17
|
+
}[];
|
|
18
|
+
billing_cycle_anchor: number;
|
|
19
|
+
interval: {
|
|
20
|
+
interval_count: number;
|
|
21
|
+
interval: string;
|
|
22
|
+
};
|
|
23
|
+
notes: string;
|
|
24
|
+
currency: string;
|
|
25
|
+
church: {
|
|
26
|
+
name: string;
|
|
27
|
+
subDomain: string;
|
|
28
|
+
churchURL: string;
|
|
29
|
+
logo: string;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
export declare const StripeProvider: PaymentProvider;
|
|
33
|
+
export { buildSavedMethodBody };
|
|
34
|
+
//# sourceMappingURL=StripeProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StripeProvider.d.ts","sourceRoot":"","sources":["../../../src/donations/providers/StripeProvider.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,eAAe,EAAkB,aAAa,EAAE,YAAY,EAAiB,MAAM,SAAS,CAAC;AA6D3G,iBAAS,oBAAoB,CAAC,GAAG,EAAE,aAAa,EAAE,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgBzF;AAED,eAAO,MAAM,cAAc,EAAE,eA4B5B,CAAC;AAEF,OAAO,EAAE,oBAAoB,EAAE,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useMemo, useState } from "react";
|
|
4
|
+
import { loadStripe } from "@stripe/stripe-js";
|
|
5
|
+
import { Elements } from "@stripe/react-stripe-js";
|
|
6
|
+
import { Box, ToggleButtonGroup, ToggleButton } from "@mui/material";
|
|
7
|
+
import { NonAuthDonationInner } from "../components/NonAuthDonationInner";
|
|
8
|
+
import { DonationHelper } from "../helpers";
|
|
9
|
+
const stripeSupportedCurrencies = [
|
|
10
|
+
"usd", "eur", "gbp", "cad", "aud", "inr", "jpy", "sgd", "hkd", "sek", "nok", "dkk", "chf", "mxn", "brl"
|
|
11
|
+
];
|
|
12
|
+
const toggleSx = {
|
|
13
|
+
backgroundColor: "#FFFFFF",
|
|
14
|
+
color: "#333",
|
|
15
|
+
"&.Mui-selected": { backgroundColor: "#1976d2", color: "#FFFFFF" },
|
|
16
|
+
"&:hover": { backgroundColor: "#f5f5f5" },
|
|
17
|
+
"&.Mui-selected:hover": { backgroundColor: "#1565c0" }
|
|
18
|
+
};
|
|
19
|
+
// Stripe guest form: owns its own card/bank (ACH) toggle and Elements wrapper,
|
|
20
|
+
// then renders the existing Stripe inner form. This is what the NonAuthDonation
|
|
21
|
+
// shell used to inline for `=== "stripe"`.
|
|
22
|
+
const StripeGuestForm = (props) => {
|
|
23
|
+
const [paymentType, setPaymentType] = useState("card");
|
|
24
|
+
const stripePromise = useMemo(() => (props.gateway?.publicKey ? loadStripe(props.gateway.publicKey) : null), [props.gateway?.publicKey]);
|
|
25
|
+
const currency = props.gateway?.currency || "usd";
|
|
26
|
+
return (_jsxs(Box, { children: [_jsx(Box, { sx: { mb: 3 }, children: _jsxs(ToggleButtonGroup, { value: paymentType, exclusive: true, onChange: (_, value) => value && setPaymentType(value), fullWidth: true, size: "small", sx: { backgroundColor: "#FFFFFF", borderRadius: 1 }, children: [_jsx(ToggleButton, { value: "card", sx: toggleSx, children: "Credit/Debit Card" }), currency === "usd" && _jsx(ToggleButton, { value: "bank", sx: toggleSx, children: "Bank Account (ACH)" })] }) }), _jsx(Elements, { stripe: stripePromise, children: _jsx(NonAuthDonationInner, { churchId: props.churchId, mainContainerCssProps: props.mainContainerCssProps, showHeader: false, recaptchaSiteKey: props.recaptchaSiteKey, churchLogo: props?.churchLogo, paymentType: paymentType, allowSingleGift: props.allowSingleGift, allowRecurring: props.allowRecurring, showFundSelector: props.showFundSelector, allowedFundIds: props.allowedFundIds, defaultFundId: props.defaultFundId }) })] }));
|
|
27
|
+
};
|
|
28
|
+
// Member Stripe donations charge a saved payment method (cards are added in
|
|
29
|
+
// PaymentMethods, not inline) — so the body is the saved-method shape.
|
|
30
|
+
function buildSavedMethodBody(ctx, token, providerKey) {
|
|
31
|
+
return {
|
|
32
|
+
id: token.id,
|
|
33
|
+
type: token.type,
|
|
34
|
+
provider: providerKey,
|
|
35
|
+
customerId: ctx.customerId,
|
|
36
|
+
gatewayId: ctx.gatewayId,
|
|
37
|
+
person: ctx.person,
|
|
38
|
+
amount: ctx.amount,
|
|
39
|
+
funds: ctx.funds,
|
|
40
|
+
billing_cycle_anchor: ctx.billingCycleAnchor,
|
|
41
|
+
interval: ctx.interval,
|
|
42
|
+
notes: ctx.notes,
|
|
43
|
+
currency: ctx.currency,
|
|
44
|
+
church: ctx.church
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
export const StripeProvider = {
|
|
48
|
+
key: "stripe",
|
|
49
|
+
descriptor: {
|
|
50
|
+
adminValue: "Stripe",
|
|
51
|
+
label: "Stripe",
|
|
52
|
+
keyLabels: { public: "settings.givingSettingsEdit.pubKey", private: "settings.givingSettingsEdit.secKey" },
|
|
53
|
+
feeFields: ["card", "ach"],
|
|
54
|
+
currencies: stripeSupportedCurrencies,
|
|
55
|
+
selectableInAdmin: true,
|
|
56
|
+
setupInstructionsKey: "settings.givingSettingsEdit.stripeSetup",
|
|
57
|
+
signupUrl: () => "https://dashboard.stripe.com/"
|
|
58
|
+
},
|
|
59
|
+
capabilities: { savedCard: true, savedBank: true, guestAch: true, memberNewCard: false, recurring: true, editRecurring: true },
|
|
60
|
+
MemberWrapper: ({ stripePromise, children }) => _jsx(Elements, { stripe: stripePromise ?? null, children: children }),
|
|
61
|
+
buildChargeRequest: (ctx, token) => ({
|
|
62
|
+
endpoint: ctx.recurring ? "/donate/subscribe" : "/donate/charge",
|
|
63
|
+
body: buildSavedMethodBody(ctx, token, "stripe")
|
|
64
|
+
}),
|
|
65
|
+
finalizeResult: async (result, { stripe }) => {
|
|
66
|
+
const tds = await DonationHelper.handle3DSIfRequired(result, stripe ?? null);
|
|
67
|
+
if (!tds.requiresAction)
|
|
68
|
+
return { result };
|
|
69
|
+
return { result, requiresAction: true, success: tds.success, error: tds.error };
|
|
70
|
+
},
|
|
71
|
+
GuestForm: StripeGuestForm
|
|
72
|
+
};
|
|
73
|
+
export { buildSavedMethodBody };
|
|
74
|
+
//# sourceMappingURL=StripeProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StripeProvider.js","sourceRoot":"","sources":["../../../src/donations/providers/StripeProvider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAc,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,GAAG,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AACrE,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAG5C,MAAM,yBAAyB,GAAG;IAChC,KAAK,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C7E,IAAI,CAAC,GAAG,CAAC,cAAc;YAAE,OAAO,EAAE,MAAM,EAAE,CAAC;QAC3C,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK,EAAE,CAAC;IAClF,CAAC;IAED,SAAS,EAAE,eAAe;CAC3B,CAAC;AAEF,OAAO,EAAE,oBAAoB,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/donations/providers/index.ts"],"names":[],"mappings":"AAGA,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// Built-in providers are wired up directly inside registry.ts (so bundlers can't
|
|
2
|
+
// drop the registration). Add a new built-in there; or call registerPaymentProvider
|
|
3
|
+
// at runtime for a host-app gateway.
|
|
4
|
+
export * from "./types";
|
|
5
|
+
export * from "./registry";
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/donations/providers/index.ts"],"names":[],"mappings":"AAAA,iFAAiF;AACjF,oFAAoF;AACpF,qCAAqC;AACrC,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { PaymentProvider } from "./types";
|
|
2
|
+
export declare function registerPaymentProvider(provider: PaymentProvider): void;
|
|
3
|
+
export declare function getPaymentProvider(provider: string | undefined | null): PaymentProvider;
|
|
4
|
+
export declare function hasPaymentProvider(provider: string | undefined | null): boolean;
|
|
5
|
+
export declare function listPaymentProviders(): PaymentProvider[];
|
|
6
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/donations/providers/registry.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAiB/C,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,eAAe,GAAG,IAAI,CAEvE;AAID,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,eAAe,CAIvF;AAED,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,OAAO,CAG/E;AAED,wBAAgB,oBAAoB,IAAI,eAAe,EAAE,CAExD"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { DonationHelper } from "../helpers";
|
|
2
|
+
import { StripeProvider } from "./StripeProvider";
|
|
3
|
+
import { KingdomFundingProvider } from "./KingdomFundingProvider";
|
|
4
|
+
import { PayPalProvider } from "./PayPalProvider";
|
|
5
|
+
// Built-ins are referenced directly (not registered via a module side-effect),
|
|
6
|
+
// so bundlers can't tree-shake the registration away. Built lazily on first
|
|
7
|
+
// access so the providers/components import cycle is fully resolved by call time.
|
|
8
|
+
const custom = new Map();
|
|
9
|
+
let builtins = null;
|
|
10
|
+
function getBuiltins() {
|
|
11
|
+
if (!builtins) {
|
|
12
|
+
builtins = new Map();
|
|
13
|
+
for (const p of [StripeProvider, KingdomFundingProvider, PayPalProvider])
|
|
14
|
+
builtins.set(p.key, p);
|
|
15
|
+
}
|
|
16
|
+
return builtins;
|
|
17
|
+
}
|
|
18
|
+
// Register an additional provider at runtime (e.g. a host app's custom gateway).
|
|
19
|
+
export function registerPaymentProvider(provider) {
|
|
20
|
+
custom.set(provider.key, provider);
|
|
21
|
+
}
|
|
22
|
+
// Resolves by normalized provider name. Falls back to Stripe so an unknown or
|
|
23
|
+
// misconfigured provider never hard-crashes the donor form.
|
|
24
|
+
export function getPaymentProvider(provider) {
|
|
25
|
+
const key = DonationHelper.normalizeProvider(provider || "");
|
|
26
|
+
const all = getBuiltins();
|
|
27
|
+
return custom.get(key) ?? all.get(key) ?? all.get("stripe");
|
|
28
|
+
}
|
|
29
|
+
export function hasPaymentProvider(provider) {
|
|
30
|
+
const key = DonationHelper.normalizeProvider(provider || "");
|
|
31
|
+
return custom.has(key) || getBuiltins().has(key);
|
|
32
|
+
}
|
|
33
|
+
export function listPaymentProviders() {
|
|
34
|
+
return [...getBuiltins().values(), ...custom.values()];
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../../src/donations/providers/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGlD,+EAA+E;AAC/E,4EAA4E;AAC5E,kFAAkF;AAClF,MAAM,MAAM,GAAG,IAAI,GAAG,EAA2B,CAAC;AAClD,IAAI,QAAQ,GAAwC,IAAI,CAAC;AAEzD,SAAS,WAAW;IAClB,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,QAAQ,GAAG,IAAI,GAAG,EAA2B,CAAC;QAC9C,KAAK,MAAM,CAAC,IAAI,CAAC,cAAc,EAAE,sBAAsB,EAAE,cAAc,CAAC;YAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;IACnG,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,uBAAuB,CAAC,QAAyB;IAC/D,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;AACrC,CAAC;AAED,8EAA8E;AAC9E,4DAA4D;AAC5D,MAAM,UAAU,kBAAkB,CAAC,QAAmC;IACpE,MAAM,GAAG,GAAG,cAAc,CAAC,iBAAiB,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC;IAC7D,MAAM,GAAG,GAAG,WAAW,EAAE,CAAC;IAC1B,OAAO,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAE,CAAC;AAC/D,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,QAAmC;IACpE,MAAM,GAAG,GAAG,cAAc,CAAC,iBAAiB,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC;IAC7D,OAAO,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,WAAW,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACnD,CAAC;AAED,MAAM,UAAU,oBAAoB;IAClC,OAAO,CAAC,GAAG,WAAW,EAAE,CAAC,MAAM,EAAE,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;AACzD,CAAC"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import type { ReactNode, FC, ForwardRefExoticComponent, RefAttributes } from "react";
|
|
2
|
+
import type { Stripe } from "@stripe/stripe-js";
|
|
3
|
+
import type { PaymentGateway } from "../helpers";
|
|
4
|
+
import type { PaperProps } from "@mui/material/Paper";
|
|
5
|
+
export interface PaymentToken {
|
|
6
|
+
id: string;
|
|
7
|
+
type: "card" | "bank" | "paypal";
|
|
8
|
+
saved?: boolean;
|
|
9
|
+
brand?: string;
|
|
10
|
+
last4?: string;
|
|
11
|
+
expMonth?: string;
|
|
12
|
+
expYear?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface ChargeContext {
|
|
15
|
+
provider: string;
|
|
16
|
+
gatewayId?: string;
|
|
17
|
+
churchId: string;
|
|
18
|
+
amount: number;
|
|
19
|
+
funds: {
|
|
20
|
+
id: string;
|
|
21
|
+
amount: number;
|
|
22
|
+
}[];
|
|
23
|
+
person: {
|
|
24
|
+
id: string;
|
|
25
|
+
email: string;
|
|
26
|
+
name: string;
|
|
27
|
+
};
|
|
28
|
+
notes?: string;
|
|
29
|
+
church: {
|
|
30
|
+
name: string;
|
|
31
|
+
subDomain: string;
|
|
32
|
+
churchURL: string;
|
|
33
|
+
logo: string;
|
|
34
|
+
};
|
|
35
|
+
recurring: boolean;
|
|
36
|
+
interval?: {
|
|
37
|
+
interval_count: number;
|
|
38
|
+
interval: string;
|
|
39
|
+
};
|
|
40
|
+
billingCycleAnchor?: number;
|
|
41
|
+
saveCard?: boolean;
|
|
42
|
+
customerId?: string;
|
|
43
|
+
currency?: string;
|
|
44
|
+
}
|
|
45
|
+
export interface ChargeRequest {
|
|
46
|
+
endpoint: "/donate/charge" | "/donate/subscribe";
|
|
47
|
+
body: any;
|
|
48
|
+
}
|
|
49
|
+
export interface FinalizeResult {
|
|
50
|
+
result: any;
|
|
51
|
+
requiresAction?: boolean;
|
|
52
|
+
success?: boolean;
|
|
53
|
+
error?: string;
|
|
54
|
+
}
|
|
55
|
+
export interface ProviderCapabilities {
|
|
56
|
+
savedCard: boolean;
|
|
57
|
+
savedBank: boolean;
|
|
58
|
+
guestAch: boolean;
|
|
59
|
+
memberNewCard: boolean;
|
|
60
|
+
recurring: boolean;
|
|
61
|
+
editRecurring: boolean;
|
|
62
|
+
}
|
|
63
|
+
export interface ProviderDescriptor {
|
|
64
|
+
adminValue: string;
|
|
65
|
+
label: string;
|
|
66
|
+
keyLabels: {
|
|
67
|
+
public: string;
|
|
68
|
+
private: string;
|
|
69
|
+
webhook?: string;
|
|
70
|
+
};
|
|
71
|
+
feeFields: ("card" | "ach" | "paypal" | "kf")[];
|
|
72
|
+
currencies: string[] | "all";
|
|
73
|
+
selectableInAdmin: boolean;
|
|
74
|
+
betaOnly?: boolean;
|
|
75
|
+
setupInstructionsKey?: string;
|
|
76
|
+
signupUrl?: (church: any, user: any) => string;
|
|
77
|
+
}
|
|
78
|
+
export interface MemberEntryHandle {
|
|
79
|
+
tokenize(): Promise<PaymentToken>;
|
|
80
|
+
}
|
|
81
|
+
export interface MemberEntryProps {
|
|
82
|
+
gateway: PaymentGateway;
|
|
83
|
+
getContext?: () => ChargeContext;
|
|
84
|
+
}
|
|
85
|
+
export interface GuestFormProps {
|
|
86
|
+
churchId: string;
|
|
87
|
+
gateway: PaymentGateway;
|
|
88
|
+
recaptchaSiteKey: string;
|
|
89
|
+
mainContainerCssProps?: PaperProps;
|
|
90
|
+
showHeader?: boolean;
|
|
91
|
+
churchLogo?: string;
|
|
92
|
+
allowSingleGift?: boolean;
|
|
93
|
+
allowRecurring?: boolean;
|
|
94
|
+
showFundSelector?: boolean;
|
|
95
|
+
allowedFundIds?: string[];
|
|
96
|
+
defaultFundId?: string;
|
|
97
|
+
}
|
|
98
|
+
export interface PaymentProvider {
|
|
99
|
+
readonly key: string;
|
|
100
|
+
readonly descriptor: ProviderDescriptor;
|
|
101
|
+
readonly capabilities: ProviderCapabilities;
|
|
102
|
+
MemberWrapper?: FC<{
|
|
103
|
+
stripePromise?: Promise<Stripe | null> | null;
|
|
104
|
+
children: ReactNode;
|
|
105
|
+
}>;
|
|
106
|
+
MemberEntry?: ForwardRefExoticComponent<MemberEntryProps & RefAttributes<MemberEntryHandle>>;
|
|
107
|
+
buildChargeRequest(ctx: ChargeContext, token: PaymentToken): ChargeRequest;
|
|
108
|
+
finalizeResult?(result: any, deps: {
|
|
109
|
+
stripe?: Stripe | null;
|
|
110
|
+
}): Promise<FinalizeResult>;
|
|
111
|
+
GuestForm: FC<GuestFormProps>;
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/donations/providers/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,yBAAyB,EAAE,aAAa,EAAE,MAA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 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/donations/providers/types.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@churchapps/apphelper",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "Library of helper functions, components, and feature modules (donations/forms/login/markdown/website) for React and NextJS ChurchApps",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|