@licklist/design 0.63.3-dev.0 → 0.63.3-dev.1
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/iframe/ryft/RyftPaymentForm.d.ts +4 -1
- package/dist/iframe/ryft/RyftPaymentForm.d.ts.map +1 -1
- package/dist/iframe/ryft/RyftPaymentForm.js +1 -1
- package/dist/iframe/ryft/utils/ryft-form.d.ts +5 -2
- package/dist/iframe/ryft/utils/ryft-form.d.ts.map +1 -1
- package/dist/iframe/ryft/utils/ryft-form.js +1 -1
- package/dist/styles/ryft-payment-form/RyftPaymentForm.scss +8 -0
- package/package.json +1 -1
- package/src/iframe/ryft/RyftPaymentForm.tsx +11 -2
- package/src/iframe/ryft/utils/ryft-form.ts +23 -4
- package/src/styles/ryft-payment-form/RyftPaymentForm.scss +8 -0
|
@@ -6,10 +6,13 @@ export type RyftPaymentFormValues = Record<string, never>;
|
|
|
6
6
|
export interface RyftPaymentFormProps {
|
|
7
7
|
accountId: any;
|
|
8
8
|
isCreateLoading: boolean;
|
|
9
|
+
isAppUsingInIframe?: boolean;
|
|
10
|
+
onApplePayButtonClick: () => void;
|
|
11
|
+
applePayButtonDisabled?: boolean;
|
|
9
12
|
initRyft: (onSuccess: () => void, onFailure: (error?: string) => void) => Promise<void>;
|
|
10
13
|
onSubmit: () => Promise<AttemptPaymentResponse>;
|
|
11
14
|
resetReferrer?: () => void;
|
|
12
15
|
providerPaymentSettings?: ProviderPaymentSettings;
|
|
13
16
|
}
|
|
14
|
-
export declare const RyftPaymentForm: ({ accountId, isCreateLoading, providerPaymentSettings, initRyft, resetReferrer, onSubmit, }: RyftPaymentFormProps) => JSX.Element;
|
|
17
|
+
export declare const RyftPaymentForm: ({ accountId, isCreateLoading, isAppUsingInIframe, providerPaymentSettings, onApplePayButtonClick, initRyft, resetReferrer, onSubmit, }: RyftPaymentFormProps) => JSX.Element;
|
|
15
18
|
//# sourceMappingURL=RyftPaymentForm.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RyftPaymentForm.d.ts","sourceRoot":"","sources":["../../../src/iframe/ryft/RyftPaymentForm.tsx"],"names":[],"mappings":";AAOA,OAAO,EAKL,sBAAsB,EACvB,MAAM,kDAAkD,CAAC;AAC1D,OAAO,EAAE,uBAAuB,EAAE,MAAM,0EAA0E,CAAC;AAKnH,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAW/C,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AAE1D,MAAM,WAAW,oBAAoB;IAEnC,SAAS,EAAE,GAAG,CAAC;IACf,eAAe,EAAE,OAAO,CAAC;IACzB,QAAQ,EAAE,CACR,SAAS,EAAE,MAAM,IAAI,EACrB,SAAS,EAAE,CAAC,KAAK,CAAC,EAAE,MAAM,KAAK,IAAI,KAChC,OAAO,CAAC,IAAI,CAAC,CAAC;IACnB,QAAQ,EAAE,MAAM,OAAO,CAAC,sBAAsB,CAAC,CAAC;IAChD,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;IAC3B,uBAAuB,CAAC,EAAE,uBAAuB,CAAC;CACnD;AAED,eAAO,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"RyftPaymentForm.d.ts","sourceRoot":"","sources":["../../../src/iframe/ryft/RyftPaymentForm.tsx"],"names":[],"mappings":";AAOA,OAAO,EAKL,sBAAsB,EACvB,MAAM,kDAAkD,CAAC;AAC1D,OAAO,EAAE,uBAAuB,EAAE,MAAM,0EAA0E,CAAC;AAKnH,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAW/C,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AAE1D,MAAM,WAAW,oBAAoB;IAEnC,SAAS,EAAE,GAAG,CAAC;IACf,eAAe,EAAE,OAAO,CAAC;IACzB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,qBAAqB,EAAE,MAAM,IAAI,CAAC;IAClC,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,QAAQ,EAAE,CACR,SAAS,EAAE,MAAM,IAAI,EACrB,SAAS,EAAE,CAAC,KAAK,CAAC,EAAE,MAAM,KAAK,IAAI,KAChC,OAAO,CAAC,IAAI,CAAC,CAAC;IACnB,QAAQ,EAAE,MAAM,OAAO,CAAC,sBAAsB,CAAC,CAAC;IAChD,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;IAC3B,uBAAuB,CAAC,EAAE,uBAAuB,CAAC;CACnD;AAED,eAAO,MAAM,eAAe,2IASzB,oBAAoB,gBA0KtB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("tslib"),r=require("react"),n=e(r),i=require("react-router-dom"),a=require("../../static/loader/BlockLoader.js"),o=require("react-i18next"),d=e(require("react-bootstrap/Button")),
|
|
1
|
+
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("tslib"),r=require("react"),n=e(r),i=require("react-router-dom"),a=require("../../static/loader/BlockLoader.js"),o=require("react-i18next"),d=e(require("react-bootstrap/Button")),l=require("react-hook-form"),u=require("../../static/loader/ButtonLoader.js"),s=e(require("react-bootstrap/Alert"));require("../../static/index.js");var c=require("@licklist/plugins/dist/hooks/Ryft/useRyftPayment"),f=require("./utils/ryft-form.js"),m={insufficient_funds:"insufficientFunds",declined_do_not_honour:"declinedDoNotHonour",invalid_card_number:"invalidCardNumber",restricted_card:"restrictedCard",security_violation:"securityViolation",expired_card:"expiredCard",gateway_reject:"gatewayReject",bad_track_data:"badTrackData","3ds_authentication_failure":"3dsAuthenticationFailure",unknown_error:"unknownError"};exports.RyftPaymentForm=function(e){var v,y,_,p=e.accountId,E=e.isCreateLoading,g=e.isAppUsingInIframe,h=e.providerPaymentSettings,b=e.onApplePayButtonClick,R=e.initRyft,P=e.resetReferrer,k=e.onSubmit,q=o.useTranslation(["Design","Validation","Ryft"]).t,A=r.useRef(null),N=g&&(null==h?void 0:h.additionalPaymentMethodsEnabled),S=i.useHistory(),w=t.__read(r.useState(!1),2),T=w[0],F=w[1],C=t.__read(r.useState(!1),2),j=C[0],x=C[1],I=t.__read(r.useState(!1),2),M=I[0],U=I[1],B=t.__read(r.useState(void 0),2),D=B[0],L=B[1],V=c.useRyftPayment().addEventHandler,H=l.useForm(),O=function(){P&&P()},Y=function(e){(null==e?void 0:e.id)&&(null==e?void 0:e.returnUrl)&&(window.location.href="".concat(e.returnUrl,"&ps=").concat(e.id),O())};return r.useEffect((function(){var e,t,r,n,i;!(null===(t=null===(e=A.current)||void 0===e?void 0:e.childNodes)||void 0===t?void 0:t.length)||(null===(n=null===(r=A.current)||void 0===r?void 0:r.childNodes)||void 0===n?void 0:n.length)<3||!(null===(i=p.data)||void 0===i?void 0:i.account_id)||f.injectComponentsInRyftForm({t:q,isAppUsingInIframe:g,onApplePayButtonClick:b,additionalPaymentMethodsEnabled:null==h?void 0:h.additionalPaymentMethodsEnabled})}),[null===(y=null===(v=A.current)||void 0===v?void 0:v.childNodes)||void 0===y?void 0:y.length,N]),r.useEffect((function(){var e;(null===(e=p.data)||void 0===e?void 0:e.account_id)&&!p.isError&&R((function(){V("cardValidationChanged",(function(e){F(e.isValid)})),U(!1)}),(function(){return U(!0)}))}),[null===(_=p.data)||void 0===_?void 0:_.account_id]),p.isLoading||p.isFetching||E?n.createElement("div",{className:"mt-5 pt-5"},n.createElement(a.BlockLoader,null)):p.isError?n.createElement("div",{className:"mt-5 ryft-init-failure"},n.createElement(s,{key:"danger",variant:"danger"},n.createElement("h5",null,q("Ryft:errorMessage")),q("Ryft:noPaymentProviderFound"))):M?n.createElement("div",{className:"mt-5 ryft-init-failure"},n.createElement(s,{key:"danger",variant:"danger"},n.createElement("h5",null,q("Ryft:errorMessage")),q("Ryft:initFailureMessage"),n.createElement("div",{className:"flex flex-column align-items-center mt-4"},n.createElement(d,{variant:"primary",onClick:function(){S.go(0)}},q("Ryft:refresh"))))):n.createElement(n.Fragment,null,n.createElement("form",{ref:A,id:"ryft-pay-form",noValidate:!0,onSubmit:H.handleSubmit((function(){return t.__awaiter(void 0,void 0,void 0,(function(){var e,r,n;return t.__generator(this,(function(t){switch(t.label){case 0:x(!0),t.label=1;case 1:return t.trys.push([1,3,4,5]),[4,k()];case 2:if((e=t.sent())||L("unknown_error"),"requiredAction"in e){if(e.status!==c.RYFT_STATUS_PENDING_ACTION||!(null===(n=e.requiredAction)||void 0===n?void 0:n.url))return Y(e),[2];window.location.href=e.requiredAction.url,O()}return e.status===c.RYFT_STATUS_APPROVED||e.status===c.RYFT_STATUS_CAPTURED?(Y(e),[2]):(e.lastError&&(L(e.lastError),O()),[3,5]);case 3:return r=t.sent(),L(r),[3,5];case 4:return x(!1),[7];case 5:return[2]}}))}))})),className:"ryft-payment-form"},n.createElement("div",{className:"submit-button-wrapper mt-4 p-1"},n.createElement(d,{type:"submit",disabled:j||!T},j&&n.createElement(u.ButtonLoader,null),q("Design:buyNow"))),D&&n.createElement("div",{id:"ryft-payment-error"},q("".concat(m[D])))))},exports.ryftErrorMap=m;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { TFunction } from "react-i18next";
|
|
2
|
-
|
|
2
|
+
import { RyftPaymentFormProps } from "../RyftPaymentForm";
|
|
3
|
+
interface InjectComponentsInRyftForm extends Pick<RyftPaymentFormProps, "onApplePayButtonClick" | "isAppUsingInIframe"> {
|
|
3
4
|
t: TFunction<string[]>;
|
|
4
5
|
additionalPaymentMethodsEnabled?: boolean;
|
|
5
|
-
}
|
|
6
|
+
}
|
|
7
|
+
export declare const injectComponentsInRyftForm: ({ t, additionalPaymentMethodsEnabled, isAppUsingInIframe, onApplePayButtonClick, }: InjectComponentsInRyftForm) => void;
|
|
8
|
+
export {};
|
|
6
9
|
//# sourceMappingURL=ryft-form.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ryft-form.d.ts","sourceRoot":"","sources":["../../../../src/iframe/ryft/utils/ryft-form.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"ryft-form.d.ts","sourceRoot":"","sources":["../../../../src/iframe/ryft/utils/ryft-form.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE1D,UAAU,0BACR,SAAQ,IAAI,CACV,oBAAoB,EACpB,uBAAuB,GAAG,oBAAoB,CAC/C;IACD,CAAC,EAAE,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC;IACvB,+BAA+B,CAAC,EAAE,OAAO,CAAC;CAC3C;AAED,eAAO,MAAM,0BAA0B,uFAKpC,0BAA0B,SAsD5B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.injectComponentsInRyftForm=function(e){var t,n,i,d=e.t,o=e.additionalPaymentMethodsEnabled,r=document.getElementById("ryft-pay-iframe");if(
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.injectComponentsInRyftForm=function(e){var t,n,i,a,d=e.t,o=e.additionalPaymentMethodsEnabled,l=e.isAppUsingInIframe,r=e.onApplePayButtonClick,m=document.getElementById("ryft-pay-iframe");if(m){null===(t=document.getElementById("card-title-container"))||void 0===t||t.remove();var c=document.createElement("div"),p=document.createElement("div"),u=document.createElement("div");u.id="card-title-container",c.textContent=d("Design:enterCardDetails"),p.className="bold-text form-label",p.innerText=d("Design:paymentDetails"),u.append(c,p),null==m||m.before(u);var y=document.getElementById("ryft-pay-grid");if(y&&o){null===(n=document.getElementById("mobile-pay-title"))||void 0===n||n.remove(),null===(i=document.getElementById("mobile-pay-divider-container"))||void 0===i||i.remove(),null===(a=document.getElementById("apple-pay"))||void 0===a||a.remove();var v=document.createElement("div"),s=document.createElement("div"),b=document.createElement("div"),E=document.createElement("div");if(v.className="mobile-pay-title",v.innerText=d("Design:expressCheckoutWith"),v.id="mobile-pay-title",s.id="mobile-pay-divider-text",s.innerText="or",b.id="mobile-pay-divider",E.id="mobile-pay-divider-container",E.append(s,b),l){var f=document.createElement("button");f.id="apple-pay",f.type="button",f.className="bg-dark btn btn-primary apple-pay-button",f.textContent=d("Events:payWithApple"),f.onclick=r,y.append(f)}y.before(v),y.after(E)}}};
|
|
@@ -135,6 +135,14 @@
|
|
|
135
135
|
margin-bottom: 0.5rem;
|
|
136
136
|
}
|
|
137
137
|
}
|
|
138
|
+
.ryft-pay-grid {
|
|
139
|
+
display: flex;
|
|
140
|
+
flex-direction: column;
|
|
141
|
+
.apple-pay-button {
|
|
142
|
+
height: 2.5rem;
|
|
143
|
+
margin-top: 1rem;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
138
146
|
.mobile-pay-title {
|
|
139
147
|
display: block;
|
|
140
148
|
font-weight: 600;
|
package/package.json
CHANGED
|
@@ -36,6 +36,9 @@ export interface RyftPaymentFormProps {
|
|
|
36
36
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
37
37
|
accountId: any;
|
|
38
38
|
isCreateLoading: boolean;
|
|
39
|
+
isAppUsingInIframe?: boolean;
|
|
40
|
+
onApplePayButtonClick: () => void;
|
|
41
|
+
applePayButtonDisabled?: boolean;
|
|
39
42
|
initRyft: (
|
|
40
43
|
onSuccess: () => void,
|
|
41
44
|
onFailure: (error?: string) => void
|
|
@@ -48,15 +51,19 @@ export interface RyftPaymentFormProps {
|
|
|
48
51
|
export const RyftPaymentForm = ({
|
|
49
52
|
accountId,
|
|
50
53
|
isCreateLoading,
|
|
54
|
+
isAppUsingInIframe,
|
|
51
55
|
providerPaymentSettings,
|
|
56
|
+
onApplePayButtonClick,
|
|
52
57
|
initRyft,
|
|
53
58
|
resetReferrer,
|
|
54
59
|
onSubmit,
|
|
55
60
|
}: RyftPaymentFormProps) => {
|
|
56
61
|
const { t } = useTranslation(["Design", "Validation", "Ryft"]);
|
|
57
62
|
const formRef = useRef<HTMLFormElement | null>(null);
|
|
63
|
+
const showApplePayButton =
|
|
64
|
+
isAppUsingInIframe &&
|
|
65
|
+
providerPaymentSettings?.additionalPaymentMethodsEnabled;
|
|
58
66
|
const history = useHistory();
|
|
59
|
-
|
|
60
67
|
const [isValid, setIsValid] = useState(false);
|
|
61
68
|
const [isBtnDisabled, setIsBtnDisabled] = useState(false);
|
|
62
69
|
const [ryftInitFailure, setRyftInitFailure] = useState<boolean>(false);
|
|
@@ -133,12 +140,14 @@ export const RyftPaymentForm = ({
|
|
|
133
140
|
}
|
|
134
141
|
injectComponentsInRyftForm({
|
|
135
142
|
t,
|
|
143
|
+
isAppUsingInIframe,
|
|
144
|
+
onApplePayButtonClick,
|
|
136
145
|
additionalPaymentMethodsEnabled:
|
|
137
146
|
providerPaymentSettings?.additionalPaymentMethodsEnabled,
|
|
138
147
|
});
|
|
139
148
|
},
|
|
140
149
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
141
|
-
[formRef.current?.childNodes?.length]
|
|
150
|
+
[formRef.current?.childNodes?.length, showApplePayButton]
|
|
142
151
|
);
|
|
143
152
|
|
|
144
153
|
useEffect(() => {
|
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
import { TFunction } from "react-i18next";
|
|
2
|
+
import { RyftPaymentFormProps } from "../RyftPaymentForm";
|
|
3
|
+
|
|
4
|
+
interface InjectComponentsInRyftForm
|
|
5
|
+
extends Pick<
|
|
6
|
+
RyftPaymentFormProps,
|
|
7
|
+
"onApplePayButtonClick" | "isAppUsingInIframe"
|
|
8
|
+
> {
|
|
9
|
+
t: TFunction<string[]>;
|
|
10
|
+
additionalPaymentMethodsEnabled?: boolean;
|
|
11
|
+
}
|
|
2
12
|
|
|
3
13
|
export const injectComponentsInRyftForm = ({
|
|
4
14
|
t,
|
|
5
15
|
additionalPaymentMethodsEnabled,
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}) => {
|
|
16
|
+
isAppUsingInIframe,
|
|
17
|
+
onApplePayButtonClick,
|
|
18
|
+
}: InjectComponentsInRyftForm) => {
|
|
10
19
|
const cardContainer = document.getElementById("ryft-pay-iframe");
|
|
11
20
|
|
|
12
21
|
if (!cardContainer) {
|
|
@@ -34,6 +43,7 @@ export const injectComponentsInRyftForm = ({
|
|
|
34
43
|
// Removing of the old mobile title container and divider container
|
|
35
44
|
document.getElementById("mobile-pay-title")?.remove();
|
|
36
45
|
document.getElementById("mobile-pay-divider-container")?.remove();
|
|
46
|
+
document.getElementById("apple-pay")?.remove();
|
|
37
47
|
|
|
38
48
|
// Adding title and divider for apple and google pay button
|
|
39
49
|
const mobilePayTitle = document.createElement("div");
|
|
@@ -48,6 +58,15 @@ export const injectComponentsInRyftForm = ({
|
|
|
48
58
|
divider.id = "mobile-pay-divider";
|
|
49
59
|
container.id = "mobile-pay-divider-container";
|
|
50
60
|
container.append(dividerText, divider);
|
|
61
|
+
if (isAppUsingInIframe) {
|
|
62
|
+
const applePayButton = document.createElement("button");
|
|
63
|
+
applePayButton.id = "apple-pay";
|
|
64
|
+
applePayButton.type = "button";
|
|
65
|
+
applePayButton.className = "bg-dark btn btn-primary apple-pay-button";
|
|
66
|
+
applePayButton.textContent = t("Events:payWithApple");
|
|
67
|
+
applePayButton.onclick = onApplePayButtonClick;
|
|
68
|
+
payGrid.append(applePayButton);
|
|
69
|
+
}
|
|
51
70
|
payGrid.before(mobilePayTitle);
|
|
52
71
|
payGrid.after(container);
|
|
53
72
|
};
|
|
@@ -135,6 +135,14 @@
|
|
|
135
135
|
margin-bottom: 0.5rem;
|
|
136
136
|
}
|
|
137
137
|
}
|
|
138
|
+
.ryft-pay-grid {
|
|
139
|
+
display: flex;
|
|
140
|
+
flex-direction: column;
|
|
141
|
+
.apple-pay-button {
|
|
142
|
+
height: 2.5rem;
|
|
143
|
+
margin-top: 1rem;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
138
146
|
.mobile-pay-title {
|
|
139
147
|
display: block;
|
|
140
148
|
font-weight: 600;
|