@instincthub/react-ui 0.3.3 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/components/lib/index.cjs +1 -1
- package/dist/src/components/lib/index.cjs.map +1 -1
- package/dist/src/components/lib/index.js +1 -1
- package/dist/src/components/lib/index.js.map +1 -1
- package/dist/src/components/lib/paystack.cjs +1 -1
- package/dist/src/components/lib/paystack.cjs.map +1 -1
- package/dist/src/components/lib/paystack.js +1 -1
- package/dist/src/components/lib/paystack.js.map +1 -1
- package/dist/src/types/components/lib/paystack.d.ts +48 -12
- package/dist/src/types/types/index.d.ts +26 -2
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./auth/dbRequestst.cjs"),r=require("./roles.cjs"),t=require("./json/accounts.cjs"),o=require("./json/unsplashDefaultObject.cjs"),s=require("./createSubscription.cjs"),a=require("./elementIsVisibleInViewport.cjs"),i=require("./formError.cjs"),p=require("./fileToBase64.cjs"),n=require("./getPriceObjects.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./auth/dbRequestst.cjs"),r=require("./roles.cjs"),t=require("./json/accounts.cjs"),o=require("./json/unsplashDefaultObject.cjs"),s=require("./createSubscription.cjs"),a=require("./elementIsVisibleInViewport.cjs"),i=require("./formError.cjs"),p=require("./fileToBase64.cjs"),n=require("./getPriceObjects.cjs"),E=require("./convertArrayToObject.cjs"),l=require("./loadScript.cjs"),x=require("./format.cjs"),N=require("./phoneUtils.cjs"),u=require("./helpFunction.cjs"),_=require("./oauth_json.cjs"),S=require("./paystack.cjs"),O=require("./permissions.cjs"),c=require("./utils.cjs"),I=require("./queryParameters/index.cjs"),R=require("./charts.cjs"),T=require("./modals/modals.cjs"),A=require("./modals/openConfirmDelete.cjs");exports.getChannel=e.getChannel,exports.getData=e.getData,exports.INSTRUCTOR_TYPE=r.INSTRUCTOR_TYPE,exports.ROLE_GROUPING=r.ROLE_GROUPING,exports.adminAccessValidation=r.adminAccessValidation,exports.AllCoursesdataList=t.AllCoursesdataList,exports.COMMENTS_BY=t.COMMENTS_BY,exports.DataList=t.DataList,exports.accounts=t.accounts,exports.dataList=t.dataList,exports.pending=t.pending,exports.projectStartHistory=t.projectStartHistory,exports.statesNigeria=t.statesNigeria,exports.unsplashDefaultObject=o.unsplashDefaultObject,exports.createSubscription=s.default,exports.elementIsVisibleInViewport=a.default,exports.handleFormErrors=i.default,exports.fileToBase64=p.default,exports.getPriceObjects=n.default,exports.convertArrayToObject=E.default,exports.loadScript=l.default,exports.formatTime=x.formatTime,exports.E164_MAX_DIGITS=N.E164_MAX_DIGITS,exports.MAX_NATIONAL_DIGITS=N.MAX_NATIONAL_DIGITS,exports.MIN_NATIONAL_DIGITS=N.MIN_NATIONAL_DIGITS,exports.PHONE_COUNTRIES=N.PHONE_COUNTRIES,exports.buildPhoneValue=N.buildPhoneValue,exports.digitsOnly=N.digitsOnly,exports.findCountryByDialCode=N.findCountryByDialCode,exports.findCountryByIso=N.findCountryByIso,exports.formatNationalNumber=N.formatNationalNumber,exports.matchDialCode=N.matchDialCode,exports.maxNationalDigits=N.maxNationalDigits,exports.normalizeDialCode=N.normalizeDialCode,exports.parsePhoneNumber=N.parsePhoneNumber,exports.resolveCountry=N.resolveCountry,exports.searchCountries=N.searchCountries,exports.withPreferredCountries=N.withPreferredCountries,exports.API_HOST_URL=u.API_HOST_URL,exports.CODECS_URL_M3U8=u.CODECS_URL_M3U8,exports.FILE_URL=u.FILE_URL,exports.IN_DEV_MODE=u.IN_DEV_MODE,exports.TrackViewPort=u.TrackViewPort,exports.VIDEO_URL=u.VIDEO_URL,exports.abbreviateNumber=u.abbreviateNumber,exports.addUserDomain=u.addUserDomain,exports.calculateAmountAfterDeduction=u.calculateAmountAfterDeduction,exports.calculateAverageRating=u.calculateAverageRating,exports.calculateCouponDeduction=u.calculateCouponDeduction,exports.calculateTotalCredits=u.calculateTotalCredits,exports.convertArrayToFormData=u.convertArrayToFormData,exports.convertToFloat=u.convertToFloat,exports.convertToSlug=u.convertToSlug,exports.extractSubDomain=u.extractSubDomain,exports.fetchAPI=u.fetchAPI,exports.fetchData=u.fetchData,exports.findNullOrEmptyKeys=u.findNullOrEmptyKeys,exports.formatDateToWord=u.formatDateToWord,exports.formatDuration=u.formatDuration,exports.formatNumberWithCommas=u.formatNumberWithCommas,exports.getCookie=u.getCookie,exports.getNestedValue=u.getNestedValue,exports.handleError=u.handleError,exports.handleInvalid=u.handleInvalid,exports.handleResendOTP=u.handleResendOTP,exports.handleStatusError=u.handleStatusError,exports.hostUrlEncode=u.hostUrlEncode,exports.inputTagErrorEvent=u.inputTagErrorEvent,exports.isValidAlphanumeric=u.isValidAlphanumeric,exports.isValidEmail=u.isValidEmail,exports.objectIsEmpty=u.objectIsEmpty,exports.printErr=u.printErr,exports.printErrNew=u.printErrNew,exports.removeCookie=u.removeCookie,exports.removeErrMsg=u.removeErrMsg,exports.reqOptions=u.reqOptions,exports.romansFigure=u.romansFigure,exports.setCookie=u.setCookie,exports.slugifyFileName=u.slugifyFileName,exports.spinBtn=u.spinBtn,exports.stripCommaFromNumber=u.stripCommaFromNumber,exports.stripHtmlTags=u.stripHtmlTags,exports.toTitleCase=u.toTitleCase,exports.truncateHtml=u.truncateHtml,exports.paystackHook=_.paystackHook,exports.profile_goggle_provider=_.profile_goggle_provider,exports.PAYSTACK_INLINE_V2_URL=S.PAYSTACK_INLINE_V2_URL,exports.chargeAuthorization=S.chargeAuthorization,exports.handlePaymentSubmit=S.handlePaymentSubmit,exports.handlePaymentWithoutUserData=S.handlePaymentWithoutUserData,exports.payWithAccessCode=S.payWithAccessCode,exports.payWithPaystack=S.payWithPaystack,exports.paystackDataConfig=S.paystackDataConfig,exports.CHANNEL_ADMIN_ROLES=O.CHANNEL_ADMIN_ROLES,exports.CHANNEL_BLOGGER_ROLES=O.CHANNEL_BLOGGER_ROLES,exports.CHANNEL_EVENT_ROLES=O.CHANNEL_EVENT_ROLES,exports.CHANNEL_FINANCE_ROLES=O.CHANNEL_FINANCE_ROLES,exports.CHANNEL_INSTRUCTOR_ROLES=O.CHANNEL_INSTRUCTOR_ROLES,exports.CHANNEL_LEARNER_ROLES=O.CHANNEL_LEARNER_ROLES,exports.CHANNEL_MODERATOR_ROLES=O.CHANNEL_MODERATOR_ROLES,exports.CHANNEL_REGISTRAR_ROLES=O.CHANNEL_REGISTRAR_ROLES,exports.CHANNEL_SUPER_ADMIN_ROLES=O.CHANNEL_SUPER_ADMIN_ROLES,exports.ROLE_MAP=O.ROLE_MAP,exports.findPermissions=O.findPermissions,exports.hasUserPermission=O.hasUserPermission,exports.headerKeyPermission=O.headerKeyPermission,exports.headerUsernamePermission=O.headerUsernamePermission,exports.ADMIN_PERMISSION=c.ADMIN_PERMISSION,exports.APPLICATION_FEE_TYPE_OPTIONS=c.APPLICATION_FEE_TYPE_OPTIONS,exports.CODE_LANGUAGES=c.CODE_LANGUAGES,exports.COMPANY_SIZES_CHOICES=c.COMPANY_SIZES_CHOICES,exports.CONTENT_TYPE_OPTIONS=c.CONTENT_TYPE_OPTIONS,exports.COURSE_REWARD_OPTIONS=c.COURSE_REWARD_OPTIONS,exports.CREDENTIALS=c.CREDENTIALS,exports.CURRENCY_SYMBOL=c.CURRENCY_SYMBOL,exports.DURATION_FILTERS=c.DURATION_FILTERS,exports.INDUSTRIES=c.INDUSTRIES,exports.KEYWORD_DESCRIPTION=c.KEYWORD_DESCRIPTION,exports.NEXT_AUTH_SESSION_DATA_DUMMY=c.NEXT_AUTH_SESSION_DATA_DUMMY,exports.NIGERIA_BANKS=c.NIGERIA_BANKS,exports.PAYMENT_PROCESSING_OPTIONS=c.PAYMENT_PROCESSING_OPTIONS,exports.PRIVACY=c.PRIVACY,exports.PROGRAM_LEVELS=c.PROGRAM_LEVELS,exports.REGISTRAR_PERMISSION=c.REGISTRAR_PERMISSION,exports.SCOREBOARD_DURATION=c.SCOREBOARD_DURATION,exports.SKILLS_LEVELS=c.SKILLS_LEVELS,exports.STUDENT_STATUS=c.STUDENT_STATUS,exports.SUBSCRIPTION_OPTION=c.SUBSCRIPTION_OPTION,exports.SUPER_PERMISSION=c.SUPER_PERMISSION,exports.TRUE_FALSE=c.TRUE_FALSE,exports.VIDEO_PLAYER_OPTIONS=c.VIDEO_PLAYER_OPTIONS,exports.YES_NO=c.YES_NO,exports.gaugeData=c.gaugeData,exports.buildDataFilterUrl=I.buildDataFilterUrl,exports.buildPaginationUrl=I.buildPaginationUrl,exports.buildUrl=I.buildUrl,exports.cleanUrl=I.cleanUrl,exports.getQueryParam=I.getQueryParam,exports.getQueryParams=I.getQueryParams,exports.hasQueryParam=I.hasQueryParam,exports.navigateWithQuery=I.navigateWithQuery,exports.urlQueryHelper=I.urlQueryHelper,exports.calculatePercentageChange=R.calculatePercentageChange,exports.createTimeSeriesTemplate=R.createTimeSeriesTemplate,exports.formatChartValue=R.formatChartValue,exports.formatDateForChart=R.formatDateForChart,exports.generateChartColors=R.generateChartColors,exports.groupAndAggregateData=R.groupAndAggregateData,exports.transformChartData=R.transformChartData,exports.getUserEmailInputModal=T.getUserEmailInputModal,exports.openConfirmModal=T.openConfirmModal,exports.openToast=T.openToast,exports.openConfirmDelete=A.openConfirmDelete,exports.instinctHubLogoUrl="/assets/logo/instincthub-logo-color.png",exports.instinctHubLogoUrlBlack="/assets/logo/instincthub-logo-black.png",exports.instinctHubLogoUrlWhite="/assets/logo/instincthub-logo-white.png",exports.instinctHubThumbnailLogo="/assets/logo/instincthub-logo-thumbnail.png";
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../../src/components/lib/index.ts"],"sourcesContent":["// src/components/lib/index.ts\n\nexport * from \"./auth/dbRequestst\";\nexport * from \"./roles\";\n\n// JSON exports\nexport * from \"./json/accounts\";\nexport * from \"./json/countryNigeria\";\nexport * from \"./json/countryObjects\";\nexport * from \"./json/educationLevels\";\nexport * from \"./json/unsplashDefaultObject\";\n\n// Utility functions\nexport { default as createSubscription } from \"./createSubscription\";\nexport { default as elementIsVisibleInViewport } from \"./elementIsVisibleInViewport\";\nexport { default as handleFormErrors } from \"./formError\";\nexport { default as fileToBase64 } from \"./fileToBase64\";\nexport { default as getPriceObjects } from \"./getPriceObjects\";\nexport {default as convertArrayToObject} from \"./convertArrayToObject\";\nexport {default as loadScript} from \"./loadScript\";\nexport * from \"./format\";\nexport * from \"./phoneUtils\";\nexport * from \"./helpFunction\";\nexport * from \"./oauth_json\";\nexport * from \"./paystack\";\nexport * from \"./permissions\";\nexport * from \"./utils\";\nexport * from \"./queryParameters\";\n\n// Charts\nexport * from \"./charts\";\n\n// Modals\nexport * from \"./modals/modals\";\nexport * from \"./modals/openConfirmDelete\";\n\n// Logo\nexport const instinctHubLogoUrl = \"/assets/logo/instincthub-logo-color.png\";\nexport const instinctHubLogoUrlWhite =\n \"/assets/logo/instincthub-logo-white.png\";\nexport const instinctHubLogoUrlBlack =\n \"/assets/logo/instincthub-logo-black.png\";\nexport const instinctHubThumbnailLogo =\n \"/assets/logo/instincthub-logo-thumbnail.png\";\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../../src/components/lib/index.ts"],"sourcesContent":["// src/components/lib/index.ts\n\nexport * from \"./auth/dbRequestst\";\nexport * from \"./roles\";\n\n// JSON exports\nexport * from \"./json/accounts\";\nexport * from \"./json/countryNigeria\";\nexport * from \"./json/countryObjects\";\nexport * from \"./json/educationLevels\";\nexport * from \"./json/unsplashDefaultObject\";\n\n// Utility functions\nexport { default as createSubscription } from \"./createSubscription\";\nexport { default as elementIsVisibleInViewport } from \"./elementIsVisibleInViewport\";\nexport { default as handleFormErrors } from \"./formError\";\nexport { default as fileToBase64 } from \"./fileToBase64\";\nexport { default as getPriceObjects } from \"./getPriceObjects\";\nexport {default as convertArrayToObject} from \"./convertArrayToObject\";\nexport {default as loadScript} from \"./loadScript\";\nexport * from \"./format\";\nexport * from \"./phoneUtils\";\nexport * from \"./helpFunction\";\nexport * from \"./oauth_json\";\nexport * from \"./paystack\";\nexport * from \"./permissions\";\nexport * from \"./utils\";\nexport * from \"./queryParameters\";\n\n// Charts\nexport * from \"./charts\";\n\n// Modals\nexport * from \"./modals/modals\";\nexport * from \"./modals/openConfirmDelete\";\n\n// Logo\nexport const instinctHubLogoUrl = \"/assets/logo/instincthub-logo-color.png\";\nexport const instinctHubLogoUrlWhite =\n \"/assets/logo/instincthub-logo-white.png\";\nexport const instinctHubLogoUrlBlack =\n \"/assets/logo/instincthub-logo-black.png\";\nexport const instinctHubThumbnailLogo =\n \"/assets/logo/instincthub-logo-thumbnail.png\";\n"],"names":[],"mappings":"iyOAqCkC,0EAIhC,0EAFA,2EAIA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{getChannel,getData}from"./auth/dbRequestst.js";export{INSTRUCTOR_TYPE,ROLE_GROUPING,adminAccessValidation}from"./roles.js";export{AllCoursesdataList,COMMENTS_BY,DataList,accounts,dataList,pending,projectStartHistory,statesNigeria}from"./json/accounts.js";export{unsplashDefaultObject}from"./json/unsplashDefaultObject.js";export{default as createSubscription}from"./createSubscription.js";export{default as elementIsVisibleInViewport}from"./elementIsVisibleInViewport.js";export{default as handleFormErrors}from"./formError.js";export{default as fileToBase64}from"./fileToBase64.js";export{default as getPriceObjects}from"./getPriceObjects.js";export{default as convertArrayToObject}from"./convertArrayToObject.js";export{default as loadScript}from"./loadScript.js";export{formatTime}from"./format.js";export{E164_MAX_DIGITS,MAX_NATIONAL_DIGITS,MIN_NATIONAL_DIGITS,PHONE_COUNTRIES,buildPhoneValue,digitsOnly,findCountryByDialCode,findCountryByIso,formatNationalNumber,matchDialCode,maxNationalDigits,normalizeDialCode,parsePhoneNumber,resolveCountry,searchCountries,withPreferredCountries}from"./phoneUtils.js";export{API_HOST_URL,CODECS_URL_M3U8,FILE_URL,IN_DEV_MODE,TrackViewPort,VIDEO_URL,abbreviateNumber,addUserDomain,calculateAmountAfterDeduction,calculateAverageRating,calculateCouponDeduction,calculateTotalCredits,convertArrayToFormData,convertToFloat,convertToSlug,extractSubDomain,fetchAPI,fetchData,findNullOrEmptyKeys,formatDateToWord,formatDuration,formatNumberWithCommas,getCookie,getNestedValue,handleError,handleInvalid,handleResendOTP,handleStatusError,hostUrlEncode,inputTagErrorEvent,isValidAlphanumeric,isValidEmail,objectIsEmpty,printErr,printErrNew,removeCookie,removeErrMsg,reqOptions,romansFigure,setCookie,slugifyFileName,spinBtn,stripCommaFromNumber,stripHtmlTags,toTitleCase,truncateHtml}from"./helpFunction.js";export{paystackHook,profile_goggle_provider}from"./oauth_json.js";export{chargeAuthorization,handlePaymentSubmit,handlePaymentWithoutUserData,payWithPaystack,paystackDataConfig}from"./paystack.js";export{CHANNEL_ADMIN_ROLES,CHANNEL_BLOGGER_ROLES,CHANNEL_EVENT_ROLES,CHANNEL_FINANCE_ROLES,CHANNEL_INSTRUCTOR_ROLES,CHANNEL_LEARNER_ROLES,CHANNEL_MODERATOR_ROLES,CHANNEL_REGISTRAR_ROLES,CHANNEL_SUPER_ADMIN_ROLES,ROLE_MAP,findPermissions,hasUserPermission,headerKeyPermission,headerUsernamePermission}from"./permissions.js";export{ADMIN_PERMISSION,APPLICATION_FEE_TYPE_OPTIONS,CODE_LANGUAGES,COMPANY_SIZES_CHOICES,CONTENT_TYPE_OPTIONS,COURSE_REWARD_OPTIONS,CREDENTIALS,CURRENCY_SYMBOL,DURATION_FILTERS,INDUSTRIES,KEYWORD_DESCRIPTION,NEXT_AUTH_SESSION_DATA_DUMMY,NIGERIA_BANKS,PAYMENT_PROCESSING_OPTIONS,PRIVACY,PROGRAM_LEVELS,REGISTRAR_PERMISSION,SCOREBOARD_DURATION,SKILLS_LEVELS,STUDENT_STATUS,SUBSCRIPTION_OPTION,SUPER_PERMISSION,TRUE_FALSE,VIDEO_PLAYER_OPTIONS,YES_NO,gaugeData}from"./utils.js";export{buildDataFilterUrl,buildPaginationUrl,buildUrl,cleanUrl,getQueryParam,getQueryParams,hasQueryParam,navigateWithQuery,urlQueryHelper}from"./queryParameters/index.js";export{calculatePercentageChange,createTimeSeriesTemplate,formatChartValue,formatDateForChart,generateChartColors,groupAndAggregateData,transformChartData}from"./charts.js";export{getUserEmailInputModal,openConfirmModal,openToast}from"./modals/modals.js";export{openConfirmDelete}from"./modals/openConfirmDelete.js";var e="/assets/logo/instincthub-logo-color.png",t="/assets/logo/instincthub-logo-white.png",r="/assets/logo/instincthub-logo-black.png",a="/assets/logo/instincthub-logo-thumbnail.png";export{e as instinctHubLogoUrl,r as instinctHubLogoUrlBlack,t as instinctHubLogoUrlWhite,a as instinctHubThumbnailLogo};
|
|
1
|
+
export{getChannel,getData}from"./auth/dbRequestst.js";export{INSTRUCTOR_TYPE,ROLE_GROUPING,adminAccessValidation}from"./roles.js";export{AllCoursesdataList,COMMENTS_BY,DataList,accounts,dataList,pending,projectStartHistory,statesNigeria}from"./json/accounts.js";export{unsplashDefaultObject}from"./json/unsplashDefaultObject.js";export{default as createSubscription}from"./createSubscription.js";export{default as elementIsVisibleInViewport}from"./elementIsVisibleInViewport.js";export{default as handleFormErrors}from"./formError.js";export{default as fileToBase64}from"./fileToBase64.js";export{default as getPriceObjects}from"./getPriceObjects.js";export{default as convertArrayToObject}from"./convertArrayToObject.js";export{default as loadScript}from"./loadScript.js";export{formatTime}from"./format.js";export{E164_MAX_DIGITS,MAX_NATIONAL_DIGITS,MIN_NATIONAL_DIGITS,PHONE_COUNTRIES,buildPhoneValue,digitsOnly,findCountryByDialCode,findCountryByIso,formatNationalNumber,matchDialCode,maxNationalDigits,normalizeDialCode,parsePhoneNumber,resolveCountry,searchCountries,withPreferredCountries}from"./phoneUtils.js";export{API_HOST_URL,CODECS_URL_M3U8,FILE_URL,IN_DEV_MODE,TrackViewPort,VIDEO_URL,abbreviateNumber,addUserDomain,calculateAmountAfterDeduction,calculateAverageRating,calculateCouponDeduction,calculateTotalCredits,convertArrayToFormData,convertToFloat,convertToSlug,extractSubDomain,fetchAPI,fetchData,findNullOrEmptyKeys,formatDateToWord,formatDuration,formatNumberWithCommas,getCookie,getNestedValue,handleError,handleInvalid,handleResendOTP,handleStatusError,hostUrlEncode,inputTagErrorEvent,isValidAlphanumeric,isValidEmail,objectIsEmpty,printErr,printErrNew,removeCookie,removeErrMsg,reqOptions,romansFigure,setCookie,slugifyFileName,spinBtn,stripCommaFromNumber,stripHtmlTags,toTitleCase,truncateHtml}from"./helpFunction.js";export{paystackHook,profile_goggle_provider}from"./oauth_json.js";export{PAYSTACK_INLINE_V2_URL,chargeAuthorization,handlePaymentSubmit,handlePaymentWithoutUserData,payWithAccessCode,payWithPaystack,paystackDataConfig}from"./paystack.js";export{CHANNEL_ADMIN_ROLES,CHANNEL_BLOGGER_ROLES,CHANNEL_EVENT_ROLES,CHANNEL_FINANCE_ROLES,CHANNEL_INSTRUCTOR_ROLES,CHANNEL_LEARNER_ROLES,CHANNEL_MODERATOR_ROLES,CHANNEL_REGISTRAR_ROLES,CHANNEL_SUPER_ADMIN_ROLES,ROLE_MAP,findPermissions,hasUserPermission,headerKeyPermission,headerUsernamePermission}from"./permissions.js";export{ADMIN_PERMISSION,APPLICATION_FEE_TYPE_OPTIONS,CODE_LANGUAGES,COMPANY_SIZES_CHOICES,CONTENT_TYPE_OPTIONS,COURSE_REWARD_OPTIONS,CREDENTIALS,CURRENCY_SYMBOL,DURATION_FILTERS,INDUSTRIES,KEYWORD_DESCRIPTION,NEXT_AUTH_SESSION_DATA_DUMMY,NIGERIA_BANKS,PAYMENT_PROCESSING_OPTIONS,PRIVACY,PROGRAM_LEVELS,REGISTRAR_PERMISSION,SCOREBOARD_DURATION,SKILLS_LEVELS,STUDENT_STATUS,SUBSCRIPTION_OPTION,SUPER_PERMISSION,TRUE_FALSE,VIDEO_PLAYER_OPTIONS,YES_NO,gaugeData}from"./utils.js";export{buildDataFilterUrl,buildPaginationUrl,buildUrl,cleanUrl,getQueryParam,getQueryParams,hasQueryParam,navigateWithQuery,urlQueryHelper}from"./queryParameters/index.js";export{calculatePercentageChange,createTimeSeriesTemplate,formatChartValue,formatDateForChart,generateChartColors,groupAndAggregateData,transformChartData}from"./charts.js";export{getUserEmailInputModal,openConfirmModal,openToast}from"./modals/modals.js";export{openConfirmDelete}from"./modals/openConfirmDelete.js";var e="/assets/logo/instincthub-logo-color.png",t="/assets/logo/instincthub-logo-white.png",r="/assets/logo/instincthub-logo-black.png",a="/assets/logo/instincthub-logo-thumbnail.png";export{e as instinctHubLogoUrl,r as instinctHubLogoUrlBlack,t as instinctHubLogoUrlWhite,a as instinctHubThumbnailLogo};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/lib/index.ts"],"sourcesContent":["// src/components/lib/index.ts\n\nexport * from \"./auth/dbRequestst\";\nexport * from \"./roles\";\n\n// JSON exports\nexport * from \"./json/accounts\";\nexport * from \"./json/countryNigeria\";\nexport * from \"./json/countryObjects\";\nexport * from \"./json/educationLevels\";\nexport * from \"./json/unsplashDefaultObject\";\n\n// Utility functions\nexport { default as createSubscription } from \"./createSubscription\";\nexport { default as elementIsVisibleInViewport } from \"./elementIsVisibleInViewport\";\nexport { default as handleFormErrors } from \"./formError\";\nexport { default as fileToBase64 } from \"./fileToBase64\";\nexport { default as getPriceObjects } from \"./getPriceObjects\";\nexport {default as convertArrayToObject} from \"./convertArrayToObject\";\nexport {default as loadScript} from \"./loadScript\";\nexport * from \"./format\";\nexport * from \"./phoneUtils\";\nexport * from \"./helpFunction\";\nexport * from \"./oauth_json\";\nexport * from \"./paystack\";\nexport * from \"./permissions\";\nexport * from \"./utils\";\nexport * from \"./queryParameters\";\n\n// Charts\nexport * from \"./charts\";\n\n// Modals\nexport * from \"./modals/modals\";\nexport * from \"./modals/openConfirmDelete\";\n\n// Logo\nexport const instinctHubLogoUrl = \"/assets/logo/instincthub-logo-color.png\";\nexport const instinctHubLogoUrlWhite =\n \"/assets/logo/instincthub-logo-white.png\";\nexport const instinctHubLogoUrlBlack =\n \"/assets/logo/instincthub-logo-black.png\";\nexport const instinctHubThumbnailLogo =\n \"/assets/logo/instincthub-logo-thumbnail.png\";\n"],"names":["instinctHubLogoUrl","instinctHubLogoUrlWhite","instinctHubLogoUrlBlack","instinctHubThumbnailLogo"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/lib/index.ts"],"sourcesContent":["// src/components/lib/index.ts\n\nexport * from \"./auth/dbRequestst\";\nexport * from \"./roles\";\n\n// JSON exports\nexport * from \"./json/accounts\";\nexport * from \"./json/countryNigeria\";\nexport * from \"./json/countryObjects\";\nexport * from \"./json/educationLevels\";\nexport * from \"./json/unsplashDefaultObject\";\n\n// Utility functions\nexport { default as createSubscription } from \"./createSubscription\";\nexport { default as elementIsVisibleInViewport } from \"./elementIsVisibleInViewport\";\nexport { default as handleFormErrors } from \"./formError\";\nexport { default as fileToBase64 } from \"./fileToBase64\";\nexport { default as getPriceObjects } from \"./getPriceObjects\";\nexport {default as convertArrayToObject} from \"./convertArrayToObject\";\nexport {default as loadScript} from \"./loadScript\";\nexport * from \"./format\";\nexport * from \"./phoneUtils\";\nexport * from \"./helpFunction\";\nexport * from \"./oauth_json\";\nexport * from \"./paystack\";\nexport * from \"./permissions\";\nexport * from \"./utils\";\nexport * from \"./queryParameters\";\n\n// Charts\nexport * from \"./charts\";\n\n// Modals\nexport * from \"./modals/modals\";\nexport * from \"./modals/openConfirmDelete\";\n\n// Logo\nexport const instinctHubLogoUrl = \"/assets/logo/instincthub-logo-color.png\";\nexport const instinctHubLogoUrlWhite =\n \"/assets/logo/instincthub-logo-white.png\";\nexport const instinctHubLogoUrlBlack =\n \"/assets/logo/instincthub-logo-black.png\";\nexport const instinctHubThumbnailLogo =\n \"/assets/logo/instincthub-logo-thumbnail.png\";\n"],"names":["instinctHubLogoUrl","instinctHubLogoUrlWhite","instinctHubLogoUrlBlack","instinctHubThumbnailLogo"],"mappings":"2yGAqCO,IAAMA,EAAqB,0CACrBC,EACX,0CACWC,EACX,0CACWC,EACX"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_rollupPluginBabelHelpers.cjs"),n=require("./helpFunction.cjs"),a=require("./modals/modals.cjs"),t=function(e){return{authorization_code:e.authorization_code,reference:(new Date).getTime().toString(),email:e.email,first_name:e.first_name,last_name:e.last_name,amount:Math.round(100*e.amount),currency:e.currency||"NGN",publicKey:process.env.NEXT_PUBLIC_PAYSTACK_SECRET_KEY,key:process.env.NEXT_PUBLIC_PAYSTACK_PUBLIC_KEY,callback_url:window.location.href,metadata:e.metadata}},o=function(){var n=e.asyncToGenerator(e.regenerator().m(function n(t){var o,r,c,i,s;return e.regenerator().w(function(e){for(;;)switch(e.p=e.n){case 0:return o={method:"POST",body:JSON.stringify(t),headers:{Authorization:"Bearer ".concat(process.env.NEXT_PUBLIC_PAYSTACK_SECRET_KEY),"Content-Type":"application/json"}},e.p=1,e.n=2,fetch("https://api.paystack.co/transaction/charge_authorization",o);case 2:return c=e.v,e.n=3,c.json();case 3:return i=e.v,"success"===(null===(r=i.data)||void 0===r?void 0:r.status)?a.openToast("Payment was successful with reference: ".concat(i.data.reference)):a.openToast("Payment failed with reference: ".concat(i.data.reference),400),e.a(2,i.data);case 4:return e.p=4,s=e.v,a.openToast("Payment processing error occurred",400),console.error("Payment authorization error:",s),e.a(2,{status:"failed",error:s})}},n,null,[[1,4]])}));return function(e){return n.apply(this,arguments)}}(),r=function(n){return new Promise(function(){var t=e.asyncToGenerator(e.regenerator().m(function t(o){var r;return e.regenerator().w(function(t){for(;;)switch(t.p=t.n){case 0:if(t.p=0,window.PaystackPop){t.n=1;break}throw new Error("Paystack script not loaded");case 1:return t.n=2,window.PaystackPop.setup(e.objectSpread2(e.objectSpread2({},n),{},{callback:function(t){a.openToast("Payment complete! Reference: "+t.reference),o(e.objectSpread2(e.objectSpread2({},t),{},{email:n.email,amount:n.amount}))},onClose:function(){a.openToast("Transaction was not completed, window closed.",400),o({status:"canceled",cancelled:!0,reference:n.reference,email:n.email,amount:n.amount})}}));case 2:t.v.openIframe(),t.n=4;break;case 3:t.p=3,r=t.v,console.error("Paystack initialization error:",r),a.openToast("Payment could not be initiated",400),o({status:"failed",cancelled:!0,reference:n.reference,error:r,email:n.email,amount:n.amount});case 4:return t.a(2)}},t,null,[[0,3]])}));return function(e){return t.apply(this,arguments)}}())};function c(){return c=e.asyncToGenerator(e.regenerator().m(function c(i){var s,u,l;return e.regenerator().w(function(c){for(;;)switch(c.n){case 0:if(i.e&&i.e.preventDefault(),!i.openConfirm||!i.defaultConfirm){c.n=2;break}return s="By clicking okay, you are enrolling for ".concat(i.label," with id ").concat(i.objects.object_id,"."),c.n=1,a.openConfirmModal(i.defaultMsg||s);case 1:if(c.v){c.n=2;break}return c.a(2);case 2:u=function(){var c=e.asyncToGenerator(e.regenerator().m(function c(){var s,u,l,d,p,m,f,y,b,_,h,g,v,k,j,w,T,P,C,O,S,N;return e.regenerator().w(function(c){for(;;)switch(c.p=c.n){case 0:if(i.setStatus(0),s={id:0,code:"",email_list:"",object_id:"",valid_from:"",valid_to:"",days_count:0,discount_type:null,discount:0,amount:0,currency:"",active:!1,timestamp:"",channel:"",content_type:0,students:[]},!i.coupon){c.n=5;break}return d=null===(l=i.configObj.metadata)||void 0===l?void 0:l.channel_username,p=JSON.stringify({code:i.coupon,email:i.configObj.email,content_type:i.configObj.content_type,object_id:i.configObj.object_id}),m=n.reqOptions("POST",p,null,"json"),f="".concat(n.API_HOST_URL,"coupons/").concat(d,"/validate-coupon/"),c.p=1,c.n=2,fetch(f,m);case 2:return y=c.v,c.n=3,y.json();case 3:(s=c.v).detail?a.openToast(s.detail,400):s.id&&a.openToast("".concat(s.discount||"".concat(s.currency).concat(s.amount),"% token was applied.")),c.n=5;break;case 4:c.p=4,N=c.v,console.error("Coupon validation error:",N),a.openToast("Could not validate coupon",400);case 5:if(!s.discount&&!s.amount){c.n=7;break}if(100!==s.discount||"percentage"!==s.discount_type){c.n=6;break}return b={email:i.configObj.email,amount:0,status:"success",reference:"COUPON__".concat(i.coupon,"__").concat(i.configObj.email),message:"Payment complete with 100% token coupon",transaction:"",canceled:!1},i.handleDBAction(b),i.setStatus(1),c.a(2);case 6:(_=n.calculateCouponDeduction(i.configObj.amount,i.configObj.currency||"NGN",s)).discounted?(a.openToast(_.detail),u=e.objectSpread2(e.objectSpread2({},i.configObj),_)):(a.openToast(_.detail,400),u=i.configObj),c.n=8;break;case 7:u=i.configObj;case 8:if(i.gatwayCharges&&(h=i.gatwayCharges/100,g=u.amount/(1-h),v=parseFloat(g.toFixed(2)),k=v-u.amount,j=k>2e3?u.amount+2e3:v,u.amount=j),w=t(u),!u.amount){c.n=17;break}if(!u.authorization_code||!i.paymentMethod){c.n=14;break}return T="Would you prefer we charge your existing ".concat(i.paymentMethod.authorization.card_type," card that ends with ").concat(i.paymentMethod.last4,"?"),c.n=9,a.openConfirmModal(T,!0);case 9:if(!c.v){c.n=11;break}return c.n=10,o(w);case 10:P=c.v,i.handleDBAction(P),c.n=13;break;case 11:return c.n=12,r(w);case 12:C=c.v,i.handleDBAction(C);case 13:c.n=16;break;case 14:return console.log("Pay with paystack: "),c.n=15,r(w);case 15:O=c.v,i.handleDBAction(O);case 16:c.n=18;break;case 17:S={email:i.configObj.email,amount:0,status:"success",reference:"COUPON__".concat(i.coupon,"__").concat(i.configObj.email),message:"No payment required for free item",transaction:"",canceled:!1},i.handleDBAction(S);case 18:i.setStatus(1);case 19:return c.a(2)}},c,null,[[1,4]])}));return function(){return c.apply(this,arguments)}}(),l=function(){var t=e.asyncToGenerator(e.regenerator().m(function t(){var o;return e.regenerator().w(function(e){for(;;)switch(e.n){case 0:if(i.configObj.email){e.n=4;break}return e.n=1,a.getUserEmailInputModal(i.label);case 1:if(!(o=e.v)){e.n=2;break}i.configObj.email=o,n.setCookie("email",o,2),u(),e.n=3;break;case 2:return a.openToast("You need to enter a valid email!",400),e.n=3,l();case 3:e.n=5;break;case 4:n.setCookie("email",i.configObj.email,2),u();case 5:return e.a(2)}},t)}));return function(){return t.apply(this,arguments)}}(),l();case 3:return c.a(2)}},c)})),c.apply(this,arguments)}function i(){return(i=e.asyncToGenerator(e.regenerator().m(function o(c){var i,s,u,l,d,p,m,f,y,b,_,h,g,v,k,j,w,T,P,C,O,S;return e.regenerator().w(function(o){for(;;)switch(o.p=o.n){case 0:if(c.e&&c.e.preventDefault(),!c.defaultConfirm){o.n=2;break}return i=c.defaultMsg||"By clicking okay, you are proceeding with payment for ".concat(c.label,"."),o.n=1,a.openConfirmModal(i);case 1:if(o.v){o.n=2;break}return o.a(2);case 2:return c.setStatus(0),o.n=3,a.getUserEmailInputModal(c.label);case 3:if(s=o.v){o.n=4;break}return a.openToast("You need to enter a valid email to proceed!",400),c.setStatus(1),o.a(2);case 4:if(n.setCookie("email",s,2),u={email:s,first_name:"Guest",last_name:"User",amount:c.amount,currency:c.currency||"NGN",metadata:c.metadata,content_type:c.content_type,object_id:c.object_id},!c.coupon){o.n=11;break}return d=null===(l=c.metadata)||void 0===l?void 0:l.channel_username,p=JSON.stringify({code:c.coupon,email:s,content_type:c.content_type,object_id:c.object_id}),m=n.reqOptions("POST",p,null,"json"),f="".concat(n.API_HOST_URL,"coupons/").concat(d,"/validate-coupon/"),o.p=5,o.n=6,fetch(f,m);case 6:return y=o.v,o.n=7,y.json();case 7:if(b=o.v,_=b.discount||0,b.detail?a.openToast(b.detail,400):b.id&&a.openToast("".concat(_,"% discount was applied.")),!(h=n.calculateCouponDeduction(u.amount,u.currency||"NGN",b)).discounted){o.n=9;break}if(100!==_){o.n=8;break}return g={email:u.email,amount:0,status:"success",reference:"COUPON__".concat(c.coupon,"__").concat(u.email),message:"No payment required for free item",transaction:"",canceled:!1},c.handleDBAction(g),c.setStatus(1),o.a(2);case 8:a.openToast(h.detail),u=e.objectSpread2(e.objectSpread2({},u),h);case 9:o.n=11;break;case 10:o.p=10,S=o.v,console.error("Coupon validation error:",S),a.openToast("Could not validate coupon",400);case 11:if(c.gatwayCharges&&(v=c.gatwayCharges/100,k=u.amount/(1-v),j=parseFloat(k.toFixed(2)),w=j-u.amount,T=w>2e3?u.amount+2e3:j,u.amount=T),P=t(u),!(u.amount>0)){o.n=13;break}return o.n=12,r(P);case 12:C=o.v,c.handleDBAction(C),o.n=14;break;case 13:O={email:u.email,amount:0,status:"success",reference:"COUPON__".concat(c.coupon,"__").concat(u.email),message:"No payment required for free item",transaction:"",canceled:!1},c.handleDBAction(O);case 14:c.setStatus(1);case 15:return o.a(2)}},o,null,[[5,10]])}))).apply(this,arguments)}exports.chargeAuthorization=o,exports.handlePaymentSubmit=function(e){return c.apply(this,arguments)},exports.handlePaymentWithoutUserData=function(e){return i.apply(this,arguments)},exports.payWithPaystack=r,exports.paystackDataConfig=t;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_rollupPluginBabelHelpers.cjs"),n=require("./helpFunction.cjs"),a=require("./modals/modals.cjs"),t="https://js.paystack.co/v2/inline.js",o=function(e){return{reference:(new Date).getTime().toString(),email:e.email,first_name:e.first_name,last_name:e.last_name,amount:Math.round(100*e.amount),currency:e.currency||"NGN",key:process.env.NEXT_PUBLIC_PAYSTACK_PUBLIC_KEY,callback_url:window.location.href,metadata:e.metadata}},r=function(){var t=e.asyncToGenerator(e.regenerator().m(function t(o){var r,c,s,i,u,l;return e.regenerator().w(function(t){for(;;)switch(t.p=t.n){case 0:if(null!=o&&o.chargeUrl){t.n=1;break}return a.openToast("Saved card payments are not available here.",400),t.a(2,{status:"failed",message:"chargeUrl is required"});case 1:return r=n.reqOptions("POST",JSON.stringify(o.body||{}),o.token||null,"json",o.channel||null),t.p=2,t.n=3,fetch(o.chargeUrl,r);case 3:return c=t.v,t.n=4,c.json().catch(function(){return{}});case 4:if(s=t.v,i=null!=s&&s.data&&"object"===e.typeof(s.data)?s.data:s,!c.ok||"success"!==(null==i?void 0:i.status)){t.n=5;break}return a.openToast("Payment was successful with reference: ".concat(i.reference)),t.a(2,i);case 5:return u=(null==s?void 0:s.detail)||(null==i?void 0:i.gateway_response)||(null==i?void 0:i.message)||"Payment could not be completed with the saved card",a.openToast(u,400),t.a(2,e.objectSpread2(e.objectSpread2({},i),{},{status:(null==i?void 0:i.status)||"failed",message:u}));case 6:return t.p=6,l=t.v,a.openToast("Payment processing error occurred",400),console.error("Saved card charge error:",l),t.a(2,{status:"failed",error:l})}},t,null,[[2,6]])}));return function(e){return t.apply(this,arguments)}}(),c=function(n){return new Promise(function(){var t=e.asyncToGenerator(e.regenerator().m(function t(o){var r;return e.regenerator().w(function(t){for(;;)switch(t.p=t.n){case 0:if(t.p=0,window.PaystackPop){t.n=1;break}throw new Error("Paystack script not loaded");case 1:return t.n=2,window.PaystackPop.setup(e.objectSpread2(e.objectSpread2({},n),{},{callback:function(t){a.openToast("Payment complete! Reference: "+t.reference),o(e.objectSpread2(e.objectSpread2({},t),{},{email:n.email,amount:n.amount}))},onClose:function(){a.openToast("Transaction was not completed, window closed.",400),o({status:"canceled",cancelled:!0,reference:n.reference,email:n.email,amount:n.amount})}}));case 2:t.v.openIframe(),t.n=4;break;case 3:t.p=3,r=t.v,console.error("Paystack initialization error:",r),a.openToast("Payment could not be initiated",400),o({status:"failed",cancelled:!0,reference:n.reference,error:r,email:n.email,amount:n.amount});case 4:return t.a(2)}},t,null,[[0,3]])}));return function(e){return t.apply(this,arguments)}}())};function s(){return s=e.asyncToGenerator(e.regenerator().m(function t(s){var i,u,l;return e.regenerator().w(function(t){for(;;)switch(t.n){case 0:if(s.e&&s.e.preventDefault(),!s.openConfirm||!s.defaultConfirm){t.n=2;break}return i="By clicking okay, you are enrolling for ".concat(s.label," with id ").concat(s.objects.object_id,"."),t.n=1,a.openConfirmModal(s.defaultMsg||i);case 1:if(t.v){t.n=2;break}return t.a(2);case 2:u=function(){var t=e.asyncToGenerator(e.regenerator().m(function t(){var i,u,l,d,p,f,m,b,y,g,v,h,_,j,k,w,S,P,T,C,O,N,U,A,D,B;return e.regenerator().w(function(t){for(;;)switch(t.p=t.n){case 0:if(s.setStatus(0),i={id:0,code:"",email_list:"",object_id:"",valid_from:"",valid_to:"",days_count:0,discount_type:null,discount:0,amount:0,currency:"",active:!1,timestamp:"",channel:"",content_type:0,students:[]},!s.coupon){t.n=5;break}return d=null===(l=s.configObj.metadata)||void 0===l?void 0:l.channel_username,p=JSON.stringify({code:s.coupon,email:s.configObj.email,content_type:s.configObj.content_type,object_id:s.configObj.object_id}),f=n.reqOptions("POST",p,null,"json"),m="".concat(n.API_HOST_URL,"coupons/").concat(d,"/validate-coupon/"),t.p=1,t.n=2,fetch(m,f);case 2:return b=t.v,t.n=3,b.json();case 3:(i=t.v).detail?a.openToast(i.detail,400):i.id&&a.openToast("".concat(i.discount||"".concat(i.currency).concat(i.amount),"% token was applied.")),t.n=5;break;case 4:t.p=4,B=t.v,console.error("Coupon validation error:",B),a.openToast("Could not validate coupon",400);case 5:if(!i.discount&&!i.amount){t.n=7;break}if(100!==i.discount||"percentage"!==i.discount_type){t.n=6;break}return y={email:s.configObj.email,amount:0,status:"success",reference:"COUPON__".concat(s.coupon,"__").concat(s.configObj.email),message:"Payment complete with 100% token coupon",transaction:"",canceled:!1},s.handleDBAction(y),s.setStatus(1),t.a(2);case 6:(g=n.calculateCouponDeduction(s.configObj.amount,s.configObj.currency||"NGN",i)).discounted?(a.openToast(g.detail),u=e.objectSpread2(e.objectSpread2({},s.configObj),g)):(a.openToast(g.detail,400),u=s.configObj),t.n=8;break;case 7:u=s.configObj;case 8:if(s.gatwayCharges&&(v=s.gatwayCharges/100,h=u.amount/(1-v),_=parseFloat(h.toFixed(2)),j=_-u.amount,k=j>2e3?u.amount+2e3:_,u.amount=k),w=o(u),!u.amount){t.n=17;break}if(!s.paymentMethod||null===(S=s.savedCardCharge)||void 0===S||!S.chargeUrl){t.n=14;break}return T="Would you prefer we charge your existing ".concat((null===(P=s.paymentMethod.authorization)||void 0===P?void 0:P.card_type)||""," card that ends with ").concat(s.paymentMethod.last4,"?"),t.n=9,a.openConfirmModal(T,!0);case 9:if(!t.v){t.n=11;break}return t.n=10,r(e.objectSpread2(e.objectSpread2({},s.savedCardCharge),{},{body:e.objectSpread2({payment_method_id:s.paymentMethod.id,coupon:s.coupon||null,content_type:null!==(C=s.configObj.content_type)&&void 0!==C?C:null,object_id:null!==(O=s.configObj.object_id)&&void 0!==O?O:null,metadata:w.metadata||{}},s.savedCardCharge.body||{})}));case 10:N=t.v,s.handleDBAction(N),t.n=13;break;case 11:return t.n=12,c(w);case 12:U=t.v,s.handleDBAction(U);case 13:t.n=16;break;case 14:return console.log("Pay with paystack: "),t.n=15,c(w);case 15:A=t.v,s.handleDBAction(A);case 16:t.n=18;break;case 17:D={email:s.configObj.email,amount:0,status:"success",reference:"COUPON__".concat(s.coupon,"__").concat(s.configObj.email),message:"No payment required for free item",transaction:"",canceled:!1},s.handleDBAction(D);case 18:s.setStatus(1);case 19:return t.a(2)}},t,null,[[1,4]])}));return function(){return t.apply(this,arguments)}}(),l=function(){var t=e.asyncToGenerator(e.regenerator().m(function t(){var o;return e.regenerator().w(function(e){for(;;)switch(e.n){case 0:if(s.configObj.email){e.n=4;break}return e.n=1,a.getUserEmailInputModal(s.label);case 1:if(!(o=e.v)){e.n=2;break}s.configObj.email=o,n.setCookie("email",o,2),u(),e.n=3;break;case 2:return a.openToast("You need to enter a valid email!",400),e.n=3,l();case 3:e.n=5;break;case 4:n.setCookie("email",s.configObj.email,2),u();case 5:return e.a(2)}},t)}));return function(){return t.apply(this,arguments)}}(),l();case 3:return t.a(2)}},t)})),s.apply(this,arguments)}function i(){return(i=e.asyncToGenerator(e.regenerator().m(function t(r){var s,i,u,l,d,p,f,m,b,y,g,v,h,_,j,k,w,S,P,T,C,O;return e.regenerator().w(function(t){for(;;)switch(t.p=t.n){case 0:if(r.e&&r.e.preventDefault(),!r.defaultConfirm){t.n=2;break}return s=r.defaultMsg||"By clicking okay, you are proceeding with payment for ".concat(r.label,"."),t.n=1,a.openConfirmModal(s);case 1:if(t.v){t.n=2;break}return t.a(2);case 2:return r.setStatus(0),t.n=3,a.getUserEmailInputModal(r.label);case 3:if(i=t.v){t.n=4;break}return a.openToast("You need to enter a valid email to proceed!",400),r.setStatus(1),t.a(2);case 4:if(n.setCookie("email",i,2),u={email:i,first_name:"Guest",last_name:"User",amount:r.amount,currency:r.currency||"NGN",metadata:r.metadata,content_type:r.content_type,object_id:r.object_id},!r.coupon){t.n=11;break}return d=null===(l=r.metadata)||void 0===l?void 0:l.channel_username,p=JSON.stringify({code:r.coupon,email:i,content_type:r.content_type,object_id:r.object_id}),f=n.reqOptions("POST",p,null,"json"),m="".concat(n.API_HOST_URL,"coupons/").concat(d,"/validate-coupon/"),t.p=5,t.n=6,fetch(m,f);case 6:return b=t.v,t.n=7,b.json();case 7:if(y=t.v,g=y.discount||0,y.detail?a.openToast(y.detail,400):y.id&&a.openToast("".concat(g,"% discount was applied.")),!(v=n.calculateCouponDeduction(u.amount,u.currency||"NGN",y)).discounted){t.n=9;break}if(100!==g){t.n=8;break}return h={email:u.email,amount:0,status:"success",reference:"COUPON__".concat(r.coupon,"__").concat(u.email),message:"No payment required for free item",transaction:"",canceled:!1},r.handleDBAction(h),r.setStatus(1),t.a(2);case 8:a.openToast(v.detail),u=e.objectSpread2(e.objectSpread2({},u),v);case 9:t.n=11;break;case 10:t.p=10,O=t.v,console.error("Coupon validation error:",O),a.openToast("Could not validate coupon",400);case 11:if(r.gatwayCharges&&(_=r.gatwayCharges/100,j=u.amount/(1-_),k=parseFloat(j.toFixed(2)),w=k-u.amount,S=w>2e3?u.amount+2e3:k,u.amount=S),P=o(u),!(u.amount>0)){t.n=13;break}return t.n=12,c(P);case 12:T=t.v,r.handleDBAction(T),t.n=14;break;case 13:C={email:u.email,amount:0,status:"success",reference:"COUPON__".concat(r.coupon,"__").concat(u.email),message:"No payment required for free item",transaction:"",canceled:!1},r.handleDBAction(C);case 14:r.setStatus(1);case 15:return t.a(2)}},t,null,[[5,10]])}))).apply(this,arguments)}exports.PAYSTACK_INLINE_V2_URL=t,exports.chargeAuthorization=r,exports.handlePaymentSubmit=function(e){return s.apply(this,arguments)},exports.handlePaymentWithoutUserData=function(e){return i.apply(this,arguments)},exports.payWithAccessCode=function(n){var o={email:"",amount:0},r=function(){return new Promise(function(e,n){var a=window.PaystackPop;if(a&&"function"==typeof a)return e(a);var o=document.createElement("script");o.src=t,o.async=!0,o.onload=function(){return e(window.PaystackPop)},o.onerror=function(){return n(new Error("Paystack script failed to load"))},document.body.appendChild(o)})};return new Promise(function(){var t=e.asyncToGenerator(e.regenerator().m(function t(c){var s,i;return e.regenerator().w(function(t){for(;;)switch(t.p=t.n){case 0:if(t.p=0,n){t.n=1;break}throw new Error("accessCode is required");case 1:return t.n=2,r();case 2:s=t.v,(new s).resumeTransaction(n,{onSuccess:function(n){a.openToast("Payment complete! Reference: "+n.reference),c(e.objectSpread2(e.objectSpread2(e.objectSpread2({},o),n),{},{status:n.status||"success"}))},onCancel:function(){a.openToast("Transaction was not completed, window closed.",400),c(e.objectSpread2(e.objectSpread2({},o),{},{status:"canceled",cancelled:!0,reference:""}))},onError:function(n){a.openToast((null==n?void 0:n.message)||"Payment could not be initiated",400),c(e.objectSpread2(e.objectSpread2({},o),{},{status:"failed",reference:"",error:n}))}}),t.n=4;break;case 3:t.p=3,i=t.v,console.error("Paystack access code error:",i),a.openToast("Payment could not be initiated",400),c(e.objectSpread2(e.objectSpread2({},o),{},{status:"failed",reference:"",error:i}));case 4:return t.a(2)}},t,null,[[0,3]])}));return function(e){return t.apply(this,arguments)}}())},exports.payWithPaystack=c,exports.paystackDataConfig=o;
|
|
2
2
|
//# sourceMappingURL=paystack.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paystack.cjs","sources":["../../../../src/components/lib/paystack.ts"],"sourcesContent":["import {\n API_HOST_URL,\n calculateCouponDeduction,\n reqOptions,\n setCookie,\n} from \"./helpFunction\";\nimport {\n getUserEmailInputModal,\n openConfirmModal,\n openToast,\n} from \"./modals/modals\";\nimport {\n PaystackConfigObjectType,\n PaystackConfigType,\n PaystackResponseType,\n PaymentContextType,\n CouponType,\n} from \"@/types\";\n\n/**\n * Context for processing payments\n * @property {Event | null} [e] - The event object that triggered the payment\n * @property {Object} objects - Details about the item being purchased\n * @property {string} objects.title - Title of the item\n * @property {string | number | null} [objects.object_type] - Model ID of the object being purchased\n * @property {string | number | null} [objects.object_id] - Object ID of the object being purchased\n * @property {PaystackConfigObjectType} configObj - Configuration for PayStack\n * @property {PaymentMethodType} [paymentMethod] - Saved payment method if available\n * @property {Function} setStatus - Function to update UI status during payment process\n * @property {Function} handleDBAction - Callback for processing successful payments\n * @property {boolean} [defaultConfirm] - Whether to show a confirmation dialog\n * @property {string} label - Label for the payment (usually item title)\n * @property {string} [coupon] - Coupon code if applicable\n * @property {string} [defaultMsg] - Custom confirmation message\n * @property {number} [gatwayCharges] - Payment gateway charges percentage\n */\n\n/**\n * Configures the Paystack payment data for processing\n * @param obj - Object containing payment details\n * @returns PaystackConfig - Configured payment data\n */\nexport const paystackDataConfig = (\n obj: PaystackConfigObjectType\n): PaystackConfigType => ({\n authorization_code: obj.authorization_code,\n reference: new Date().getTime().toString(),\n email: obj.email,\n first_name: obj.first_name,\n last_name: obj.last_name,\n amount: Math.round(obj.amount * 100), // Amount is in the country's lowest currency. E.g Kobo, so 20000 kobo = N200\n currency: obj.currency || \"NGN\",\n publicKey: process.env.NEXT_PUBLIC_PAYSTACK_SECRET_KEY,\n key: process.env.NEXT_PUBLIC_PAYSTACK_PUBLIC_KEY,\n callback_url: window.location.href,\n metadata: obj.metadata,\n});\n\n/**\n * Charges a customer using an existing authorization\n * @param data - Payment configuration data\n * @returns Promise with transaction data\n */\nexport const chargeAuthorization = async (\n data: PaystackConfigType\n): Promise<any> => {\n // This function tries to charge user with existing card\n const url = \"https://api.paystack.co/transaction/charge_authorization\";\n const options = {\n method: \"POST\",\n body: JSON.stringify(data),\n headers: {\n Authorization: `Bearer ${process.env.NEXT_PUBLIC_PAYSTACK_SECRET_KEY}`,\n \"Content-Type\": \"application/json\",\n },\n };\n\n try {\n const req = await fetch(url, options);\n const res = await req.json();\n\n if (res.data?.status === \"success\") {\n openToast(`Payment was successful with reference: ${res.data.reference}`);\n } else {\n openToast(`Payment failed with reference: ${res.data.reference}`, 400);\n }\n\n return res.data;\n } catch (error) {\n openToast(\"Payment processing error occurred\", 400);\n console.error(\"Payment authorization error:\", error);\n return { status: \"failed\", error };\n }\n};\n\n/**\n * Initiates payment with Paystack popup\n * @param config - Payment configuration\n * @returns Promise with payment response\n */\nexport const payWithPaystack = (\n config: PaystackConfigType\n): Promise<PaystackResponseType> => {\n return new Promise(async (resolve) => {\n try {\n // Ensure PaystackPop is available\n if (!window.PaystackPop) {\n throw new Error(\"Paystack script not loaded\");\n }\n\n let handler = await window.PaystackPop.setup({\n ...config,\n callback: (response: PaystackResponseType) => {\n // This happens after the payment is completed successfully\n openToast(\"Payment complete! Reference: \" + response.reference);\n resolve({ ...response, email: config.email, amount: config.amount });\n },\n onClose: () => {\n openToast(\"Transaction was not completed, window closed.\", 400);\n resolve({\n status: \"canceled\",\n cancelled: true,\n reference: config.reference,\n email: config.email,\n amount: config.amount,\n } as PaystackResponseType);\n },\n });\n handler.openIframe();\n } catch (error) {\n console.error(\"Paystack initialization error:\", error);\n openToast(\"Payment could not be initiated\", 400);\n resolve({\n status: \"failed\",\n cancelled: true,\n reference: config.reference,\n error,\n email: config.email,\n amount: config.amount,\n } as PaystackResponseType);\n }\n });\n};\n\n/**\n * Handles the complete payment submission process\n * @example\n * ```ts\n * handlePaymentSubmit({\n * openConfirm: true,\n * defaultConfirm: true,\n * defaultMsg: \"Are you sure you want to enroll for this course?\",\n * label: \"Course Name\",\n * objects: {\n * object_id: \"123\",\n * object_type: \"course\",\n * },\n * configObj: {\n * email: \"user@example.com\",\n * amount: 1000,\n * currency: \"NGN\",\n * authorization_code: \"1234567890\",\n * first_name: \"John\",\n * last_name: \"Doe\",\n * email: \"user@example.com\",\n * },\n * coupon: \"1234567890\",\n * gatwayCharges: 10,\n * paymentMethod: {\n * authorization: {\n * card_type: \"MasterCard\",\n * last4: \"1234\",\n * },\n * },\n * handleDBAction: (data: any) => {\n * console.log(data);\n * },\n * setStatus: (status: number) => {\n * console.log(status);\n * },\n * e: Event,\n * });\n * ```\n * @param contexts - Payment context information\n * @context This function orchestrates the entire payment flow from confirmation to processing\n */\nexport async function handlePaymentSubmit(\n contexts: PaymentContextType\n): Promise<void> {\n if (contexts.e) contexts.e.preventDefault();\n\n if (contexts.openConfirm && contexts.defaultConfirm) {\n let msg = `By clicking okay, you are enrolling for ${contexts.label} with id ${contexts.objects.object_id}.`;\n const confirm = await openConfirmModal(contexts.defaultMsg || msg);\n if (!confirm) return;\n }\n\n const makePayment = async (): Promise<void> => {\n contexts.setStatus(0);\n\n // Check if contexts.coupon is valid\n let coupon_res: CouponType = {\n id: 0,\n code: \"\",\n email_list: \"\",\n object_id: \"\",\n valid_from: \"\",\n valid_to: \"\",\n days_count: 0,\n discount_type: null,\n discount: 0,\n amount: 0,\n currency: \"\",\n active: false,\n timestamp: \"\",\n channel: \"\",\n content_type: 0,\n students: [],\n };\n\n let mewConfigObj: PaystackConfigObjectType;\n\n if (contexts.coupon) {\n const handle = contexts.configObj.metadata?.channel_username;\n const couponObj = JSON.stringify({\n code: contexts.coupon,\n email: contexts.configObj.email,\n content_type: contexts.configObj.content_type,\n object_id: contexts.configObj.object_id,\n });\n\n const requestOptions = reqOptions(\"POST\", couponObj, null, \"json\");\n const url = `${API_HOST_URL}coupons/${handle}/validate-coupon/`;\n\n try {\n const dataset = await fetch(url, requestOptions);\n coupon_res = (await dataset.json()) as CouponType;\n\n if (coupon_res.detail) {\n openToast(coupon_res.detail, 400);\n } else if (coupon_res.id) {\n openToast(\n `${\n coupon_res.discount ||\n `${coupon_res.currency}${coupon_res.amount}`\n }% token was applied.`\n );\n }\n } catch (error) {\n console.error(\"Coupon validation error:\", error);\n openToast(\"Could not validate coupon\", 400);\n }\n }\n\n // Remove the discount from actual amount\n if (coupon_res.discount || coupon_res.amount) {\n if (\n coupon_res.discount === 100 &&\n coupon_res.discount_type === \"percentage\"\n ) {\n const resContext = {\n email: contexts.configObj.email,\n amount: 0,\n status: \"success\",\n reference: `COUPON__${contexts.coupon}__${contexts.configObj.email}`,\n message: \"Payment complete with 100% token coupon\",\n transaction: \"\",\n canceled: false,\n };\n contexts.handleDBAction(resContext);\n contexts.setStatus(1);\n return;\n }\n\n const amount = calculateCouponDeduction(\n contexts.configObj.amount,\n contexts.configObj.currency || \"NGN\",\n coupon_res\n );\n\n if (!amount.discounted) {\n openToast(amount.detail, 400);\n\n // Abort payment due to invalid coupon\n mewConfigObj = contexts.configObj;\n } else {\n openToast(amount.detail);\n mewConfigObj = {\n ...contexts.configObj,\n ...amount,\n };\n }\n } else {\n // No coupon applied\n mewConfigObj = contexts.configObj;\n }\n\n // Add paystack charges\n if (contexts.gatwayCharges) {\n const fee = contexts.gatwayCharges / 100;\n // Calculate the amount to charge so that after the fee deduction, it matches the intended amount\n const totalAmount = mewConfigObj.amount / (1 - fee);\n // Returns the amount rounded to 2 decimal places\n const decimalAmount = parseFloat(totalAmount.toFixed(2));\n\n // Local transactions fees are capped at ₦2000, meaning that's the absolute maximum you'll ever pay in fees per transaction\n const localCharges = decimalAmount - mewConfigObj.amount;\n\n // Only charge 2k if charges exceed threshold\n const noMoreThan2k =\n localCharges > 2000 ? mewConfigObj.amount + 2000 : decimalAmount;\n\n mewConfigObj.amount = noMoreThan2k;\n }\n\n const dataset = paystackDataConfig(mewConfigObj);\n\n if (mewConfigObj.amount) {\n if (mewConfigObj.authorization_code && contexts.paymentMethod) {\n // Ask if user wants to use existing payment method\n const msg = `Would you prefer we charge your existing ${contexts.paymentMethod.authorization.card_type} card that ends with ${contexts.paymentMethod.last4}?`;\n const confirm = await openConfirmModal(msg, true);\n\n if (confirm) {\n // Charge user with existing card\n const res = await chargeAuthorization(dataset);\n contexts.handleDBAction(res);\n } else {\n // Request for user card details\n const payActivate = await payWithPaystack(dataset);\n\n contexts.handleDBAction(payActivate);\n }\n } else {\n // Request for user card details if payment method doesn't exist\n console.log(\"Pay with paystack: \");\n const payActivate = await payWithPaystack(dataset);\n contexts.handleDBAction(payActivate);\n }\n } else {\n // If cohort is free, don't request for payment\n const resContext = {\n email: contexts.configObj.email,\n amount: 0,\n status: \"success\",\n reference: `COUPON__${contexts.coupon}__${contexts.configObj.email}`,\n message: \"No payment required for free item\",\n transaction: \"\",\n canceled: false,\n };\n contexts.handleDBAction(resContext);\n }\n\n contexts.setStatus(1);\n };\n\n // Get user email input if doesn't exist\n const checkEmailInConfig = async (): Promise<void> => {\n if (!contexts.configObj.email) {\n const emailValue = await getUserEmailInputModal(contexts.label);\n if (emailValue) {\n contexts.configObj.email = emailValue;\n setCookie(\"email\", emailValue, 2); // store for signup use\n makePayment();\n } else {\n openToast(\"You need to enter a valid email!\", 400);\n await checkEmailInConfig();\n }\n } else {\n setCookie(\"email\", contexts.configObj.email, 2); // store for signup use\n makePayment();\n }\n };\n\n checkEmailInConfig();\n}\n\n/**\n * Handles payment submission without requiring user data upfront\n * Useful for guest checkout or anonymous payments\n * @example\n * ```ts\n * handlePaymentWithoutUserData({\n * amount: 5000,\n * label: \"Course Enrollment\",\n * currency: \"NGN\",\n * metadata: {\n * content_type: \"course\",\n * object_id: \"123\",\n * },\n * handleDBAction: (data: any) => {\n * console.log(data);\n * },\n * setStatus: (status: number) => {\n * console.log(status);\n * },\n * });\n * ```\n * @param config - Minimal payment configuration without user details\n */\nexport async function handlePaymentWithoutUserData(config: {\n amount: number;\n label: string;\n currency?: string;\n metadata?: PaystackConfigObjectType[\"metadata\"];\n handleDBAction: (data?: any) => void;\n setStatus: (status: number) => void;\n coupon?: string;\n gatwayCharges?: number;\n defaultConfirm?: boolean;\n defaultMsg?: string;\n e?: Event | null;\n content_type?: string | number;\n object_id?: string | number;\n}): Promise<void> {\n if (config.e) config.e.preventDefault();\n\n if (config.defaultConfirm) {\n const msg =\n config.defaultMsg ||\n `By clicking okay, you are proceeding with payment for ${config.label}.`;\n const confirm = await openConfirmModal(msg);\n if (!confirm) return;\n }\n\n config.setStatus(0);\n\n // Always prompt for email input\n const emailValue = await getUserEmailInputModal(config.label);\n\n if (!emailValue) {\n openToast(\"You need to enter a valid email to proceed!\", 400);\n config.setStatus(1);\n return;\n }\n\n // Store email for potential signup\n setCookie(\"email\", emailValue, 2);\n\n // Build minimal config object\n let configObj: PaystackConfigObjectType = {\n email: emailValue,\n first_name: \"Guest\",\n last_name: \"User\",\n amount: config.amount,\n currency: config.currency || \"NGN\",\n metadata: config.metadata,\n content_type: config.content_type,\n object_id: config.object_id,\n };\n\n // Handle coupon validation if provided\n if (config.coupon) {\n const handle = config.metadata?.channel_username;\n const couponObj = JSON.stringify({\n code: config.coupon,\n email: emailValue,\n content_type: config.content_type,\n object_id: config.object_id,\n });\n\n const requestOptions = reqOptions(\"POST\", couponObj, null, \"json\");\n const url = `${API_HOST_URL}coupons/${handle}/validate-coupon/`;\n\n try {\n const dataset = await fetch(url, requestOptions);\n const res = await dataset.json();\n\n const discount = res.discount || 0;\n if (res.detail) {\n openToast(res.detail, 400);\n } else if (res.id) {\n openToast(`${discount}% discount was applied.`);\n }\n\n const _discounted = calculateCouponDeduction(\n configObj.amount,\n configObj.currency || \"NGN\",\n res\n );\n\n // Apply discount\n if (_discounted.discounted) {\n if (discount === 100) {\n const resContext = {\n email: configObj.email,\n amount: 0,\n status: \"success\",\n reference: `COUPON__${config.coupon}__${configObj.email}`,\n message: \"No payment required for free item\",\n transaction: \"\",\n canceled: false,\n };\n config.handleDBAction(resContext);\n config.setStatus(1);\n return;\n }\n\n openToast(_discounted.detail);\n configObj = {\n ...configObj,\n ..._discounted,\n };\n }\n } catch (error) {\n console.error(\"Coupon validation error:\", error);\n openToast(\"Could not validate coupon\", 400);\n }\n }\n\n // Add gateway charges if applicable\n if (config.gatwayCharges) {\n const fee = config.gatwayCharges / 100;\n const totalAmount = configObj.amount / (1 - fee);\n const decimalAmount = parseFloat(totalAmount.toFixed(2));\n const localCharges = decimalAmount - configObj.amount;\n const noMoreThan2k =\n localCharges > 2000 ? configObj.amount + 2000 : decimalAmount;\n configObj.amount = noMoreThan2k;\n }\n\n const dataset = paystackDataConfig(configObj);\n\n if (configObj.amount > 0) {\n // Process payment with Paystack\n const payActivate = await payWithPaystack(dataset);\n config.handleDBAction(payActivate);\n } else {\n // Free item\n const resContext = {\n email: configObj.email,\n amount: 0,\n status: \"success\",\n reference: `COUPON__${config.coupon}__${configObj.email}`,\n message: \"No payment required for free item\",\n transaction: \"\",\n canceled: false,\n };\n config.handleDBAction(resContext);\n }\n\n config.setStatus(1);\n}\n\n// Add PaystackPop to Window interface\ndeclare global {\n interface Window {\n PaystackPop: {\n setup: (config: any) => { openIframe: () => void };\n };\n }\n}\n"],"names":["paystackDataConfig","obj","authorization_code","reference","Date","getTime","toString","email","first_name","last_name","amount","Math","round","currency","publicKey","process","env","NEXT_PUBLIC_PAYSTACK_SECRET_KEY","key","NEXT_PUBLIC_PAYSTACK_PUBLIC_KEY","callback_url","window","location","href","metadata","chargeAuthorization","_ref","_asyncToGenerator","_regenerator","regenerator","m","_callee","data","options","_res$data","req","res","_t","w","_context","p","n","method","body","JSON","stringify","headers","Authorization","concat","fetch","v","json","status","openToast","a","console","error","_x","apply","this","arguments","payWithPaystack","config","Promise","_ref2","_callee2","resolve","_t2","_context2","PaystackPop","Error","setup","_objectSpread","callback","response","objectSpread2","onClose","cancelled","openIframe","_x2","_handlePaymentSubmit","asyncToGenerator","_callee5","contexts","msg","makePayment","_checkEmailInConfig","_context5","e","preventDefault","openConfirm","defaultConfirm","label","objects","object_id","openConfirmModal","defaultMsg","_ref3","_callee3","coupon_res","mewConfigObj","_contexts$configObj$m","handle","couponObj","requestOptions","url","_dataset","resContext","fee","totalAmount","decimalAmount","localCharges","noMoreThan2k","dataset","_msg","payActivate","_payActivate","_resContext","_t3","_context3","setStatus","id","code","email_list","valid_from","valid_to","days_count","discount_type","discount","active","timestamp","channel","content_type","students","coupon","configObj","channel_username","reqOptions","API_HOST_URL","detail","message","transaction","canceled","handleDBAction","calculateCouponDeduction","discounted","gatwayCharges","parseFloat","toFixed","paymentMethod","authorization","card_type","last4","log","checkEmailInConfig","_ref4","_callee4","emailValue","_context4","getUserEmailInputModal","setCookie","_handlePaymentWithoutUserData","_callee6","_config$metadata","_dataset2","_discounted","_resContext2","_t4","_context6","handlePaymentSubmit","_x3","handlePaymentWithoutUserData","_x4"],"mappings":"sMA0CaA,EAAqB,SAChCC,GAA6B,MACL,CACxBC,mBAAoBD,EAAIC,mBACxBC,WAAW,IAAIC,MAAOC,UAAUC,WAChCC,MAAON,EAAIM,MACXC,WAAYP,EAAIO,WAChBC,UAAWR,EAAIQ,UACfC,OAAQC,KAAKC,MAAmB,IAAbX,EAAIS,QACvBG,SAAUZ,EAAIY,UAAY,MAC1BC,UAAWC,QAAQC,IAAIC,gCACvBC,IAAKH,QAAQC,IAAIG,gCACjBC,aAAcC,OAAOC,SAASC,KAC9BC,SAAUvB,EAAIuB,SACf,EAOYC,EAAmB,WAAA,IAAAC,EAAAC,EAAAA,iBAAAC,EAAAC,cAAAC,EAAG,SAAAC,EACjCC,GAAwB,IAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAA,OAAAT,gBAAAU,EAAA,SAAAC,GAAA,cAAAA,EAAAC,EAAAD,EAAAE,GAAA,KAAA,EAWvB,OAPKR,EAAU,CACdS,OAAQ,OACRC,KAAMC,KAAKC,UAAUb,GACrBc,QAAS,CACPC,cAAa,UAAAC,OAAYjC,QAAQC,IAAIC,iCACrC,eAAgB,qBAEnBsB,EAAAC,EAAA,EAAAD,EAAAE,EAAA,EAG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eH,GAVzCS,EAAOoF,gBACHtC,EAAM9C,EAAOoF,cAAgB,IAC7BrC,EAAc0B,EAAU7H,QAAU,EAAIkG,GACtCE,EAAgBqC,WAAWtC,EAAYuC,QAAQ,IAC/CrC,EAAeD,EAAgByB,EAAU7H,OACzCsG,EACJD,EAAe,IAAOwB,EAAU7H,OAAS,IAAOoG,EAClDyB,EAAU7H,OAASsG,GAGfC,EAAUjH,EAAmBuI,KAE/BA,EAAU7H,OAAS,GAAC,CAAA8J,EAAA/H,EAAA,GAAA,KAAA,CAAA,OAAA+H,EAAA/H,EAAA,GAEIoB,EAAgBoD,GAAQ,KAAA,GAA5CE,EAAWqD,EAAAtH,EACjBY,EAAOiF,eAAe5B,GAAaqD,EAAA/H,EAAA,GAAA,MAAA,KAAA,GAG7BkE,EAAa,CACjBpG,MAAOgI,EAAUhI,MACjBG,OAAQ,EACR0C,OAAQ,UACRjD,UAAS6C,WAAAA,OAAac,EAAOwE,OAAMtF,MAAAA,OAAKuF,EAAUhI,OAClDqI,QAAS,oCACTC,YAAa,GACbC,UAAU,GAEZhF,EAAOiF,eAAepC,GAAY,KAAA,GAGpC7C,EAAO0D,UAAU,GAAG,KAAA,GAAA,OAAAgD,EAAAlH,EAAA,GAAA,EAAA4G,EAAA,KAAA,CAAA,CAAA,EAAA,KACrB,KAAAxG,MAAAC,KAAAC,UAAA,2DApWqB6G,SAAmBC,GAAA,OAAA1F,EAAAtB,MAAAC,KAAAC,UAAA,uCAsNnB+G,SAA4BC,GAAA,OAAAX,EAAAvG,MAAAC,KAAAC,UAAA"}
|
|
1
|
+
{"version":3,"file":"paystack.cjs","sources":["../../../../src/components/lib/paystack.ts"],"sourcesContent":["import {\n API_HOST_URL,\n calculateCouponDeduction,\n reqOptions,\n setCookie,\n} from \"./helpFunction\";\nimport {\n getUserEmailInputModal,\n openConfirmModal,\n openToast,\n} from \"./modals/modals\";\nimport {\n PaystackConfigObjectType,\n PaystackConfigType,\n PaystackResponseType,\n PaymentContextType,\n CouponType,\n SavedCardChargeOptionsType,\n} from \"@/types\";\n\n/** Paystack inline v2 script, needed for server-initialised transactions. */\nexport const PAYSTACK_INLINE_V2_URL = \"https://js.paystack.co/v2/inline.js\";\n\n/**\n * Context for processing payments\n * @property {Event | null} [e] - The event object that triggered the payment\n * @property {Object} objects - Details about the item being purchased\n * @property {string} objects.title - Title of the item\n * @property {string | number | null} [objects.object_type] - Model ID of the object being purchased\n * @property {string | number | null} [objects.object_id] - Object ID of the object being purchased\n * @property {PaystackConfigObjectType} configObj - Configuration for PayStack\n * @property {PaymentMethodType} [paymentMethod] - Saved payment method if available\n * @property {Function} setStatus - Function to update UI status during payment process\n * @property {Function} handleDBAction - Callback for processing successful payments\n * @property {boolean} [defaultConfirm] - Whether to show a confirmation dialog\n * @property {string} label - Label for the payment (usually item title)\n * @property {string} [coupon] - Coupon code if applicable\n * @property {string} [defaultMsg] - Custom confirmation message\n * @property {number} [gatwayCharges] - Payment gateway charges percentage\n */\n\n/**\n * Configures the Paystack popup data.\n *\n * Only the PUBLIC key (`NEXT_PUBLIC_PAYSTACK_PUBLIC_KEY`) is ever read here.\n * The secret key must never reach the browser: anything a `NEXT_PUBLIC_*`\n * variable holds is inlined into the shipped JavaScript.\n * @param obj - Object containing payment details\n * @returns PaystackConfig - Configured payment data\n */\nexport const paystackDataConfig = (\n obj: PaystackConfigObjectType\n): PaystackConfigType => ({\n reference: new Date().getTime().toString(),\n email: obj.email,\n first_name: obj.first_name,\n last_name: obj.last_name,\n amount: Math.round(obj.amount * 100), // Amount is in the country's lowest currency. E.g Kobo, so 20000 kobo = N200\n currency: obj.currency || \"NGN\",\n key: process.env.NEXT_PUBLIC_PAYSTACK_PUBLIC_KEY,\n callback_url: window.location.href,\n metadata: obj.metadata,\n});\n\n/**\n * Charges the logged-in user's saved card THROUGH THE APP'S SERVER.\n *\n * The browser never calls Paystack's charge_authorization API and never sends\n * an authorization code or an amount the server trusts. It POSTs only what\n * identifies the purchase (`body`, e.g. the saved payment method id, the item\n * and a coupon code) to `chargeUrl`; the server looks the card up by the\n * logged-in user, prices the item itself and charges it with its own secret\n * key. The server is expected to answer with the Paystack transaction object\n * (`status`, `reference`, `amount`, ...), optionally wrapped in `data`.\n *\n * @example\n * ```ts\n * const res = await chargeAuthorization({\n * chargeUrl: `${API_HOST_URL}payments/${channel}/paystack/charge-saved-card/`,\n * token,\n * body: { payment_method_id: card.id, item_type: \"course\", item_id: course.id },\n * });\n * if (res.status === \"success\") recordPayment(res);\n * ```\n * @param options - Server endpoint, auth token and purchase identifiers\n * @returns Promise with the transaction data (status \"failed\" on error)\n */\nexport const chargeAuthorization = async (\n options: SavedCardChargeOptionsType\n): Promise<any> => {\n if (!options?.chargeUrl) {\n openToast(\"Saved card payments are not available here.\", 400);\n return { status: \"failed\", message: \"chargeUrl is required\" };\n }\n\n const requestOptions = reqOptions(\n \"POST\",\n JSON.stringify(options.body || {}),\n options.token || null,\n \"json\",\n options.channel || null\n );\n\n try {\n const req = await fetch(options.chargeUrl, requestOptions);\n const res = await req.json().catch(() => ({}));\n const data = res?.data && typeof res.data === \"object\" ? res.data : res;\n\n if (req.ok && data?.status === \"success\") {\n openToast(`Payment was successful with reference: ${data.reference}`);\n return data;\n }\n\n const message =\n res?.detail ||\n data?.gateway_response ||\n data?.message ||\n \"Payment could not be completed with the saved card\";\n openToast(message, 400);\n return { ...data, status: data?.status || \"failed\", message };\n } catch (error) {\n openToast(\"Payment processing error occurred\", 400);\n console.error(\"Saved card charge error:\", error);\n return { status: \"failed\", error };\n }\n};\n\n/**\n * Opens the Paystack popup for a transaction the app's SERVER initialised\n * (POST /transaction/initialize with the secret key), so amount, email and\n * metadata are fixed server-side and cannot be changed in the browser.\n *\n * Uses Paystack inline v2 (`resumeTransaction`). The v2 script is loaded on\n * demand when it is not already on the page.\n * @param accessCode - `access_code` returned by the server's initialize call\n * @returns Promise with the payment response (`status: \"canceled\"` on close)\n */\nexport const payWithAccessCode = (\n accessCode: string\n): Promise<PaystackResponseType> => {\n const empty = { email: \"\", amount: 0 };\n\n const loadV2 = (): Promise<any> =>\n new Promise((resolve, reject) => {\n const existing = (window as any).PaystackPop;\n if (existing && typeof existing === \"function\") {\n return resolve(existing);\n }\n const script = document.createElement(\"script\");\n script.src = PAYSTACK_INLINE_V2_URL;\n script.async = true;\n script.onload = () => resolve((window as any).PaystackPop);\n script.onerror = () => reject(new Error(\"Paystack script failed to load\"));\n document.body.appendChild(script);\n });\n\n return new Promise(async (resolve) => {\n try {\n if (!accessCode) throw new Error(\"accessCode is required\");\n const Pop = await loadV2();\n const popup = new Pop();\n popup.resumeTransaction(accessCode, {\n onSuccess: (response: PaystackResponseType) => {\n openToast(\"Payment complete! Reference: \" + response.reference);\n resolve({ ...empty, ...response, status: response.status || \"success\" });\n },\n onCancel: () => {\n openToast(\"Transaction was not completed, window closed.\", 400);\n resolve({\n ...empty,\n status: \"canceled\",\n cancelled: true,\n reference: \"\",\n } as PaystackResponseType);\n },\n onError: (error: any) => {\n openToast(error?.message || \"Payment could not be initiated\", 400);\n resolve({ ...empty, status: \"failed\", reference: \"\", error });\n },\n });\n } catch (error) {\n console.error(\"Paystack access code error:\", error);\n openToast(\"Payment could not be initiated\", 400);\n resolve({ ...empty, status: \"failed\", reference: \"\", error });\n }\n });\n};\n\n/**\n * Initiates payment with Paystack popup\n * @param config - Payment configuration\n * @returns Promise with payment response\n */\nexport const payWithPaystack = (\n config: PaystackConfigType\n): Promise<PaystackResponseType> => {\n return new Promise(async (resolve) => {\n try {\n // Ensure PaystackPop is available\n if (!window.PaystackPop) {\n throw new Error(\"Paystack script not loaded\");\n }\n\n let handler = await window.PaystackPop.setup({\n ...config,\n callback: (response: PaystackResponseType) => {\n // This happens after the payment is completed successfully\n openToast(\"Payment complete! Reference: \" + response.reference);\n resolve({ ...response, email: config.email, amount: config.amount });\n },\n onClose: () => {\n openToast(\"Transaction was not completed, window closed.\", 400);\n resolve({\n status: \"canceled\",\n cancelled: true,\n reference: config.reference,\n email: config.email,\n amount: config.amount,\n } as PaystackResponseType);\n },\n });\n handler.openIframe();\n } catch (error) {\n console.error(\"Paystack initialization error:\", error);\n openToast(\"Payment could not be initiated\", 400);\n resolve({\n status: \"failed\",\n cancelled: true,\n reference: config.reference,\n error,\n email: config.email,\n amount: config.amount,\n } as PaystackResponseType);\n }\n });\n};\n\n/**\n * Handles the complete payment submission process\n * @example\n * ```ts\n * handlePaymentSubmit({\n * openConfirm: true,\n * defaultConfirm: true,\n * defaultMsg: \"Are you sure you want to enroll for this course?\",\n * label: \"Course Name\",\n * objects: {\n * object_id: \"123\",\n * object_type: \"course\",\n * },\n * configObj: {\n * email: \"user@example.com\",\n * amount: 1000,\n * currency: \"NGN\",\n * first_name: \"John\",\n * last_name: \"Doe\",\n * email: \"user@example.com\",\n * },\n * coupon: \"1234567890\",\n * gatwayCharges: 10,\n * paymentMethod: savedCard, // from user-payment-method-list\n * // Saved cards are charged by YOUR server, never from the browser.\n * // Without savedCardCharge the user always gets the Paystack popup.\n * savedCardCharge: {\n * chargeUrl: `${API_HOST_URL}payments/${channel}/paystack/charge-saved-card/`,\n * token,\n * body: { item_type: \"course\", item_id: \"123\" },\n * },\n * handleDBAction: (data: any) => {\n * console.log(data);\n * },\n * setStatus: (status: number) => {\n * console.log(status);\n * },\n * e: Event,\n * });\n * ```\n * @param contexts - Payment context information\n * @context This function orchestrates the entire payment flow from confirmation to processing\n */\nexport async function handlePaymentSubmit(\n contexts: PaymentContextType\n): Promise<void> {\n if (contexts.e) contexts.e.preventDefault();\n\n if (contexts.openConfirm && contexts.defaultConfirm) {\n let msg = `By clicking okay, you are enrolling for ${contexts.label} with id ${contexts.objects.object_id}.`;\n const confirm = await openConfirmModal(contexts.defaultMsg || msg);\n if (!confirm) return;\n }\n\n const makePayment = async (): Promise<void> => {\n contexts.setStatus(0);\n\n // Check if contexts.coupon is valid\n let coupon_res: CouponType = {\n id: 0,\n code: \"\",\n email_list: \"\",\n object_id: \"\",\n valid_from: \"\",\n valid_to: \"\",\n days_count: 0,\n discount_type: null,\n discount: 0,\n amount: 0,\n currency: \"\",\n active: false,\n timestamp: \"\",\n channel: \"\",\n content_type: 0,\n students: [],\n };\n\n let mewConfigObj: PaystackConfigObjectType;\n\n if (contexts.coupon) {\n const handle = contexts.configObj.metadata?.channel_username;\n const couponObj = JSON.stringify({\n code: contexts.coupon,\n email: contexts.configObj.email,\n content_type: contexts.configObj.content_type,\n object_id: contexts.configObj.object_id,\n });\n\n const requestOptions = reqOptions(\"POST\", couponObj, null, \"json\");\n const url = `${API_HOST_URL}coupons/${handle}/validate-coupon/`;\n\n try {\n const dataset = await fetch(url, requestOptions);\n coupon_res = (await dataset.json()) as CouponType;\n\n if (coupon_res.detail) {\n openToast(coupon_res.detail, 400);\n } else if (coupon_res.id) {\n openToast(\n `${\n coupon_res.discount ||\n `${coupon_res.currency}${coupon_res.amount}`\n }% token was applied.`\n );\n }\n } catch (error) {\n console.error(\"Coupon validation error:\", error);\n openToast(\"Could not validate coupon\", 400);\n }\n }\n\n // Remove the discount from actual amount\n if (coupon_res.discount || coupon_res.amount) {\n if (\n coupon_res.discount === 100 &&\n coupon_res.discount_type === \"percentage\"\n ) {\n const resContext = {\n email: contexts.configObj.email,\n amount: 0,\n status: \"success\",\n reference: `COUPON__${contexts.coupon}__${contexts.configObj.email}`,\n message: \"Payment complete with 100% token coupon\",\n transaction: \"\",\n canceled: false,\n };\n contexts.handleDBAction(resContext);\n contexts.setStatus(1);\n return;\n }\n\n const amount = calculateCouponDeduction(\n contexts.configObj.amount,\n contexts.configObj.currency || \"NGN\",\n coupon_res\n );\n\n if (!amount.discounted) {\n openToast(amount.detail, 400);\n\n // Abort payment due to invalid coupon\n mewConfigObj = contexts.configObj;\n } else {\n openToast(amount.detail);\n mewConfigObj = {\n ...contexts.configObj,\n ...amount,\n };\n }\n } else {\n // No coupon applied\n mewConfigObj = contexts.configObj;\n }\n\n // Add paystack charges\n if (contexts.gatwayCharges) {\n const fee = contexts.gatwayCharges / 100;\n // Calculate the amount to charge so that after the fee deduction, it matches the intended amount\n const totalAmount = mewConfigObj.amount / (1 - fee);\n // Returns the amount rounded to 2 decimal places\n const decimalAmount = parseFloat(totalAmount.toFixed(2));\n\n // Local transactions fees are capped at ₦2000, meaning that's the absolute maximum you'll ever pay in fees per transaction\n const localCharges = decimalAmount - mewConfigObj.amount;\n\n // Only charge 2k if charges exceed threshold\n const noMoreThan2k =\n localCharges > 2000 ? mewConfigObj.amount + 2000 : decimalAmount;\n\n mewConfigObj.amount = noMoreThan2k;\n }\n\n const dataset = paystackDataConfig(mewConfigObj);\n\n if (mewConfigObj.amount) {\n if (contexts.paymentMethod && contexts.savedCardCharge?.chargeUrl) {\n // Ask if user wants to use existing payment method\n const msg = `Would you prefer we charge your existing ${contexts.paymentMethod.authorization?.card_type || \"\"} card that ends with ${contexts.paymentMethod.last4}?`;\n const confirm = await openConfirmModal(msg, true);\n\n if (confirm) {\n // Charge the saved card on the server: it prices the item itself.\n const res = await chargeAuthorization({\n ...contexts.savedCardCharge,\n body: {\n payment_method_id: contexts.paymentMethod.id,\n coupon: contexts.coupon || null,\n content_type: contexts.configObj.content_type ?? null,\n object_id: contexts.configObj.object_id ?? null,\n metadata: dataset.metadata || {},\n ...(contexts.savedCardCharge.body || {}),\n },\n });\n contexts.handleDBAction(res);\n } else {\n // Request for user card details\n const payActivate = await payWithPaystack(dataset);\n\n contexts.handleDBAction(payActivate);\n }\n } else {\n // Request for user card details if payment method doesn't exist\n console.log(\"Pay with paystack: \");\n const payActivate = await payWithPaystack(dataset);\n contexts.handleDBAction(payActivate);\n }\n } else {\n // If cohort is free, don't request for payment\n const resContext = {\n email: contexts.configObj.email,\n amount: 0,\n status: \"success\",\n reference: `COUPON__${contexts.coupon}__${contexts.configObj.email}`,\n message: \"No payment required for free item\",\n transaction: \"\",\n canceled: false,\n };\n contexts.handleDBAction(resContext);\n }\n\n contexts.setStatus(1);\n };\n\n // Get user email input if doesn't exist\n const checkEmailInConfig = async (): Promise<void> => {\n if (!contexts.configObj.email) {\n const emailValue = await getUserEmailInputModal(contexts.label);\n if (emailValue) {\n contexts.configObj.email = emailValue;\n setCookie(\"email\", emailValue, 2); // store for signup use\n makePayment();\n } else {\n openToast(\"You need to enter a valid email!\", 400);\n await checkEmailInConfig();\n }\n } else {\n setCookie(\"email\", contexts.configObj.email, 2); // store for signup use\n makePayment();\n }\n };\n\n checkEmailInConfig();\n}\n\n/**\n * Handles payment submission without requiring user data upfront\n * Useful for guest checkout or anonymous payments\n * @example\n * ```ts\n * handlePaymentWithoutUserData({\n * amount: 5000,\n * label: \"Course Enrollment\",\n * currency: \"NGN\",\n * metadata: {\n * content_type: \"course\",\n * object_id: \"123\",\n * },\n * handleDBAction: (data: any) => {\n * console.log(data);\n * },\n * setStatus: (status: number) => {\n * console.log(status);\n * },\n * });\n * ```\n * @param config - Minimal payment configuration without user details\n */\nexport async function handlePaymentWithoutUserData(config: {\n amount: number;\n label: string;\n currency?: string;\n metadata?: PaystackConfigObjectType[\"metadata\"];\n handleDBAction: (data?: any) => void;\n setStatus: (status: number) => void;\n coupon?: string;\n gatwayCharges?: number;\n defaultConfirm?: boolean;\n defaultMsg?: string;\n e?: Event | null;\n content_type?: string | number;\n object_id?: string | number;\n}): Promise<void> {\n if (config.e) config.e.preventDefault();\n\n if (config.defaultConfirm) {\n const msg =\n config.defaultMsg ||\n `By clicking okay, you are proceeding with payment for ${config.label}.`;\n const confirm = await openConfirmModal(msg);\n if (!confirm) return;\n }\n\n config.setStatus(0);\n\n // Always prompt for email input\n const emailValue = await getUserEmailInputModal(config.label);\n\n if (!emailValue) {\n openToast(\"You need to enter a valid email to proceed!\", 400);\n config.setStatus(1);\n return;\n }\n\n // Store email for potential signup\n setCookie(\"email\", emailValue, 2);\n\n // Build minimal config object\n let configObj: PaystackConfigObjectType = {\n email: emailValue,\n first_name: \"Guest\",\n last_name: \"User\",\n amount: config.amount,\n currency: config.currency || \"NGN\",\n metadata: config.metadata,\n content_type: config.content_type,\n object_id: config.object_id,\n };\n\n // Handle coupon validation if provided\n if (config.coupon) {\n const handle = config.metadata?.channel_username;\n const couponObj = JSON.stringify({\n code: config.coupon,\n email: emailValue,\n content_type: config.content_type,\n object_id: config.object_id,\n });\n\n const requestOptions = reqOptions(\"POST\", couponObj, null, \"json\");\n const url = `${API_HOST_URL}coupons/${handle}/validate-coupon/`;\n\n try {\n const dataset = await fetch(url, requestOptions);\n const res = await dataset.json();\n\n const discount = res.discount || 0;\n if (res.detail) {\n openToast(res.detail, 400);\n } else if (res.id) {\n openToast(`${discount}% discount was applied.`);\n }\n\n const _discounted = calculateCouponDeduction(\n configObj.amount,\n configObj.currency || \"NGN\",\n res\n );\n\n // Apply discount\n if (_discounted.discounted) {\n if (discount === 100) {\n const resContext = {\n email: configObj.email,\n amount: 0,\n status: \"success\",\n reference: `COUPON__${config.coupon}__${configObj.email}`,\n message: \"No payment required for free item\",\n transaction: \"\",\n canceled: false,\n };\n config.handleDBAction(resContext);\n config.setStatus(1);\n return;\n }\n\n openToast(_discounted.detail);\n configObj = {\n ...configObj,\n ..._discounted,\n };\n }\n } catch (error) {\n console.error(\"Coupon validation error:\", error);\n openToast(\"Could not validate coupon\", 400);\n }\n }\n\n // Add gateway charges if applicable\n if (config.gatwayCharges) {\n const fee = config.gatwayCharges / 100;\n const totalAmount = configObj.amount / (1 - fee);\n const decimalAmount = parseFloat(totalAmount.toFixed(2));\n const localCharges = decimalAmount - configObj.amount;\n const noMoreThan2k =\n localCharges > 2000 ? configObj.amount + 2000 : decimalAmount;\n configObj.amount = noMoreThan2k;\n }\n\n const dataset = paystackDataConfig(configObj);\n\n if (configObj.amount > 0) {\n // Process payment with Paystack\n const payActivate = await payWithPaystack(dataset);\n config.handleDBAction(payActivate);\n } else {\n // Free item\n const resContext = {\n email: configObj.email,\n amount: 0,\n status: \"success\",\n reference: `COUPON__${config.coupon}__${configObj.email}`,\n message: \"No payment required for free item\",\n transaction: \"\",\n canceled: false,\n };\n config.handleDBAction(resContext);\n }\n\n config.setStatus(1);\n}\n\n// Add PaystackPop to Window interface\ndeclare global {\n interface Window {\n PaystackPop: {\n setup: (config: any) => { openIframe: () => void };\n };\n }\n}\n"],"names":["PAYSTACK_INLINE_V2_URL","paystackDataConfig","obj","reference","Date","getTime","toString","email","first_name","last_name","amount","Math","round","currency","key","process","env","NEXT_PUBLIC_PAYSTACK_PUBLIC_KEY","callback_url","window","location","href","metadata","chargeAuthorization","_ref","_asyncToGenerator","_regenerator","regenerator","m","_callee","options","requestOptions","req","res","data","message","_t","w","_context","p","n","chargeUrl","openToast","a","status","reqOptions","JSON","stringify","body","token","channel","fetch","v","json","_typeof","ok","concat","detail","gateway_response","_objectSpread","console","error","_x","apply","this","arguments","payWithPaystack","config","Promise","_ref3","_callee3","resolve","_t3","_context3","PaystackPop","Error","setup","callback","response","objectSpread2","onClose","cancelled","openIframe","_x3","_handlePaymentSubmit","asyncToGenerator","_callee6","contexts","msg","makePayment","_checkEmailInConfig","_context6","e","preventDefault","openConfirm","defaultConfirm","label","objects","object_id","openConfirmModal","defaultMsg","_ref4","_callee4","coupon_res","mewConfigObj","_contexts$configObj$m","handle","couponObj","url","_dataset","resContext","fee","totalAmount","decimalAmount","localCharges","noMoreThan2k","dataset","_contexts$savedCardCh","_contexts$paymentMeth","_msg","_contexts$configObj$c","_contexts$configObj$o","payActivate","_payActivate","_resContext","_t4","_context4","setStatus","id","code","email_list","valid_from","valid_to","days_count","discount_type","discount","active","timestamp","content_type","students","coupon","configObj","channel_username","API_HOST_URL","transaction","canceled","handleDBAction","calculateCouponDeduction","discounted","gatwayCharges","parseFloat","toFixed","paymentMethod","savedCardCharge","authorization","card_type","last4","payment_method_id","log","checkEmailInConfig","_ref5","_callee5","emailValue","_context5","getUserEmailInputModal","setCookie","_handlePaymentWithoutUserData","_callee7","_config$metadata","_dataset2","_discounted","_resContext2","_t5","_context7","handlePaymentSubmit","_x4","handlePaymentWithoutUserData","_x5","accessCode","empty","loadV2","reject","existing","script","document","createElement","src","async","onload","onerror","appendChild","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SAACvH,GACVpC,EAAAA,UAAU,gCAAkCoC,EAAS3E,WACrDoE,EAAOZ,EAAAA,cAAAA,EAAAA,cAAAA,EAAAoB,cAAA,CAAA,EAAMoG,GAAUrG,GAAQ,GAAA,CAAElC,OAAQkC,EAASlC,QAAU,YAC7D,EACD0J,SAAU,WACR5J,YAAU,gDAAiD,KAC3D6B,EAAOZ,EAAAoB,cAAApB,EAAAoB,iBACFoG,GAAK,CAAA,EAAA,CACRvI,OAAQ,WACRqC,WAAW,EACX9E,UAAW,KAEd,EACDoM,QAAS,SAAC1I,GACRnB,EAAAA,WAAUmB,aAAK,EAALA,EAAO1B,UAAW,iCAAkC,KAC9DoC,EAAOZ,EAAAoB,cAAApB,EAAAoB,iBAAMoG,GAAK,CAAA,EAAA,CAAEvI,OAAQ,SAAUzC,UAAW,GAAI0D,MAAAA,IACvD,IACCsI,EAAA3J,EAAA,EAAA,MAAA,KAAA,EAAA2J,EAAA5J,EAAA,EAAA2J,EAAAC,EAAA/I,EAEHQ,QAAQC,MAAM,8BAA6BqI,GAC3CxJ,YAAU,iCAAkC,KAC5C6B,EAAOZ,EAAAoB,cAAApB,EAAAoB,iBAAMoG,GAAK,CAAA,EAAA,CAAEvI,OAAQ,SAAUzC,UAAW,GAAI0D,MAAKqI,KAAI,KAAA,EAAA,OAAAC,EAAAxJ,EAAA,GAAA,EAAAqJ,EAAA,KAAA,CAAA,CAAA,EAAA,IAEjE,IAAA,OAAA,SAAAQ,GAAA,OAAAT,EAAAhI,MAAAC,KAAAC,UAAA,CAAC,CA7BgB,GA8BpB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{asyncToGenerator as e,regenerator as n,objectSpread2 as a}from"../../../_virtual/_rollupPluginBabelHelpers.js";import{calculateCouponDeduction as t,setCookie as o,reqOptions as c,API_HOST_URL as r}from"./helpFunction.js";import{openConfirmModal as i,openToast as s,getUserEmailInputModal as u}from"./modals/modals.js";var l=function(e){return{authorization_code:e.authorization_code,reference:(new Date).getTime().toString(),email:e.email,first_name:e.first_name,last_name:e.last_name,amount:Math.round(100*e.amount),currency:e.currency||"NGN",publicKey:process.env.NEXT_PUBLIC_PAYSTACK_SECRET_KEY,key:process.env.NEXT_PUBLIC_PAYSTACK_PUBLIC_KEY,callback_url:window.location.href,metadata:e.metadata}},d=function(){var a=e(n().m(function e(a){var t,o,c,r,i;return n().w(function(e){for(;;)switch(e.p=e.n){case 0:return t={method:"POST",body:JSON.stringify(a),headers:{Authorization:"Bearer ".concat(process.env.NEXT_PUBLIC_PAYSTACK_SECRET_KEY),"Content-Type":"application/json"}},e.p=1,e.n=2,fetch("https://api.paystack.co/transaction/charge_authorization",t);case 2:return c=e.v,e.n=3,c.json();case 3:return r=e.v,"success"===(null===(o=r.data)||void 0===o?void 0:o.status)?s("Payment was successful with reference: ".concat(r.data.reference)):s("Payment failed with reference: ".concat(r.data.reference),400),e.a(2,r.data);case 4:return e.p=4,i=e.v,s("Payment processing error occurred",400),console.error("Payment authorization error:",i),e.a(2,{status:"failed",error:i})}},e,null,[[1,4]])}));return function(e){return a.apply(this,arguments)}}(),m=function(t){return new Promise(function(){var o=e(n().m(function e(o){var c;return n().w(function(e){for(;;)switch(e.p=e.n){case 0:if(e.p=0,window.PaystackPop){e.n=1;break}throw new Error("Paystack script not loaded");case 1:return e.n=2,window.PaystackPop.setup(a(a({},t),{},{callback:function(e){s("Payment complete! Reference: "+e.reference),o(a(a({},e),{},{email:t.email,amount:t.amount}))},onClose:function(){s("Transaction was not completed, window closed.",400),o({status:"canceled",cancelled:!0,reference:t.reference,email:t.email,amount:t.amount})}}));case 2:e.v.openIframe(),e.n=4;break;case 3:e.p=3,c=e.v,console.error("Paystack initialization error:",c),s("Payment could not be initiated",400),o({status:"failed",cancelled:!0,reference:t.reference,error:c,email:t.email,amount:t.amount});case 4:return e.a(2)}},e,null,[[0,3]])}));return function(e){return o.apply(this,arguments)}}())};function f(e){return p.apply(this,arguments)}function p(){return p=e(n().m(function f(p){var y,_,b;return n().w(function(f){for(;;)switch(f.n){case 0:if(p.e&&p.e.preventDefault(),!p.openConfirm||!p.defaultConfirm){f.n=2;break}return y="By clicking okay, you are enrolling for ".concat(p.label," with id ").concat(p.objects.object_id,"."),f.n=1,i(p.defaultMsg||y);case 1:if(f.v){f.n=2;break}return f.a(2);case 2:_=function(){var o=e(n().m(function e(){var o,u,f,y,_,b,h,v,g,k,w,j,O,P,C,N,S,B,A,T,D,E;return n().w(function(e){for(;;)switch(e.p=e.n){case 0:if(p.setStatus(0),o={id:0,code:"",email_list:"",object_id:"",valid_from:"",valid_to:"",days_count:0,discount_type:null,discount:0,amount:0,currency:"",active:!1,timestamp:"",channel:"",content_type:0,students:[]},!p.coupon){e.n=5;break}return y=null===(f=p.configObj.metadata)||void 0===f?void 0:f.channel_username,_=JSON.stringify({code:p.coupon,email:p.configObj.email,content_type:p.configObj.content_type,object_id:p.configObj.object_id}),b=c("POST",_,null,"json"),h="".concat(r,"coupons/").concat(y,"/validate-coupon/"),e.p=1,e.n=2,fetch(h,b);case 2:return v=e.v,e.n=3,v.json();case 3:(o=e.v).detail?s(o.detail,400):o.id&&s("".concat(o.discount||"".concat(o.currency).concat(o.amount),"% token was applied.")),e.n=5;break;case 4:e.p=4,E=e.v,console.error("Coupon validation error:",E),s("Could not validate coupon",400);case 5:if(!o.discount&&!o.amount){e.n=7;break}if(100!==o.discount||"percentage"!==o.discount_type){e.n=6;break}return g={email:p.configObj.email,amount:0,status:"success",reference:"COUPON__".concat(p.coupon,"__").concat(p.configObj.email),message:"Payment complete with 100% token coupon",transaction:"",canceled:!1},p.handleDBAction(g),p.setStatus(1),e.a(2);case 6:(k=t(p.configObj.amount,p.configObj.currency||"NGN",o)).discounted?(s(k.detail),u=a(a({},p.configObj),k)):(s(k.detail,400),u=p.configObj),e.n=8;break;case 7:u=p.configObj;case 8:if(p.gatwayCharges&&(w=p.gatwayCharges/100,j=u.amount/(1-w),O=parseFloat(j.toFixed(2)),P=O-u.amount,C=P>2e3?u.amount+2e3:O,u.amount=C),N=l(u),!u.amount){e.n=17;break}if(!u.authorization_code||!p.paymentMethod){e.n=14;break}return S="Would you prefer we charge your existing ".concat(p.paymentMethod.authorization.card_type," card that ends with ").concat(p.paymentMethod.last4,"?"),e.n=9,i(S,!0);case 9:if(!e.v){e.n=11;break}return e.n=10,d(N);case 10:B=e.v,p.handleDBAction(B),e.n=13;break;case 11:return e.n=12,m(N);case 12:A=e.v,p.handleDBAction(A);case 13:e.n=16;break;case 14:return console.log("Pay with paystack: "),e.n=15,m(N);case 15:T=e.v,p.handleDBAction(T);case 16:e.n=18;break;case 17:D={email:p.configObj.email,amount:0,status:"success",reference:"COUPON__".concat(p.coupon,"__").concat(p.configObj.email),message:"No payment required for free item",transaction:"",canceled:!1},p.handleDBAction(D);case 18:p.setStatus(1);case 19:return e.a(2)}},e,null,[[1,4]])}));return function(){return o.apply(this,arguments)}}(),b=function(){var a=e(n().m(function e(){var a;return n().w(function(e){for(;;)switch(e.n){case 0:if(p.configObj.email){e.n=4;break}return e.n=1,u(p.label);case 1:if(!(a=e.v)){e.n=2;break}p.configObj.email=a,o("email",a,2),_(),e.n=3;break;case 2:return s("You need to enter a valid email!",400),e.n=3,b();case 3:e.n=5;break;case 4:o("email",p.configObj.email,2),_();case 5:return e.a(2)}},e)}));return function(){return a.apply(this,arguments)}}(),b();case 3:return f.a(2)}},f)})),p.apply(this,arguments)}function y(e){return _.apply(this,arguments)}function _(){return(_=e(n().m(function e(d){var f,p,y,_,b,h,v,g,k,w,j,O,P,C,N,S,B,A,T,D,E,U;return n().w(function(e){for(;;)switch(e.p=e.n){case 0:if(d.e&&d.e.preventDefault(),!d.defaultConfirm){e.n=2;break}return f=d.defaultMsg||"By clicking okay, you are proceeding with payment for ".concat(d.label,"."),e.n=1,i(f);case 1:if(e.v){e.n=2;break}return e.a(2);case 2:return d.setStatus(0),e.n=3,u(d.label);case 3:if(p=e.v){e.n=4;break}return s("You need to enter a valid email to proceed!",400),d.setStatus(1),e.a(2);case 4:if(o("email",p,2),y={email:p,first_name:"Guest",last_name:"User",amount:d.amount,currency:d.currency||"NGN",metadata:d.metadata,content_type:d.content_type,object_id:d.object_id},!d.coupon){e.n=11;break}return b=null===(_=d.metadata)||void 0===_?void 0:_.channel_username,h=JSON.stringify({code:d.coupon,email:p,content_type:d.content_type,object_id:d.object_id}),v=c("POST",h,null,"json"),g="".concat(r,"coupons/").concat(b,"/validate-coupon/"),e.p=5,e.n=6,fetch(g,v);case 6:return k=e.v,e.n=7,k.json();case 7:if(w=e.v,j=w.discount||0,w.detail?s(w.detail,400):w.id&&s("".concat(j,"% discount was applied.")),!(O=t(y.amount,y.currency||"NGN",w)).discounted){e.n=9;break}if(100!==j){e.n=8;break}return P={email:y.email,amount:0,status:"success",reference:"COUPON__".concat(d.coupon,"__").concat(y.email),message:"No payment required for free item",transaction:"",canceled:!1},d.handleDBAction(P),d.setStatus(1),e.a(2);case 8:s(O.detail),y=a(a({},y),O);case 9:e.n=11;break;case 10:e.p=10,U=e.v,console.error("Coupon validation error:",U),s("Could not validate coupon",400);case 11:if(d.gatwayCharges&&(C=d.gatwayCharges/100,N=y.amount/(1-C),S=parseFloat(N.toFixed(2)),B=S-y.amount,A=B>2e3?y.amount+2e3:S,y.amount=A),T=l(y),!(y.amount>0)){e.n=13;break}return e.n=12,m(T);case 12:D=e.v,d.handleDBAction(D),e.n=14;break;case 13:E={email:y.email,amount:0,status:"success",reference:"COUPON__".concat(d.coupon,"__").concat(y.email),message:"No payment required for free item",transaction:"",canceled:!1},d.handleDBAction(E);case 14:d.setStatus(1);case 15:return e.a(2)}},e,null,[[5,10]])}))).apply(this,arguments)}export{d as chargeAuthorization,f as handlePaymentSubmit,y as handlePaymentWithoutUserData,m as payWithPaystack,l as paystackDataConfig};
|
|
1
|
+
import{asyncToGenerator as e,regenerator as n,objectSpread2 as a,typeof as t}from"../../../_virtual/_rollupPluginBabelHelpers.js";import{calculateCouponDeduction as r,setCookie as o,reqOptions as c,API_HOST_URL as i}from"./helpFunction.js";import{openConfirmModal as s,openToast as u,getUserEmailInputModal as l}from"./modals/modals.js";var d="https://js.paystack.co/v2/inline.js",f=function(e){return{reference:(new Date).getTime().toString(),email:e.email,first_name:e.first_name,last_name:e.last_name,amount:Math.round(100*e.amount),currency:e.currency||"NGN",key:process.env.NEXT_PUBLIC_PAYSTACK_PUBLIC_KEY,callback_url:window.location.href,metadata:e.metadata}},m=function(){var r=e(n().m(function e(r){var o,i,s,l,d,f;return n().w(function(e){for(;;)switch(e.p=e.n){case 0:if(null!=r&&r.chargeUrl){e.n=1;break}return u("Saved card payments are not available here.",400),e.a(2,{status:"failed",message:"chargeUrl is required"});case 1:return o=c("POST",JSON.stringify(r.body||{}),r.token||null,"json",r.channel||null),e.p=2,e.n=3,fetch(r.chargeUrl,o);case 3:return i=e.v,e.n=4,i.json().catch(function(){return{}});case 4:if(s=e.v,l=null!=s&&s.data&&"object"===t(s.data)?s.data:s,!i.ok||"success"!==(null==l?void 0:l.status)){e.n=5;break}return u("Payment was successful with reference: ".concat(l.reference)),e.a(2,l);case 5:return d=(null==s?void 0:s.detail)||(null==l?void 0:l.gateway_response)||(null==l?void 0:l.message)||"Payment could not be completed with the saved card",u(d,400),e.a(2,a(a({},l),{},{status:(null==l?void 0:l.status)||"failed",message:d}));case 6:return e.p=6,f=e.v,u("Payment processing error occurred",400),console.error("Saved card charge error:",f),e.a(2,{status:"failed",error:f})}},e,null,[[2,6]])}));return function(e){return r.apply(this,arguments)}}(),p=function(t){var r={email:"",amount:0},o=function(){return new Promise(function(e,n){var a=window.PaystackPop;if(a&&"function"==typeof a)return e(a);var t=document.createElement("script");t.src=d,t.async=!0,t.onload=function(){return e(window.PaystackPop)},t.onerror=function(){return n(new Error("Paystack script failed to load"))},document.body.appendChild(t)})};return new Promise(function(){var c=e(n().m(function e(c){var i,s;return n().w(function(e){for(;;)switch(e.p=e.n){case 0:if(e.p=0,t){e.n=1;break}throw new Error("accessCode is required");case 1:return e.n=2,o();case 2:i=e.v,(new i).resumeTransaction(t,{onSuccess:function(e){u("Payment complete! Reference: "+e.reference),c(a(a(a({},r),e),{},{status:e.status||"success"}))},onCancel:function(){u("Transaction was not completed, window closed.",400),c(a(a({},r),{},{status:"canceled",cancelled:!0,reference:""}))},onError:function(e){u((null==e?void 0:e.message)||"Payment could not be initiated",400),c(a(a({},r),{},{status:"failed",reference:"",error:e}))}}),e.n=4;break;case 3:e.p=3,s=e.v,console.error("Paystack access code error:",s),u("Payment could not be initiated",400),c(a(a({},r),{},{status:"failed",reference:"",error:s}));case 4:return e.a(2)}},e,null,[[0,3]])}));return function(e){return c.apply(this,arguments)}}())},y=function(t){return new Promise(function(){var r=e(n().m(function e(r){var o;return n().w(function(e){for(;;)switch(e.p=e.n){case 0:if(e.p=0,window.PaystackPop){e.n=1;break}throw new Error("Paystack script not loaded");case 1:return e.n=2,window.PaystackPop.setup(a(a({},t),{},{callback:function(e){u("Payment complete! Reference: "+e.reference),r(a(a({},e),{},{email:t.email,amount:t.amount}))},onClose:function(){u("Transaction was not completed, window closed.",400),r({status:"canceled",cancelled:!0,reference:t.reference,email:t.email,amount:t.amount})}}));case 2:e.v.openIframe(),e.n=4;break;case 3:e.p=3,o=e.v,console.error("Paystack initialization error:",o),u("Payment could not be initiated",400),r({status:"failed",cancelled:!0,reference:t.reference,error:o,email:t.email,amount:t.amount});case 4:return e.a(2)}},e,null,[[0,3]])}));return function(e){return r.apply(this,arguments)}}())};function b(e){return v.apply(this,arguments)}function v(){return v=e(n().m(function t(d){var p,b,v;return n().w(function(t){for(;;)switch(t.n){case 0:if(d.e&&d.e.preventDefault(),!d.openConfirm||!d.defaultConfirm){t.n=2;break}return p="By clicking okay, you are enrolling for ".concat(d.label," with id ").concat(d.objects.object_id,"."),t.n=1,s(d.defaultMsg||p);case 1:if(t.v){t.n=2;break}return t.a(2);case 2:b=function(){var t=e(n().m(function e(){var t,o,l,p,b,v,h,g,_,w,k,j,P,O,C,N,S,B,D,U,A,T,E,M,G,q;return n().w(function(e){for(;;)switch(e.p=e.n){case 0:if(d.setStatus(0),t={id:0,code:"",email_list:"",object_id:"",valid_from:"",valid_to:"",days_count:0,discount_type:null,discount:0,amount:0,currency:"",active:!1,timestamp:"",channel:"",content_type:0,students:[]},!d.coupon){e.n=5;break}return p=null===(l=d.configObj.metadata)||void 0===l?void 0:l.channel_username,b=JSON.stringify({code:d.coupon,email:d.configObj.email,content_type:d.configObj.content_type,object_id:d.configObj.object_id}),v=c("POST",b,null,"json"),h="".concat(i,"coupons/").concat(p,"/validate-coupon/"),e.p=1,e.n=2,fetch(h,v);case 2:return g=e.v,e.n=3,g.json();case 3:(t=e.v).detail?u(t.detail,400):t.id&&u("".concat(t.discount||"".concat(t.currency).concat(t.amount),"% token was applied.")),e.n=5;break;case 4:e.p=4,q=e.v,console.error("Coupon validation error:",q),u("Could not validate coupon",400);case 5:if(!t.discount&&!t.amount){e.n=7;break}if(100!==t.discount||"percentage"!==t.discount_type){e.n=6;break}return _={email:d.configObj.email,amount:0,status:"success",reference:"COUPON__".concat(d.coupon,"__").concat(d.configObj.email),message:"Payment complete with 100% token coupon",transaction:"",canceled:!1},d.handleDBAction(_),d.setStatus(1),e.a(2);case 6:(w=r(d.configObj.amount,d.configObj.currency||"NGN",t)).discounted?(u(w.detail),o=a(a({},d.configObj),w)):(u(w.detail,400),o=d.configObj),e.n=8;break;case 7:o=d.configObj;case 8:if(d.gatwayCharges&&(k=d.gatwayCharges/100,j=o.amount/(1-k),P=parseFloat(j.toFixed(2)),O=P-o.amount,C=O>2e3?o.amount+2e3:P,o.amount=C),N=f(o),!o.amount){e.n=17;break}if(!d.paymentMethod||null===(S=d.savedCardCharge)||void 0===S||!S.chargeUrl){e.n=14;break}return D="Would you prefer we charge your existing ".concat((null===(B=d.paymentMethod.authorization)||void 0===B?void 0:B.card_type)||""," card that ends with ").concat(d.paymentMethod.last4,"?"),e.n=9,s(D,!0);case 9:if(!e.v){e.n=11;break}return e.n=10,m(a(a({},d.savedCardCharge),{},{body:a({payment_method_id:d.paymentMethod.id,coupon:d.coupon||null,content_type:null!==(U=d.configObj.content_type)&&void 0!==U?U:null,object_id:null!==(A=d.configObj.object_id)&&void 0!==A?A:null,metadata:N.metadata||{}},d.savedCardCharge.body||{})}));case 10:T=e.v,d.handleDBAction(T),e.n=13;break;case 11:return e.n=12,y(N);case 12:E=e.v,d.handleDBAction(E);case 13:e.n=16;break;case 14:return console.log("Pay with paystack: "),e.n=15,y(N);case 15:M=e.v,d.handleDBAction(M);case 16:e.n=18;break;case 17:G={email:d.configObj.email,amount:0,status:"success",reference:"COUPON__".concat(d.coupon,"__").concat(d.configObj.email),message:"No payment required for free item",transaction:"",canceled:!1},d.handleDBAction(G);case 18:d.setStatus(1);case 19:return e.a(2)}},e,null,[[1,4]])}));return function(){return t.apply(this,arguments)}}(),v=function(){var a=e(n().m(function e(){var a;return n().w(function(e){for(;;)switch(e.n){case 0:if(d.configObj.email){e.n=4;break}return e.n=1,l(d.label);case 1:if(!(a=e.v)){e.n=2;break}d.configObj.email=a,o("email",a,2),b(),e.n=3;break;case 2:return u("You need to enter a valid email!",400),e.n=3,v();case 3:e.n=5;break;case 4:o("email",d.configObj.email,2),b();case 5:return e.a(2)}},e)}));return function(){return a.apply(this,arguments)}}(),v();case 3:return t.a(2)}},t)})),v.apply(this,arguments)}function h(e){return g.apply(this,arguments)}function g(){return(g=e(n().m(function e(t){var d,m,p,b,v,h,g,_,w,k,j,P,O,C,N,S,B,D,U,A,T,E;return n().w(function(e){for(;;)switch(e.p=e.n){case 0:if(t.e&&t.e.preventDefault(),!t.defaultConfirm){e.n=2;break}return d=t.defaultMsg||"By clicking okay, you are proceeding with payment for ".concat(t.label,"."),e.n=1,s(d);case 1:if(e.v){e.n=2;break}return e.a(2);case 2:return t.setStatus(0),e.n=3,l(t.label);case 3:if(m=e.v){e.n=4;break}return u("You need to enter a valid email to proceed!",400),t.setStatus(1),e.a(2);case 4:if(o("email",m,2),p={email:m,first_name:"Guest",last_name:"User",amount:t.amount,currency:t.currency||"NGN",metadata:t.metadata,content_type:t.content_type,object_id:t.object_id},!t.coupon){e.n=11;break}return v=null===(b=t.metadata)||void 0===b?void 0:b.channel_username,h=JSON.stringify({code:t.coupon,email:m,content_type:t.content_type,object_id:t.object_id}),g=c("POST",h,null,"json"),_="".concat(i,"coupons/").concat(v,"/validate-coupon/"),e.p=5,e.n=6,fetch(_,g);case 6:return w=e.v,e.n=7,w.json();case 7:if(k=e.v,j=k.discount||0,k.detail?u(k.detail,400):k.id&&u("".concat(j,"% discount was applied.")),!(P=r(p.amount,p.currency||"NGN",k)).discounted){e.n=9;break}if(100!==j){e.n=8;break}return O={email:p.email,amount:0,status:"success",reference:"COUPON__".concat(t.coupon,"__").concat(p.email),message:"No payment required for free item",transaction:"",canceled:!1},t.handleDBAction(O),t.setStatus(1),e.a(2);case 8:u(P.detail),p=a(a({},p),P);case 9:e.n=11;break;case 10:e.p=10,E=e.v,console.error("Coupon validation error:",E),u("Could not validate coupon",400);case 11:if(t.gatwayCharges&&(C=t.gatwayCharges/100,N=p.amount/(1-C),S=parseFloat(N.toFixed(2)),B=S-p.amount,D=B>2e3?p.amount+2e3:S,p.amount=D),U=f(p),!(p.amount>0)){e.n=13;break}return e.n=12,y(U);case 12:A=e.v,t.handleDBAction(A),e.n=14;break;case 13:T={email:p.email,amount:0,status:"success",reference:"COUPON__".concat(t.coupon,"__").concat(p.email),message:"No payment required for free item",transaction:"",canceled:!1},t.handleDBAction(T);case 14:t.setStatus(1);case 15:return e.a(2)}},e,null,[[5,10]])}))).apply(this,arguments)}export{d as PAYSTACK_INLINE_V2_URL,m as chargeAuthorization,b as handlePaymentSubmit,h as handlePaymentWithoutUserData,p as payWithAccessCode,y as payWithPaystack,f as paystackDataConfig};
|
|
2
2
|
//# sourceMappingURL=paystack.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paystack.js","sources":["../../../../src/components/lib/paystack.ts"],"sourcesContent":["import {\n API_HOST_URL,\n calculateCouponDeduction,\n reqOptions,\n setCookie,\n} from \"./helpFunction\";\nimport {\n getUserEmailInputModal,\n openConfirmModal,\n openToast,\n} from \"./modals/modals\";\nimport {\n PaystackConfigObjectType,\n PaystackConfigType,\n PaystackResponseType,\n PaymentContextType,\n CouponType,\n} from \"@/types\";\n\n/**\n * Context for processing payments\n * @property {Event | null} [e] - The event object that triggered the payment\n * @property {Object} objects - Details about the item being purchased\n * @property {string} objects.title - Title of the item\n * @property {string | number | null} [objects.object_type] - Model ID of the object being purchased\n * @property {string | number | null} [objects.object_id] - Object ID of the object being purchased\n * @property {PaystackConfigObjectType} configObj - Configuration for PayStack\n * @property {PaymentMethodType} [paymentMethod] - Saved payment method if available\n * @property {Function} setStatus - Function to update UI status during payment process\n * @property {Function} handleDBAction - Callback for processing successful payments\n * @property {boolean} [defaultConfirm] - Whether to show a confirmation dialog\n * @property {string} label - Label for the payment (usually item title)\n * @property {string} [coupon] - Coupon code if applicable\n * @property {string} [defaultMsg] - Custom confirmation message\n * @property {number} [gatwayCharges] - Payment gateway charges percentage\n */\n\n/**\n * Configures the Paystack payment data for processing\n * @param obj - Object containing payment details\n * @returns PaystackConfig - Configured payment data\n */\nexport const paystackDataConfig = (\n obj: PaystackConfigObjectType\n): PaystackConfigType => ({\n authorization_code: obj.authorization_code,\n reference: new Date().getTime().toString(),\n email: obj.email,\n first_name: obj.first_name,\n last_name: obj.last_name,\n amount: Math.round(obj.amount * 100), // Amount is in the country's lowest currency. E.g Kobo, so 20000 kobo = N200\n currency: obj.currency || \"NGN\",\n publicKey: process.env.NEXT_PUBLIC_PAYSTACK_SECRET_KEY,\n key: process.env.NEXT_PUBLIC_PAYSTACK_PUBLIC_KEY,\n callback_url: window.location.href,\n metadata: obj.metadata,\n});\n\n/**\n * Charges a customer using an existing authorization\n * @param data - Payment configuration data\n * @returns Promise with transaction data\n */\nexport const chargeAuthorization = async (\n data: PaystackConfigType\n): Promise<any> => {\n // This function tries to charge user with existing card\n const url = \"https://api.paystack.co/transaction/charge_authorization\";\n const options = {\n method: \"POST\",\n body: JSON.stringify(data),\n headers: {\n Authorization: `Bearer ${process.env.NEXT_PUBLIC_PAYSTACK_SECRET_KEY}`,\n \"Content-Type\": \"application/json\",\n },\n };\n\n try {\n const req = await fetch(url, options);\n const res = await req.json();\n\n if (res.data?.status === \"success\") {\n openToast(`Payment was successful with reference: ${res.data.reference}`);\n } else {\n openToast(`Payment failed with reference: ${res.data.reference}`, 400);\n }\n\n return res.data;\n } catch (error) {\n openToast(\"Payment processing error occurred\", 400);\n console.error(\"Payment authorization error:\", error);\n return { status: \"failed\", error };\n }\n};\n\n/**\n * Initiates payment with Paystack popup\n * @param config - Payment configuration\n * @returns Promise with payment response\n */\nexport const payWithPaystack = (\n config: PaystackConfigType\n): Promise<PaystackResponseType> => {\n return new Promise(async (resolve) => {\n try {\n // Ensure PaystackPop is available\n if (!window.PaystackPop) {\n throw new Error(\"Paystack script not loaded\");\n }\n\n let handler = await window.PaystackPop.setup({\n ...config,\n callback: (response: PaystackResponseType) => {\n // This happens after the payment is completed successfully\n openToast(\"Payment complete! Reference: \" + response.reference);\n resolve({ ...response, email: config.email, amount: config.amount });\n },\n onClose: () => {\n openToast(\"Transaction was not completed, window closed.\", 400);\n resolve({\n status: \"canceled\",\n cancelled: true,\n reference: config.reference,\n email: config.email,\n amount: config.amount,\n } as PaystackResponseType);\n },\n });\n handler.openIframe();\n } catch (error) {\n console.error(\"Paystack initialization error:\", error);\n openToast(\"Payment could not be initiated\", 400);\n resolve({\n status: \"failed\",\n cancelled: true,\n reference: config.reference,\n error,\n email: config.email,\n amount: config.amount,\n } as PaystackResponseType);\n }\n });\n};\n\n/**\n * Handles the complete payment submission process\n * @example\n * ```ts\n * handlePaymentSubmit({\n * openConfirm: true,\n * defaultConfirm: true,\n * defaultMsg: \"Are you sure you want to enroll for this course?\",\n * label: \"Course Name\",\n * objects: {\n * object_id: \"123\",\n * object_type: \"course\",\n * },\n * configObj: {\n * email: \"user@example.com\",\n * amount: 1000,\n * currency: \"NGN\",\n * authorization_code: \"1234567890\",\n * first_name: \"John\",\n * last_name: \"Doe\",\n * email: \"user@example.com\",\n * },\n * coupon: \"1234567890\",\n * gatwayCharges: 10,\n * paymentMethod: {\n * authorization: {\n * card_type: \"MasterCard\",\n * last4: \"1234\",\n * },\n * },\n * handleDBAction: (data: any) => {\n * console.log(data);\n * },\n * setStatus: (status: number) => {\n * console.log(status);\n * },\n * e: Event,\n * });\n * ```\n * @param contexts - Payment context information\n * @context This function orchestrates the entire payment flow from confirmation to processing\n */\nexport async function handlePaymentSubmit(\n contexts: PaymentContextType\n): Promise<void> {\n if (contexts.e) contexts.e.preventDefault();\n\n if (contexts.openConfirm && contexts.defaultConfirm) {\n let msg = `By clicking okay, you are enrolling for ${contexts.label} with id ${contexts.objects.object_id}.`;\n const confirm = await openConfirmModal(contexts.defaultMsg || msg);\n if (!confirm) return;\n }\n\n const makePayment = async (): Promise<void> => {\n contexts.setStatus(0);\n\n // Check if contexts.coupon is valid\n let coupon_res: CouponType = {\n id: 0,\n code: \"\",\n email_list: \"\",\n object_id: \"\",\n valid_from: \"\",\n valid_to: \"\",\n days_count: 0,\n discount_type: null,\n discount: 0,\n amount: 0,\n currency: \"\",\n active: false,\n timestamp: \"\",\n channel: \"\",\n content_type: 0,\n students: [],\n };\n\n let mewConfigObj: PaystackConfigObjectType;\n\n if (contexts.coupon) {\n const handle = contexts.configObj.metadata?.channel_username;\n const couponObj = JSON.stringify({\n code: contexts.coupon,\n email: contexts.configObj.email,\n content_type: contexts.configObj.content_type,\n object_id: contexts.configObj.object_id,\n });\n\n const requestOptions = reqOptions(\"POST\", couponObj, null, \"json\");\n const url = `${API_HOST_URL}coupons/${handle}/validate-coupon/`;\n\n try {\n const dataset = await fetch(url, requestOptions);\n coupon_res = (await dataset.json()) as CouponType;\n\n if (coupon_res.detail) {\n openToast(coupon_res.detail, 400);\n } else if (coupon_res.id) {\n openToast(\n `${\n coupon_res.discount ||\n `${coupon_res.currency}${coupon_res.amount}`\n }% token was applied.`\n );\n }\n } catch (error) {\n console.error(\"Coupon validation error:\", error);\n openToast(\"Could not validate coupon\", 400);\n }\n }\n\n // Remove the discount from actual amount\n if (coupon_res.discount || coupon_res.amount) {\n if (\n coupon_res.discount === 100 &&\n coupon_res.discount_type === \"percentage\"\n ) {\n const resContext = {\n email: contexts.configObj.email,\n amount: 0,\n status: \"success\",\n reference: `COUPON__${contexts.coupon}__${contexts.configObj.email}`,\n message: \"Payment complete with 100% token coupon\",\n transaction: \"\",\n canceled: false,\n };\n contexts.handleDBAction(resContext);\n contexts.setStatus(1);\n return;\n }\n\n const amount = calculateCouponDeduction(\n contexts.configObj.amount,\n contexts.configObj.currency || \"NGN\",\n coupon_res\n );\n\n if (!amount.discounted) {\n openToast(amount.detail, 400);\n\n // Abort payment due to invalid coupon\n mewConfigObj = contexts.configObj;\n } else {\n openToast(amount.detail);\n mewConfigObj = {\n ...contexts.configObj,\n ...amount,\n };\n }\n } else {\n // No coupon applied\n mewConfigObj = contexts.configObj;\n }\n\n // Add paystack charges\n if (contexts.gatwayCharges) {\n const fee = contexts.gatwayCharges / 100;\n // Calculate the amount to charge so that after the fee deduction, it matches the intended amount\n const totalAmount = mewConfigObj.amount / (1 - fee);\n // Returns the amount rounded to 2 decimal places\n const decimalAmount = parseFloat(totalAmount.toFixed(2));\n\n // Local transactions fees are capped at ₦2000, meaning that's the absolute maximum you'll ever pay in fees per transaction\n const localCharges = decimalAmount - mewConfigObj.amount;\n\n // Only charge 2k if charges exceed threshold\n const noMoreThan2k =\n localCharges > 2000 ? mewConfigObj.amount + 2000 : decimalAmount;\n\n mewConfigObj.amount = noMoreThan2k;\n }\n\n const dataset = paystackDataConfig(mewConfigObj);\n\n if (mewConfigObj.amount) {\n if (mewConfigObj.authorization_code && contexts.paymentMethod) {\n // Ask if user wants to use existing payment method\n const msg = `Would you prefer we charge your existing ${contexts.paymentMethod.authorization.card_type} card that ends with ${contexts.paymentMethod.last4}?`;\n const confirm = await openConfirmModal(msg, true);\n\n if (confirm) {\n // Charge user with existing card\n const res = await chargeAuthorization(dataset);\n contexts.handleDBAction(res);\n } else {\n // Request for user card details\n const payActivate = await payWithPaystack(dataset);\n\n contexts.handleDBAction(payActivate);\n }\n } else {\n // Request for user card details if payment method doesn't exist\n console.log(\"Pay with paystack: \");\n const payActivate = await payWithPaystack(dataset);\n contexts.handleDBAction(payActivate);\n }\n } else {\n // If cohort is free, don't request for payment\n const resContext = {\n email: contexts.configObj.email,\n amount: 0,\n status: \"success\",\n reference: `COUPON__${contexts.coupon}__${contexts.configObj.email}`,\n message: \"No payment required for free item\",\n transaction: \"\",\n canceled: false,\n };\n contexts.handleDBAction(resContext);\n }\n\n contexts.setStatus(1);\n };\n\n // Get user email input if doesn't exist\n const checkEmailInConfig = async (): Promise<void> => {\n if (!contexts.configObj.email) {\n const emailValue = await getUserEmailInputModal(contexts.label);\n if (emailValue) {\n contexts.configObj.email = emailValue;\n setCookie(\"email\", emailValue, 2); // store for signup use\n makePayment();\n } else {\n openToast(\"You need to enter a valid email!\", 400);\n await checkEmailInConfig();\n }\n } else {\n setCookie(\"email\", contexts.configObj.email, 2); // store for signup use\n makePayment();\n }\n };\n\n checkEmailInConfig();\n}\n\n/**\n * Handles payment submission without requiring user data upfront\n * Useful for guest checkout or anonymous payments\n * @example\n * ```ts\n * handlePaymentWithoutUserData({\n * amount: 5000,\n * label: \"Course Enrollment\",\n * currency: \"NGN\",\n * metadata: {\n * content_type: \"course\",\n * object_id: \"123\",\n * },\n * handleDBAction: (data: any) => {\n * console.log(data);\n * },\n * setStatus: (status: number) => {\n * console.log(status);\n * },\n * });\n * ```\n * @param config - Minimal payment configuration without user details\n */\nexport async function handlePaymentWithoutUserData(config: {\n amount: number;\n label: string;\n currency?: string;\n metadata?: PaystackConfigObjectType[\"metadata\"];\n handleDBAction: (data?: any) => void;\n setStatus: (status: number) => void;\n coupon?: string;\n gatwayCharges?: number;\n defaultConfirm?: boolean;\n defaultMsg?: string;\n e?: Event | null;\n content_type?: string | number;\n object_id?: string | number;\n}): Promise<void> {\n if (config.e) config.e.preventDefault();\n\n if (config.defaultConfirm) {\n const msg =\n config.defaultMsg ||\n `By clicking okay, you are proceeding with payment for ${config.label}.`;\n const confirm = await openConfirmModal(msg);\n if (!confirm) return;\n }\n\n config.setStatus(0);\n\n // Always prompt for email input\n const emailValue = await getUserEmailInputModal(config.label);\n\n if (!emailValue) {\n openToast(\"You need to enter a valid email to proceed!\", 400);\n config.setStatus(1);\n return;\n }\n\n // Store email for potential signup\n setCookie(\"email\", emailValue, 2);\n\n // Build minimal config object\n let configObj: PaystackConfigObjectType = {\n email: emailValue,\n first_name: \"Guest\",\n last_name: \"User\",\n amount: config.amount,\n currency: config.currency || \"NGN\",\n metadata: config.metadata,\n content_type: config.content_type,\n object_id: config.object_id,\n };\n\n // Handle coupon validation if provided\n if (config.coupon) {\n const handle = config.metadata?.channel_username;\n const couponObj = JSON.stringify({\n code: config.coupon,\n email: emailValue,\n content_type: config.content_type,\n object_id: config.object_id,\n });\n\n const requestOptions = reqOptions(\"POST\", couponObj, null, \"json\");\n const url = `${API_HOST_URL}coupons/${handle}/validate-coupon/`;\n\n try {\n const dataset = await fetch(url, requestOptions);\n const res = await dataset.json();\n\n const discount = res.discount || 0;\n if (res.detail) {\n openToast(res.detail, 400);\n } else if (res.id) {\n openToast(`${discount}% discount was applied.`);\n }\n\n const _discounted = calculateCouponDeduction(\n configObj.amount,\n configObj.currency || \"NGN\",\n res\n );\n\n // Apply discount\n if (_discounted.discounted) {\n if (discount === 100) {\n const resContext = {\n email: configObj.email,\n amount: 0,\n status: \"success\",\n reference: `COUPON__${config.coupon}__${configObj.email}`,\n message: \"No payment required for free item\",\n transaction: \"\",\n canceled: false,\n };\n config.handleDBAction(resContext);\n config.setStatus(1);\n return;\n }\n\n openToast(_discounted.detail);\n configObj = {\n ...configObj,\n ..._discounted,\n };\n }\n } catch (error) {\n console.error(\"Coupon validation error:\", error);\n openToast(\"Could not validate coupon\", 400);\n }\n }\n\n // Add gateway charges if applicable\n if (config.gatwayCharges) {\n const fee = config.gatwayCharges / 100;\n const totalAmount = configObj.amount / (1 - fee);\n const decimalAmount = parseFloat(totalAmount.toFixed(2));\n const localCharges = decimalAmount - configObj.amount;\n const noMoreThan2k =\n localCharges > 2000 ? configObj.amount + 2000 : decimalAmount;\n configObj.amount = noMoreThan2k;\n }\n\n const dataset = paystackDataConfig(configObj);\n\n if (configObj.amount > 0) {\n // Process payment with Paystack\n const payActivate = await payWithPaystack(dataset);\n config.handleDBAction(payActivate);\n } else {\n // Free item\n const resContext = {\n email: configObj.email,\n amount: 0,\n status: \"success\",\n reference: `COUPON__${config.coupon}__${configObj.email}`,\n message: \"No payment required for free item\",\n transaction: \"\",\n canceled: false,\n };\n config.handleDBAction(resContext);\n }\n\n config.setStatus(1);\n}\n\n// Add PaystackPop to Window interface\ndeclare global {\n interface Window {\n PaystackPop: {\n setup: (config: any) => { openIframe: () => void };\n };\n }\n}\n"],"names":["paystackDataConfig","obj","authorization_code","reference","Date","getTime","toString","email","first_name","last_name","amount","Math","round","currency","publicKey","process","env","NEXT_PUBLIC_PAYSTACK_SECRET_KEY","key","NEXT_PUBLIC_PAYSTACK_PUBLIC_KEY","callback_url","window","location","href","metadata","chargeAuthorization","_ref","_asyncToGenerator","_regenerator","m","_callee","data","options","_res$data","req","res","_t","w","_context","p","n","method","body","JSON","stringify","headers","Authorization","concat","fetch","v","json","status","openToast","a","console","error","_x","apply","this","arguments","payWithPaystack","config","Promise","_ref2","_callee2","resolve","_t2","_context2","PaystackPop","Error","setup","_objectSpread","callback","response","onClose","cancelled","openIframe","_x2","handlePaymentSubmit","_x3","_handlePaymentSubmit","_callee5","contexts","msg","makePayment","_checkEmailInConfig","_context5","e","preventDefault","openConfirm","defaultConfirm","label","objects","object_id","openConfirmModal","defaultMsg","_ref3","_callee3","coupon_res","mewConfigObj","_contexts$configObj$m","handle","couponObj","requestOptions","url","_dataset","resContext","fee","totalAmount","decimalAmount","localCharges","noMoreThan2k","dataset","_msg","payActivate","_payActivate","_resContext","_t3","_context3","setStatus","id","code","email_list","valid_from","valid_to","days_count","discount_type","discount","active","timestamp","channel","content_type","students","coupon","configObj","channel_username","reqOptions","API_HOST_URL","detail","message","transaction","canceled","handleDBAction","calculateCouponDeduction","discounted","gatwayCharges","parseFloat","toFixed","paymentMethod","authorization","card_type","last4","log","checkEmailInConfig","_ref4","_callee4","emailValue","_context4","getUserEmailInputModal","setCookie","handlePaymentWithoutUserData","_x4","_handlePaymentWithoutUserData","_callee6","_config$metadata","_dataset2","_discounted","_resContext2","_t4","_context6"],"mappings":"yUA0CaA,EAAqB,SAChCC,GAA6B,MACL,CACxBC,mBAAoBD,EAAIC,mBACxBC,WAAW,IAAIC,MAAOC,UAAUC,WAChCC,MAAON,EAAIM,MACXC,WAAYP,EAAIO,WAChBC,UAAWR,EAAIQ,UACfC,OAAQC,KAAKC,MAAmB,IAAbX,EAAIS,QACvBG,SAAUZ,EAAIY,UAAY,MAC1BC,UAAWC,QAAQC,IAAIC,gCACvBC,IAAKH,QAAQC,IAAIG,gCACjBC,aAAcC,OAAOC,SAASC,KAC9BC,SAAUvB,EAAIuB,SACf,EAOYC,EAAmB,WAAA,IAAAC,EAAAC,EAAAC,IAAAC,EAAG,SAAAC,EACjCC,GAAwB,IAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAA,OAAAR,IAAAS,EAAA,SAAAC,GAAA,cAAAA,EAAAC,EAAAD,EAAAE,GAAA,KAAA,EAWvB,OAPKR,EAAU,CACdS,OAAQ,OACRC,KAAMC,KAAKC,UAAUb,GACrBc,QAAS,CACPC,cAAa,UAAAC,OAAYhC,QAAQC,IAAIC,iCACrC,eAAgB,qBAEnBqB,EAAAC,EAAA,EAAAD,EAAAE,EAAA,EAGmBQ,MAXR,2DAWmBhB,GAAQ,KAAA,EAA5B,OAAHE,EAAGI,EAAAW,EAAAX,EAAAE,EAAA,EACSN,EAAIgB,OAAM,KAAA,EAM3B,OANK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S,GAAC,CAAA+J,EAAAjI,EAAA,GAAA,KAAA,CAAA,OAAAiI,EAAAjI,EAAA,GAEIoB,EAAgBoD,GAAQ,KAAA,GAA5CE,EAAWuD,EAAAxH,EACjBY,EAAOiF,eAAe5B,GAAauD,EAAAjI,EAAA,GAAA,MAAA,KAAA,GAG7BkE,EAAa,CACjBnG,MAAO+H,EAAU/H,MACjBG,OAAQ,EACRyC,OAAQ,UACRhD,UAAS4C,WAAAA,OAAac,EAAOwE,OAAMtF,MAAAA,OAAKuF,EAAU/H,OAClDoI,QAAS,oCACTC,YAAa,GACbC,UAAU,GAEZhF,EAAOiF,eAAepC,GAAY,KAAA,GAGpC7C,EAAO0D,UAAU,GAAG,KAAA,GAAA,OAAAkD,EAAApH,EAAA,GAAA,EAAA8G,EAAA,KAAA,CAAA,CAAA,EAAA,KACrB,KAAA1G,MAAAC,KAAAC,UAAA"}
|
|
1
|
+
{"version":3,"file":"paystack.js","sources":["../../../../src/components/lib/paystack.ts"],"sourcesContent":["import {\n API_HOST_URL,\n calculateCouponDeduction,\n reqOptions,\n setCookie,\n} from \"./helpFunction\";\nimport {\n getUserEmailInputModal,\n openConfirmModal,\n openToast,\n} from \"./modals/modals\";\nimport {\n PaystackConfigObjectType,\n PaystackConfigType,\n PaystackResponseType,\n PaymentContextType,\n CouponType,\n SavedCardChargeOptionsType,\n} from \"@/types\";\n\n/** Paystack inline v2 script, needed for server-initialised transactions. */\nexport const PAYSTACK_INLINE_V2_URL = \"https://js.paystack.co/v2/inline.js\";\n\n/**\n * Context for processing payments\n * @property {Event | null} [e] - The event object that triggered the payment\n * @property {Object} objects - Details about the item being purchased\n * @property {string} objects.title - Title of the item\n * @property {string | number | null} [objects.object_type] - Model ID of the object being purchased\n * @property {string | number | null} [objects.object_id] - Object ID of the object being purchased\n * @property {PaystackConfigObjectType} configObj - Configuration for PayStack\n * @property {PaymentMethodType} [paymentMethod] - Saved payment method if available\n * @property {Function} setStatus - Function to update UI status during payment process\n * @property {Function} handleDBAction - Callback for processing successful payments\n * @property {boolean} [defaultConfirm] - Whether to show a confirmation dialog\n * @property {string} label - Label for the payment (usually item title)\n * @property {string} [coupon] - Coupon code if applicable\n * @property {string} [defaultMsg] - Custom confirmation message\n * @property {number} [gatwayCharges] - Payment gateway charges percentage\n */\n\n/**\n * Configures the Paystack popup data.\n *\n * Only the PUBLIC key (`NEXT_PUBLIC_PAYSTACK_PUBLIC_KEY`) is ever read here.\n * The secret key must never reach the browser: anything a `NEXT_PUBLIC_*`\n * variable holds is inlined into the shipped JavaScript.\n * @param obj - Object containing payment details\n * @returns PaystackConfig - Configured payment data\n */\nexport const paystackDataConfig = (\n obj: PaystackConfigObjectType\n): PaystackConfigType => ({\n reference: new Date().getTime().toString(),\n email: obj.email,\n first_name: obj.first_name,\n last_name: obj.last_name,\n amount: Math.round(obj.amount * 100), // Amount is in the country's lowest currency. E.g Kobo, so 20000 kobo = N200\n currency: obj.currency || \"NGN\",\n key: process.env.NEXT_PUBLIC_PAYSTACK_PUBLIC_KEY,\n callback_url: window.location.href,\n metadata: obj.metadata,\n});\n\n/**\n * Charges the logged-in user's saved card THROUGH THE APP'S SERVER.\n *\n * The browser never calls Paystack's charge_authorization API and never sends\n * an authorization code or an amount the server trusts. It POSTs only what\n * identifies the purchase (`body`, e.g. the saved payment method id, the item\n * and a coupon code) to `chargeUrl`; the server looks the card up by the\n * logged-in user, prices the item itself and charges it with its own secret\n * key. The server is expected to answer with the Paystack transaction object\n * (`status`, `reference`, `amount`, ...), optionally wrapped in `data`.\n *\n * @example\n * ```ts\n * const res = await chargeAuthorization({\n * chargeUrl: `${API_HOST_URL}payments/${channel}/paystack/charge-saved-card/`,\n * token,\n * body: { payment_method_id: card.id, item_type: \"course\", item_id: course.id },\n * });\n * if (res.status === \"success\") recordPayment(res);\n * ```\n * @param options - Server endpoint, auth token and purchase identifiers\n * @returns Promise with the transaction data (status \"failed\" on error)\n */\nexport const chargeAuthorization = async (\n options: SavedCardChargeOptionsType\n): Promise<any> => {\n if (!options?.chargeUrl) {\n openToast(\"Saved card payments are not available here.\", 400);\n return { status: \"failed\", message: \"chargeUrl is required\" };\n }\n\n const requestOptions = reqOptions(\n \"POST\",\n JSON.stringify(options.body || {}),\n options.token || null,\n \"json\",\n options.channel || null\n );\n\n try {\n const req = await fetch(options.chargeUrl, requestOptions);\n const res = await req.json().catch(() => ({}));\n const data = res?.data && typeof res.data === \"object\" ? res.data : res;\n\n if (req.ok && data?.status === \"success\") {\n openToast(`Payment was successful with reference: ${data.reference}`);\n return data;\n }\n\n const message =\n res?.detail ||\n data?.gateway_response ||\n data?.message ||\n \"Payment could not be completed with the saved card\";\n openToast(message, 400);\n return { ...data, status: data?.status || \"failed\", message };\n } catch (error) {\n openToast(\"Payment processing error occurred\", 400);\n console.error(\"Saved card charge error:\", error);\n return { status: \"failed\", error };\n }\n};\n\n/**\n * Opens the Paystack popup for a transaction the app's SERVER initialised\n * (POST /transaction/initialize with the secret key), so amount, email and\n * metadata are fixed server-side and cannot be changed in the browser.\n *\n * Uses Paystack inline v2 (`resumeTransaction`). The v2 script is loaded on\n * demand when it is not already on the page.\n * @param accessCode - `access_code` returned by the server's initialize call\n * @returns Promise with the payment response (`status: \"canceled\"` on close)\n */\nexport const payWithAccessCode = (\n accessCode: string\n): Promise<PaystackResponseType> => {\n const empty = { email: \"\", amount: 0 };\n\n const loadV2 = (): Promise<any> =>\n new Promise((resolve, reject) => {\n const existing = (window as any).PaystackPop;\n if (existing && typeof existing === \"function\") {\n return resolve(existing);\n }\n const script = document.createElement(\"script\");\n script.src = PAYSTACK_INLINE_V2_URL;\n script.async = true;\n script.onload = () => resolve((window as any).PaystackPop);\n script.onerror = () => reject(new Error(\"Paystack script failed to load\"));\n document.body.appendChild(script);\n });\n\n return new Promise(async (resolve) => {\n try {\n if (!accessCode) throw new Error(\"accessCode is required\");\n const Pop = await loadV2();\n const popup = new Pop();\n popup.resumeTransaction(accessCode, {\n onSuccess: (response: PaystackResponseType) => {\n openToast(\"Payment complete! Reference: \" + response.reference);\n resolve({ ...empty, ...response, status: response.status || \"success\" });\n },\n onCancel: () => {\n openToast(\"Transaction was not completed, window closed.\", 400);\n resolve({\n ...empty,\n status: \"canceled\",\n cancelled: true,\n reference: \"\",\n } as PaystackResponseType);\n },\n onError: (error: any) => {\n openToast(error?.message || \"Payment could not be initiated\", 400);\n resolve({ ...empty, status: \"failed\", reference: \"\", error });\n },\n });\n } catch (error) {\n console.error(\"Paystack access code error:\", error);\n openToast(\"Payment could not be initiated\", 400);\n resolve({ ...empty, status: \"failed\", reference: \"\", error });\n }\n });\n};\n\n/**\n * Initiates payment with Paystack popup\n * @param config - Payment configuration\n * @returns Promise with payment response\n */\nexport const payWithPaystack = (\n config: PaystackConfigType\n): Promise<PaystackResponseType> => {\n return new Promise(async (resolve) => {\n try {\n // Ensure PaystackPop is available\n if (!window.PaystackPop) {\n throw new Error(\"Paystack script not loaded\");\n }\n\n let handler = await window.PaystackPop.setup({\n ...config,\n callback: (response: PaystackResponseType) => {\n // This happens after the payment is completed successfully\n openToast(\"Payment complete! Reference: \" + response.reference);\n resolve({ ...response, email: config.email, amount: config.amount });\n },\n onClose: () => {\n openToast(\"Transaction was not completed, window closed.\", 400);\n resolve({\n status: \"canceled\",\n cancelled: true,\n reference: config.reference,\n email: config.email,\n amount: config.amount,\n } as PaystackResponseType);\n },\n });\n handler.openIframe();\n } catch (error) {\n console.error(\"Paystack initialization error:\", error);\n openToast(\"Payment could not be initiated\", 400);\n resolve({\n status: \"failed\",\n cancelled: true,\n reference: config.reference,\n error,\n email: config.email,\n amount: config.amount,\n } as PaystackResponseType);\n }\n });\n};\n\n/**\n * Handles the complete payment submission process\n * @example\n * ```ts\n * handlePaymentSubmit({\n * openConfirm: true,\n * defaultConfirm: true,\n * defaultMsg: \"Are you sure you want to enroll for this course?\",\n * label: \"Course Name\",\n * objects: {\n * object_id: \"123\",\n * object_type: \"course\",\n * },\n * configObj: {\n * email: \"user@example.com\",\n * amount: 1000,\n * currency: \"NGN\",\n * first_name: \"John\",\n * last_name: \"Doe\",\n * email: \"user@example.com\",\n * },\n * coupon: \"1234567890\",\n * gatwayCharges: 10,\n * paymentMethod: savedCard, // from user-payment-method-list\n * // Saved cards are charged by YOUR server, never from the browser.\n * // Without savedCardCharge the user always gets the Paystack popup.\n * savedCardCharge: {\n * chargeUrl: `${API_HOST_URL}payments/${channel}/paystack/charge-saved-card/`,\n * token,\n * body: { item_type: \"course\", item_id: \"123\" },\n * },\n * handleDBAction: (data: any) => {\n * console.log(data);\n * },\n * setStatus: (status: number) => {\n * console.log(status);\n * },\n * e: Event,\n * });\n * ```\n * @param contexts - Payment context information\n * @context This function orchestrates the entire payment flow from confirmation to processing\n */\nexport async function handlePaymentSubmit(\n contexts: PaymentContextType\n): Promise<void> {\n if (contexts.e) contexts.e.preventDefault();\n\n if (contexts.openConfirm && contexts.defaultConfirm) {\n let msg = `By clicking okay, you are enrolling for ${contexts.label} with id ${contexts.objects.object_id}.`;\n const confirm = await openConfirmModal(contexts.defaultMsg || msg);\n if (!confirm) return;\n }\n\n const makePayment = async (): Promise<void> => {\n contexts.setStatus(0);\n\n // Check if contexts.coupon is valid\n let coupon_res: CouponType = {\n id: 0,\n code: \"\",\n email_list: \"\",\n object_id: \"\",\n valid_from: \"\",\n valid_to: \"\",\n days_count: 0,\n discount_type: null,\n discount: 0,\n amount: 0,\n currency: \"\",\n active: false,\n timestamp: \"\",\n channel: \"\",\n content_type: 0,\n students: [],\n };\n\n let mewConfigObj: PaystackConfigObjectType;\n\n if (contexts.coupon) {\n const handle = contexts.configObj.metadata?.channel_username;\n const couponObj = JSON.stringify({\n code: contexts.coupon,\n email: contexts.configObj.email,\n content_type: contexts.configObj.content_type,\n object_id: contexts.configObj.object_id,\n });\n\n const requestOptions = reqOptions(\"POST\", couponObj, null, \"json\");\n const url = `${API_HOST_URL}coupons/${handle}/validate-coupon/`;\n\n try {\n const dataset = await fetch(url, requestOptions);\n coupon_res = (await dataset.json()) as CouponType;\n\n if (coupon_res.detail) {\n openToast(coupon_res.detail, 400);\n } else if (coupon_res.id) {\n openToast(\n `${\n coupon_res.discount ||\n `${coupon_res.currency}${coupon_res.amount}`\n }% token was applied.`\n );\n }\n } catch (error) {\n console.error(\"Coupon validation error:\", error);\n openToast(\"Could not validate coupon\", 400);\n }\n }\n\n // Remove the discount from actual amount\n if (coupon_res.discount || coupon_res.amount) {\n if (\n coupon_res.discount === 100 &&\n coupon_res.discount_type === \"percentage\"\n ) {\n const resContext = {\n email: contexts.configObj.email,\n amount: 0,\n status: \"success\",\n reference: `COUPON__${contexts.coupon}__${contexts.configObj.email}`,\n message: \"Payment complete with 100% token coupon\",\n transaction: \"\",\n canceled: false,\n };\n contexts.handleDBAction(resContext);\n contexts.setStatus(1);\n return;\n }\n\n const amount = calculateCouponDeduction(\n contexts.configObj.amount,\n contexts.configObj.currency || \"NGN\",\n coupon_res\n );\n\n if (!amount.discounted) {\n openToast(amount.detail, 400);\n\n // Abort payment due to invalid coupon\n mewConfigObj = contexts.configObj;\n } else {\n openToast(amount.detail);\n mewConfigObj = {\n ...contexts.configObj,\n ...amount,\n };\n }\n } else {\n // No coupon applied\n mewConfigObj = contexts.configObj;\n }\n\n // Add paystack charges\n if (contexts.gatwayCharges) {\n const fee = contexts.gatwayCharges / 100;\n // Calculate the amount to charge so that after the fee deduction, it matches the intended amount\n const totalAmount = mewConfigObj.amount / (1 - fee);\n // Returns the amount rounded to 2 decimal places\n const decimalAmount = parseFloat(totalAmount.toFixed(2));\n\n // Local transactions fees are capped at ₦2000, meaning that's the absolute maximum you'll ever pay in fees per transaction\n const localCharges = decimalAmount - mewConfigObj.amount;\n\n // Only charge 2k if charges exceed threshold\n const noMoreThan2k =\n localCharges > 2000 ? mewConfigObj.amount + 2000 : decimalAmount;\n\n mewConfigObj.amount = noMoreThan2k;\n }\n\n const dataset = paystackDataConfig(mewConfigObj);\n\n if (mewConfigObj.amount) {\n if (contexts.paymentMethod && contexts.savedCardCharge?.chargeUrl) {\n // Ask if user wants to use existing payment method\n const msg = `Would you prefer we charge your existing ${contexts.paymentMethod.authorization?.card_type || \"\"} card that ends with ${contexts.paymentMethod.last4}?`;\n const confirm = await openConfirmModal(msg, true);\n\n if (confirm) {\n // Charge the saved card on the server: it prices the item itself.\n const res = await chargeAuthorization({\n ...contexts.savedCardCharge,\n body: {\n payment_method_id: contexts.paymentMethod.id,\n coupon: contexts.coupon || null,\n content_type: contexts.configObj.content_type ?? null,\n object_id: contexts.configObj.object_id ?? null,\n metadata: dataset.metadata || {},\n ...(contexts.savedCardCharge.body || {}),\n },\n });\n contexts.handleDBAction(res);\n } else {\n // Request for user card details\n const payActivate = await payWithPaystack(dataset);\n\n contexts.handleDBAction(payActivate);\n }\n } else {\n // Request for user card details if payment method doesn't exist\n console.log(\"Pay with paystack: \");\n const payActivate = await payWithPaystack(dataset);\n contexts.handleDBAction(payActivate);\n }\n } else {\n // If cohort is free, don't request for payment\n const resContext = {\n email: contexts.configObj.email,\n amount: 0,\n status: \"success\",\n reference: `COUPON__${contexts.coupon}__${contexts.configObj.email}`,\n message: \"No payment required for free item\",\n transaction: \"\",\n canceled: false,\n };\n contexts.handleDBAction(resContext);\n }\n\n contexts.setStatus(1);\n };\n\n // Get user email input if doesn't exist\n const checkEmailInConfig = async (): Promise<void> => {\n if (!contexts.configObj.email) {\n const emailValue = await getUserEmailInputModal(contexts.label);\n if (emailValue) {\n contexts.configObj.email = emailValue;\n setCookie(\"email\", emailValue, 2); // store for signup use\n makePayment();\n } else {\n openToast(\"You need to enter a valid email!\", 400);\n await checkEmailInConfig();\n }\n } else {\n setCookie(\"email\", contexts.configObj.email, 2); // store for signup use\n makePayment();\n }\n };\n\n checkEmailInConfig();\n}\n\n/**\n * Handles payment submission without requiring user data upfront\n * Useful for guest checkout or anonymous payments\n * @example\n * ```ts\n * handlePaymentWithoutUserData({\n * amount: 5000,\n * label: \"Course Enrollment\",\n * currency: \"NGN\",\n * metadata: {\n * content_type: \"course\",\n * object_id: \"123\",\n * },\n * handleDBAction: (data: any) => {\n * console.log(data);\n * },\n * setStatus: (status: number) => {\n * console.log(status);\n * },\n * });\n * ```\n * @param config - Minimal payment configuration without user details\n */\nexport async function handlePaymentWithoutUserData(config: {\n amount: number;\n label: string;\n currency?: string;\n metadata?: PaystackConfigObjectType[\"metadata\"];\n handleDBAction: (data?: any) => void;\n setStatus: (status: number) => void;\n coupon?: string;\n gatwayCharges?: number;\n defaultConfirm?: boolean;\n defaultMsg?: string;\n e?: Event | null;\n content_type?: string | number;\n object_id?: string | number;\n}): Promise<void> {\n if (config.e) config.e.preventDefault();\n\n if (config.defaultConfirm) {\n const msg =\n config.defaultMsg ||\n `By clicking okay, you are proceeding with payment for ${config.label}.`;\n const confirm = await openConfirmModal(msg);\n if (!confirm) return;\n }\n\n config.setStatus(0);\n\n // Always prompt for email input\n const emailValue = await getUserEmailInputModal(config.label);\n\n if (!emailValue) {\n openToast(\"You need to enter a valid email to proceed!\", 400);\n config.setStatus(1);\n return;\n }\n\n // Store email for potential signup\n setCookie(\"email\", emailValue, 2);\n\n // Build minimal config object\n let configObj: PaystackConfigObjectType = {\n email: emailValue,\n first_name: \"Guest\",\n last_name: \"User\",\n amount: config.amount,\n currency: config.currency || \"NGN\",\n metadata: config.metadata,\n content_type: config.content_type,\n object_id: config.object_id,\n };\n\n // Handle coupon validation if provided\n if (config.coupon) {\n const handle = config.metadata?.channel_username;\n const couponObj = JSON.stringify({\n code: config.coupon,\n email: emailValue,\n content_type: config.content_type,\n object_id: config.object_id,\n });\n\n const requestOptions = reqOptions(\"POST\", couponObj, null, \"json\");\n const url = `${API_HOST_URL}coupons/${handle}/validate-coupon/`;\n\n try {\n const dataset = await fetch(url, requestOptions);\n const res = await dataset.json();\n\n const discount = res.discount || 0;\n if (res.detail) {\n openToast(res.detail, 400);\n } else if (res.id) {\n openToast(`${discount}% discount was applied.`);\n }\n\n const _discounted = calculateCouponDeduction(\n configObj.amount,\n configObj.currency || \"NGN\",\n res\n );\n\n // Apply discount\n if (_discounted.discounted) {\n if (discount === 100) {\n const resContext = {\n email: configObj.email,\n amount: 0,\n status: \"success\",\n reference: `COUPON__${config.coupon}__${configObj.email}`,\n message: \"No payment required for free item\",\n transaction: \"\",\n canceled: false,\n };\n config.handleDBAction(resContext);\n config.setStatus(1);\n return;\n }\n\n openToast(_discounted.detail);\n configObj = {\n ...configObj,\n ..._discounted,\n };\n }\n } catch (error) {\n console.error(\"Coupon validation error:\", error);\n openToast(\"Could not validate coupon\", 400);\n }\n }\n\n // Add gateway charges if applicable\n if (config.gatwayCharges) {\n const fee = config.gatwayCharges / 100;\n const totalAmount = configObj.amount / (1 - fee);\n const decimalAmount = parseFloat(totalAmount.toFixed(2));\n const localCharges = decimalAmount - configObj.amount;\n const noMoreThan2k =\n localCharges > 2000 ? configObj.amount + 2000 : decimalAmount;\n configObj.amount = noMoreThan2k;\n }\n\n const dataset = paystackDataConfig(configObj);\n\n if (configObj.amount > 0) {\n // Process payment with Paystack\n const payActivate = await payWithPaystack(dataset);\n config.handleDBAction(payActivate);\n } else {\n // Free item\n const resContext = {\n email: configObj.email,\n amount: 0,\n status: \"success\",\n reference: `COUPON__${config.coupon}__${configObj.email}`,\n message: \"No payment required for free item\",\n transaction: \"\",\n canceled: false,\n };\n config.handleDBAction(resContext);\n }\n\n config.setStatus(1);\n}\n\n// Add PaystackPop to Window interface\ndeclare global {\n interface Window {\n PaystackPop: {\n setup: (config: any) => { openIframe: () => void };\n };\n }\n}\n"],"names":["PAYSTACK_INLINE_V2_URL","paystackDataConfig","obj","reference","Date","getTime","toString","email","first_name","last_name","amount","Math","round","currency","key","process","env","NEXT_PUBLIC_PAYSTACK_PUBLIC_KEY","callback_url","window","location","href","metadata","chargeAuthorization","_ref","_asyncToGenerator","_regenerator","m","_callee","options","requestOptions","req","res","data","message","_t","w","_context","p","n","chargeUrl","openToast","a","status","reqOptions","JSON","stringify","body","token","channel","fetch","v","json","_typeof","ok","concat","detail","gateway_response","_objectSpread","console","error","_x","apply","this","arguments","payWithAccessCode","accessCode","empty","loadV2","Promise","resolve","reject","existing","PaystackPop","script","document","createElement","src","async","onload","onerror","Error","appendChild","_ref2","_callee2","Pop","_t2","_context2","resumeTransaction","onSuccess","response","onCancel","cancelled","onError","_x2","payWithPaystack","config","_ref3","_callee3","_t3","_context3","setup","callback","onClose","openIframe","_x3","handlePaymentSubmit","_x4","_handlePaymentSubmit","_callee6","contexts","msg","makePayment","_checkEmailInConfig","_context6","e","preventDefault","openConfirm","defaultConfirm","label","objects","object_id","openConfirmModal","defaultMsg","_ref4","_callee4","coupon_res","mewConfigObj","_contexts$configObj$m","handle","couponObj","url","_dataset","resContext","fee","totalAmount","decimalAmount","localCharges","noMoreThan2k","dataset","_contexts$savedCardCh","_contexts$paymentMeth","_msg","_contexts$configObj$c","_contexts$configObj$o","payActivate","_payActivate","_resContext","_t4","_context4","setStatus","id","code","email_list","valid_from","valid_to","days_count","discount_type","discount","active","timestamp","content_type","students","coupon","configObj","channel_username","API_HOST_URL","transaction","canceled","handleDBAction","calculateCouponDeduction","discounted","gatwayCharges","parseFloat","toFixed","paymentMethod","savedCardCharge","authorization","card_type","last4","payment_method_id","log","checkEmailInConfig","_ref5","_callee5","emailValue","_context5","getUserEmailInputModal","setCookie","handlePaymentWithoutUserData","_x5","_handlePaymentWithoutUserData","_callee7","_config$metadata","_dataset2","_discounted","_resContext2","_t5","_context7"],"mappings":"iVAqBO,IAAMA,EAAyB,sCA6BzBC,EAAqB,SAChCC,GAA6B,MACL,CACxBC,WAAW,IAAIC,MAAOC,UAAUC,WAChCC,MAAOL,EAAIK,MACXC,WAAYN,EAAIM,WAChBC,UAAWP,EAAIO,UACfC,OAAQC,KAAKC,MAAmB,IAAbV,EAAIQ,QACvBG,SAAUX,EAAIW,UAAY,MAC1BC,IAAKC,QAAQC,IAAIC,gCACjBC,aAAcC,OAAOC,SAASC,KAC9BC,SAAUpB,EAAIoB,SACf,EAyBYC,EAAmB,WAAA,IAAAC,EAAAC,EAAAC,IAAAC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