New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@moneyhash/js-sdk

Package Overview
Dependencies
Maintainers
0
Versions
82
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@moneyhash/js-sdk - npm Package Compare versions

Comparing version 1.0.0-beta.5 to 1.0.0

dist/sdkEmbed-9010c7b6.cjs

2

dist/headless.cjs.js

@@ -1,1 +0,1 @@

"use strict";var B=Object.defineProperty,O=Object.defineProperties;var Y=Object.getOwnPropertyDescriptors;var M=Object.getOwnPropertySymbols;var J=Object.prototype.hasOwnProperty,z=Object.prototype.propertyIsEnumerable;var _=(n,e,t)=>e in n?B(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,E=(n,e)=>{for(var t in e||(e={}))J.call(e,t)&&_(n,t,e[t]);if(M)for(var t of M(e))z.call(e,t)&&_(n,t,e[t]);return n},F=(n,e)=>O(n,Y(e));var m=(n,e,t)=>(_(n,typeof e!="symbol"?e+"":e,t),t),K=(n,e,t)=>{if(!e.has(n))throw TypeError("Cannot "+t)};var u=(n,e,t)=>{if(e.has(n))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(n):e.set(n,t)};var y=(n,e,t)=>(K(n,e,"access private method"),t);var P=(n,e,t)=>new Promise((r,s)=>{var d=i=>{try{a(t.next(i))}catch(l){s(l)}},o=i=>{try{a(t.throw(i))}catch(l){s(l)}},a=i=>i.done?r(i.value):Promise.resolve(i.value).then(d,o);a((t=t.apply(n,e)).next())});const g=require("./sdkEmbed-bae6b7db.cjs");function G(){return typeof window!="undefined"}const h=class{constructor(){G()&&this.initSDKCommunicationIframe()}initSDKCommunicationIframe(){if(document.getElementById("moneyhash-headless-sdk"))return;const e=g.getIframeUrl(),t=new URL(`${e}/embed/headless-sdk`);t.searchParams.set("sdk","true"),t.searchParams.set("parent",window.location.origin),t.searchParams.set("version","js@1.0.0-beta.5");const r=document.createElement("iframe");r.id="moneyhash-headless-sdk",r.src=t.toString(),r.hidden=!0,document.body.appendChild(r),h.messagingService=new g.MessagingService({target:r.contentWindow,targetOrigin:e}),h.isCommunicationReady=new Promise(s=>{var o;const d=a=>{var i;a.data.type==="headlessSDK:init"&&(s(),(i=h.messagingService)==null||i.removeListener(d))};(o=h.messagingService)==null||o.onReceive(d)})}request(r){return P(this,arguments,function*({api:e,payload:t}){return yield h.isCommunicationReady,new Promise((s,d)=>{var a,i;(a=h.messagingService)==null||a.send({type:e,data:t});const o=l=>{var f;const{type:c,data:p}=l.data;c===e&&(p.status==="resolved"?s(p.payload):d(p.payload),(f=h.messagingService)==null||f.removeListener(o))};(i=h.messagingService)==null||i.onReceive(o)})})}};let b=h;m(b,"messagingService",null),m(b,"isCommunicationReady");class Q{constructor(){m(this,"promise");m(this,"resolve");m(this,"reject");this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}}function X(){var e;return(e=window.MONEYHASH_VAULT_API_URL)!=null?e:"https://vault.moneyhash.io"}function T(){var e;return(e=window.MONEYHASH_VAULT_INPUT_IFRAME_URL)!=null?e:"https://vault.moneyhash.io"}function Z(n){return(Array.isArray(n)?n.length:Object.keys(n).length)===0}function ee(n,e){return new Promise((t,r)=>{if(document.getElementById(e)){t(void 0);return}const d=document.createElement("script");d.src=n,d.id=e,d.addEventListener("load",()=>{t(void 0)}),d.addEventListener("error",()=>{r(new Error("Script failed to load"))}),document.body.appendChild(d)})}function $(){var e;return(e=window.API_URL)!=null?e:"https://web.moneyhash.io"}const H=new Set(["method","customerBalance","savedCard"]);var I,V,A,j,S,q,k,N,L,W,U,D,R,x;class te{constructor(e){u(this,I);u(this,A);u(this,S);u(this,k);u(this,L);u(this,U);u(this,R);m(this,"options");m(this,"sdkApiHandler",new b);m(this,"sdkEmbed");m(this,"vaultSubmitListener",{current:null});this.options=e,this.sdkEmbed=new g.SDKEmbed(F(E({},e),{headless:!0})),y(this,L,W).call(this,this.vaultSubmitListener)}getIntentDetails(e){return this.sdkApiHandler.request({api:"sdk:getIntentDetails",payload:{intentType:this.options.type,intentId:e,lang:this.sdkEmbed.lang}})}getIntentMethods(e){return this.sdkApiHandler.request({api:"sdk:getIntentMethods",payload:{intentType:this.options.type,intentId:e,lang:this.sdkEmbed.lang}})}proceedWith({intentId:e,type:t,id:r,metaData:s}){return g.throwIf(!H.has(t),`type must be a valid one (${[...H].join(" | ")})`),this.sdkApiHandler.request({api:"sdk:proceedWith",payload:{proceedWith:t,intentType:this.options.type,intentId:e,id:r,lang:this.sdkEmbed.lang,metaData:s}})}resetSelectedMethod(e){return this.sdkApiHandler.request({api:"sdk:resetSelectedMethod",payload:{intentType:this.options.type,intentId:e,lang:this.sdkEmbed.lang}})}deleteCard({cardId:e,intentSecret:t}){return g.throwIf(this.options.type==="payout","deleteCard is allowed only for payment intent!"),this.sdkApiHandler.request({api:"sdk:deleteCard",payload:{cardId:e,intentSecret:t,lang:this.sdkEmbed.lang}})}payWithApplePay(l){return P(this,arguments,function*({intentId:e,currency:t,amount:r,countryCode:s,onCancel:d=()=>{},onError:o,onComplete:a,billingData:i={}}){if(yield ee("https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js","moneyHash-apple-pay-sdk"),!ApplePaySession)return;const c=new ApplePaySession(3,{countryCode:s,currencyCode:t,supportedNetworks:["visa","masterCard","amex","discover","mada"],merchantCapabilities:["supports3DS"],total:{label:"Apple Pay",type:"final",amount:`${r}`}}),{__providerId__:p,state:f,intent:C}=yield this.proceedWith({intentId:e,type:"method",id:"APPLE_PAY"});try{if(f==="INTENT_FORM"){if(Z(i))throw new Error("Billing data is missing while calling payWithApplePay");yield this.sdkApiHandler.request({api:"sdk:submitNativeForm",payload:{intentId:e,paymentMethod:"APPLE_PAY",providerId:p,lang:this.sdkEmbed.lang,billingData:i}})}}catch(w){throw yield this.resetSelectedMethod(e),w}c.onvalidatemerchant=w=>{fetch(`${$()}/api/v1/providers/applepay/session/`,{method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify({secret:C.secret,validation_url:w.validationURL})}).then(v=>v.ok?v.json():Promise.reject()).then(v=>c.completeMerchantValidation(v)).catch(o)},c.onpaymentauthorized=w=>{fetch(`${$()}/api/v1/providers/applepay/token/`,{method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify({token_data:w.payment.token,secret:C.secret})}).then(v=>v.ok?v.json():Promise.reject()).then(()=>{c.completePayment(ApplePaySession.STATUS_SUCCESS),a()}).catch(()=>{c.completePayment(ApplePaySession.STATUS_FAILURE),o()})},c.oncancel=d,c.begin()})}renderForm({selector:e,intentId:t}){return g.throwIf(!e,"selector is required for renderForm"),g.throwIf(!t,"intentId is required for renderForm"),this.sdkEmbed.render({selector:e,intentId:t})}setLocale(e){return this.sdkEmbed.setLocale(e)}removeEventListeners(){return this.sdkEmbed.abortService()}elements({styles:e}){const t=[];return y(this,k,N).call(this,t),{create:({elementType:r,elementOptions:s})=>{const d=new Map,o=document.querySelector(s.selector);return g.throwIf(!o,`Couldn't find an element with selector ${s.selector}!`),o.classList.add("MoneyHashElement"),t.push(a=>{var l,c,p;const{type:i}=a.data;i===`${r}@focus`&&(o.classList.add("MoneyHashElement--focus"),(l=d.get(`${r}@focus`))==null||l()),i===`${r}@blur`&&(o.classList.remove("MoneyHashElement--focus"),(c=d.get(`${r}@blur`))==null||c()),i===`${r}@changeInput`&&((p=d.get(`${r}@changeInput`))==null||p())}),{mount:()=>y(this,U,D).call(this,{container:o,elementType:r,elementOptions:s,styles:E(E({},e),s.styles)}),on:(a,i)=>{d.set(`${r}@${a}`,i)}}}}}submitForm(d){return P(this,arguments,function*({intentId:e,accessToken:t,billingData:r,shippingData:s}){const o=new Q;let a,i;t&&(this.vaultSubmitListener.current=c=>{const{type:p,data:f}=c.data;p==="vaultSubmit:success"&&o.resolve(f),p==="vaultSubmit:error"&&o.reject(f)},i=y(this,R,x).call(this,t),a=yield o.promise);const l=yield this.sdkApiHandler.request({api:"sdk:submitNativeForm",payload:{intentId:e,paymentMethod:"CARD",lang:this.sdkEmbed.lang,billingData:r,shippingData:s,cardEmbed:a}});return i&&i.remove(),l})}submitCvv(r){return P(this,arguments,function*({intentId:e,cvv:t}){return this.sdkApiHandler.request({api:"sdk:submitCardCvv",payload:{intentId:e,cvv:t,lang:this.sdkEmbed.lang}})})}renderUrl(e,t){switch(t){case"IFRAME":return y(this,I,V).call(this,e);case"POPUP_IFRAME":return y(this,A,j).call(this,e);case"REDIRECT":return y(this,S,q).call(this,e);default:return null}}}I=new WeakSet,V=function(e){const t=document.querySelector("#rendered-url-iframe-container"),r=document.createElement("iframe");return r.src=e,r.style.setProperty("border","0","important"),r.style.setProperty("width","100vw","important"),r.style.setProperty("height","100vh","important"),t==null||t.replaceChildren(r),r},A=new WeakSet,j=function(e){return window.open(`${e}`,"","width=600,height=400,left=200,top=200")},S=new WeakSet,q=function(e){return window.open(e,"_blank")},k=new WeakSet,N=function(e){const t=r=>{e.forEach(s=>{s(r)})};window.addEventListener("message",t)},L=new WeakSet,W=function(e){const t=r=>{e.current&&e.current(r)};window.addEventListener("message",t)},U=new WeakSet,D=function({container:e,elementType:t,elementOptions:r,styles:s}){var i,l;const d=T(),o=new URL(`${d}/vaultField/vaultField.html`);o.searchParams.set("parent",window.location.origin),o.searchParams.set("type",t),o.searchParams.set("placeholder",(i=r.placeholder)!=null?i:""),o.searchParams.set("color",(s==null?void 0:s.color)||"#000"),o.searchParams.set("placeholderColor",(s==null?void 0:s.placeholderColor)||"#ccc"),o.searchParams.set("backgroundColor",(s==null?void 0:s.backgroundColor)||"transparent");const a=document.createElement("iframe");a.src=o.toString(),a.style.height=(l=r.height)!=null?l:"40px",a.style.setProperty("overflow","hidden","important"),a.style.setProperty("display","block","important"),a.style.setProperty("width","100%","important"),a.style.setProperty("maxWidth","100%","important"),a.style.setProperty("border","0","important"),a.style.setProperty("margin","0","important"),a.style.setProperty("padding","0","important"),a.style.setProperty("userSelect","none","important"),a.style.setProperty("colorScheme","light only","important"),e.replaceChildren(a)},R=new WeakSet,x=function(e){const t=T(),r=X(),s=new URL(`${t}/vaultSubmit/vaultSubmit.html`);s.searchParams.set("parent",window.location.origin),s.searchParams.set("vault_api_url",`${r}/api/v1/tokens/`),s.searchParams.set("access_token",e);const d=document.createElement("iframe");return d.id="moneyhash-submit-iframe",d.src=s.toString(),d.hidden=!0,document.body.appendChild(d),d};module.exports=te;
"use strict";var S=Object.defineProperty,I=Object.defineProperties;var C=Object.getOwnPropertyDescriptors;var k=Object.getOwnPropertySymbols;var q=Object.prototype.hasOwnProperty,R=Object.prototype.propertyIsEnumerable;var g=(s,e,t)=>e in s?S(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,v=(s,e)=>{for(var t in e||(e={}))q.call(e,t)&&g(s,t,e[t]);if(k)for(var t of k(e))R.call(e,t)&&g(s,t,e[t]);return s},f=(s,e)=>I(s,C(e));var m=(s,e,t)=>(g(s,typeof e!="symbol"?e+"":e,t),t);var w=(s,e,t)=>new Promise((c,r)=>{var d=n=>{try{a(t.next(n))}catch(l){r(l)}},o=n=>{try{a(t.throw(n))}catch(l){r(l)}},a=n=>n.done?c(n.value):Promise.resolve(n.value).then(d,o);a((t=t.apply(s,e)).next())});const h=require("./sdkEmbed-9010c7b6.cjs");function L(){return typeof window!="undefined"}const i=class{constructor(){L()&&this.initSDKCommunicationIframe()}initSDKCommunicationIframe(){if(document.getElementById("moneyhash-headless-sdk"))return;const e=new URL("https://embed.moneyhash.io/embed/headless-sdk");e.searchParams.set("sdk","true"),e.searchParams.set("parent",window.location.origin),e.searchParams.set("version","js@0.0.0-development");const t=document.createElement("iframe");t.id="moneyhash-headless-sdk",t.src=e.toString(),t.hidden=!0,document.body.appendChild(t),i.messagingService=new h.MessagingService({target:t.contentWindow,targetOrigin:"https://embed.moneyhash.io"}),i.isCommunicationReady=new Promise(c=>{var d;const r=o=>{var a;o.data.type==="headlessSDK:init"&&(c(),(a=i.messagingService)==null||a.removeListener(r))};(d=i.messagingService)==null||d.onReceive(r)})}request(c){return w(this,arguments,function*({api:e,payload:t}){return yield i.isCommunicationReady,new Promise((r,d)=>{var a,n;(a=i.messagingService)==null||a.send({type:e,data:t});const o=l=>{var y;const{type:E,data:u}=l.data;E===e&&(u.status==="resolved"?r(u.payload):d(u.payload),(y=i.messagingService)==null||y.removeListener(o))};(n=i.messagingService)==null||n.onReceive(o)})})}};let p=i;m(p,"messagingService",null),m(p,"isCommunicationReady");const b=new Set(["method","customerBalance","savedCard"]);class M{constructor(e){m(this,"options");m(this,"sdkApiHandler",new p);m(this,"sdkEmbed");this.options=e,this.sdkEmbed=new h.SDKEmbed(f(v({},e),{headless:!0}))}getIntentDetails(e){return this.sdkApiHandler.request({api:"sdk:getIntentDetails",payload:{intentType:this.options.type,intentId:e,lang:this.sdkEmbed.lang}})}getIntentMethods(e){return this.sdkApiHandler.request({api:"sdk:getIntentMethods",payload:{intentType:this.options.type,intentId:e,lang:this.sdkEmbed.lang}})}proceedWith({intentId:e,type:t,id:c,metaData:r}){return h.throwIf(!b.has(t),`type must be a valid one (${[...b].join(" | ")})`),this.sdkApiHandler.request({api:"sdk:proceedWith",payload:{proceedWith:t,intentType:this.options.type,intentId:e,id:c,lang:this.sdkEmbed.lang,metaData:r}})}resetSelectedMethod(e){return this.sdkApiHandler.request({api:"sdk:resetSelectedMethod",payload:{intentType:this.options.type,intentId:e,lang:this.sdkEmbed.lang}})}deleteCard({cardId:e,intentSecret:t}){return h.throwIf(this.options.type==="payout","deleteCard is allowed only for payment intent!"),this.sdkApiHandler.request({api:"sdk:deleteCard",payload:{cardId:e,intentSecret:t,lang:this.sdkEmbed.lang}})}renderForm({selector:e,intentId:t}){return h.throwIf(!e,"selector is required for renderForm"),h.throwIf(!t,"intentId is required for renderForm"),this.sdkEmbed.render({selector:e,intentId:t})}setLocale(e){return this.sdkEmbed.setLocale(e)}removeEventListeners(){return this.sdkEmbed.abortService()}}module.exports=M;

@@ -10,5 +10,2 @@ export declare interface AbstractIntent {

};
subtotalAmount: string | null;
fees: Array<FeesItem> | null;
totalDiscounts: string | null;
secret: string;

@@ -18,11 +15,2 @@ isLive: boolean;

export declare interface AppleNativePayData {
method: "APPLE_PAY";
merchantId: string;
countryCode: string;
currencyCode: string;
amount: string;
supportedNetworks: string[];
}
export declare type AuthorizeOperationStatus = "pending" | "pending_authentication" | "failed" | "successful";

@@ -58,8 +46,2 @@

export declare type CardInfo = {
brand: string;
lastFourDigits: string;
logo: string;
};
export declare type CustomerBalances = [

@@ -74,26 +56,2 @@ {

declare type ElementEvents = "focus" | "blur" | "changeInput";
declare type ElementProps = {
elementType: ElementType;
elementOptions: {
selector: string;
height?: string;
placeholder?: string;
styles?: ElementStyles;
};
};
declare type ElementsProps = {
styles?: ElementStyles;
};
declare type ElementStyles = {
color?: string;
backgroundColor?: string;
placeholderColor?: string;
};
declare type ElementType = "cardHolderName" | "cardNumber" | "cardCvv" | "cardExpiryMonth" | "cardExpiryYear";
export declare type ErrorResponse = {

@@ -104,61 +62,2 @@ code: number;

export declare interface FeesItem {
title: Record<SupportedLanguages, string>;
value: string;
}
export declare type Field = {
type: FieldType;
name: string;
label: string;
hint: string;
value: string;
readOnly: boolean;
validation: {
required: boolean;
minLength: number | null;
maxLength: number | null;
};
dependsOn?: string;
optionsList?: Array<{
label: string;
value: string;
}>;
optionsMap?: Record<string, Array<{
label: string;
value: string;
}>>;
};
export declare type FieldType = "text" | "number" | "email" | "date" | "phoneNumber" | "select";
export declare type FormField = {
choices?: Record<string, string> | null;
error_messages: {
blank: string;
null?: string;
required: string;
invalid: string;
min_length: string;
max_length: string;
};
field_name: string;
help_text?: string | null;
label?: string;
max_length?: number | null;
min_length?: number | null;
read_only: boolean;
required: boolean;
type: "PhoneNumberField" | "ChoiceField" | "CharField" | "IntegerField" | "EmailField" | "DateField";
value: string;
};
declare type FormFields = {
billing: Array<Field> | null;
shipping: Array<Field> | null;
card: {
accessToken: string;
} | null;
};
declare interface InputAllowedStyle {

@@ -191,12 +90,5 @@ height?: number;

transaction: PaymentTransaction;
redirect: Redirect | null;
selectedMethod: PaymentMethodSlugs | null;
/**
* Intent state to guide you through different actions required. check [README](https://docs.moneyhash.io/docs/javascript-sdk#integrating)
*/
state: IntentState;
stateDetails: IntentStateDetails;
shippingData: Shipping | null;
productItems: ProductItem[] | null;
nativePayData: AppleNativePayData | null;
__providerId__: string | null;
} : {

@@ -206,8 +98,3 @@ intent: PayoutIntent;

selectedMethod: PaymentMethodSlugs | null;
/**
* Intent state to guide you through different actions required. check [README](https://docs.moneyhash.io/docs/javascript-sdk#integrating)
*/
state: IntentState;
stateDetails: IntentStateDetails;
__providerId__: never;
};

@@ -224,12 +111,4 @@

export declare type IntentState = "METHOD_SELECTION" | "INTENT_FORM" | "INTENT_PROCESSED" | "TRANSACTION_WAITING_USER_ACTION" | "TRANSACTION_FAILED" | "EXPIRED" | "CLOSED" | "NATIVE_PAY" | "FORM_FIELDS" | "URL_TO_RENDER" | "SAVED_CARD_CVV";
export declare type IntentState = "METHOD_SELECTION" | "INTENT_FORM" | "INTENT_PROCESSED" | "TRANSACTION_WAITING_USER_ACTION" | "TRANSACTION_FAILED" | "EXPIRED" | "CLOSED";
export declare type IntentStateDetails<TType extends IntentState = IntentState> = TType extends "FORM_FIELDS" ? FormFields : TType extends "URL_TO_RENDER" ? {
url: string;
renderStrategy: UrlRenderStrategy;
} : TType extends "SAVED_CARD_CVV" ? {
card: CardInfo;
cvvField: Field;
} : null;
export declare type IntentStatus = "PROCESSED" | "UNPROCESSED" | "CLOSED" | "TIME_EXPIRED" | "PENDING" | "EXPIRED";

@@ -239,7 +118,2 @@

export declare interface LoaderStyle {
backgroundColor: string;
color: string;
}
export declare interface Method {

@@ -251,80 +125,11 @@ id: PaymentMethodSlugs;

confirmationRequired: boolean;
requiredBillingFields: FormField[] | null;
}
declare class MoneyHashHeadless<TType extends IntentType> {
#private;
private options;
private sdkApiHandler;
private sdkEmbed;
private vaultSubmitListener;
constructor(options: MoneyHashHeadlessOptions<TType>);
/**
* Get intent details
* @example
* ```
* await moneyHash.getIntentDetails('<intent_id>');
* ```
*
* @returns Promise<{@link IntentDetails}>
*/
getIntentDetails(intentId: string): Promise<IntentDetails<TType>>;
/**
* Get intent available payment/payout methods, saved cards and customer balances
* @example
* ```
* await moneyHash.getIntentMethods('<intent_id>');
* ```
* @returns Promise<{@link IntentMethods}>
*/
getIntentMethods(intentId: string): Promise<IntentMethods<TType>>;
/**
* Proceed with a payment/payout method, card or wallet
*
* @example
* <caption>Proceed with a payment/payout method</caption>
* ```
* await moneyHash.proceedWith({
* intentId: '<intent_id>',
* type: 'method',
* id: '<method_id>',
* })
* ```
* @see {@link Method} - for \<method_id>
*
* @example
* <caption>Proceed with a customer balance. e.g. wallet</caption>
* ```
* await moneyHash.proceedWith({
* intentId: '<intent_id>',
* type: 'customerBalance',
* id: '<customer_balance_id>',
* })
* ```
* @see {@link CustomerBalances} - for \<customer_balance_id>
*
* @example
* <caption>Proceed with a customer saved card</caption>
* ```
* // Card doesn't require CVV
* await moneyHash.proceedWith({
* intentId: '<intent_id>',
* type: 'savedCard',
* id: '<card_id>',
* })
*
* // Card requires CVV
* await moneyHash.proceedWith({
* intentId: '<intent_id>',
* type: 'savedCard',
* id: '<card_id>',
* metaData: {
* cvv: '<cvv>',
* }
* })
* ```
* @see {@link Card} - for \<card_id> & if card requires cvv or not
*
* @returns Promise<{@link IntentDetails}>
*/
proceedWith({ intentId, type, id, metaData, }: {

@@ -338,31 +143,3 @@ type: "method" | "customerBalance" | "savedCard";

}): Promise<IntentDetails<TType>>;
/**
* Reset the selected method on and intent to null
*
* @description Can be used for `back` button after method selection
* or `retry` button on failed transaction UI to try a different
* method by the user.
*
* @example
* ```
* await moneyHash.resetSelectedMethod('<intent_id>');
* ```
*
* @returns Promise<{@link IntentDetails}>
*/
resetSelectedMethod(intentId: string): Promise<IntentDetails<TType>>;
/**
* Delete a customer saved card
*
* @example
* ```
* await moneyHash.deleteCard({
* cardId: '<card_id>',
* intentSecret: '<intent_secret>',
* });
* ```
* @see {@link Card} - for \<card_id>
* @see {@link AbstractIntent} - for \<intent_secret>
* @returns Promise<{ message: 'success'} >
*/
deleteCard({ cardId, intentSecret, }: {

@@ -374,66 +151,2 @@ cardId: string;

}>;
/**
* Pay with native apple pay
*
* @example
* ```
* moneyHash
* .payWithApplePay({
* intentId: paymentIntentId,
* countryCode: "AE",
* amount: intentDetails.intent.amount.formatted,
* currency: intentDetails.intent.amount.currency,
* billingData: {
* email: "test@test.com",
* },
* onCancel: () => console.log("CANCEL"),
* onComplete: async () => {
* // Will fire after a successful payment
* console.log("COMPLETE");
* },
* onError: async () => {
* // Will fire after a failure payment
* console.log("ERROR");
* },
* })
* .catch(error => {
* console.log(error);
* error.message | string
* // Native apple pay button need to be triggered from click event directly
- Must create a new ApplePaySession from a user gesture handler.
// intent requires billing data to proceed with the native integration
- Billing data is missing while calling payWithApplePay
error | Record<string, string>
{email: "Enter a valid email address."}
* });
* ```
*/
payWithApplePay({ intentId, currency, amount, countryCode, onCancel, onError, onComplete, billingData, }: {
intentId: string;
countryCode: string;
currency: string;
amount: number;
onCancel?: () => void;
onError: () => void;
onComplete: () => void;
billingData?: Record<string, unknown>;
}): Promise<void>;
/**
* Render SDK embed forms and payment integrations
*
* @description must be called if `state` of an intent is `INTENT_FORM` to let MoneyHash handle the payment.
* you can listen for completion or failure of an intent by providing `onComplete` `onFail` callbacks on MoneyHash instance.
*
* @example
* ```
* await moneyHash.renderForm({
* selector: '<container_css_selector>',
* intentId: '<intentId>',
* });
* ```
* {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | CSS Selector MDN}
* @returns Promise<void>
*/
renderForm({ selector, intentId }: {

@@ -443,37 +156,4 @@ selector: string;

}): Promise<void>;
/**
* Change the embed localization
*
* @description we currently support 3 languages `English`, `Arabic`, `Français`.
*
* @example
* ```
* await moneyHash.setLocale("<locale_code>");
* ```
*
* @returns Promise<void>
*/
setLocale(locale: string): Promise<void>;
/**
* Cleanup all listeners set by the SDK
* @returns Promise<void>
*/
removeEventListeners(): Promise<void>;
elements({ styles }: ElementsProps): {
create: ({ elementType, elementOptions }: ElementProps) => {
mount: () => void;
on: (eventName: ElementEvents, callback: () => void) => void;
};
};
submitForm({ intentId, accessToken, billingData, shippingData, }: {
intentId: string;
accessToken?: string | null;
billingData?: Record<string, unknown>;
shippingData?: Record<string, unknown>;
}): Promise<IntentDetails<TType>>;
submitCvv({ intentId, cvv }: {
intentId: string;
cvv: string;
}): Promise<IntentDetails<TType>>;
renderUrl(url: string, renderStrategy: "IFRAME" | "POPUP_IFRAME" | "REDIRECT"): HTMLIFrameElement | Window | null;
}

@@ -499,5 +179,2 @@ export default MoneyHashHeadless;

state: IntentState;
shippingData: Shipping | null;
productItems: ProductItem[] | null;
nativePayData: AppleNativePayData | null;
};

@@ -538,13 +215,2 @@

export declare interface ProductItem {
name: string;
type: string;
amount: string;
category: string;
quantity: number;
description: string;
subcategory: string;
reference_id: string;
}
export declare type PurchaseOperationStatus = "pending" | "pending_authentication" | "pending_external_action" | "pending_online_external_action" | "pending_authorization" | "failed" | "successful";

@@ -559,58 +225,12 @@

declare interface SDKEmbedOptions<TType extends IntentType> {
/**
* Intent type `payment`, `payout`
*/
type: TType;
/**
* Locale of rendered embed. Can be changed programmatically with `moneyHash.setLocale`
*/
locale?: string;
/**
* Listen for intent completion. e.g. successful transaction, intent closed, intent expired ...etc
* @param {OnCompleteEventOptions} event
*
* @see {@link PaymentIntentEventOptions} - Payment intent event
* @see {@link PayoutIntentEventOptions} - Payout intent event
*/
onComplete?(event: OnCompleteEventOptions<TType>): void;
/**
* Listen for intent transaction failure status
* @param {OnFailEventOptions} event
*
* @see {@link PaymentIntentEventOptions} - Payment intent event
* @see {@link PayoutIntentEventOptions} - Payout intent event
*/
onFail?(event: OnFailEventOptions<TType>): void;
/**
* Customize input styles and submit button of MoneyHash embed
*/
styles?: {
submitButton?: ButtonStyle;
input?: InputStyle;
loader?: LoaderStyle;
};
}
export declare interface Shipping {
phone_number: string | null;
created: string | null;
modified: string | null;
first_name: string | null;
last_name: string | null;
email: string | null;
address: string | null;
country: string | null;
city: string | null;
street: string | null;
floor: string | null;
building: string | null;
state: string | null;
postal_code: string | null;
apartment: string | null;
description: string | null;
shipping_method: string | null;
}
export declare type SupportedLanguages = "ar" | "en" | "fr";
declare interface TextStyle {

@@ -685,6 +305,4 @@ color?: string;

export declare type UrlRenderStrategy = "IFRAME" | "POPUP_IFRAME" | "REDIRECT";
export declare type VoidOperationStatus = "pending" | "failed" | "successful";
export { }

@@ -1,46 +0,37 @@

var B = Object.defineProperty, O = Object.defineProperties;
var Y = Object.getOwnPropertyDescriptors;
var M = Object.getOwnPropertySymbols;
var J = Object.prototype.hasOwnProperty, z = Object.prototype.propertyIsEnumerable;
var _ = (a, e, t) => e in a ? B(a, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[e] = t, S = (a, e) => {
var E = Object.defineProperty, C = Object.defineProperties;
var q = Object.getOwnPropertyDescriptors;
var k = Object.getOwnPropertySymbols;
var I = Object.prototype.hasOwnProperty, R = Object.prototype.propertyIsEnumerable;
var g = (s, e, t) => e in s ? E(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t, v = (s, e) => {
for (var t in e || (e = {}))
J.call(e, t) && _(a, t, e[t]);
if (M)
for (var t of M(e))
z.call(e, t) && _(a, t, e[t]);
return a;
}, F = (a, e) => O(a, Y(e));
var m = (a, e, t) => (_(a, typeof e != "symbol" ? e + "" : e, t), t), K = (a, e, t) => {
if (!e.has(a))
throw TypeError("Cannot " + t);
};
var u = (a, e, t) => {
if (e.has(a))
throw TypeError("Cannot add the same private member more than once");
e instanceof WeakSet ? e.add(a) : e.set(a, t);
};
var y = (a, e, t) => (K(a, e, "access private method"), t);
var P = (a, e, t) => new Promise((r, s) => {
var d = (i) => {
I.call(e, t) && g(s, t, e[t]);
if (k)
for (var t of k(e))
R.call(e, t) && g(s, t, e[t]);
return s;
}, f = (s, e) => C(s, q(e));
var m = (s, e, t) => (g(s, typeof e != "symbol" ? e + "" : e, t), t);
var b = (s, e, t) => new Promise((h, a) => {
var d = (n) => {
try {
n(t.next(i));
r(t.next(n));
} catch (l) {
s(l);
a(l);
}
}, o = (i) => {
}, o = (n) => {
try {
n(t.throw(i));
r(t.throw(n));
} catch (l) {
s(l);
a(l);
}
}, n = (i) => i.done ? r(i.value) : Promise.resolve(i.value).then(d, o);
n((t = t.apply(a, e)).next());
}, r = (n) => n.done ? h(n.value) : Promise.resolve(n.value).then(d, o);
r((t = t.apply(s, e)).next());
});
import { M as G, g as Q, S as X, t as w } from "./sdkEmbed-ea26512a.js";
function Z() {
import { M, S as L, t as p } from "./sdkEmbed-ac39bdd9.js";
function P() {
return typeof window != "undefined";
}
const h = class {
const i = class {
constructor() {
Z() && this.initSDKCommunicationIframe();
P() && this.initSDKCommunicationIframe();
}

@@ -50,25 +41,27 @@ initSDKCommunicationIframe() {

return;
const e = Q(), t = new URL(`${e}/embed/headless-sdk`);
t.searchParams.set("sdk", "true"), t.searchParams.set("parent", window.location.origin), t.searchParams.set("version", "js@1.0.0-beta.5");
const r = document.createElement("iframe");
r.id = "moneyhash-headless-sdk", r.src = t.toString(), r.hidden = !0, document.body.appendChild(r), h.messagingService = new G({
target: r.contentWindow,
targetOrigin: e
}), h.isCommunicationReady = new Promise((s) => {
var o;
const d = (n) => {
var i;
n.data.type === "headlessSDK:init" && (s(), (i = h.messagingService) == null || i.removeListener(d));
const e = new URL(
"https://embed.moneyhash.io/embed/headless-sdk"
);
e.searchParams.set("sdk", "true"), e.searchParams.set("parent", window.location.origin), e.searchParams.set("version", "js@0.0.0-development");
const t = document.createElement("iframe");
t.id = "moneyhash-headless-sdk", t.src = e.toString(), t.hidden = !0, document.body.appendChild(t), i.messagingService = new M({
target: t.contentWindow,
targetOrigin: "https://embed.moneyhash.io"
}), i.isCommunicationReady = new Promise((h) => {
var d;
const a = (o) => {
var r;
o.data.type === "headlessSDK:init" && (h(), (r = i.messagingService) == null || r.removeListener(a));
};
(o = h.messagingService) == null || o.onReceive(d);
(d = i.messagingService) == null || d.onReceive(a);
});
}
request(r) {
return P(this, arguments, function* ({
request(h) {
return b(this, arguments, function* ({
api: e,
payload: t
}) {
return yield h.isCommunicationReady, new Promise((s, d) => {
var n, i;
(n = h.messagingService) == null || n.send({
return yield i.isCommunicationReady, new Promise((a, d) => {
var r, n;
(r = i.messagingService) == null || r.send({
type: e,

@@ -78,7 +71,7 @@ data: t

const o = (l) => {
var g;
const { type: c, data: p } = l.data;
c === e && (p.status === "resolved" ? s(p.payload) : d(p.payload), (g = h.messagingService) == null || g.removeListener(o));
var y;
const { type: S, data: u } = l.data;
S === e && (u.status === "resolved" ? a(u.payload) : d(u.payload), (y = i.messagingService) == null || y.removeListener(o));
};
(i = h.messagingService) == null || i.onReceive(o);
(n = i.messagingService) == null || n.onReceive(o);
});

@@ -88,44 +81,5 @@ });

};
let b = h;
m(b, "messagingService", null), m(b, "isCommunicationReady");
class ee {
constructor() {
m(this, "promise");
m(this, "resolve");
m(this, "reject");
this.promise = new Promise((e, t) => {
this.resolve = e, this.reject = t;
});
}
}
function te() {
var e;
return (e = window.MONEYHASH_VAULT_API_URL) != null ? e : "https://vault.moneyhash.io";
}
function T() {
var e;
return (e = window.MONEYHASH_VAULT_INPUT_IFRAME_URL) != null ? e : "https://vault.moneyhash.io";
}
function re(a) {
return (Array.isArray(a) ? a.length : Object.keys(a).length) === 0;
}
function se(a, e) {
return new Promise((t, r) => {
if (document.getElementById(e)) {
t(void 0);
return;
}
const d = document.createElement("script");
d.src = a, d.id = e, d.addEventListener("load", () => {
t(void 0);
}), d.addEventListener("error", () => {
r(new Error("Script failed to load"));
}), document.body.appendChild(d);
});
}
function $() {
var e;
return (e = window.API_URL) != null ? e : "https://web.moneyhash.io";
}
const H = /* @__PURE__ */ new Set([
let c = i;
m(c, "messagingService", null), m(c, "isCommunicationReady");
const w = /* @__PURE__ */ new Set([
"method",

@@ -135,29 +89,9 @@ "customerBalance",

]);
var A, V, E, j, k, N, I, q, L, W, U, D, R, x;
class ie {
class W {
constructor(e) {
u(this, A);
u(this, E);
u(this, k);
u(this, I);
u(this, L);
u(this, U);
u(this, R);
m(this, "options");
m(this, "sdkApiHandler", new b());
m(this, "sdkApiHandler", new c());
m(this, "sdkEmbed");
m(this, "vaultSubmitListener", {
current: null
});
this.options = e, this.sdkEmbed = new X(F(S({}, e), { headless: !0 })), y(this, L, W).call(this, this.vaultSubmitListener);
this.options = e, this.sdkEmbed = new L(f(v({}, e), { headless: !0 }));
}
/**
* Get intent details
* @example
* ```
* await moneyHash.getIntentDetails('<intent_id>');
* ```
*
* @returns Promise<{@link IntentDetails}>
*/
getIntentDetails(e) {

@@ -173,10 +107,2 @@ return this.sdkApiHandler.request({

}
/**
* Get intent available payment/payout methods, saved cards and customer balances
* @example
* ```
* await moneyHash.getIntentMethods('<intent_id>');
* ```
* @returns Promise<{@link IntentMethods}>
*/
getIntentMethods(e) {

@@ -192,60 +118,11 @@ return this.sdkApiHandler.request({

}
/**
* Proceed with a payment/payout method, card or wallet
*
* @example
* <caption>Proceed with a payment/payout method</caption>
* ```
* await moneyHash.proceedWith({
* intentId: '<intent_id>',
* type: 'method',
* id: '<method_id>',
* })
* ```
* @see {@link Method} - for \<method_id>
*
* @example
* <caption>Proceed with a customer balance. e.g. wallet</caption>
* ```
* await moneyHash.proceedWith({
* intentId: '<intent_id>',
* type: 'customerBalance',
* id: '<customer_balance_id>',
* })
* ```
* @see {@link CustomerBalances} - for \<customer_balance_id>
*
* @example
* <caption>Proceed with a customer saved card</caption>
* ```
* // Card doesn't require CVV
* await moneyHash.proceedWith({
* intentId: '<intent_id>',
* type: 'savedCard',
* id: '<card_id>',
* })
*
* // Card requires CVV
* await moneyHash.proceedWith({
* intentId: '<intent_id>',
* type: 'savedCard',
* id: '<card_id>',
* metaData: {
* cvv: '<cvv>',
* }
* })
* ```
* @see {@link Card} - for \<card_id> & if card requires cvv or not
*
* @returns Promise<{@link IntentDetails}>
*/
proceedWith({
intentId: e,
type: t,
id: r,
metaData: s
id: h,
metaData: a
}) {
return w(
!H.has(t),
`type must be a valid one (${[...H].join(
return p(
!w.has(t),
`type must be a valid one (${[...w].join(
" | "

@@ -259,22 +136,8 @@ )})`

intentId: e,
id: r,
id: h,
lang: this.sdkEmbed.lang,
metaData: s
metaData: a
}
});
}
/**
* Reset the selected method on and intent to null
*
* @description Can be used for `back` button after method selection
* or `retry` button on failed transaction UI to try a different
* method by the user.
*
* @example
* ```
* await moneyHash.resetSelectedMethod('<intent_id>');
* ```
*
* @returns Promise<{@link IntentDetails}>
*/
resetSelectedMethod(e) {

@@ -290,16 +153,2 @@ return this.sdkApiHandler.request({

}
/**
* Delete a customer saved card
*
* @example
* ```
* await moneyHash.deleteCard({
* cardId: '<card_id>',
* intentSecret: '<intent_secret>',
* });
* ```
* @see {@link Card} - for \<card_id>
* @see {@link AbstractIntent} - for \<intent_secret>
* @returns Promise<{ message: 'success'} >
*/
deleteCard({

@@ -309,3 +158,3 @@ cardId: e,

}) {
return w(
return p(
this.options.type === "payout",

@@ -322,294 +171,14 @@ "deleteCard is allowed only for payment intent!"

}
/**
* Pay with native apple pay
*
* @example
* ```
* moneyHash
* .payWithApplePay({
* intentId: paymentIntentId,
* countryCode: "AE",
* amount: intentDetails.intent.amount.formatted,
* currency: intentDetails.intent.amount.currency,
* billingData: {
* email: "test@test.com",
* },
* onCancel: () => console.log("CANCEL"),
* onComplete: async () => {
* // Will fire after a successful payment
* console.log("COMPLETE");
* },
* onError: async () => {
* // Will fire after a failure payment
* console.log("ERROR");
* },
* })
* .catch(error => {
* console.log(error);
* error.message | string
* // Native apple pay button need to be triggered from click event directly
- Must create a new ApplePaySession from a user gesture handler.
// intent requires billing data to proceed with the native integration
- Billing data is missing while calling payWithApplePay
error | Record<string, string>
{email: "Enter a valid email address."}
* });
* ```
*/
payWithApplePay(l) {
return P(this, arguments, function* ({
intentId: e,
currency: t,
amount: r,
countryCode: s,
onCancel: d = () => {
},
onError: o,
onComplete: n,
billingData: i = {}
}) {
if (yield se(
"https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js",
"moneyHash-apple-pay-sdk"
), !ApplePaySession)
return;
const c = new ApplePaySession(3, {
countryCode: s,
currencyCode: t,
supportedNetworks: ["visa", "masterCard", "amex", "discover", "mada"],
merchantCapabilities: ["supports3DS"],
total: {
label: "Apple Pay",
type: "final",
amount: `${r}`
}
}), {
__providerId__: p,
state: g,
intent: C
} = yield this.proceedWith({
intentId: e,
type: "method",
id: "APPLE_PAY"
});
try {
if (g === "INTENT_FORM") {
if (re(i))
throw new Error(
"Billing data is missing while calling payWithApplePay"
);
yield this.sdkApiHandler.request({
api: "sdk:submitNativeForm",
payload: {
intentId: e,
paymentMethod: "APPLE_PAY",
providerId: p,
lang: this.sdkEmbed.lang,
billingData: i
}
});
}
} catch (v) {
throw yield this.resetSelectedMethod(e), v;
}
c.onvalidatemerchant = (v) => {
fetch(`${$()}/api/v1/providers/applepay/session/`, {
method: "post",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({
secret: C.secret,
validation_url: v.validationURL
})
}).then((f) => f.ok ? f.json() : Promise.reject()).then(
(f) => c.completeMerchantValidation(f)
).catch(o);
}, c.onpaymentauthorized = (v) => {
fetch(`${$()}/api/v1/providers/applepay/token/`, {
method: "post",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({
token_data: v.payment.token,
secret: C.secret
})
}).then((f) => f.ok ? f.json() : Promise.reject()).then(() => {
c.completePayment(ApplePaySession.STATUS_SUCCESS), n();
}).catch(() => {
c.completePayment(ApplePaySession.STATUS_FAILURE), o();
});
}, c.oncancel = d, c.begin();
});
}
/**
* Render SDK embed forms and payment integrations
*
* @description must be called if `state` of an intent is `INTENT_FORM` to let MoneyHash handle the payment.
* you can listen for completion or failure of an intent by providing `onComplete` `onFail` callbacks on MoneyHash instance.
*
* @example
* ```
* await moneyHash.renderForm({
* selector: '<container_css_selector>',
* intentId: '<intentId>',
* });
* ```
* {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | CSS Selector MDN}
* @returns Promise<void>
*/
renderForm({ selector: e, intentId: t }) {
return w(!e, "selector is required for renderForm"), w(!t, "intentId is required for renderForm"), this.sdkEmbed.render({ selector: e, intentId: t });
return p(!e, "selector is required for renderForm"), p(!t, "intentId is required for renderForm"), this.sdkEmbed.render({ selector: e, intentId: t });
}
/**
* Change the embed localization
*
* @description we currently support 3 languages `English`, `Arabic`, `Français`.
*
* @example
* ```
* await moneyHash.setLocale("<locale_code>");
* ```
*
* @returns Promise<void>
*/
setLocale(e) {
return this.sdkEmbed.setLocale(e);
}
/**
* Cleanup all listeners set by the SDK
* @returns Promise<void>
*/
removeEventListeners() {
return this.sdkEmbed.abortService();
}
elements({ styles: e }) {
const t = [];
return y(this, I, q).call(this, t), {
create: ({ elementType: r, elementOptions: s }) => {
const d = /* @__PURE__ */ new Map(), o = document.querySelector(
s.selector
);
return w(
!o,
`Couldn't find an element with selector ${s.selector}!`
), o.classList.add("MoneyHashElement"), t.push((n) => {
var l, c, p;
const { type: i } = n.data;
i === `${r}@focus` && (o.classList.add("MoneyHashElement--focus"), (l = d.get(`${r}@focus`)) == null || l()), i === `${r}@blur` && (o.classList.remove("MoneyHashElement--focus"), (c = d.get(`${r}@blur`)) == null || c()), i === `${r}@changeInput` && ((p = d.get(`${r}@changeInput`)) == null || p());
}), {
mount: () => y(this, U, D).call(this, {
container: o,
elementType: r,
elementOptions: s,
styles: S(S({}, e), s.styles)
}),
on: (n, i) => {
d.set(`${r}@${n}`, i);
}
};
}
};
}
submitForm(d) {
return P(this, arguments, function* ({
intentId: e,
accessToken: t,
billingData: r,
shippingData: s
}) {
const o = new ee();
let n, i;
t && (this.vaultSubmitListener.current = (c) => {
const { type: p, data: g } = c.data;
p === "vaultSubmit:success" && o.resolve(g), p === "vaultSubmit:error" && o.reject(g);
}, i = y(this, R, x).call(this, t), n = yield o.promise);
const l = yield this.sdkApiHandler.request({
api: "sdk:submitNativeForm",
payload: {
intentId: e,
paymentMethod: "CARD",
lang: this.sdkEmbed.lang,
billingData: r,
shippingData: s,
cardEmbed: n
}
});
return i && i.remove(), l;
});
}
submitCvv(r) {
return P(this, arguments, function* ({ intentId: e, cvv: t }) {
return this.sdkApiHandler.request({
api: "sdk:submitCardCvv",
payload: {
intentId: e,
cvv: t,
lang: this.sdkEmbed.lang
}
});
});
}
renderUrl(e, t) {
switch (t) {
case "IFRAME":
return y(this, A, V).call(this, e);
case "POPUP_IFRAME":
return y(this, E, j).call(this, e);
case "REDIRECT":
return y(this, k, N).call(this, e);
default:
return null;
}
}
}
A = new WeakSet(), V = function(e) {
const t = document.querySelector("#rendered-url-iframe-container"), r = document.createElement("iframe");
return r.src = e, r.style.setProperty("border", "0", "important"), r.style.setProperty("width", "100vw", "important"), r.style.setProperty("height", "100vh", "important"), t == null || t.replaceChildren(r), r;
}, E = new WeakSet(), j = function(e) {
return window.open(`${e}`, "", "width=600,height=400,left=200,top=200");
}, k = new WeakSet(), N = function(e) {
return window.open(e, "_blank");
}, I = new WeakSet(), q = function(e) {
const t = (r) => {
e.forEach((s) => {
s(r);
});
};
window.addEventListener("message", t);
}, L = new WeakSet(), W = function(e) {
const t = (r) => {
e.current && e.current(r);
};
window.addEventListener("message", t);
}, U = new WeakSet(), D = function({
container: e,
elementType: t,
elementOptions: r,
styles: s
}) {
var i, l;
const d = T(), o = new URL(`${d}/vaultField/vaultField.html`);
o.searchParams.set("parent", window.location.origin), o.searchParams.set("type", t), o.searchParams.set("placeholder", (i = r.placeholder) != null ? i : ""), o.searchParams.set("color", (s == null ? void 0 : s.color) || "#000"), o.searchParams.set(
"placeholderColor",
(s == null ? void 0 : s.placeholderColor) || "#ccc"
), o.searchParams.set(
"backgroundColor",
(s == null ? void 0 : s.backgroundColor) || "transparent"
);
const n = document.createElement("iframe");
n.src = o.toString(), n.style.height = (l = r.height) != null ? l : "40px", n.style.setProperty("overflow", "hidden", "important"), n.style.setProperty("display", "block", "important"), n.style.setProperty("width", "100%", "important"), n.style.setProperty("maxWidth", "100%", "important"), n.style.setProperty("border", "0", "important"), n.style.setProperty("margin", "0", "important"), n.style.setProperty("padding", "0", "important"), n.style.setProperty("userSelect", "none", "important"), n.style.setProperty("colorScheme", "light only", "important"), e.replaceChildren(n);
}, R = new WeakSet(), x = function(e) {
const t = T(), r = te(), s = new URL(
`${t}/vaultSubmit/vaultSubmit.html`
);
s.searchParams.set("parent", window.location.origin), s.searchParams.set("vault_api_url", `${r}/api/v1/tokens/`), s.searchParams.set("access_token", e);
const d = document.createElement("iframe");
return d.id = "moneyhash-submit-iframe", d.src = s.toString(), d.hidden = !0, document.body.appendChild(d), d;
};
export {
ie as default
W as default
};

@@ -1,1 +0,1 @@

(function(o,n){typeof exports=="object"&&typeof module!="undefined"?module.exports=n():typeof define=="function"&&define.amd?define(n):(o=typeof globalThis!="undefined"?globalThis:o||self,o.MoneyHash=n())})(this,function(){var C,Y,M,J,F,z,$,K,T,G,H,Q,j,X;"use strict";var ie=Object.defineProperty,ne=Object.defineProperties;var re=Object.getOwnPropertyDescriptors;var D=Object.getOwnPropertySymbols;var ae=Object.prototype.hasOwnProperty,oe=Object.prototype.propertyIsEnumerable;var V=(o,n,c)=>n in o?ie(o,n,{enumerable:!0,configurable:!0,writable:!0,value:c}):o[n]=c,A=(o,n)=>{for(var c in n||(n={}))ae.call(n,c)&&V(o,c,n[c]);if(D)for(var c of D(n))oe.call(n,c)&&V(o,c,n[c]);return o},x=(o,n)=>ne(o,re(n));var m=(o,n,c)=>(V(o,typeof n!="symbol"?n+"":n,c),c),de=(o,n,c)=>{if(!n.has(o))throw TypeError("Cannot "+c)};var E=(o,n,c)=>{if(n.has(o))throw TypeError("Cannot add the same private member more than once");n instanceof WeakSet?n.add(o):n.set(o,c)};var L=(o,n,c)=>(de(o,n,"access private method"),c);var I=(o,n,c)=>new Promise((R,f)=>{var N=b=>{try{k(c.next(b))}catch(U){f(U)}},_=b=>{try{k(c.throw(b))}catch(U){f(U)}},k=b=>b.done?R(b.value):Promise.resolve(b.value).then(N,_);k((c=c.apply(o,n)).next())});class o{constructor(e){m(this,"target");m(this,"targetOrigin");m(this,"listeners");m(this,"onIncomingMessageBind",this.onIncomingMessage.bind(this));this.target=e.target,this.targetOrigin=e.targetOrigin,this.listeners=[],window.addEventListener("message",this.onIncomingMessageBind)}send(e){this.target.postMessage(e,this.targetOrigin)}onReceive(e){this.listeners.push(e)}removeListener(e){this.listeners=this.listeners.filter(t=>t!==e)}onIncomingMessage(e){e.origin===this.targetOrigin&&this.listeners.forEach(t=>{t(e,this.send.bind(this))})}abortService(){window.removeEventListener("message",this.onIncomingMessageBind)}}function n(){var e;return(e=window.MONEYHASH_IFRAME_URL)!=null?e:"https://embed.moneyhash.io"}function c(){return typeof window!="undefined"}const v=class{constructor(){c()&&this.initSDKCommunicationIframe()}initSDKCommunicationIframe(){if(document.getElementById("moneyhash-headless-sdk"))return;const e=n(),t=new URL(`${e}/embed/headless-sdk`);t.searchParams.set("sdk","true"),t.searchParams.set("parent",window.location.origin),t.searchParams.set("version","js@1.0.0-beta.5");const s=document.createElement("iframe");s.id="moneyhash-headless-sdk",s.src=t.toString(),s.hidden=!0,document.body.appendChild(s),v.messagingService=new o({target:s.contentWindow,targetOrigin:e}),v.isCommunicationReady=new Promise(i=>{var r;const d=a=>{var l;a.data.type==="headlessSDK:init"&&(i(),(l=v.messagingService)==null||l.removeListener(d))};(r=v.messagingService)==null||r.onReceive(d)})}request(s){return I(this,arguments,function*({api:e,payload:t}){return yield v.isCommunicationReady,new Promise((i,d)=>{var a,l;(a=v.messagingService)==null||a.send({type:e,data:t});const r=g=>{var y;const{type:h,data:u}=g.data;h===e&&(u.status==="resolved"?i(u.payload):d(u.payload),(y=v.messagingService)==null||y.removeListener(r))};(l=v.messagingService)==null||l.onReceive(r)})})}};let R=v;m(R,"messagingService",null),m(R,"isCommunicationReady");function f(p,e){if(p)throw new Error(e)}function N(p,e){p&&console.warn(e)}const _=new Set(["payment","payout"]),k=new Set(["en","fr","ar"]);class b{constructor(e){m(this,"options");m(this,"messagingService",null);m(this,"iframe",null);m(this,"isCommunicationReady",null);f(!_.has(e.type),`MoneyHash constructor must be called with valid type (${[..._].join(" | ")})!`),this.options=e}get lang(){var t;const e=(t=this.options.locale)==null?void 0:t.split("-")[0];return N(!!e&&!k.has(e),`Supported languages (${[...k].join(" | ")})`),e||"en"}render({selector:e,intentId:t}){var a,l;(a=this.messagingService)==null||a.abortService();const s=n(),i=new URL(`${s}/embed/${this.options.type}/${t}`);i.searchParams.set("sdk","true"),i.searchParams.set("parent",window.location.origin),i.searchParams.set("version","js@1.0.0-beta.5");const d=(l=this.options.locale)==null?void 0:l.split("-")[0];d&&i.searchParams.set("lang",d),this.iframe=document.createElement("iframe"),this.iframe.src=i.toString(),this.iframe.style.height="100%",this.iframe.style.width="100%",this.iframe.style.border="0";const r=document.querySelector(e);return f(!r,`Couldn't find an element with selector ${e}!`),r.replaceChildren(this.iframe),this.messagingService=new o({target:this.iframe.contentWindow,targetOrigin:s}),this.isCommunicationReady=new Promise(g=>{var u;const h=y=>{var P;y.data.type==="sdk:init"&&(g(),(P=this.messagingService)==null||P.removeListener(h))};(u=this.messagingService)==null||u.onReceive(h)}),this.messagingService.onReceive((g,h)=>{var P,S,w,B;const{type:u,data:y}=g.data;switch(u){case"sdk:init":{h({type:"sdk:init",data:{headless:Boolean(this.options.headless),styles:this.options.styles}});break}case"onComplete":{(S=(P=this.options).onComplete)==null||S.call(P,A({type:this.options.type},y)),this.options.headless&&this.iframe&&(this.iframe.hidden=!0);break}case"onFail":{(B=(w=this.options).onFail)==null||B.call(w,A({type:this.options.type},y)),this.options.headless&&this.iframe&&(this.iframe.hidden=!0);break}}}),this.isCommunicationReady}setLocale(e){return I(this,null,function*(){var t;yield this==null?void 0:this.isCommunicationReady,this.options.locale=e,(t=this.messagingService)==null||t.send({type:"changeLanguage",data:{locale:e}})})}abortService(){return I(this,null,function*(){var e;yield this==null?void 0:this.isCommunicationReady,(e=this.messagingService)==null||e.abortService()})}}class U{constructor(){m(this,"promise");m(this,"resolve");m(this,"reject");this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}}function Z(){var e;return(e=window.MONEYHASH_VAULT_API_URL)!=null?e:"https://vault.moneyhash.io"}function q(){var e;return(e=window.MONEYHASH_VAULT_INPUT_IFRAME_URL)!=null?e:"https://vault.moneyhash.io"}function ee(p){return(Array.isArray(p)?p.length:Object.keys(p).length)===0}function te(p,e){return new Promise((t,s)=>{if(document.getElementById(e)){t(void 0);return}const d=document.createElement("script");d.src=p,d.id=e,d.addEventListener("load",()=>{t(void 0)}),d.addEventListener("error",()=>{s(new Error("Script failed to load"))}),document.body.appendChild(d)})}function O(){var e;return(e=window.API_URL)!=null?e:"https://web.moneyhash.io"}const W=new Set(["method","customerBalance","savedCard"]);class se{constructor(e){E(this,C);E(this,M);E(this,F);E(this,$);E(this,T);E(this,H);E(this,j);m(this,"options");m(this,"sdkApiHandler",new R);m(this,"sdkEmbed");m(this,"vaultSubmitListener",{current:null});this.options=e,this.sdkEmbed=new b(x(A({},e),{headless:!0})),L(this,T,G).call(this,this.vaultSubmitListener)}getIntentDetails(e){return this.sdkApiHandler.request({api:"sdk:getIntentDetails",payload:{intentType:this.options.type,intentId:e,lang:this.sdkEmbed.lang}})}getIntentMethods(e){return this.sdkApiHandler.request({api:"sdk:getIntentMethods",payload:{intentType:this.options.type,intentId:e,lang:this.sdkEmbed.lang}})}proceedWith({intentId:e,type:t,id:s,metaData:i}){return f(!W.has(t),`type must be a valid one (${[...W].join(" | ")})`),this.sdkApiHandler.request({api:"sdk:proceedWith",payload:{proceedWith:t,intentType:this.options.type,intentId:e,id:s,lang:this.sdkEmbed.lang,metaData:i}})}resetSelectedMethod(e){return this.sdkApiHandler.request({api:"sdk:resetSelectedMethod",payload:{intentType:this.options.type,intentId:e,lang:this.sdkEmbed.lang}})}deleteCard({cardId:e,intentSecret:t}){return f(this.options.type==="payout","deleteCard is allowed only for payment intent!"),this.sdkApiHandler.request({api:"sdk:deleteCard",payload:{cardId:e,intentSecret:t,lang:this.sdkEmbed.lang}})}payWithApplePay(g){return I(this,arguments,function*({intentId:e,currency:t,amount:s,countryCode:i,onCancel:d=()=>{},onError:r,onComplete:a,billingData:l={}}){if(yield te("https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js","moneyHash-apple-pay-sdk"),!ApplePaySession)return;const h=new ApplePaySession(3,{countryCode:i,currencyCode:t,supportedNetworks:["visa","masterCard","amex","discover","mada"],merchantCapabilities:["supports3DS"],total:{label:"Apple Pay",type:"final",amount:`${s}`}}),{__providerId__:u,state:y,intent:P}=yield this.proceedWith({intentId:e,type:"method",id:"APPLE_PAY"});try{if(y==="INTENT_FORM"){if(ee(l))throw new Error("Billing data is missing while calling payWithApplePay");yield this.sdkApiHandler.request({api:"sdk:submitNativeForm",payload:{intentId:e,paymentMethod:"APPLE_PAY",providerId:u,lang:this.sdkEmbed.lang,billingData:l}})}}catch(S){throw yield this.resetSelectedMethod(e),S}h.onvalidatemerchant=S=>{fetch(`${O()}/api/v1/providers/applepay/session/`,{method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify({secret:P.secret,validation_url:S.validationURL})}).then(w=>w.ok?w.json():Promise.reject()).then(w=>h.completeMerchantValidation(w)).catch(r)},h.onpaymentauthorized=S=>{fetch(`${O()}/api/v1/providers/applepay/token/`,{method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify({token_data:S.payment.token,secret:P.secret})}).then(w=>w.ok?w.json():Promise.reject()).then(()=>{h.completePayment(ApplePaySession.STATUS_SUCCESS),a()}).catch(()=>{h.completePayment(ApplePaySession.STATUS_FAILURE),r()})},h.oncancel=d,h.begin()})}renderForm({selector:e,intentId:t}){return f(!e,"selector is required for renderForm"),f(!t,"intentId is required for renderForm"),this.sdkEmbed.render({selector:e,intentId:t})}setLocale(e){return this.sdkEmbed.setLocale(e)}removeEventListeners(){return this.sdkEmbed.abortService()}elements({styles:e}){const t=[];return L(this,$,K).call(this,t),{create:({elementType:s,elementOptions:i})=>{const d=new Map,r=document.querySelector(i.selector);return f(!r,`Couldn't find an element with selector ${i.selector}!`),r.classList.add("MoneyHashElement"),t.push(a=>{var g,h,u;const{type:l}=a.data;l===`${s}@focus`&&(r.classList.add("MoneyHashElement--focus"),(g=d.get(`${s}@focus`))==null||g()),l===`${s}@blur`&&(r.classList.remove("MoneyHashElement--focus"),(h=d.get(`${s}@blur`))==null||h()),l===`${s}@changeInput`&&((u=d.get(`${s}@changeInput`))==null||u())}),{mount:()=>L(this,H,Q).call(this,{container:r,elementType:s,elementOptions:i,styles:A(A({},e),i.styles)}),on:(a,l)=>{d.set(`${s}@${a}`,l)}}}}}submitForm(d){return I(this,arguments,function*({intentId:e,accessToken:t,billingData:s,shippingData:i}){const r=new U;let a,l;t&&(this.vaultSubmitListener.current=h=>{const{type:u,data:y}=h.data;u==="vaultSubmit:success"&&r.resolve(y),u==="vaultSubmit:error"&&r.reject(y)},l=L(this,j,X).call(this,t),a=yield r.promise);const g=yield this.sdkApiHandler.request({api:"sdk:submitNativeForm",payload:{intentId:e,paymentMethod:"CARD",lang:this.sdkEmbed.lang,billingData:s,shippingData:i,cardEmbed:a}});return l&&l.remove(),g})}submitCvv(s){return I(this,arguments,function*({intentId:e,cvv:t}){return this.sdkApiHandler.request({api:"sdk:submitCardCvv",payload:{intentId:e,cvv:t,lang:this.sdkEmbed.lang}})})}renderUrl(e,t){switch(t){case"IFRAME":return L(this,C,Y).call(this,e);case"POPUP_IFRAME":return L(this,M,J).call(this,e);case"REDIRECT":return L(this,F,z).call(this,e);default:return null}}}return C=new WeakSet,Y=function(e){const t=document.querySelector("#rendered-url-iframe-container"),s=document.createElement("iframe");return s.src=e,s.style.setProperty("border","0","important"),s.style.setProperty("width","100vw","important"),s.style.setProperty("height","100vh","important"),t==null||t.replaceChildren(s),s},M=new WeakSet,J=function(e){return window.open(`${e}`,"","width=600,height=400,left=200,top=200")},F=new WeakSet,z=function(e){return window.open(e,"_blank")},$=new WeakSet,K=function(e){const t=s=>{e.forEach(i=>{i(s)})};window.addEventListener("message",t)},T=new WeakSet,G=function(e){const t=s=>{e.current&&e.current(s)};window.addEventListener("message",t)},H=new WeakSet,Q=function({container:e,elementType:t,elementOptions:s,styles:i}){var l,g;const d=q(),r=new URL(`${d}/vaultField/vaultField.html`);r.searchParams.set("parent",window.location.origin),r.searchParams.set("type",t),r.searchParams.set("placeholder",(l=s.placeholder)!=null?l:""),r.searchParams.set("color",(i==null?void 0:i.color)||"#000"),r.searchParams.set("placeholderColor",(i==null?void 0:i.placeholderColor)||"#ccc"),r.searchParams.set("backgroundColor",(i==null?void 0:i.backgroundColor)||"transparent");const a=document.createElement("iframe");a.src=r.toString(),a.style.height=(g=s.height)!=null?g:"40px",a.style.setProperty("overflow","hidden","important"),a.style.setProperty("display","block","important"),a.style.setProperty("width","100%","important"),a.style.setProperty("maxWidth","100%","important"),a.style.setProperty("border","0","important"),a.style.setProperty("margin","0","important"),a.style.setProperty("padding","0","important"),a.style.setProperty("userSelect","none","important"),a.style.setProperty("colorScheme","light only","important"),e.replaceChildren(a)},j=new WeakSet,X=function(e){const t=q(),s=Z(),i=new URL(`${t}/vaultSubmit/vaultSubmit.html`);i.searchParams.set("parent",window.location.origin),i.searchParams.set("vault_api_url",`${s}/api/v1/tokens/`),i.searchParams.set("access_token",e);const d=document.createElement("iframe");return d.id="moneyhash-submit-iframe",d.src=i.toString(),d.hidden=!0,document.body.appendChild(d),d},se});
(function(n,s){typeof exports=="object"&&typeof module!="undefined"?module.exports=s():typeof define=="function"&&define.amd?define(s):(n=typeof globalThis!="undefined"?globalThis:n||self,n.MoneyHash=s())})(this,function(){"use strict";var B=Object.defineProperty,H=Object.defineProperties;var O=Object.getOwnPropertyDescriptors;var T=Object.getOwnPropertySymbols;var j=Object.prototype.hasOwnProperty,W=Object.prototype.propertyIsEnumerable;var L=(n,s,i)=>s in n?B(n,s,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[s]=i,R=(n,s)=>{for(var i in s||(s={}))j.call(s,i)&&L(n,i,s[i]);if(T)for(var i of T(s))W.call(s,i)&&L(n,i,s[i]);return n},$=(n,s)=>H(n,O(s));var a=(n,s,i)=>(L(n,typeof s!="symbol"?s+"":s,i),i);var I=(n,s,i)=>new Promise((c,S)=>{var C=r=>{try{b(i.next(r))}catch(k){S(k)}},E=r=>{try{b(i.throw(r))}catch(k){S(k)}},b=r=>r.done?c(r.value):Promise.resolve(r.value).then(C,E);b((i=i.apply(n,s)).next())});class n{constructor(e){a(this,"target");a(this,"targetOrigin");a(this,"listeners");a(this,"onIncomingMessageBind",this.onIncomingMessage.bind(this));this.target=e.target,this.targetOrigin=e.targetOrigin,this.listeners=[],window.addEventListener("message",this.onIncomingMessageBind)}send(e){this.target.postMessage(e,this.targetOrigin)}onReceive(e){this.listeners.push(e)}removeListener(e){this.listeners=this.listeners.filter(t=>t!==e)}onIncomingMessage(e){e.origin===this.targetOrigin&&this.listeners.forEach(t=>{t(e,this.send.bind(this))})}abortService(){window.removeEventListener("message",this.onIncomingMessageBind)}}function s(){return typeof window!="undefined"}const o=class{constructor(){s()&&this.initSDKCommunicationIframe()}initSDKCommunicationIframe(){if(document.getElementById("moneyhash-headless-sdk"))return;const e=new URL("https://embed.moneyhash.io/embed/headless-sdk");e.searchParams.set("sdk","true"),e.searchParams.set("parent",window.location.origin),e.searchParams.set("version","js@0.0.0-development");const t=document.createElement("iframe");t.id="moneyhash-headless-sdk",t.src=e.toString(),t.hidden=!0,document.body.appendChild(t),o.messagingService=new n({target:t.contentWindow,targetOrigin:"https://embed.moneyhash.io"}),o.isCommunicationReady=new Promise(d=>{var p;const h=u=>{var m;u.data.type==="headlessSDK:init"&&(d(),(m=o.messagingService)==null||m.removeListener(h))};(p=o.messagingService)==null||p.onReceive(h)})}request(d){return I(this,arguments,function*({api:e,payload:t}){return yield o.isCommunicationReady,new Promise((h,p)=>{var m,f;(m=o.messagingService)==null||m.send({type:e,data:t});const u=v=>{var g;const{type:w,data:l}=v.data;w===e&&(l.status==="resolved"?h(l.payload):p(l.payload),(g=o.messagingService)==null||g.removeListener(u))};(f=o.messagingService)==null||f.onReceive(u)})})}};let i=o;a(i,"messagingService",null),a(i,"isCommunicationReady");function c(y,e){if(y)throw new Error(e)}function S(y,e){y&&console.warn(e)}const C=new Set(["payment","payout"]),E=new Set(["en","fr","ar"]);class b{constructor(e){a(this,"options");a(this,"messagingService",null);a(this,"iframe",null);a(this,"isCommunicationReady",null);c(!C.has(e.type),`MoneyHash constructor must be called with valid type (${[...C].join(" | ")})!`),this.options=e}get lang(){var t;const e=(t=this.options.locale)==null?void 0:t.split("-")[0];return S(!!e&&!E.has(e),`Supported languages (${[...E].join(" | ")})`),e||"en"}render({selector:e,intentId:t}){var u,m;(u=this.messagingService)==null||u.abortService();const d=new URL(`https://embed.moneyhash.io/embed/${this.options.type}/${t}`);d.searchParams.set("sdk","true"),d.searchParams.set("parent",window.location.origin),d.searchParams.set("version","js@0.0.0-development");const h=(m=this.options.locale)==null?void 0:m.split("-")[0];h&&d.searchParams.set("lang",h),this.iframe=document.createElement("iframe"),this.iframe.src=d.toString(),this.iframe.style.height="100%",this.iframe.style.width="100%",this.iframe.style.border="0";const p=document.querySelector(e);return c(!p,`Couldn't find an element with selector ${e}!`),p.replaceChildren(this.iframe),this.messagingService=new n({target:this.iframe.contentWindow,targetOrigin:"https://embed.moneyhash.io"}),this.isCommunicationReady=new Promise(f=>{var w;const v=l=>{var g;l.data.type==="sdk:init"&&(f(),(g=this.messagingService)==null||g.removeListener(v))};(w=this.messagingService)==null||w.onReceive(v)}),this.messagingService.onReceive((f,v)=>{var g,M,P,q;const{type:w,data:l}=f.data;switch(w){case"sdk:init":{v({type:"sdk:init",data:{headless:Boolean(this.options.headless),styles:this.options.styles}});break}case"onComplete":{(M=(g=this.options).onComplete)==null||M.call(g,R({type:this.options.type},l)),this.options.headless&&this.iframe&&(this.iframe.hidden=!0);break}case"onFail":{(q=(P=this.options).onFail)==null||q.call(P,R({type:this.options.type},l)),this.options.headless&&this.iframe&&(this.iframe.hidden=!0);break}}}),this.isCommunicationReady}setLocale(e){return I(this,null,function*(){var t;yield this==null?void 0:this.isCommunicationReady,this.options.locale=e,(t=this.messagingService)==null||t.send({type:"changeLanguage",data:{locale:e}})})}abortService(){return I(this,null,function*(){var e;yield this==null?void 0:this.isCommunicationReady,(e=this.messagingService)==null||e.abortService()})}}const r=new Set(["method","customerBalance","savedCard"]);class k{constructor(e){a(this,"options");a(this,"sdkApiHandler",new i);a(this,"sdkEmbed");this.options=e,this.sdkEmbed=new b($(R({},e),{headless:!0}))}getIntentDetails(e){return this.sdkApiHandler.request({api:"sdk:getIntentDetails",payload:{intentType:this.options.type,intentId:e,lang:this.sdkEmbed.lang}})}getIntentMethods(e){return this.sdkApiHandler.request({api:"sdk:getIntentMethods",payload:{intentType:this.options.type,intentId:e,lang:this.sdkEmbed.lang}})}proceedWith({intentId:e,type:t,id:d,metaData:h}){return c(!r.has(t),`type must be a valid one (${[...r].join(" | ")})`),this.sdkApiHandler.request({api:"sdk:proceedWith",payload:{proceedWith:t,intentType:this.options.type,intentId:e,id:d,lang:this.sdkEmbed.lang,metaData:h}})}resetSelectedMethod(e){return this.sdkApiHandler.request({api:"sdk:resetSelectedMethod",payload:{intentType:this.options.type,intentId:e,lang:this.sdkEmbed.lang}})}deleteCard({cardId:e,intentSecret:t}){return c(this.options.type==="payout","deleteCard is allowed only for payment intent!"),this.sdkApiHandler.request({api:"sdk:deleteCard",payload:{cardId:e,intentSecret:t,lang:this.sdkEmbed.lang}})}renderForm({selector:e,intentId:t}){return c(!e,"selector is required for renderForm"),c(!t,"intentId is required for renderForm"),this.sdkEmbed.render({selector:e,intentId:t})}setLocale(e){return this.sdkEmbed.setLocale(e)}removeEventListeners(){return this.sdkEmbed.abortService()}}return k});

@@ -1,1 +0,1 @@

"use strict";var o=Object.defineProperty;var i=(s,e,r)=>e in s?o(s,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):s[e]=r;var t=(s,e,r)=>(i(s,typeof e!="symbol"?e+"":e,r),r);const d=require("./sdkEmbed-bae6b7db.cjs");class n{constructor(e){t(this,"options");t(this,"sdkEmbed");this.options=e,this.sdkEmbed=new d.SDKEmbed(e)}start({selector:e,intentId:r}){return d.throwIf(!e,"selector is required for start"),d.throwIf(!r,"intentId is required for start"),this.sdkEmbed.render({selector:e,intentId:r})}setLocale(e){return this.sdkEmbed.setLocale(e)}removeEventListeners(){return this.sdkEmbed.abortService()}}module.exports=n;
"use strict";var o=Object.defineProperty;var i=(s,e,r)=>e in s?o(s,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):s[e]=r;var t=(s,e,r)=>(i(s,typeof e!="symbol"?e+"":e,r),r);const d=require("./sdkEmbed-9010c7b6.cjs");class n{constructor(e){t(this,"options");t(this,"sdkEmbed");this.options=e,this.sdkEmbed=new d.SDKEmbed(e)}start({selector:e,intentId:r}){return d.throwIf(!e,"selector is required for start"),d.throwIf(!r,"intentId is required for start"),this.sdkEmbed.render({selector:e,intentId:r})}setLocale(e){return this.sdkEmbed.setLocale(e)}removeEventListeners(){return this.sdkEmbed.abortService()}}module.exports=n;

@@ -10,5 +10,2 @@ export declare interface AbstractIntent {

};
subtotalAmount: string | null;
fees: Array<FeesItem> | null;
totalDiscounts: string | null;
secret: string;

@@ -18,11 +15,2 @@ isLive: boolean;

export declare interface AppleNativePayData {
method: "APPLE_PAY";
merchantId: string;
countryCode: string;
currencyCode: string;
amount: string;
supportedNetworks: string[];
}
export declare type AuthorizeOperationStatus = "pending" | "pending_authentication" | "failed" | "successful";

@@ -47,46 +35,2 @@

export declare type CardInfo = {
brand: string;
lastFourDigits: string;
logo: string;
};
export declare interface FeesItem {
title: Record<SupportedLanguages, string>;
value: string;
}
export declare type Field = {
type: FieldType;
name: string;
label: string;
hint: string;
value: string;
readOnly: boolean;
validation: {
required: boolean;
minLength: number | null;
maxLength: number | null;
};
dependsOn?: string;
optionsList?: Array<{
label: string;
value: string;
}>;
optionsMap?: Record<string, Array<{
label: string;
value: string;
}>>;
};
export declare type FieldType = "text" | "number" | "email" | "date" | "phoneNumber" | "select";
declare type FormFields = {
billing: Array<Field> | null;
shipping: Array<Field> | null;
card: {
accessToken: string;
} | null;
};
declare interface InputAllowedStyle {

@@ -116,12 +60,4 @@ height?: number;

export declare type IntentState = "METHOD_SELECTION" | "INTENT_FORM" | "INTENT_PROCESSED" | "TRANSACTION_WAITING_USER_ACTION" | "TRANSACTION_FAILED" | "EXPIRED" | "CLOSED" | "NATIVE_PAY" | "FORM_FIELDS" | "URL_TO_RENDER" | "SAVED_CARD_CVV";
export declare type IntentState = "METHOD_SELECTION" | "INTENT_FORM" | "INTENT_PROCESSED" | "TRANSACTION_WAITING_USER_ACTION" | "TRANSACTION_FAILED" | "EXPIRED" | "CLOSED";
export declare type IntentStateDetails<TType extends IntentState = IntentState> = TType extends "FORM_FIELDS" ? FormFields : TType extends "URL_TO_RENDER" ? {
url: string;
renderStrategy: UrlRenderStrategy;
} : TType extends "SAVED_CARD_CVV" ? {
card: CardInfo;
cvvField: Field;
} : null;
export declare type IntentStatus = "PROCESSED" | "UNPROCESSED" | "CLOSED" | "TIME_EXPIRED" | "PENDING" | "EXPIRED";

@@ -131,7 +67,2 @@

export declare interface LoaderStyle {
backgroundColor: string;
color: string;
}
declare class MoneyHash<TType extends IntentType> {

@@ -141,17 +72,2 @@ options: MoneyHashOptions<TType>;

constructor(options: MoneyHashOptions<TType>);
/**
* Render SDK embed and let MoneyHash handle everything for you
*
* @description you can listen for completion or failure of an intent by providing `onComplete` `onFail` callbacks on MoneyHash instance.
*
* @example
* ```
* await moneyHash.start({
* selector: '<container_css_selector>',
* intentId: '<intentId>',
* });
* ```
* {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | CSS Selector MDN}
* @returns Promise<void>
*/
start({ selector, intentId }: {

@@ -161,19 +77,3 @@ selector: string;

}): Promise<void>;
/**
* Change the embed localization
*
* @description we currently support 3 languages `English`, `Arabic`, `Français`.
*
* @example
* ```
* await moneyHash.setLocale("<locale_code>");
* ```
*
* @returns Promise<void>
*/
setLocale(locale: string): Promise<void>;
/**
* Cleanup all listeners set by the SDK
* @returns Promise<void>
*/
removeEventListeners(): Promise<void>;

@@ -200,5 +100,2 @@ }

state: IntentState;
shippingData: Shipping | null;
productItems: ProductItem[] | null;
nativePayData: AppleNativePayData | null;
};

@@ -239,13 +136,2 @@

export declare interface ProductItem {
name: string;
type: string;
amount: string;
category: string;
quantity: number;
description: string;
subcategory: string;
reference_id: string;
}
export declare type PurchaseOperationStatus = "pending" | "pending_authentication" | "pending_external_action" | "pending_online_external_action" | "pending_authorization" | "failed" | "successful";

@@ -260,58 +146,12 @@

declare interface SDKEmbedOptions<TType extends IntentType> {
/**
* Intent type `payment`, `payout`
*/
type: TType;
/**
* Locale of rendered embed. Can be changed programmatically with `moneyHash.setLocale`
*/
locale?: string;
/**
* Listen for intent completion. e.g. successful transaction, intent closed, intent expired ...etc
* @param {OnCompleteEventOptions} event
*
* @see {@link PaymentIntentEventOptions} - Payment intent event
* @see {@link PayoutIntentEventOptions} - Payout intent event
*/
onComplete?(event: OnCompleteEventOptions<TType>): void;
/**
* Listen for intent transaction failure status
* @param {OnFailEventOptions} event
*
* @see {@link PaymentIntentEventOptions} - Payment intent event
* @see {@link PayoutIntentEventOptions} - Payout intent event
*/
onFail?(event: OnFailEventOptions<TType>): void;
/**
* Customize input styles and submit button of MoneyHash embed
*/
styles?: {
submitButton?: ButtonStyle;
input?: InputStyle;
loader?: LoaderStyle;
};
}
export declare interface Shipping {
phone_number: string | null;
created: string | null;
modified: string | null;
first_name: string | null;
last_name: string | null;
email: string | null;
address: string | null;
country: string | null;
city: string | null;
street: string | null;
floor: string | null;
building: string | null;
state: string | null;
postal_code: string | null;
apartment: string | null;
description: string | null;
shipping_method: string | null;
}
export declare type SupportedLanguages = "ar" | "en" | "fr";
declare interface TextStyle {

@@ -386,6 +226,4 @@ color?: string;

export declare type UrlRenderStrategy = "IFRAME" | "POPUP_IFRAME" | "REDIRECT";
export declare type VoidOperationStatus = "pending" | "failed" | "successful";
export { }
var o = Object.defineProperty;
var i = (s, e, r) => e in s ? o(s, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : s[e] = r;
var t = (s, e, r) => (i(s, typeof e != "symbol" ? e + "" : e, r), r);
import { S as a, t as d } from "./sdkEmbed-ea26512a.js";
import { S as a, t as d } from "./sdkEmbed-ac39bdd9.js";
class b {

@@ -11,39 +11,8 @@ constructor(e) {

}
/**
* Render SDK embed and let MoneyHash handle everything for you
*
* @description you can listen for completion or failure of an intent by providing `onComplete` `onFail` callbacks on MoneyHash instance.
*
* @example
* ```
* await moneyHash.start({
* selector: '<container_css_selector>',
* intentId: '<intentId>',
* });
* ```
* {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | CSS Selector MDN}
* @returns Promise<void>
*/
start({ selector: e, intentId: r }) {
return d(!e, "selector is required for start"), d(!r, "intentId is required for start"), this.sdkEmbed.render({ selector: e, intentId: r });
}
/**
* Change the embed localization
*
* @description we currently support 3 languages `English`, `Arabic`, `Français`.
*
* @example
* ```
* await moneyHash.setLocale("<locale_code>");
* ```
*
* @returns Promise<void>
*/
setLocale(e) {
return this.sdkEmbed.setLocale(e);
}
/**
* Cleanup all listeners set by the SDK
* @returns Promise<void>
*/
removeEventListeners() {

@@ -50,0 +19,0 @@ return this.sdkEmbed.abortService();

@@ -1,1 +0,1 @@

(function(i,t){typeof exports=="object"&&typeof module!="undefined"?module.exports=t():typeof define=="function"&&define.amd?define(t):(i=typeof globalThis!="undefined"?globalThis:i||self,i.MoneyHash=t())})(this,function(){"use strict";var F=Object.defineProperty;var O=Object.getOwnPropertySymbols;var U=Object.prototype.hasOwnProperty,$=Object.prototype.propertyIsEnumerable;var v=(i,t,s)=>t in i?F(i,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):i[t]=s,w=(i,t)=>{for(var s in t||(t={}))U.call(t,s)&&v(i,s,t[s]);if(O)for(var s of O(t))$.call(t,s)&&v(i,s,t[s]);return i};var a=(i,t,s)=>(v(i,typeof t!="symbol"?t+"":t,s),s);var b=(i,t,s)=>new Promise((p,o)=>{var m=n=>{try{h(s.next(n))}catch(e){o(e)}},f=n=>{try{h(s.throw(n))}catch(e){o(e)}},h=n=>n.done?p(n.value):Promise.resolve(n.value).then(m,f);h((s=s.apply(i,t)).next())});class i{constructor(e){a(this,"target");a(this,"targetOrigin");a(this,"listeners");a(this,"onIncomingMessageBind",this.onIncomingMessage.bind(this));this.target=e.target,this.targetOrigin=e.targetOrigin,this.listeners=[],window.addEventListener("message",this.onIncomingMessageBind)}send(e){this.target.postMessage(e,this.targetOrigin)}onReceive(e){this.listeners.push(e)}removeListener(e){this.listeners=this.listeners.filter(r=>r!==e)}onIncomingMessage(e){e.origin===this.targetOrigin&&this.listeners.forEach(r=>{r(e,this.send.bind(this))})}abortService(){window.removeEventListener("message",this.onIncomingMessageBind)}}function t(n,e){if(n)throw new Error(e)}function s(n,e){n&&console.warn(e)}function p(){var e;return(e=window.MONEYHASH_IFRAME_URL)!=null?e:"https://embed.moneyhash.io"}const o=new Set(["payment","payout"]),m=new Set(["en","fr","ar"]);class f{constructor(e){a(this,"options");a(this,"messagingService",null);a(this,"iframe",null);a(this,"isCommunicationReady",null);t(!o.has(e.type),`MoneyHash constructor must be called with valid type (${[...o].join(" | ")})!`),this.options=e}get lang(){var r;const e=(r=this.options.locale)==null?void 0:r.split("-")[0];return s(!!e&&!m.has(e),`Supported languages (${[...m].join(" | ")})`),e||"en"}render({selector:e,intentId:r}){var L,M;(L=this.messagingService)==null||L.abortService();const S=p(),c=new URL(`${S}/embed/${this.options.type}/${r}`);c.searchParams.set("sdk","true"),c.searchParams.set("parent",window.location.origin),c.searchParams.set("version","js@1.0.0-beta.5");const R=(M=this.options.locale)==null?void 0:M.split("-")[0];R&&c.searchParams.set("lang",R),this.iframe=document.createElement("iframe"),this.iframe.src=c.toString(),this.iframe.style.height="100%",this.iframe.style.width="100%",this.iframe.style.border="0";const E=document.querySelector(e);return t(!E,`Couldn't find an element with selector ${e}!`),E.replaceChildren(this.iframe),this.messagingService=new i({target:this.iframe.contentWindow,targetOrigin:S}),this.isCommunicationReady=new Promise(y=>{var l;const g=u=>{var d;u.data.type==="sdk:init"&&(y(),(d=this.messagingService)==null||d.removeListener(g))};(l=this.messagingService)==null||l.onReceive(g)}),this.messagingService.onReceive((y,g)=>{var d,k,I,C;const{type:l,data:u}=y.data;switch(l){case"sdk:init":{g({type:"sdk:init",data:{headless:Boolean(this.options.headless),styles:this.options.styles}});break}case"onComplete":{(k=(d=this.options).onComplete)==null||k.call(d,w({type:this.options.type},u)),this.options.headless&&this.iframe&&(this.iframe.hidden=!0);break}case"onFail":{(C=(I=this.options).onFail)==null||C.call(I,w({type:this.options.type},u)),this.options.headless&&this.iframe&&(this.iframe.hidden=!0);break}}}),this.isCommunicationReady}setLocale(e){return b(this,null,function*(){var r;yield this==null?void 0:this.isCommunicationReady,this.options.locale=e,(r=this.messagingService)==null||r.send({type:"changeLanguage",data:{locale:e}})})}abortService(){return b(this,null,function*(){var e;yield this==null?void 0:this.isCommunicationReady,(e=this.messagingService)==null||e.abortService()})}}class h{constructor(e){a(this,"options");a(this,"sdkEmbed");this.options=e,this.sdkEmbed=new f(e)}start({selector:e,intentId:r}){return t(!e,"selector is required for start"),t(!r,"intentId is required for start"),this.sdkEmbed.render({selector:e,intentId:r})}setLocale(e){return this.sdkEmbed.setLocale(e)}removeEventListeners(){return this.sdkEmbed.abortService()}}return h});
(function(n,t){typeof exports=="object"&&typeof module!="undefined"?module.exports=t():typeof define=="function"&&define.amd?define(t):(n=typeof globalThis!="undefined"?globalThis:n||self,n.MoneyHash=t())})(this,function(){"use strict";var I=Object.defineProperty;var C=Object.getOwnPropertySymbols;var O=Object.prototype.hasOwnProperty,$=Object.prototype.propertyIsEnumerable;var y=(n,t,s)=>t in n?I(n,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):n[t]=s,v=(n,t)=>{for(var s in t||(t={}))O.call(t,s)&&y(n,s,t[s]);if(C)for(var s of C(t))$.call(t,s)&&y(n,s,t[s]);return n};var r=(n,t,s)=>(y(n,typeof t!="symbol"?t+"":t,s),s);var w=(n,t,s)=>new Promise((d,o)=>{var p=e=>{try{a(s.next(e))}catch(i){o(i)}},u=e=>{try{a(s.throw(e))}catch(i){o(i)}},a=e=>e.done?d(e.value):Promise.resolve(e.value).then(p,u);a((s=s.apply(n,t)).next())});class n{constructor(e){r(this,"target");r(this,"targetOrigin");r(this,"listeners");r(this,"onIncomingMessageBind",this.onIncomingMessage.bind(this));this.target=e.target,this.targetOrigin=e.targetOrigin,this.listeners=[],window.addEventListener("message",this.onIncomingMessageBind)}send(e){this.target.postMessage(e,this.targetOrigin)}onReceive(e){this.listeners.push(e)}removeListener(e){this.listeners=this.listeners.filter(i=>i!==e)}onIncomingMessage(e){e.origin===this.targetOrigin&&this.listeners.forEach(i=>{i(e,this.send.bind(this))})}abortService(){window.removeEventListener("message",this.onIncomingMessageBind)}}function t(a,e){if(a)throw new Error(e)}function s(a,e){a&&console.warn(e)}const d=new Set(["payment","payout"]),o=new Set(["en","fr","ar"]);class p{constructor(e){r(this,"options");r(this,"messagingService",null);r(this,"iframe",null);r(this,"isCommunicationReady",null);t(!d.has(e.type),`MoneyHash constructor must be called with valid type (${[...d].join(" | ")})!`),this.options=e}get lang(){var i;const e=(i=this.options.locale)==null?void 0:i.split("-")[0];return s(!!e&&!o.has(e),`Supported languages (${[...o].join(" | ")})`),e||"en"}render({selector:e,intentId:i}){var k,E;(k=this.messagingService)==null||k.abortService();const h=new URL(`https://embed.moneyhash.io/embed/${this.options.type}/${i}`);h.searchParams.set("sdk","true"),h.searchParams.set("parent",window.location.origin),h.searchParams.set("version","js@0.0.0-development");const b=(E=this.options.locale)==null?void 0:E.split("-")[0];b&&h.searchParams.set("lang",b),this.iframe=document.createElement("iframe"),this.iframe.src=h.toString(),this.iframe.style.height="100%",this.iframe.style.width="100%",this.iframe.style.border="0";const S=document.querySelector(e);return t(!S,`Couldn't find an element with selector ${e}!`),S.replaceChildren(this.iframe),this.messagingService=new n({target:this.iframe.contentWindow,targetOrigin:"https://embed.moneyhash.io"}),this.isCommunicationReady=new Promise(f=>{var g;const m=l=>{var c;l.data.type==="sdk:init"&&(f(),(c=this.messagingService)==null||c.removeListener(m))};(g=this.messagingService)==null||g.onReceive(m)}),this.messagingService.onReceive((f,m)=>{var c,L,M,R;const{type:g,data:l}=f.data;switch(g){case"sdk:init":{m({type:"sdk:init",data:{headless:Boolean(this.options.headless),styles:this.options.styles}});break}case"onComplete":{(L=(c=this.options).onComplete)==null||L.call(c,v({type:this.options.type},l)),this.options.headless&&this.iframe&&(this.iframe.hidden=!0);break}case"onFail":{(R=(M=this.options).onFail)==null||R.call(M,v({type:this.options.type},l)),this.options.headless&&this.iframe&&(this.iframe.hidden=!0);break}}}),this.isCommunicationReady}setLocale(e){return w(this,null,function*(){var i;yield this==null?void 0:this.isCommunicationReady,this.options.locale=e,(i=this.messagingService)==null||i.send({type:"changeLanguage",data:{locale:e}})})}abortService(){return w(this,null,function*(){var e;yield this==null?void 0:this.isCommunicationReady,(e=this.messagingService)==null||e.abortService()})}}class u{constructor(e){r(this,"options");r(this,"sdkEmbed");this.options=e,this.sdkEmbed=new p(e)}start({selector:e,intentId:i}){return t(!e,"selector is required for start"),t(!i,"intentId is required for start"),this.sdkEmbed.render({selector:e,intentId:i})}setLocale(e){return this.sdkEmbed.setLocale(e)}removeEventListeners(){return this.sdkEmbed.abortService()}}return u});
{
"name": "@moneyhash/js-sdk",
"version": "1.0.0-beta.5",
"version": "1.0.0",
"description": "MoneyHash JavaScript SDK",

@@ -55,3 +55,4 @@ "type": "module",

"prepare": "is-ci || husky install",
"release": "release-it"
"prerelease": "yarn build:production && yarn build:umd",
"release": "np"
},

@@ -98,3 +99,2 @@ "keywords": [

"prettier": "2.5.1",
"release-it": "^17.6.0",
"typescript": "^4.9.3",

@@ -101,0 +101,0 @@ "vite": "^4.1.0",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc