{"version":3,"file":"financialGateway.js","sources":["../../../../Framework/Core/Controls/financialGateway.ts"],"sourcesContent":["// \r\n// Copyright by the Spark Development Network\r\n//\r\n// Licensed under the Rock Community License (the \"License\");\r\n// you may not use this file except in compliance with the License.\r\n// You may obtain a copy of the License at\r\n//\r\n// http://www.rockrms.com/license\r\n//\r\n// Unless required by applicable law or agreed to in writing, software\r\n// distributed under the License is distributed on an \"AS IS\" BASIS,\r\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n// See the License for the specific language governing permissions and\r\n// limitations under the License.\r\n// \r\n//\r\n\r\nimport { inject, InjectionKey, provide } from \"vue\";\r\n\r\n/** The function signature that will be called when the payment can be submitted. */\r\ntype SubmitPaymentFunction = () => void;\r\n\r\n/**\r\n * The object to be provided by a parent so that it can interact with the\r\n * financial gateway.\r\n */\r\ntype SubmitPaymentObject = {\r\n /** The callback to use when submitting the payment. */\r\n callback?: SubmitPaymentFunction;\r\n};\r\n\r\n/** The unique symbol that holds our custom data. */\r\nconst submitPaymentCallbackSymbol: InjectionKey = Symbol(\"gateway-submit-payment-callback\");\r\n\r\n/**\r\n * Prepares the gateway control for use. This provides a custom object into the\r\n * calling controls namespace and then returns the function that can be used to\r\n * attempt to submit the payment.\r\n */\r\nexport const provideSubmitPayment = (): SubmitPaymentFunction => {\r\n const container: SubmitPaymentObject = {};\r\n provide(submitPaymentCallbackSymbol, container);\r\n\r\n return () => {\r\n if (container.callback) {\r\n container.callback();\r\n }\r\n else {\r\n throw \"Submit payment callback has not been defined.\";\r\n }\r\n };\r\n};\r\n\r\n/**\r\n * Provides the callback from the gateway component that should be called when\r\n * the user presses a button to initiate payment.\r\n *\r\n * @param callback The function to be called when the payment should be attempted.\r\n */\r\nexport const onSubmitPayment = (callback: SubmitPaymentFunction): void => {\r\n const container = inject(submitPaymentCallbackSymbol);\r\n\r\n if (!container) {\r\n throw \"Gateway control has not been properly initialized.\";\r\n }\r\n\r\n container.callback = callback;\r\n};\r\n"],"names":["submitPaymentCallbackSymbol","Symbol","provideSubmitPayment","container","provide","callback","onSubmitPayment","inject"],"mappings":";;;;;;;;;;YAgCA,IAAMA,2BAA8D,GAAGC,MAAM,CAAC,iCAAiC,CAAC,CAAA;AAOnGC,gBAAAA,oBAAoB,mCAAGA,MAA6B;cAC7D,IAAMC,SAA8B,GAAG,EAAE,CAAA;YACzCC,EAAAA,OAAO,CAACJ,2BAA2B,EAAEG,SAAS,CAAC,CAAA;YAE/C,EAAA,OAAO,MAAM;gBACT,IAAIA,SAAS,CAACE,QAAQ,EAAE;kBACpBF,SAAS,CAACE,QAAQ,EAAE,CAAA;YACxB,KAAC,MACI;YACD,MAAA,MAAM,+CAA+C,CAAA;YACzD,KAAA;eACH,CAAA;YACL,GAAC;AAQYC,gBAAAA,eAAe,8BAAID,QAA+B,IAAW;YACtE,EAAA,IAAMF,SAAS,GAAGI,MAAM,CAACP,2BAA2B,CAAC,CAAA;cAErD,IAAI,CAACG,SAAS,EAAE;YACZ,IAAA,MAAM,oDAAoD,CAAA;YAC9D,GAAA;cAEAA,SAAS,CAACE,QAAQ,GAAGA,QAAQ,CAAA;YACjC;;;;;;;;"}