authscape 1.0.334 → 1.0.336
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/index.js +78 -56
- package/package.json +1 -1
- package/src/components/stripe/StripePayment.js +31 -14
package/index.js
CHANGED
|
@@ -2937,6 +2937,7 @@ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefine
|
|
|
2937
2937
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
2938
2938
|
var CheckoutForm = function CheckoutForm(_ref) {
|
|
2939
2939
|
var payButtonText = _ref.payButtonText,
|
|
2940
|
+
invoiceId = _ref.invoiceId,
|
|
2940
2941
|
clientSecret = _ref.clientSecret,
|
|
2941
2942
|
currentUser = _ref.currentUser,
|
|
2942
2943
|
paymentMethodType = _ref.paymentMethodType,
|
|
@@ -2955,7 +2956,7 @@ var CheckoutForm = function CheckoutForm(_ref) {
|
|
|
2955
2956
|
setErrorMessage = _useState4[1];
|
|
2956
2957
|
var handleSubmit = /*#__PURE__*/function () {
|
|
2957
2958
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(event) {
|
|
2958
|
-
var _yield$stripe$confirm, error, response, setupIntent, addPaymentMethodResponse, _response, _yield$stripe$confirm2, _error,
|
|
2959
|
+
var _yield$stripe$confirm, error, response, setupIntent, addPaymentMethodResponse, _response, _response2, _yield$stripe$confirm2, _error, _response3, paymentIntent;
|
|
2959
2960
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
2960
2961
|
while (1) switch (_context.prev = _context.next) {
|
|
2961
2962
|
case 0:
|
|
@@ -2971,7 +2972,7 @@ var CheckoutForm = function CheckoutForm(_ref) {
|
|
|
2971
2972
|
return _context.abrupt("return");
|
|
2972
2973
|
case 4:
|
|
2973
2974
|
if (!(amount == null || currentUser != null)) {
|
|
2974
|
-
_context.next =
|
|
2975
|
+
_context.next = 54;
|
|
2975
2976
|
break;
|
|
2976
2977
|
}
|
|
2977
2978
|
_context.next = 7;
|
|
@@ -2995,7 +2996,7 @@ var CheckoutForm = function CheckoutForm(_ref) {
|
|
|
2995
2996
|
// details incomplete)
|
|
2996
2997
|
setIsPaymentProcessing(false);
|
|
2997
2998
|
setErrorMessage(error.message);
|
|
2998
|
-
_context.next =
|
|
2999
|
+
_context.next = 52;
|
|
2999
3000
|
break;
|
|
3000
3001
|
case 14:
|
|
3001
3002
|
// Your customer will be redirected to your `return_url`. For some payment
|
|
@@ -3009,7 +3010,7 @@ var CheckoutForm = function CheckoutForm(_ref) {
|
|
|
3009
3010
|
response = _context.sent;
|
|
3010
3011
|
setupIntent = response.setupIntent;
|
|
3011
3012
|
_context.t0 = setupIntent.status;
|
|
3012
|
-
_context.next = _context.t0 === 'succeeded' ? 22 : _context.t0 === 'processing' ?
|
|
3013
|
+
_context.next = _context.t0 === 'succeeded' ? 22 : _context.t0 === 'processing' ? 43 : _context.t0 === 'requires_payment_method' ? 46 : 49;
|
|
3013
3014
|
break;
|
|
3014
3015
|
case 22:
|
|
3015
3016
|
_context.next = 24;
|
|
@@ -3021,51 +3022,70 @@ var CheckoutForm = function CheckoutForm(_ref) {
|
|
|
3021
3022
|
case 24:
|
|
3022
3023
|
addPaymentMethodResponse = _context.sent;
|
|
3023
3024
|
if (!(addPaymentMethodResponse != null && addPaymentMethodResponse.status == 200)) {
|
|
3024
|
-
_context.next =
|
|
3025
|
+
_context.next = 41;
|
|
3025
3026
|
break;
|
|
3026
3027
|
}
|
|
3027
3028
|
onResponse("succeeded", setupIntent.id, setupIntent.payment_method);
|
|
3028
3029
|
if (!(amount != null)) {
|
|
3029
|
-
_context.next =
|
|
3030
|
+
_context.next = 39;
|
|
3030
3031
|
break;
|
|
3031
3032
|
}
|
|
3032
|
-
|
|
3033
|
+
if (!(invoiceId != null)) {
|
|
3034
|
+
_context.next = 35;
|
|
3035
|
+
break;
|
|
3036
|
+
}
|
|
3037
|
+
_context.next = 31;
|
|
3038
|
+
return apiService().post("/Invoices/PayInvoice", {
|
|
3039
|
+
invoiceId: invoiceId,
|
|
3040
|
+
walletPaymentMethodId: addPaymentMethodResponse.data
|
|
3041
|
+
});
|
|
3042
|
+
case 31:
|
|
3043
|
+
_response = _context.sent;
|
|
3044
|
+
if (_response != null && _response.status == 200) {
|
|
3045
|
+
onResponse("paid", null);
|
|
3046
|
+
} else {
|
|
3047
|
+
onResponse("failed", null);
|
|
3048
|
+
}
|
|
3049
|
+
_context.next = 39;
|
|
3050
|
+
break;
|
|
3051
|
+
case 35:
|
|
3052
|
+
_context.next = 37;
|
|
3033
3053
|
return apiService().post("/Payment/Charge", {
|
|
3034
3054
|
paymentMethodType: paymentMethodType,
|
|
3035
3055
|
walletPaymentMethodId: addPaymentMethodResponse.data,
|
|
3036
3056
|
amount: amount
|
|
3037
3057
|
});
|
|
3038
|
-
case
|
|
3039
|
-
|
|
3040
|
-
if (
|
|
3041
|
-
onResponse("paid",
|
|
3058
|
+
case 37:
|
|
3059
|
+
_response2 = _context.sent;
|
|
3060
|
+
if (_response2 != null && _response2.status == 200) {
|
|
3061
|
+
onResponse("paid", _response2.data.stripePaymentIntentId);
|
|
3042
3062
|
} else {
|
|
3043
3063
|
onResponse("failed", null);
|
|
3044
3064
|
}
|
|
3045
|
-
case
|
|
3046
|
-
_context.next =
|
|
3065
|
+
case 39:
|
|
3066
|
+
_context.next = 42;
|
|
3047
3067
|
break;
|
|
3048
|
-
case
|
|
3068
|
+
case 41:
|
|
3049
3069
|
onResponse("failed", null);
|
|
3050
|
-
case
|
|
3051
|
-
return _context.abrupt("break",
|
|
3052
|
-
case
|
|
3070
|
+
case 42:
|
|
3071
|
+
return _context.abrupt("break", 52);
|
|
3072
|
+
case 43:
|
|
3053
3073
|
onResponse("processing", setupIntent.id, setupIntent.payment_method);
|
|
3054
3074
|
setIsPaymentProcessing(false);
|
|
3055
|
-
return _context.abrupt("break",
|
|
3056
|
-
case
|
|
3075
|
+
return _context.abrupt("break", 52);
|
|
3076
|
+
case 46:
|
|
3057
3077
|
onResponse("requires_payment_method", null);
|
|
3058
3078
|
setIsPaymentProcessing(false);
|
|
3059
|
-
return _context.abrupt("break",
|
|
3060
|
-
case
|
|
3079
|
+
return _context.abrupt("break", 52);
|
|
3080
|
+
case 49:
|
|
3061
3081
|
onResponse("failed", null);
|
|
3062
3082
|
setIsPaymentProcessing(false);
|
|
3063
|
-
return _context.abrupt("break",
|
|
3064
|
-
case
|
|
3065
|
-
_context.next =
|
|
3083
|
+
return _context.abrupt("break", 52);
|
|
3084
|
+
case 52:
|
|
3085
|
+
_context.next = 88;
|
|
3066
3086
|
break;
|
|
3067
|
-
case
|
|
3068
|
-
_context.next =
|
|
3087
|
+
case 54:
|
|
3088
|
+
_context.next = 56;
|
|
3069
3089
|
return stripe.confirmPayment({
|
|
3070
3090
|
//`Elements` instance that was used to create the Payment Element
|
|
3071
3091
|
elements: elements,
|
|
@@ -3074,11 +3094,11 @@ var CheckoutForm = function CheckoutForm(_ref) {
|
|
|
3074
3094
|
return_url: process.env.websiteBaseUri + '/confirmPayment?redirectUrl=' + encodeURIComponent(window.location.search)
|
|
3075
3095
|
}
|
|
3076
3096
|
});
|
|
3077
|
-
case
|
|
3097
|
+
case 56:
|
|
3078
3098
|
_yield$stripe$confirm2 = _context.sent;
|
|
3079
3099
|
_error = _yield$stripe$confirm2.error;
|
|
3080
3100
|
if (!_error) {
|
|
3081
|
-
_context.next =
|
|
3101
|
+
_context.next = 63;
|
|
3082
3102
|
break;
|
|
3083
3103
|
}
|
|
3084
3104
|
// This point will only be reached if there is an immediate error when
|
|
@@ -3086,50 +3106,50 @@ var CheckoutForm = function CheckoutForm(_ref) {
|
|
|
3086
3106
|
// details incomplete)
|
|
3087
3107
|
setIsPaymentProcessing(false);
|
|
3088
3108
|
setErrorMessage(_error.message);
|
|
3089
|
-
_context.next =
|
|
3109
|
+
_context.next = 88;
|
|
3090
3110
|
break;
|
|
3091
|
-
case
|
|
3111
|
+
case 63:
|
|
3092
3112
|
// Your customer will be redirected to your `return_url`. For some payment
|
|
3093
3113
|
// methods like iDEAL, your customer will be redirected to an intermediate
|
|
3094
3114
|
// site first to authorize the payment, then redirected to the `return_url`.
|
|
3095
|
-
|
|
3115
|
+
_response3 = null;
|
|
3096
3116
|
if (!(amount == null)) {
|
|
3097
|
-
_context.next =
|
|
3117
|
+
_context.next = 70;
|
|
3098
3118
|
break;
|
|
3099
3119
|
}
|
|
3100
|
-
_context.next =
|
|
3120
|
+
_context.next = 67;
|
|
3101
3121
|
return stripe.retrieveSetupIntent(clientSecret);
|
|
3102
|
-
case
|
|
3103
|
-
|
|
3104
|
-
_context.next =
|
|
3122
|
+
case 67:
|
|
3123
|
+
_response3 = _context.sent;
|
|
3124
|
+
_context.next = 73;
|
|
3105
3125
|
break;
|
|
3106
|
-
case
|
|
3107
|
-
_context.next =
|
|
3126
|
+
case 70:
|
|
3127
|
+
_context.next = 72;
|
|
3108
3128
|
return stripe.retrievePaymentIntent(clientSecret);
|
|
3109
|
-
case
|
|
3110
|
-
|
|
3111
|
-
case
|
|
3112
|
-
paymentIntent =
|
|
3129
|
+
case 72:
|
|
3130
|
+
_response3 = _context.sent;
|
|
3131
|
+
case 73:
|
|
3132
|
+
paymentIntent = _response3.paymentIntent;
|
|
3113
3133
|
_context.t1 = paymentIntent.status;
|
|
3114
|
-
_context.next = _context.t1 === 'succeeded' ?
|
|
3134
|
+
_context.next = _context.t1 === 'succeeded' ? 77 : _context.t1 === 'processing' ? 79 : _context.t1 === 'requires_payment_method' ? 82 : 85;
|
|
3115
3135
|
break;
|
|
3116
|
-
case
|
|
3136
|
+
case 77:
|
|
3117
3137
|
// need to store the payment intent with the customer if they are logged in... currentUser
|
|
3118
3138
|
onResponse("succeeded", paymentIntent.id);
|
|
3119
|
-
return _context.abrupt("break",
|
|
3120
|
-
case
|
|
3139
|
+
return _context.abrupt("break", 88);
|
|
3140
|
+
case 79:
|
|
3121
3141
|
onResponse("processing", paymentIntent.id);
|
|
3122
3142
|
setIsPaymentProcessing(false);
|
|
3123
|
-
return _context.abrupt("break",
|
|
3124
|
-
case
|
|
3143
|
+
return _context.abrupt("break", 88);
|
|
3144
|
+
case 82:
|
|
3125
3145
|
onResponse("requires_payment_method", null);
|
|
3126
3146
|
setIsPaymentProcessing(false);
|
|
3127
|
-
return _context.abrupt("break",
|
|
3128
|
-
case
|
|
3147
|
+
return _context.abrupt("break", 88);
|
|
3148
|
+
case 85:
|
|
3129
3149
|
onResponse("failed", null);
|
|
3130
3150
|
setIsPaymentProcessing(false);
|
|
3131
|
-
return _context.abrupt("break",
|
|
3132
|
-
case
|
|
3151
|
+
return _context.abrupt("break", 88);
|
|
3152
|
+
case 88:
|
|
3133
3153
|
case "end":
|
|
3134
3154
|
return _context.stop();
|
|
3135
3155
|
}
|
|
@@ -3404,6 +3424,7 @@ function StripePayment(_ref3) {
|
|
|
3404
3424
|
options: options
|
|
3405
3425
|
}, /*#__PURE__*/_react["default"].createElement(CheckoutForm, {
|
|
3406
3426
|
payButtonText: payButtonText,
|
|
3427
|
+
invoiceId: invoiceId,
|
|
3407
3428
|
clientSecret: options != null ? options.clientSecret : null,
|
|
3408
3429
|
onResponse: onResponse,
|
|
3409
3430
|
paymentMethodType: paymentMethodType,
|
|
@@ -3457,7 +3478,7 @@ function StripePayment(_ref3) {
|
|
|
3457
3478
|
marginTop: 2
|
|
3458
3479
|
},
|
|
3459
3480
|
onClick: /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
3460
|
-
var response,
|
|
3481
|
+
var response, _response4;
|
|
3461
3482
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
3462
3483
|
while (1) switch (_context3.prev = _context3.next) {
|
|
3463
3484
|
case 0:
|
|
@@ -3485,9 +3506,9 @@ function StripePayment(_ref3) {
|
|
|
3485
3506
|
amount: amount
|
|
3486
3507
|
});
|
|
3487
3508
|
case 9:
|
|
3488
|
-
|
|
3489
|
-
if (
|
|
3490
|
-
onResponse("paid",
|
|
3509
|
+
_response4 = _context3.sent;
|
|
3510
|
+
if (_response4 != null && _response4.status == 200) {
|
|
3511
|
+
onResponse("paid", _response4.data.stripePaymentIntentId);
|
|
3491
3512
|
}
|
|
3492
3513
|
case 11:
|
|
3493
3514
|
case "end":
|
|
@@ -3505,6 +3526,7 @@ function StripePayment(_ref3) {
|
|
|
3505
3526
|
options: options
|
|
3506
3527
|
}, /*#__PURE__*/_react["default"].createElement(CheckoutForm, {
|
|
3507
3528
|
payButtonText: payButtonText,
|
|
3529
|
+
invoiceId: invoiceId,
|
|
3508
3530
|
clientSecret: options != null ? options.clientSecret : null,
|
|
3509
3531
|
onResponse: onResponse,
|
|
3510
3532
|
paymentMethodType: paymentMethodType,
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@ import PaymentRoundedIcon from '@mui/icons-material/PaymentRounded';
|
|
|
5
5
|
import Typography from '@mui/material/Typography';
|
|
6
6
|
import { Select, Grid, MenuItem, Box, Button, Tab, Tabs, TextField } from '@mui/material';
|
|
7
7
|
|
|
8
|
-
const CheckoutForm = ({payButtonText, clientSecret, currentUser, paymentMethodType, walletId, onResponse, amount}) => {
|
|
8
|
+
const CheckoutForm = ({payButtonText, invoiceId, clientSecret, currentUser, paymentMethodType, walletId, onResponse, amount}) => {
|
|
9
9
|
|
|
10
10
|
const [isPaymentProcessing, setIsPaymentProcessing] = useState(false);
|
|
11
11
|
|
|
@@ -79,21 +79,38 @@ import { Select, Grid, MenuItem, Box, Button, Tab, Tabs, TextField } from '@mui/
|
|
|
79
79
|
|
|
80
80
|
if (amount != null)
|
|
81
81
|
{
|
|
82
|
-
|
|
83
|
-
let response = await apiService().post("/Payment/Charge", {
|
|
84
|
-
|
|
85
|
-
paymentMethodType: paymentMethodType,
|
|
86
|
-
walletPaymentMethodId: addPaymentMethodResponse.data,
|
|
87
|
-
amount: amount
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
if (response != null && response.status == 200)
|
|
82
|
+
if (invoiceId != null)
|
|
91
83
|
{
|
|
92
|
-
|
|
84
|
+
let response = await apiService().post("/Invoices/PayInvoice", {
|
|
85
|
+
invoiceId: invoiceId,
|
|
86
|
+
walletPaymentMethodId: addPaymentMethodResponse.data
|
|
87
|
+
});
|
|
88
|
+
if (response != null && response.status == 200)
|
|
89
|
+
{
|
|
90
|
+
onResponse("paid", null);
|
|
91
|
+
}
|
|
92
|
+
else
|
|
93
|
+
{
|
|
94
|
+
onResponse("failed", null);
|
|
95
|
+
}
|
|
93
96
|
}
|
|
94
97
|
else
|
|
95
98
|
{
|
|
96
|
-
|
|
99
|
+
// charge the customer
|
|
100
|
+
let response = await apiService().post("/Payment/Charge", {
|
|
101
|
+
paymentMethodType: paymentMethodType,
|
|
102
|
+
walletPaymentMethodId: addPaymentMethodResponse.data,
|
|
103
|
+
amount: amount
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
if (response != null && response.status == 200)
|
|
107
|
+
{
|
|
108
|
+
onResponse("paid", response.data.stripePaymentIntentId);
|
|
109
|
+
}
|
|
110
|
+
else
|
|
111
|
+
{
|
|
112
|
+
onResponse("failed", null);
|
|
113
|
+
}
|
|
97
114
|
}
|
|
98
115
|
}
|
|
99
116
|
|
|
@@ -341,7 +358,7 @@ import { Select, Grid, MenuItem, Box, Button, Tab, Tabs, TextField } from '@mui/
|
|
|
341
358
|
|
|
342
359
|
{(options != null && process.env.stripePublicKey != null) &&
|
|
343
360
|
<Elements stripe={stripePromise} options={options}>
|
|
344
|
-
<CheckoutForm payButtonText={payButtonText} clientSecret={options != null ? options.clientSecret : null} onResponse={onResponse} paymentMethodType={paymentMethodType} currentUser={currentUser} walletId={walletId} amount={amount} />
|
|
361
|
+
<CheckoutForm payButtonText={payButtonText} invoiceId={invoiceId} clientSecret={options != null ? options.clientSecret : null} onResponse={onResponse} paymentMethodType={paymentMethodType} currentUser={currentUser} walletId={walletId} amount={amount} />
|
|
345
362
|
</Elements>
|
|
346
363
|
}
|
|
347
364
|
</Box>
|
|
@@ -417,7 +434,7 @@ import { Select, Grid, MenuItem, Box, Button, Tab, Tabs, TextField } from '@mui/
|
|
|
417
434
|
|
|
418
435
|
{(options != null && process.env.stripePublicKey != null) &&
|
|
419
436
|
<Elements stripe={stripePromise} options={options}>
|
|
420
|
-
<CheckoutForm payButtonText={payButtonText} clientSecret={options != null ? options.clientSecret : null} onResponse={onResponse} paymentMethodType={paymentMethodType} walletId={walletId} currentUser={currentUser} amount={amount} />
|
|
437
|
+
<CheckoutForm payButtonText={payButtonText} invoiceId={invoiceId} clientSecret={options != null ? options.clientSecret : null} onResponse={onResponse} paymentMethodType={paymentMethodType} walletId={walletId} currentUser={currentUser} amount={amount} />
|
|
421
438
|
</Elements>
|
|
422
439
|
}
|
|
423
440
|
</Box>
|