@aptos-scp/scp-component-store-selling-features-domain-model 3.4.0 → 3.5.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.
@@ -4,20 +4,28 @@ export declare enum PaymentNotificationSessionState {
4
4
  Inactive = "Inactive",
5
5
  Initializing = "Initializing",
6
6
  InProgress = "InProgress",
7
+ Cancelled = "Cancelled",
7
8
  Completed = "Completed"
8
9
  }
9
10
  export declare class PaymentNotificationSession implements IState {
10
11
  private readonly _type;
11
12
  private readonly _state;
12
13
  private readonly _paymentAuthorizationResponse;
14
+ private readonly _authorizationServiceRequestId;
13
15
  static createFromJsonObject(paymentNotificationSessionJsonObj: any): PaymentNotificationSession;
14
- static create(): PaymentNotificationSession;
16
+ /**
17
+ * @param requestId Optional idempotency key (`serviceProcessing.requestID`) for pay-by-link before an authorization response exists.
18
+ */
19
+ static create(requestId?: string): PaymentNotificationSession;
15
20
  get type(): string;
16
21
  get state(): PaymentNotificationSessionState;
17
22
  get paymentAuthorizationResponse(): any;
23
+ get authorizationServiceRequestId(): string | undefined;
24
+ get isCancelled(): boolean;
18
25
  get stateValues(): Readonly<Map<string, any>>;
19
26
  initialize(): PaymentNotificationSession;
20
27
  inProgress(lastPaymentAuthorizationResponse?: any): PaymentNotificationSession;
21
28
  complete(): PaymentNotificationSession;
29
+ cancelled(): PaymentNotificationSession;
22
30
  private constructor();
23
31
  }
@@ -8,27 +8,41 @@ var PaymentNotificationSessionState;
8
8
  PaymentNotificationSessionState["Inactive"] = "Inactive";
9
9
  PaymentNotificationSessionState["Initializing"] = "Initializing";
10
10
  PaymentNotificationSessionState["InProgress"] = "InProgress";
11
+ PaymentNotificationSessionState["Cancelled"] = "Cancelled";
11
12
  PaymentNotificationSessionState["Completed"] = "Completed";
12
13
  })(PaymentNotificationSessionState = exports.PaymentNotificationSessionState || (exports.PaymentNotificationSessionState = {}));
13
14
  class PaymentNotificationSession {
14
- constructor(state, paymentAuthorizationResponse) {
15
+ constructor(state, paymentAuthorizationResponse, authorizationServiceRequestId) {
15
16
  this._type = exports.PAYMENT_NOTIFICATION_SESSION;
16
17
  this._state = state;
17
18
  if (state === PaymentNotificationSessionState.Initializing ||
18
19
  state === PaymentNotificationSessionState.Completed) {
19
20
  this._paymentAuthorizationResponse = undefined;
21
+ this._authorizationServiceRequestId = undefined;
22
+ }
23
+ else if (state === PaymentNotificationSessionState.Cancelled) {
24
+ this._paymentAuthorizationResponse = undefined;
25
+ this._authorizationServiceRequestId = authorizationServiceRequestId;
20
26
  }
21
27
  else if (paymentAuthorizationResponse) {
22
28
  this._paymentAuthorizationResponse = paymentAuthorizationResponse;
29
+ this._authorizationServiceRequestId = authorizationServiceRequestId;
30
+ }
31
+ else {
32
+ this._paymentAuthorizationResponse = undefined;
33
+ this._authorizationServiceRequestId = authorizationServiceRequestId;
23
34
  }
24
35
  }
25
36
  static createFromJsonObject(paymentNotificationSessionJsonObj) {
26
37
  logger.traceEntry("createFromJsonObject");
27
- return new PaymentNotificationSession(paymentNotificationSessionJsonObj._state, paymentNotificationSessionJsonObj._paymentAuthorizationResponse);
38
+ return new PaymentNotificationSession(paymentNotificationSessionJsonObj._state, paymentNotificationSessionJsonObj._paymentAuthorizationResponse, paymentNotificationSessionJsonObj._authorizationServiceRequestId);
28
39
  }
29
- static create() {
40
+ /**
41
+ * @param requestId Optional idempotency key (`serviceProcessing.requestID`) for pay-by-link before an authorization response exists.
42
+ */
43
+ static create(requestId) {
30
44
  logger.traceEntry("create");
31
- return new PaymentNotificationSession(PaymentNotificationSessionState.Inactive);
45
+ return new PaymentNotificationSession(PaymentNotificationSessionState.Inactive, undefined, requestId);
32
46
  }
33
47
  get type() {
34
48
  return this._type;
@@ -39,21 +53,31 @@ class PaymentNotificationSession {
39
53
  get paymentAuthorizationResponse() {
40
54
  return this._paymentAuthorizationResponse;
41
55
  }
56
+ get authorizationServiceRequestId() {
57
+ return this._authorizationServiceRequestId;
58
+ }
59
+ get isCancelled() {
60
+ return this._state === PaymentNotificationSessionState.Cancelled;
61
+ }
42
62
  get stateValues() {
43
63
  return new Map([
44
64
  ["PaymentNotificationSession.state", this._state],
45
65
  ["PaymentNotificationSession.paymentAuthorizationResponse", this._paymentAuthorizationResponse],
66
+ ["PaymentNotificationSession.authorizationServiceRequestId", this._authorizationServiceRequestId],
46
67
  ]);
47
68
  }
48
69
  initialize() {
49
70
  return new PaymentNotificationSession(PaymentNotificationSessionState.Initializing);
50
71
  }
51
72
  inProgress(lastPaymentAuthorizationResponse) {
52
- return new PaymentNotificationSession(PaymentNotificationSessionState.InProgress, lastPaymentAuthorizationResponse);
73
+ return new PaymentNotificationSession(PaymentNotificationSessionState.InProgress, lastPaymentAuthorizationResponse, this._authorizationServiceRequestId);
53
74
  }
54
75
  complete() {
55
76
  return new PaymentNotificationSession(PaymentNotificationSessionState.Completed);
56
77
  }
78
+ cancelled() {
79
+ return new PaymentNotificationSession(PaymentNotificationSessionState.Cancelled, undefined, this._authorizationServiceRequestId);
80
+ }
57
81
  }
58
82
  exports.PaymentNotificationSession = PaymentNotificationSession;
59
83
  //# sourceMappingURL=PaymentNotificationSession.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aptos-scp/scp-component-store-selling-features-domain-model",
3
- "version": "3.4.0",
3
+ "version": "3.5.0",
4
4
  "description": "This component library provides the common components to handle the coordination of processing the business events from the UI.",
5
5
  "private": false,
6
6
  "license": "SEE LICENSE IN LICENSE.md",