@openhive-eu/payment 1.0.0-beta.1 → 1.0.0-beta.3
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/index.js +1 -1
- package/dist/index.js.gz +0 -0
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.gz +0 -0
- package/dist/react-widget.d.ts +9 -39
- package/dist/react.js +885 -900
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -5862,7 +5862,7 @@ var pd = Object.defineProperty, A = (t, e, r, n) => {
|
|
|
5862
5862
|
};
|
|
5863
5863
|
class w extends Ce {
|
|
5864
5864
|
constructor() {
|
|
5865
|
-
super(...arguments), this.token = "", this.currency = "EUR", this.defaultAmount = "", this.defaultReference = "", this.readOnlyAmount = !1, this.customerName = "", this.customerEmail = "", this.customerPhone = "", this.locale = "fr", this.payClientRef = "", this._amount = "", this._email = "", this._phone = "", this._paymentReference = "", this._method = "", this._channel = void 0, this._country = s0.code, this._loading = !1, this._success = !1, this._paymentMethods = [], this._methodsLoading = !0, this._methodsError = null, this._initialized = !1, this._t = ot("fr"), this._apiUrl = "https://
|
|
5865
|
+
super(...arguments), this.token = "", this.currency = "EUR", this.defaultAmount = "", this.defaultReference = "", this.readOnlyAmount = !1, this.customerName = "", this.customerEmail = "", this.customerPhone = "", this.locale = "fr", this.payClientRef = "", this._amount = "", this._email = "", this._phone = "", this._paymentReference = "", this._method = "", this._channel = void 0, this._country = s0.code, this._loading = !1, this._success = !1, this._paymentMethods = [], this._methodsLoading = !0, this._methodsError = null, this._initialized = !1, this._t = ot("fr"), this._apiUrl = "https://payment.openhive-staging.eu/api/payment-methods";
|
|
5866
5866
|
}
|
|
5867
5867
|
createRenderRoot() {
|
|
5868
5868
|
return this;
|
package/dist/index.js.gz
CHANGED
|
Binary file
|
package/dist/index.min.js
CHANGED
|
@@ -123,7 +123,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
123
123
|
>
|
|
124
124
|
<p>Something went wrong while loading the payment component.</p>
|
|
125
125
|
</div>
|
|
126
|
-
`}var yi=Object.defineProperty,_=(t,e,r,n)=>{for(var o=void 0,i=t.length-1,a;i>=0;i--)(a=t[i])&&(o=a(e,r,o)||o);return o&&yi(e,r,o),o};class w extends _e{constructor(){super(...arguments),this.token="",this.currency="EUR",this.defaultAmount="",this.defaultReference="",this.readOnlyAmount=!1,this.customerName="",this.customerEmail="",this.customerPhone="",this.locale="fr",this.payClientRef="",this._amount="",this._email="",this._phone="",this._paymentReference="",this._method="",this._channel=void 0,this._country=$o.code,this._loading=!1,this._success=!1,this._paymentMethods=[],this._methodsLoading=!0,this._methodsError=null,this._initialized=!1,this._t=Ct("fr"),this._apiUrl="https://
|
|
126
|
+
`}var yi=Object.defineProperty,_=(t,e,r,n)=>{for(var o=void 0,i=t.length-1,a;i>=0;i--)(a=t[i])&&(o=a(e,r,o)||o);return o&&yi(e,r,o),o};class w extends _e{constructor(){super(...arguments),this.token="",this.currency="EUR",this.defaultAmount="",this.defaultReference="",this.readOnlyAmount=!1,this.customerName="",this.customerEmail="",this.customerPhone="",this.locale="fr",this.payClientRef="",this._amount="",this._email="",this._phone="",this._paymentReference="",this._method="",this._channel=void 0,this._country=$o.code,this._loading=!1,this._success=!1,this._paymentMethods=[],this._methodsLoading=!0,this._methodsError=null,this._initialized=!1,this._t=Ct("fr"),this._apiUrl="https://payment.openhive-staging.eu/api/payment-methods"}createRenderRoot(){return this}get payClient(){return this._payClient}set payClient(e){this._payClient=e,this._initialized&&this._fetchPaymentMethods()}willUpdate(e){this._initialized?e.has("locale")&&(this._t=Ct(this.locale)):(this._initialized=!0,this._amount=t1(this.defaultAmount),this._email=this.customerEmail,this._phone=this.customerPhone,this._paymentReference=this.defaultReference,this._t=Ct(this.locale))}firstUpdated(){this._fetchPaymentMethods()}_getPayClient(){if(this._payClient)return this._payClient;if(this.payClientRef){const e=globalThis[this.payClientRef];if(e)return e}return new W1(this._apiUrl,this.token,this.locale)}async _fetchPaymentMethods(){this._methodsLoading=!0,this._methodsError=null;try{this._paymentMethods=await this._getPayClient().getPaymentMethods()}catch(e){this._methodsError=e instanceof Error?e.message:"Failed to load payment methods"}finally{this._methodsLoading=!1}}_validateAmount(e){const r=parseFloat(e.replace(",",".").replace(/\s/g,""));return!isNaN(r)&&r>0}get _isValid(){return!this._amount||!this._validateAmount(this._amount)||!this._paymentReference||!this._method?!1:this._channel==="email"?kr(this._email):this._channel==="sms"?Ar(this._country,this._phone):!0}_onAmountInput(e){const r=e.target;this._amount=t1(r.value)}_onReferenceInput(e){this._paymentReference=e.target.value}_onMethodChange(e){this._method=e.target.value}_onChannelChange(e){this._channel=e.target.value}_onEmailInput(e){this._email=e.target.value}_onPhoneInput(e){this._phone=so(this._country,e.target.value)}_onCountryChange(e){this._country=e.target.value}async _onSubmit(e){e.preventDefault(),this._loading=!0;const r=this._method.indexOf("_"),n=r>=0?this._method.substring(0,r):this._method,o=r>=0?this._method.substring(r+1):"",i={order_reference:this._paymentReference,channel:this._channel==="email"?"email":this._channel==="sms"?"sms":"link",amount:ei(this._amount),currency:this.currency,method:o,customer_contact:this._channel==="email"?this._email:this._channel==="sms"?this._phone:this._email,partner:n};this._success=!0;try{await Promise.resolve(this.dispatchEvent(new CustomEvent("request-to-pay",{detail:i,bubbles:!0,composed:!0})))}catch(a){console.error(a)}finally{this._loading=!1}}_onClose(){this._success=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,composed:!0}))}_renderMethods(){return this._methodsLoading?ni():this._paymentMethods.map(e=>$i({name:"payment-method",value:e.id,checked:this._method===e.id,onChange:this._onMethodChange.bind(this),label:e.name,logoSvg:e.logoSvg}))}_renderChannels(){return C`
|
|
127
127
|
${i1({name:"channel",value:"email",checked:this._channel==="email",onChange:this._onChannelChange.bind(this),label:this._t.email,icon:ui})}
|
|
128
128
|
${i1({name:"channel",value:"sms",checked:this._channel==="sms",onChange:this._onChannelChange.bind(this),label:this._t.textMessage,icon:pi})}
|
|
129
129
|
`}_renderForm(){const e=this._amount?!this._validateAmount(this._amount):!1,r=this._email?!kr(this._email):!1,n=this._phone?!Ar(this._country,this._phone):!1;return C`
|
package/dist/index.min.js.gz
CHANGED
|
Binary file
|
package/dist/react-widget.d.ts
CHANGED
|
@@ -1,40 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { type EventName } from "@lit/react";
|
|
2
|
+
import { PaymentWidget } from "./payment-widget";
|
|
2
3
|
import "./register";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
"openhive-pay": React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement> & {
|
|
11
|
-
token?: string;
|
|
12
|
-
currency?: string;
|
|
13
|
-
"default-amount"?: string;
|
|
14
|
-
"default-reference"?: string;
|
|
15
|
-
"read-only-amount"?: string;
|
|
16
|
-
"customer-name"?: string;
|
|
17
|
-
"customer-email"?: string;
|
|
18
|
-
"customer-phone"?: string;
|
|
19
|
-
locale?: string;
|
|
20
|
-
}, HTMLElement>;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
export interface PaymentProps {
|
|
25
|
-
token?: string;
|
|
26
|
-
currency?: Currency;
|
|
27
|
-
defaultAmount?: string;
|
|
28
|
-
defaultReference?: string;
|
|
29
|
-
readOnlyAmount?: boolean;
|
|
30
|
-
customerName?: string;
|
|
31
|
-
customerEmail?: string;
|
|
32
|
-
customerPhone?: string;
|
|
33
|
-
locale?: string;
|
|
34
|
-
payClient?: PayClientInterface;
|
|
35
|
-
onRequestToPay?: (detail: RequestToPay) => void;
|
|
36
|
-
onClose?: () => void;
|
|
37
|
-
className?: string;
|
|
38
|
-
style?: React.CSSProperties;
|
|
39
|
-
}
|
|
40
|
-
export declare function Payment({ token, currency, defaultAmount, defaultReference, readOnlyAmount, customerName, customerEmail, customerPhone, locale, payClient, onRequestToPay, onClose, className, style, }: PaymentProps): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
export type { RequestToPay, Currency } from "./lib/api-client";
|
|
5
|
+
export type { PayClientInterface } from "./lib/pay-client";
|
|
6
|
+
import type { RequestToPay } from "./lib/api-client";
|
|
7
|
+
export declare const Payment: import("@lit/react").ReactWebComponent<PaymentWidget, {
|
|
8
|
+
onRequestToPay: EventName<CustomEvent<RequestToPay>>;
|
|
9
|
+
onClose: EventName<Event>;
|
|
10
|
+
}>;
|