@ikas/storefront 6.1.0-beta.69 → 6.1.0-beta.70
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.
|
@@ -2,10 +2,6 @@ import * as React from "react";
|
|
|
2
2
|
import { IkasProduct } from "../../models";
|
|
3
3
|
declare type PaypalExpressCheckoutProps = {
|
|
4
4
|
product: IkasProduct;
|
|
5
|
-
layout?: "vertical" | "horizontal";
|
|
6
|
-
color?: "gold" | "blue" | "silver" | "white" | "black";
|
|
7
|
-
shape?: "rect" | "pill";
|
|
8
|
-
label?: "paypal" | "checkout" | "buynow" | "pay" | "installment" | "subscribe" | "donate";
|
|
9
5
|
errorMessage?: string;
|
|
10
6
|
quantity?: number;
|
|
11
7
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as
|
|
1
|
+
import{__awaiter as t,__generator as e,__assign as r}from'./../../ext/tslib/tslib.es6.js';import*as n from"react";import{observer as o}from"mobx-react-lite";import{IkasBaseStore as i}from"../../store/base.js";import"../../store/customer/index.js";import"../../store/cart/index.js";import a from"../../store/checkout/index.js";import{IkasStorefrontConfig as u}from"@ikas/storefront-config";import{getStorefrontSettings as s}from"@ikas/storefront-api";var c=o((function(o){var c=o.product,l=o.errorMessage,d=o.quantity,p=void 0===d?1:d,f=i.getInstance(),v=f.customerStore.customer,h=n.useState(""),m=h[0],g=h[1],y=n.useState(!1),w=y[0],b=y[1],S=n.useState(null),I=S[0],P=S[1],C=n.useRef(null),E=n.useRef(null),U=n.useRef(null),j=n.useRef(null),R=function(t){U.current=t};n.useEffect((function(){t(void 0,void 0,void 0,(function(){var t,r,n;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,a.getPayPalClientId({})];case 1:return t=e.sent(),g((null===(n=t.data)||void 0===n?void 0:n.clientId)||""),[3,3];case 2:return r=e.sent(),console.error("Error fetching Client ID:",r),[3,3];case 3:return[2]}}))}))}),[c]),n.useEffect((function(){t(void 0,void 0,void 0,(function(){var t,r,n,o;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,s()];case 1:return t=e.sent(),(null===(n=t.data)||void 0===n?void 0:n.paypalSettings)&&P(null===(o=t.data)||void 0===o?void 0:o.paypalSettings),[3,3];case 2:return r=e.sent(),console.error("getStorefrontSettings error",r),[3,3];case 3:return[2]}}))}))}),[]);var A=function(n){return t(void 0,void 0,void 0,(function(){var t,o,i;return e(this,(function(e){switch(e.label){case 0:return t=C.current,o=U.current,t&&o?(i=E.current,[4,a.updatePaypalOrder({input:r(r({cartId:o,transactionId:t,customer:v?{email:v.email,firstName:v.firstName,id:v.id,lastName:v.lastName}:null,address:i?{city:i.city,country:i.countryCode,postalCode:i.postalCode,state:i.state}:null},n.shippingSettingsId?{shippingSettingsId:n.shippingSettingsId}:{}),n.shippingZoneRateId?{shippingZoneRateId:n.shippingZoneRateId}:{})})]):[2,!1];case 1:return[2,!!e.sent().data]}}))}))},k=function(t){if(I)return I.find((function(e){return e.label===t}))};return n.useEffect((function(){if(m&&I){var n=k("productPageBuyButton");if(!n||"disabled"!==n.value){var o=document.querySelector("#paypal-button-container");o&&(o.innerHTML="");var i=document.querySelector('script[src^="https://www.paypal.com/sdk/js"]');i&&document.body.removeChild(i);var s=k("productColor"),l=k("productShape"),d=k("productLabel"),v=k("productTagline"),h=document.createElement("script");return h.src="https://www.paypal.com/sdk/js?client-id=".concat(m,"¤cy=").concat(c.selectedVariant.price.currency,"&disable-funding=credit,card"),h.setAttribute("data-page-type","product-details"),h.addEventListener("load",(function(){window.paypal&&window.paypal.Buttons({style:r(r(r(r({},s?{color:null==s?void 0:s.value}:{}),l?{shape:null==l?void 0:l.value}:{}),d?{label:null==d?void 0:d.value}:{}),v?{tagline:"true"===(null==v?void 0:v.value)}:{}),onClick:function(r,n){return t(void 0,void 0,void 0,(function(){return e(this,(function(r){switch(r.label){case 0:return[4,t(void 0,void 0,void 0,(function(){return e(this,(function(t){if(f.cartStore.cart)try{f.cartStore.removeCart()}catch(t){console.error("Error removing items:",t)}return[2]}))}))];case 1:return r.sent(),[2,n.resolve()]}}))}))},createOrder:function(){return t(void 0,void 0,void 0,(function(){var r,n,o,i,s;return e(this,(function(l){switch(l.label){case 0:return[4,t(void 0,void 0,void 0,(function(){var t,r,n,o,i;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,f.cartStore.addItem(c.selectedVariant,c,p)];case 1:return t=e.sent(),(null===(i=null===(o=t.response)||void 0===o?void 0:o.data)||void 0===i?void 0:i.id)?(r=t.response.data,R(r.id),[2,r.id]):[2,null];case 2:return n=e.sent(),console.log("err",n),[2,null];case 3:return[2]}}))}))];case 1:return l.sent(),[4,t(void 0,void 0,void 0,(function(){var t,r,n,o,i,s;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),t=u.getPaymentGateways().map((function(t){return t.id})),(r=U.current)?[4,a.listPaymentGateway({cartId:r,id:{in:t},locale:u.getCurrentLocale(),transactionAmount:c.selectedVariant.finalPrice})]:[2,null];case 1:return n=e.sent(),[2,(null===(s=null===(i=n.data)||void 0===i?void 0:i.find((function(t){return"PAYPAL"===t.code})))||void 0===s?void 0:s.id)||null];case 2:return o=e.sent(),console.error("Error fetching PayPal ID:",o),[2,null];case 3:return[2]}}))}))];case 2:return r=l.sent(),(n=U.current)&&r?[4,a.createPayPalOrder({input:{cartId:n,paymentGatewayId:r},isPayNow:!0})]:[3,4];case 3:return o=l.sent(),b(!1),R(n),(null===(i=o.data)||void 0===i?void 0:i.transactionId)&&(v=o.data.transactionId,C.current=v,d={failUrl:o.data.failUrl,returnUrl:o.data.returnUrl},j.current={failUrl:d.failUrl,returnUrl:d.returnUrl}),[2,null===(s=o.data)||void 0===s?void 0:s.sessionToken];case 4:console.log("err"),l.label=5;case 5:return[2]}var d,v}))}))},onShippingOptionsChange:function(r,n){return t(this,void 0,void 0,(function(){var t,o,i;return e(this,(function(e){switch(e.label){case 0:return console.log("selectedShippingOption",r),t=r.selectedShippingOption.id.split(":"),o=t[0],i=t[1],[4,A({shippingSettingsId:o,shippingZoneRateId:i})];case 1:return e.sent()?[2]:[2,n.reject()]}}))}))},onShippingAddressChange:function(r,n){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return console.log("SHIPPING_ADDRESS",r),function(t){E.current=t}(r.shippingAddress),[4,A({})];case 1:return t.sent()?[2]:[2,n.reject()]}}))}))},onApprove:function(r,n){return t(this,void 0,void 0,(function(){return e(this,(function(t){return[2,n.order.capture().then((function(t){console.log("data",r),console.log("details",t),console.log("urls",j),j.current&&(console.log("burda"),"COMPLETED"===t.status?window.location.href=j.current.returnUrl:window.location.href=window.location.href=j.current.failUrl)})).catch((function(t){return b(!0)}))]}))}))},onError:function(t){console.error("PayPal button error:",t)}}).render("#paypal-button-container")})),document.body.appendChild(h),function(){document.body.removeChild(h)}}}}),[m,c.id,I]),n.createElement("div",null,n.createElement("div",{id:"paypal-button-container"}),!!w&&!!l&&n.createElement("div",{className:"paypal__error__message"},l))}));export{c as PaypalExpressCheckout};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ikas/storefront",
|
|
3
|
-
"version": "6.1.0-beta.
|
|
3
|
+
"version": "6.1.0-beta.70",
|
|
4
4
|
"description": "Storefront functionality for ikas storefront themes.",
|
|
5
5
|
"author": "ikas",
|
|
6
6
|
"license": "ISC",
|
|
@@ -21,11 +21,11 @@
|
|
|
21
21
|
"swiper": "11.0.6"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@ikas/storefront-api": "^6.1.0-beta.
|
|
25
|
-
"@ikas/storefront-config": "^6.1.0-beta.
|
|
26
|
-
"@ikas/storefront-model-functions": "^6.1.0-beta.
|
|
27
|
-
"@ikas/storefront-models": "^6.1.0-beta.
|
|
28
|
-
"@ikas/storefront-providers": "^6.1.0-beta.
|
|
24
|
+
"@ikas/storefront-api": "^6.1.0-beta.70",
|
|
25
|
+
"@ikas/storefront-config": "^6.1.0-beta.70",
|
|
26
|
+
"@ikas/storefront-model-functions": "^6.1.0-beta.70",
|
|
27
|
+
"@ikas/storefront-models": "^6.1.0-beta.70",
|
|
28
|
+
"@ikas/storefront-providers": "^6.1.0-beta.70",
|
|
29
29
|
"@ikas/localized-address": "1.0.0-beta.6",
|
|
30
30
|
"@adyen/adyen-web": "^5.57.0",
|
|
31
31
|
"@rollup/plugin-commonjs": "^22.0.0",
|
|
@@ -60,11 +60,11 @@
|
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
62
62
|
"@ikas/localized-address": "1.0.0-beta.6",
|
|
63
|
-
"@ikas/storefront-api": "^6.1.0-beta.
|
|
64
|
-
"@ikas/storefront-config": "^6.1.0-beta.
|
|
65
|
-
"@ikas/storefront-model-functions": "^6.1.0-beta.
|
|
66
|
-
"@ikas/storefront-models": "^6.1.0-beta.
|
|
67
|
-
"@ikas/storefront-providers": "^6.1.0-beta.
|
|
63
|
+
"@ikas/storefront-api": "^6.1.0-beta.70",
|
|
64
|
+
"@ikas/storefront-config": "^6.1.0-beta.70",
|
|
65
|
+
"@ikas/storefront-model-functions": "^6.1.0-beta.70",
|
|
66
|
+
"@ikas/storefront-models": "^6.1.0-beta.70",
|
|
67
|
+
"@ikas/storefront-providers": "^6.1.0-beta.70",
|
|
68
68
|
"mobx": "^6.1.3",
|
|
69
69
|
"mobx-react-lite": "^3.1.5",
|
|
70
70
|
"next": "12.2.0",
|