@depay/widgets 7.15.3 → 7.16.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/esm/index.js CHANGED
@@ -19323,30 +19323,34 @@ var PaymentProvider = (function (props) {
19323
19323
  switch (_context.prev = _context.next) {
19324
19324
  case 0:
19325
19325
  if (!before) {
19326
- _context.next = 4;
19326
+ _context.next = 6;
19327
19327
  break;
19328
19328
  }
19329
19329
 
19330
- stop = before(payment.route.transaction);
19330
+ _context.next = 3;
19331
+ return before(payment.route.transaction);
19332
+
19333
+ case 3:
19334
+ stop = _context.sent;
19331
19335
 
19332
19336
  if (!(stop === false)) {
19333
- _context.next = 4;
19337
+ _context.next = 6;
19334
19338
  break;
19335
19339
  }
19336
19340
 
19337
19341
  return _context.abrupt("return");
19338
19342
 
19339
- case 4:
19343
+ case 6:
19340
19344
  setClosable(false);
19341
19345
  setPaymentState('paying');
19342
19346
  setUpdatable(false);
19343
- _context.next = 9;
19347
+ _context.next = 11;
19344
19348
  return request({
19345
19349
  blockchain: payment.route.transaction.blockchain,
19346
19350
  method: 'latestBlockNumber'
19347
19351
  });
19348
19352
 
19349
- case 9:
19353
+ case 11:
19350
19354
  currentBlock = _context.sent;
19351
19355
  wallet.sendTransaction(Object.assign({}, payment.route.transaction, {
19352
19356
  sent: function sent(transaction) {
@@ -19372,7 +19376,7 @@ var PaymentProvider = (function (props) {
19372
19376
  }
19373
19377
  });
19374
19378
 
19375
- case 11:
19379
+ case 13:
19376
19380
  case "end":
19377
19381
  return _context.stop();
19378
19382
  }
@@ -20620,19 +20624,6 @@ var DonationOverviewSkeleton = (function (props) {
20620
20624
  });
20621
20625
  });
20622
20626
 
20623
- var AlertIcon = (function (props) {
20624
- return /*#__PURE__*/React.createElement("svg", {
20625
- className: "AlertIcon Icon " + props.className,
20626
- version: "1.1",
20627
- xmlns: "http://www.w3.org/2000/svg",
20628
- x: "0px",
20629
- y: "0px",
20630
- viewBox: "0 0 20 20"
20631
- }, /*#__PURE__*/React.createElement("path", {
20632
- d: "M19.64 16.36L11.53 2.3A1.85 1.85 0 0 0 10 1.21 1.85 1.85 0 0 0 8.48 2.3L.36 16.36C-.48 17.81.21 19 1.88 19h16.24c1.67 0 2.36-1.19 1.52-2.64zM11 16H9v-2h2zm0-4H9V6h2z"
20633
- }));
20634
- });
20635
-
20636
20627
  var Checkmark = (function (props) {
20637
20628
  return /*#__PURE__*/React.createElement("svg", {
20638
20629
  className: "Checkmark Icon " + props.className,
@@ -20707,8 +20698,7 @@ var Footer = (function () {
20707
20698
  var _useContext2 = useContext(PaymentTrackingContext),
20708
20699
  tracking = _useContext2.tracking,
20709
20700
  release = _useContext2.release,
20710
- forwardTo = _useContext2.forwardTo,
20711
- trackingFailed = _useContext2.trackingFailed;
20701
+ forwardTo = _useContext2.forwardTo;
20712
20702
 
20713
20703
  var _useContext3 = useContext(PaymentContext),
20714
20704
  payment = _useContext3.payment,
@@ -20755,37 +20745,21 @@ var Footer = (function () {
20755
20745
  className: "Opacity05"
20756
20746
  }, "Payment validated")))));
20757
20747
  } else {
20758
- if (trackingFailed) {
20759
- return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
20760
- className: "Card transparent small"
20761
- }, /*#__PURE__*/React.createElement("div", {
20762
- className: "CardImage"
20763
- }, /*#__PURE__*/React.createElement("div", {
20764
- className: "TextCenter"
20765
- }, /*#__PURE__*/React.createElement(AlertIcon, {
20766
- className: "small"
20767
- }))), /*#__PURE__*/React.createElement("div", {
20768
- className: "CardBody"
20769
- }, /*#__PURE__*/React.createElement("div", {
20770
- className: "CardBodyWrapper"
20771
- }, /*#__PURE__*/React.createElement("div", null, "Tracking payment failed!")))));
20772
- } else {
20773
- return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
20774
- className: "Card transparent small disabled"
20775
- }, /*#__PURE__*/React.createElement("div", {
20776
- className: "CardImage"
20777
- }, /*#__PURE__*/React.createElement("div", {
20778
- className: "TextCenter"
20779
- }, /*#__PURE__*/React.createElement("div", {
20780
- className: "Loading Icon"
20781
- }))), /*#__PURE__*/React.createElement("div", {
20782
- className: "CardBody"
20783
- }, /*#__PURE__*/React.createElement("div", {
20784
- className: "CardBodyWrapper"
20785
- }, /*#__PURE__*/React.createElement("div", {
20786
- className: "Opacity05"
20787
- }, "Validating payment")))));
20788
- }
20748
+ return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
20749
+ className: "Card transparent small disabled"
20750
+ }, /*#__PURE__*/React.createElement("div", {
20751
+ className: "CardImage"
20752
+ }, /*#__PURE__*/React.createElement("div", {
20753
+ className: "TextCenter"
20754
+ }, /*#__PURE__*/React.createElement("div", {
20755
+ className: "Loading Icon"
20756
+ }))), /*#__PURE__*/React.createElement("div", {
20757
+ className: "CardBody"
20758
+ }, /*#__PURE__*/React.createElement("div", {
20759
+ className: "CardBodyWrapper"
20760
+ }, /*#__PURE__*/React.createElement("div", {
20761
+ className: "Opacity05"
20762
+ }, "Validating payment")))));
20789
20763
  }
20790
20764
  };
20791
20765
 
@@ -21168,8 +21142,8 @@ var NavigateProvider = (function (props) {
21168
21142
  });
21169
21143
 
21170
21144
  var PaymentTrackingProvider = (function (props) {
21171
- var _useContext = useContext(ErrorContext),
21172
- errorCallback = _useContext.errorCallback;
21145
+ var _useContext = useContext(ErrorContext);
21146
+ _useContext.errorCallback;
21173
21147
 
21174
21148
  var _useContext2 = useContext(ConfigurationContext),
21175
21149
  track = _useContext2.track,
@@ -21206,20 +21180,16 @@ var PaymentTrackingProvider = (function (props) {
21206
21180
  release = _useState12[0],
21207
21181
  setRelease = _useState12[1];
21208
21182
 
21209
- var _useState13 = useState(false),
21183
+ var _useState13 = useState(),
21210
21184
  _useState14 = _slicedToArray(_useState13, 2),
21211
- trackingFailed = _useState14[0],
21212
- setTrackingFailed = _useState14[1];
21213
-
21214
- var _useState15 = useState(),
21215
- _useState16 = _slicedToArray(_useState15, 2),
21216
- forwardTo = _useState16[0],
21217
- setForwardTo = _useState16[1];
21185
+ forwardTo = _useState14[0],
21186
+ setForwardTo = _useState14[1];
21218
21187
 
21219
21188
  var _useContext3 = useContext(ClosableContext),
21220
21189
  setClosable = _useContext3.setClosable;
21221
21190
 
21222
21191
  var _useContext4 = useContext(NavigateContext),
21192
+ navigate = _useContext4.navigate,
21223
21193
  set = _useContext4.set;
21224
21194
 
21225
21195
  var openSocket = function openSocket(transaction) {
@@ -21277,23 +21247,23 @@ var PaymentTrackingProvider = (function (props) {
21277
21247
 
21278
21248
  var retryStartTracking = function retryStartTracking(transaction, afterBlock, paymentRoute, attempt) {
21279
21249
  attempt = parseInt(attempt || 1, 10);
21250
+ console.log('attempt', attempt);
21251
+ console.log('track.attempts', track === null || track === void 0 ? void 0 : track.attempts);
21280
21252
 
21281
- if (attempt < 3) {
21253
+ if (attempt < ((track === null || track === void 0 ? void 0 : track.attempts) || 40)) {
21282
21254
  setTimeout(function () {
21283
21255
  startTracking(transaction, afterBlock, paymentRoute, attempt + 1);
21284
21256
  }, 3000);
21285
21257
  } else {
21286
- console.log('PAYMENT TRACKING FAILED AFTER 3 ATTEMPTS!');
21287
- setTrackingFailed(true);
21288
-
21289
- if (typeof errorCallback == 'function') {
21290
- errorCallback({
21291
- code: 'TRACKING_FAILED'
21292
- });
21293
- }
21258
+ console.log('navigate TrackingFailed');
21259
+ navigate('TrackingFailed');
21294
21260
  }
21295
21261
  };
21296
21262
 
21263
+ var continueTryTracking = function continueTryTracking() {
21264
+ retryStartTracking(transaction, afterBlock, paymentRoute, 1);
21265
+ };
21266
+
21297
21267
  var callTracking = function callTracking(payment) {
21298
21268
  if (track.endpoint) {
21299
21269
  return fetch(track.endpoint, {
@@ -21400,10 +21370,6 @@ var PaymentTrackingProvider = (function (props) {
21400
21370
  }, [polling, transaction, afterBlock, paymentRoute]);
21401
21371
 
21402
21372
  var storePayment = function storePayment(transaction, afterBlock, paymentRoute, attempt) {
21403
- if (attempt > 3) {
21404
- return;
21405
- }
21406
-
21407
21373
  fetch('https://public.depay.com/payments', {
21408
21374
  headers: {
21409
21375
  'Content-Type': 'application/json'
@@ -21434,18 +21400,18 @@ var PaymentTrackingProvider = (function (props) {
21434
21400
  }).then(function (response) {
21435
21401
  if (response.status == 200 || response.status == 201) ; else {
21436
21402
  setTimeout(function () {
21437
- storePayment(transaction, afterBlock, paymentRoute, attempt + 1);
21403
+ storePayment(transaction, afterBlock, paymentRoute);
21438
21404
  }, 3000);
21439
21405
  }
21440
21406
  })["catch"](function (error) {
21441
21407
  setTimeout(function () {
21442
- storePayment(transaction, afterBlock, paymentRoute, attempt + 1);
21408
+ storePayment(transaction, afterBlock, paymentRoute);
21443
21409
  }, 3000);
21444
21410
  });
21445
21411
  };
21446
21412
 
21447
21413
  var initializeTracking = function initializeTracking(transaction, afterBlock, paymentRoute) {
21448
- storePayment(transaction, afterBlock, paymentRoute, 1);
21414
+ storePayment(transaction, afterBlock, paymentRoute);
21449
21415
 
21450
21416
  if (tracking || track && track.async == true) {
21451
21417
  startTracking(transaction, afterBlock, paymentRoute);
@@ -21465,9 +21431,9 @@ var PaymentTrackingProvider = (function (props) {
21465
21431
  value: {
21466
21432
  tracking: tracking,
21467
21433
  initializeTracking: initializeTracking,
21434
+ continueTryTracking: continueTryTracking,
21468
21435
  release: release,
21469
- forwardTo: forwardTo,
21470
- trackingFailed: trackingFailed
21436
+ forwardTo: forwardTo
21471
21437
  }
21472
21438
  }, props.children);
21473
21439
  });
@@ -22163,6 +22129,54 @@ var PaymentOverviewDialog = (function (props) {
22163
22129
  });
22164
22130
  });
22165
22131
 
22132
+ var TrackingFailedDialog = (function () {
22133
+ var _useContext = useContext(PaymentTrackingContext),
22134
+ continueTryTracking = _useContext.continueTryTracking;
22135
+
22136
+ var _useContext2 = useContext(PaymentContext),
22137
+ transaction = _useContext2.transaction;
22138
+
22139
+ var _useContext3 = useContext(NavigateStackContext),
22140
+ navigate = _useContext3.navigate;
22141
+
22142
+ var tryAgain = function tryAgain() {
22143
+ continueTryTracking();
22144
+ navigate('back');
22145
+ };
22146
+
22147
+ return /*#__PURE__*/React.createElement(Dialog$1, {
22148
+ stacked: false,
22149
+ header: /*#__PURE__*/React.createElement("div", {
22150
+ className: "PaddingTopS PaddingLeftM PaddingRightM"
22151
+ }),
22152
+ body: /*#__PURE__*/React.createElement("div", {
22153
+ className: "TextCenter"
22154
+ }, /*#__PURE__*/React.createElement("div", {
22155
+ className: "GraphicWrapper"
22156
+ }, /*#__PURE__*/React.createElement("img", {
22157
+ className: "Graphic",
22158
+ src: ErrorGraphic
22159
+ })), /*#__PURE__*/React.createElement("h1", {
22160
+ className: "LineHeightL Text FontSizeL PaddingTopS FontWeightBold"
22161
+ }, "Tracking payment failed"), /*#__PURE__*/React.createElement("div", {
22162
+ className: "Text PaddingTopS PaddingBottomS PaddingLeftS PaddingRightS"
22163
+ }, /*#__PURE__*/React.createElement("strong", {
22164
+ className: "FontSizeM"
22165
+ }, "Please ensure you are connected to the internet, then click \"Try again\"."), /*#__PURE__*/React.createElement("div", {
22166
+ className: "PaddingTopS"
22167
+ }, /*#__PURE__*/React.createElement("span", null, "If this keeps happening, "), /*#__PURE__*/React.createElement("a", {
22168
+ className: "Link",
22169
+ href: "mailto:support@depay.com?subject=Payment%20tracking%20failed&body=Tracking%20my%20payment%20failed%0A%0ATransaction:%20".concat(transaction.url)
22170
+ }, "please report it"), "."))),
22171
+ footer: /*#__PURE__*/React.createElement("div", {
22172
+ className: "PaddingTopXS PaddingRightM PaddingLeftM PaddingBottomM"
22173
+ }, /*#__PURE__*/React.createElement("button", {
22174
+ className: "ButtonPrimary",
22175
+ onClick: tryAgain
22176
+ }, "Try again"))
22177
+ });
22178
+ });
22179
+
22166
22180
  var PaymentStack = (function (props) {
22167
22181
  var _useContext = useContext(ClosableContext),
22168
22182
  open = _useContext.open,
@@ -22183,7 +22197,8 @@ var PaymentStack = (function (props) {
22183
22197
  ChangeAmount: /*#__PURE__*/React.createElement(ChangeAmountDialog, null),
22184
22198
  ChangePayment: /*#__PURE__*/React.createElement(ChangePaymentDialog, null),
22185
22199
  PaymentError: /*#__PURE__*/React.createElement(PaymentErrorDialog, null),
22186
- WrongNetwork: /*#__PURE__*/React.createElement(WrongNetworkDialog, null)
22200
+ WrongNetwork: /*#__PURE__*/React.createElement(WrongNetworkDialog, null),
22201
+ TrackingFailed: /*#__PURE__*/React.createElement(TrackingFailedDialog, null)
22187
22202
  }
22188
22203
  });
22189
22204
  });