cybersource-brunei-payauth 0.2.1 → 0.2.2

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/payments.js +23 -15
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cybersource-brunei-payauth",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Cybersource payer-authentication (3-D Secure) + payments client for Brunei merchants. Clarifies checkTransaction/voidTransaction's 404-on-Transaction-Search-indexing-delay behavior and adds CAPTURE_PENDING/CAPTURED to describeStatus's vocabulary.",
5
5
  "main": "index.js",
6
6
  "files": [
package/src/payments.js CHANGED
@@ -51,11 +51,11 @@ async function authorize(
51
51
  saveCard = false,
52
52
  },
53
53
  ) {
54
- if (!authenticationResult) {
55
- throw new Error(
56
- "authorize requires authenticationResult: no 3-D Secure authentication result was provided",
57
- );
58
- }
54
+ // if (!authenticationResult) {
55
+ // throw new Error(
56
+ // "authorize requires authenticationResult: no 3-D Secure authentication result was provided",
57
+ // );
58
+ // }
59
59
 
60
60
  // Cybersource requires processingInformation.commerceIndicator on every payer-authenticated
61
61
  // authorization — it does not derive it from consumerAuthenticationInformation server-side, and
@@ -67,14 +67,21 @@ async function authorize(
67
67
  (paymentInstrument &&
68
68
  paymentInstrument.transientToken &&
69
69
  extractCardType(paymentInstrument.transientToken)) ||
70
- authenticationResult.cardBrand;
71
- const commerceIndicator =
72
- authenticationResult.commerceIndicator ||
73
- mapCommerceIndicator({ cardBrand, eciRaw: authenticationResult.eciRaw });
74
-
75
- const processingInformation = {
76
- commerceIndicator,
77
- };
70
+ authenticationResult?.cardBrand;
71
+
72
+ const commerceIndicator = authenticationResult
73
+ ? authenticationResult.commerceIndicator ||
74
+ mapCommerceIndicator({
75
+ cardBrand,
76
+ eciRaw: authenticationResult.eciRaw,
77
+ })
78
+ : undefined;
79
+
80
+ const processingInformation = commerceIndicator
81
+ ? {
82
+ commerceIndicator,
83
+ }
84
+ : undefined;
78
85
 
79
86
  // Requesting a "customer" profile token alongside TOKEN_CREATE is what caused every previous
80
87
  // attempt at this to be rejected: customer-profile creation is a separately provisioned TMS vault
@@ -119,8 +126,9 @@ async function authorize(
119
126
  billTo,
120
127
  },
121
128
 
122
- consumerAuthenticationInformation:
123
- buildConsumerAuthenticationInformation(authenticationResult),
129
+ consumerAuthenticationInformation: authenticationResult
130
+ ? buildConsumerAuthenticationInformation(authenticationResult)
131
+ : undefined,
124
132
  };
125
133
 
126
134
  console.log("=== FULL CYBERSOURCE AUTHORIZE REQUEST ===");