@ikas/storefront 6.1.0-beta.60 → 6.1.0-beta.61

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.
@@ -6,6 +6,7 @@ declare type PaypalExpressCheckoutProps = {
6
6
  color?: "gold" | "blue" | "silver" | "white" | "black";
7
7
  shape?: "rect" | "pill";
8
8
  label?: "paypal" | "checkout" | "buynow" | "pay" | "installment" | "subscribe" | "donate";
9
+ errorMessage?: string;
9
10
  };
10
11
  export declare const PaypalExpressCheckout: React.FC<PaypalExpressCheckoutProps>;
11
12
  export {};
@@ -1 +1 @@
1
- import{__awaiter as t,__generator as e}from'./../../ext/tslib/tslib.es6.js';import*as n from"react";import{observer as r}from"mobx-react-lite";import{IkasBaseStore as o}from"../../store/base.js";import"../../store/customer/index.js";import"../../store/cart/index.js";import a from"../../store/checkout/index.js";import{IkasStorefrontConfig as i}from"@ikas/storefront-config";var c=r((function(r){var c=r.product,s=r.layout,d=r.color,u=r.shape,l=r.label,p=o.getInstance(),f=p.cartStore.cart,v=n.useState(""),m=v[0],y=v[1],h=n.useState(""),g=h[0],I=h[1],P=n.useState(""),w=P[0],b=P[1],E=n.useRef(null);return n.useEffect((function(){if(w){t(void 0,void 0,void 0,(function(){var t,n,r,o,s,d;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),t=i.getPaymentGateways().map((function(t){return t.id})),[4,a.listPaymentGateway({cartId:w,id:{in:t},locale:i.getCurrentLocale(),transactionAmount:c.selectedVariant.finalPrice})];case 1:return n=e.sent(),r=null===(d=null===(s=n.data)||void 0===s?void 0:s.find((function(t){return"PAYPAL"===t.code})))||void 0===d?void 0:d.id,I(r||""),[3,3];case 2:return o=e.sent(),console.error("Error fetching PayPal ID:",o),[3,3];case 3:return[2]}}))}))}}),[w,c.selectedVariant.finalPrice]),n.useEffect((function(){if(w&&g){t(void 0,void 0,void 0,(function(){var t,n,r;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,a.getPayPalClientId({input:{cartId:w,paymentGatewayId:g}})];case 1:return t=e.sent(),y((null===(r=t.data)||void 0===r?void 0:r.clientId)||""),[3,3];case 2:return n=e.sent(),console.error("Error fetching Client ID:",n),[3,3];case 3:return[2]}}))}))}}),[w,g]),n.useEffect((function(){f&&b(f.id)}),[null==f?void 0:f.id]),n.useEffect((function(){if(w&&g&&m){var n=document.createElement("script");return n.src="https://www.paypal.com/sdk/js?client-id=".concat(m,"&currency=").concat(c.selectedVariant.price.currency),n.setAttribute("data-page-type","product-details"),n.addEventListener("load",(function(){window.paypal&&window.paypal.Buttons({style:{layout:s,color:d,shape:u,label:l},createOrder:function(){return t(void 0,void 0,void 0,(function(){var t,n,r;return e(this,(function(e){switch(e.label){case 0:return[4,a.createPayPalOrder({input:{cartId:w,paymentGatewayId:g},isPayNow:!0})];case 1:return t=e.sent(),console.log("res",t.data),(null===(n=t.data)||void 0===n?void 0:n.transactionId)&&(o=t.data.transactionId,E.current=o),[2,null===(r=t.data)||void 0===r?void 0:r.sessionToken]}var o}))}))},onShippingOptionsChange:function(t){console.log("SELECTED_OPTION",t.selectedShippingOption)},onShippingAddressChange:function(n){return t(this,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:return console.log("SHIPPING_ADDRESS",n),t=E.current,console.log("Transaction ID (Ref):",t),t?[4,a.updatePaypalOrder({input:{cartId:w,transactionId:t}})]:[2];case 1:return r=e.sent(),console.log("updatePaypalResponse",r),[2]}}))}))},onApprove:function(t,e){return e.order.capture().then((function(e){console.log("data",t),console.log("details",e)}))}}).render("#paypal-button-container")})),document.body.appendChild(n),function(){document.body.removeChild(n)}}}),[m]),n.createElement("div",null,n.createElement("div",{id:"paypal-button-container"}),n.createElement("div",{onClick:function(){return t(void 0,void 0,void 0,(function(){var t,n,r,o;return e(this,(function(e){switch(e.label){case 0:return[4,p.cartStore.addItem(c.selectedVariant,c)];case 1:return t=e.sent(),(null===(o=null===(r=t.response)||void 0===r?void 0:r.data)||void 0===o?void 0:o.id)?(n=t.response.data,b(n.id),[2]):[2]}}))}))}},"paypal"))}));export{c as PaypalExpressCheckout};
1
+ import{__awaiter as t,__generator as e,__assign as n}from'./../../ext/tslib/tslib.es6.js';import*as r from"react";import{observer as i}from"mobx-react-lite";import{IkasBaseStore as o}from"../../store/base.js";import"../../store/customer/index.js";import"../../store/cart/index.js";import a from"../../store/checkout/index.js";import{IkasStorefrontConfig as s}from"@ikas/storefront-config";var c=i((function(i){var c=i.product,u=i.layout,l=i.color,d=i.shape,p=i.label,f=i.errorMessage,v=o.getInstance(),h=v.cartStore.cart,m=v.customerStore.customer,g=r.useState(""),y=g[0],w=g[1],I=r.useState(""),b=I[0],P=I[1],S=r.useState(""),E=S[0],C=S[1],U=r.useState(!1),j=U[0],A=U[1],R=r.useRef(null),N=r.useRef(null),O=r.useRef(null);r.useEffect((function(){if(E){t(void 0,void 0,void 0,(function(){var t,n,r,i,o,u;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),t=s.getPaymentGateways().map((function(t){return t.id})),[4,a.listPaymentGateway({cartId:E,id:{in:t},locale:s.getCurrentLocale(),transactionAmount:c.selectedVariant.finalPrice})];case 1:return n=e.sent(),r=null===(u=null===(o=n.data)||void 0===o?void 0:o.find((function(t){return"PAYPAL"===t.code})))||void 0===u?void 0:u.id,P(r||""),[3,3];case 2:return i=e.sent(),console.error("Error fetching PayPal ID:",i),[3,3];case 3:return[2]}}))}))}}),[E,c.selectedVariant.finalPrice]),r.useEffect((function(){if(E&&b){t(void 0,void 0,void 0,(function(){var t,n,r;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,a.getPayPalClientId({input:{cartId:E,paymentGatewayId:b}})];case 1:return t=e.sent(),w((null===(r=t.data)||void 0===r?void 0:r.clientId)||""),[3,3];case 2:return n=e.sent(),console.error("Error fetching Client ID:",n),[3,3];case 3:return[2]}}))}))}}),[E,b]),r.useEffect((function(){h&&C(h.id)}),[null==h?void 0:h.id]);var _=function(r){return t(void 0,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return(t=R.current)?(i=N.current,[4,a.updatePaypalOrder({input:n(n({cartId:E,transactionId:t,customer:m?{email:m.email,firstName:m.firstName,id:m.id,lastName:m.lastName}:null,address:i?{city:i.city,country:i.countryCode,postalCode:i.postalCode,state:i.state}:null},r.shippingSettingsId?{shippingSettingsId:r.shippingSettingsId}:{}),r.shippingZoneRateId?{shippingZoneRateId:r.shippingZoneRateId}:{})})]):[2,!1];case 1:return[2,!!e.sent().data]}}))}))};return r.useEffect((function(){if(E&&b&&y){var n=document.createElement("script");return n.src="https://www.paypal.com/sdk/js?client-id=".concat(y,"&currency=").concat(c.selectedVariant.price.currency),n.setAttribute("data-page-type","product-details"),n.addEventListener("load",(function(){window.paypal&&window.paypal.Buttons({style:{layout:u,color:l,shape:d,label:p},createOrder:function(){return t(void 0,void 0,void 0,(function(){var t,n,r;return e(this,(function(e){switch(e.label){case 0:return[4,a.createPayPalOrder({input:{cartId:E,paymentGatewayId:b},isPayNow:!0})];case 1:return t=e.sent(),A(!1),(null===(n=t.data)||void 0===n?void 0:n.transactionId)&&(o=t.data.transactionId,R.current=o,i={failUrl:t.data.failUrl,returnUrl:t.data.returnUrl},O.current={failUrl:i.failUrl,returnUrl:i.returnUrl}),[2,null===(r=t.data)||void 0===r?void 0:r.sessionToken]}var i,o}))}))},onShippingOptionsChange:function(n,r){return t(this,void 0,void 0,(function(){var t,i,o;return e(this,(function(e){switch(e.label){case 0:return console.log("selectedShippingOption",n),t=n.selectedShippingOption.id.split(":"),i=t[0],o=t[1],[4,_({shippingSettingsId:i,shippingZoneRateId:o})];case 1:return e.sent()?[2]:[2,r.reject()]}}))}))},onShippingAddressChange:function(n,r){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return console.log("SHIPPING_ADDRESS",n),function(t){N.current=t}(n.shippingAddress),[4,_({})];case 1:return t.sent()?[2]:[2,r.reject()]}}))}))},onApprove:function(n,r){return t(this,void 0,void 0,(function(){return e(this,(function(t){return[2,r.order.capture().then((function(t){console.log("data",n),console.log("details",t),console.log("urls",O),O.current&&(console.log("burda"),"COMPLETED"===t.status?window.location.href=O.current.returnUrl:window.location.href=window.location.href=O.current.failUrl)})).catch((function(t){return A(!0)}))]}))}))},onError:function(t){console.error("PayPal button error:",t)}}).render("#paypal-button-container")})),document.body.appendChild(n),function(){document.body.removeChild(n)}}}),[y]),r.createElement("div",null,r.createElement("div",{id:"paypal-button-container"}),!E&&r.createElement("div",{onClick:function(){return t(void 0,void 0,void 0,(function(){var t,n,r,i;return e(this,(function(e){switch(e.label){case 0:return[4,v.cartStore.addItem(c.selectedVariant,c)];case 1:return t=e.sent(),(null===(i=null===(r=t.response)||void 0===r?void 0:r.data)||void 0===i?void 0:i.id)?(n=t.response.data,C(n.id),[2]):[2]}}))}))}},"Paypal Button ******"),!!j&&!!f&&r.createElement("div",{className:"paypal__error__message"},f))}));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.60",
3
+ "version": "6.1.0-beta.61",
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.60",
25
- "@ikas/storefront-config": "^6.1.0-beta.60",
26
- "@ikas/storefront-model-functions": "^6.1.0-beta.60",
27
- "@ikas/storefront-models": "^6.1.0-beta.60",
28
- "@ikas/storefront-providers": "^6.1.0-beta.60",
24
+ "@ikas/storefront-api": "^6.1.0-beta.61",
25
+ "@ikas/storefront-config": "^6.1.0-beta.61",
26
+ "@ikas/storefront-model-functions": "^6.1.0-beta.61",
27
+ "@ikas/storefront-models": "^6.1.0-beta.61",
28
+ "@ikas/storefront-providers": "^6.1.0-beta.61",
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.60",
64
- "@ikas/storefront-config": "^6.1.0-beta.60",
65
- "@ikas/storefront-model-functions": "^6.1.0-beta.60",
66
- "@ikas/storefront-models": "^6.1.0-beta.60",
67
- "@ikas/storefront-providers": "^6.1.0-beta.60",
63
+ "@ikas/storefront-api": "^6.1.0-beta.61",
64
+ "@ikas/storefront-config": "^6.1.0-beta.61",
65
+ "@ikas/storefront-model-functions": "^6.1.0-beta.61",
66
+ "@ikas/storefront-models": "^6.1.0-beta.61",
67
+ "@ikas/storefront-providers": "^6.1.0-beta.61",
68
68
  "mobx": "^6.1.3",
69
69
  "mobx-react-lite": "^3.1.5",
70
70
  "next": "12.2.0",