Skip to content

Commit 0cfd4c7

Browse files
authored
Merge pull request #28 from jbransvisa/master
25.1.0
2 parents d0d0ba5 + a2a8868 commit 0cfd4c7

34 files changed

+195
-169
lines changed

.env

+17-17
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
CONFIG_PORT =
1+
CONFIG_PORT =
22

33
PAYMENT_GATEWAY_EXTENSION_DESTINATION_URL =
44
PAYMENT_GATEWAY_EXTENSION_HEADER_VALUE =
55
PAYMENT_GATEWAY_RUN_ENVIRONMENT =
66
PAYMENT_GATEWAY_ENABLE_DEBUG =
77

8-
PAYMENT_GATEWAY_MERCHANT_ID =
9-
PAYMENT_GATEWAY_MERCHANT_KEY_ID =
10-
PAYMENT_GATEWAY_MERCHANT_SECRET_KEY =
8+
PAYMENT_GATEWAY_MERCHANT_ID =
9+
PAYMENT_GATEWAY_MERCHANT_KEY_ID =
10+
PAYMENT_GATEWAY_MERCHANT_SECRET_KEY =
1111

1212
PAYMENT_GATEWAY_TARGET_ORIGINS =
1313
PAYMENT_GATEWAY_VERIFICATION_KEY =
1414
PAYMENT_GATEWAY_CC_ALLOWED_CARD_NETWORKS =
15-
PAYMENT_GATEWAY_3DS_RETURN_URL =
15+
PAYMENT_GATEWAY_3DS_RETURN_URL =
1616
PAYMENT_GATEWAY_SCA_CHALLENGE =
1717
PAYMENT_GATEWAY_ORDER_RECONCILIATION =
1818
PAYMENT_GATEWAY_WHITELIST_URLS =
@@ -22,25 +22,25 @@ PAYMENT_GATEWAY_APPLE_PAY_MERCHANT_ID =
2222
PAYMENT_GATEWAY_APPLE_PAY_CERTIFICATE_PATH =
2323
PAYMENT_GATEWAY_APPLE_PAY_KEY_PATH =
2424

25-
PAYMENT_GATEWAY_ENABLE_RATE_LIMITER =
26-
PAYMENT_GATEWAY_LIMIT_SAVED_CARD_RATE =
25+
PAYMENT_GATEWAY_ENABLE_RATE_LIMITER =
26+
PAYMENT_GATEWAY_LIMIT_SAVED_CARD_RATE =
2727
PAYMENT_GATEWAY_SAVED_CARD_LIMIT_FRAME =
2828

2929
PAYMENT_GATEWAY_DECISION_SYNC =
30-
PAYMENT_GATEWAY_DECISION_MANAGER =
31-
PAYMENT_GATEWAY_RUN_SYNC =
32-
PAYMENT_GATEWAY_DECISION_SYNC_MULTI_MID =
33-
PAYMENT_GATEWAY_NETWORK_TOKEN_MULTI_MID =
30+
PAYMENT_GATEWAY_DECISION_MANAGER =
31+
PAYMENT_GATEWAY_RUN_SYNC =
32+
PAYMENT_GATEWAY_DECISION_SYNC_MULTI_MID =
33+
PAYMENT_GATEWAY_NETWORK_TOKEN_MULTI_MID =
3434

35-
PAYMENT_GATEWAY_UC_ALLOWED_PAYMENTS =
36-
PAYMENT_GATEWAY_UC_BILLING_TYPE =
35+
PAYMENT_GATEWAY_UC_ALLOWED_PAYMENTS =
36+
PAYMENT_GATEWAY_UC_BILLING_TYPE =
3737
PAYMENT_GATEWAY_UC_ENABLE_PHONE =
3838
PAYMENT_GATEWAY_UC_ENABLE_EMAIL =
39-
PAYMENT_GATEWAY_UC_ENABLE_NETWORK_ICONS =
40-
PAYMENT_GATEWAY_UC_ENABLE_SHIPPING =
41-
PAYMENT_GATEWAY_UC_ALLOWED_SHIP_TO_COUNTRIES =
39+
PAYMENT_GATEWAY_UC_ENABLE_NETWORK_ICONS =
40+
PAYMENT_GATEWAY_UC_ENABLE_SHIPPING =
41+
PAYMENT_GATEWAY_UC_ALLOWED_SHIP_TO_COUNTRIES =
4242

43-
PAYMENT_GATEWAY_SERVERLESS_DEPLOYMENT =
43+
PAYMENT_GATEWAY_SERVERLESS_DEPLOYMENT =
4444
FUNCTIONS_HTTPWORKER_PORT =
4545

4646
CT_PROJECT_KEY =

docs/Microform-Setup.md

+8-19
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,22 @@ Microform Integration replaces the primary account number (PAN) or card verifica
44

55
## Setting Up the Client Side
66

7-
- Add the Microform Integration JavaScript library to your page by loading it directly from Cybersource and this can be achieved dynamically per environment by using the asset path returned in the JWT (JSON Web Token).
7+
- Add the Microform Integration JavaScript library to your page by loading it directly using the clientLibrary and clientLibraryIntegrity values provided in the `isv_clientLibrary` and `isv_clientLibraryIntegrity` custom fields from the Payment Create call.
88

9-
ctx": [
10-
{
11-
"data": {
12-
"clientLibrary": https://testflex.cybersource.com/microform/bundle/v2/flex-microform.min.js
13-
...
14-
15-
a. For Test Environment:
16-
17-
<script src="https://testflex.cybersource.com/microform/bundle/v2/flex-microform.min.js"></script>
18-
19-
b. For Production Environment:
20-
21-
<script src="https://flex.cybersource.com/microform/bundle/v2/flex-microform.min.js"></script>
9+
<script src="[INSERT isv_clientLibrary VALUE HERE]" integrity="[INSERT isv_clientLibraryIntegrity VALUE HERE]" crossorigin="anonymous"></script>
2210

2311
- Create the HTML placeholder objects to attach to the microforms.
2412

25-
<div id="numbercontainer" class="form-control"></div>
13+
<div id="number-container" class="form-control"></div>
14+
<div id="securityCode-container" class="form-control"></div>
2615

27-
- Invoke the Flex SDK by passing the Capture Context that was generated in the Payment create call.
16+
- Invoke the Flex SDK by passing the Capture Context from `isv_tokenCaptureContextSignature` custom field from the Payment create call.
2817

29-
var flex = new Flex(captureContext);
18+
var flex = new Flex(isv_tokenCaptureContextSignature);
3019

3120
- Initiate the microform object with styling to match your web page.
3221

33-
var microform = flex.microform({ styles: myStyles });
22+
var microform = flex.microform("card",{ styles: myStyles });
3423

3524
- Create and attach the microform fields to the HTML objects through the Microform Integration JavaScript library.
3625

@@ -46,4 +35,4 @@ Microform Integration replaces the primary account number (PAN) or card verifica
4635

4736
Once the microform integration v2 is setup, you can continue to the [Process a Card Payment Without Payer Authentication](Process-a-Card-Payment-Without-Payer-Authentication.md) or [Process a Payment a Card Payment With Payer Authentication](Process-a-Card-Payment-With-Payer-Authentication.md) process.
4837

49-
**_NOTE:_** For more details, refer [Microform Integration v2 Cybersource Documentation](https://developer.cybersource.com/docs/cybs/en-us/digital-accept-flex/developer/all/rest/digital-accept-flex/microform-integ-v2.html).
38+
**_NOTE:_** For more details, refer [Microform Integration v2 Cybersource Documentation](https://developer.cybersource.com/docs/cybs/en-us/digital-accept-flex/developer/all/rest/digital-accept-flex/microform-integ-v2.html).

docs/Tokenization.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,9 @@ Merchant Centre → Customers → Customer list → Select a Customer → Custom
3737
| ---------------------------------------------- | ------------ | -------- |
3838
| custom.fields.isv_tokenCaptureContextSignature | empty string | Yes |
3939

40-
2. The response should have the `isv_tokenCaptureContextSignature` and `isv_tokenVerificationContext` custom fields.
41-
Set the `isv_tokenCaptureContextSignature` custom field value to the captureContext of flex object which will load Cybersource Microform
40+
2. The response should include `isv_tokenCaptureContextSignature`, `isv_tokenVerificationContext`, `isv_clientLibrary`, and `clientLibraryIntegrity`. The `isv_clientLibrary` and `isv_clientLibraryIntegrity` are obtained by decoding the capture context received from Cybersource. Additionally, set the `isv_tokenCaptureContextSignature` custom field value to the captureContext of the Flex object, which will load the Cybersource Microform.
4241

43-
flexInstance = new Flex(captureContext);
42+
flexInstance = new Flex(isv_tokenCaptureContextSignature);
4443

4544
3. Use the Microform Integration v2 to tokenize card details. See <https://github.com/CyberSource/cybersource-flex-samples-node> for an example of how to use the captureContext obtained above and the Microform JS to tokenize a Card
4645

docs/unified-checkout/Tokenization.md

-48
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# Tokenization
22

3-
- [Tokenization with Microform](#Tokenization-with-Microform)
4-
53
- [Tokenization with Unified Checkout](#Tokenization-with-UnifiedCheckout)
64

75
- [Customization-in-Tokenization](#customization-in-tokenization)
@@ -21,52 +19,6 @@ The customer saved tokens can be viewed in:
2119

2220
Merchant Centre → Customers → Customer list → Select a Customer → Custom Fields
2321

24-
# Tokenization with Microform
25-
26-
## Tokenize a card
27-
28-
1. Tokenize Card details using Cybersource Microform v2
29-
30-
a. If there are no cards available, update the customer by creating a custom type with the following
31-
32-
| Property | Value | Required |
33-
| ---------------------------------------------- | ---------------------------- | -------- |
34-
| custom.type.key | isv_payments_customer_tokens | Yes |
35-
| custom.fields.isv_tokenCaptureContextSignature | empty string | Yes |
36-
37-
b. If there are tokens available already, update the customer by setting the following custom field
38-
39-
| Property | Value | Required |
40-
| ---------------------------------------------- | ------------ | -------- |
41-
| custom.fields.isv_tokenCaptureContextSignature | empty string | Yes |
42-
43-
2. The response should have the `isv_tokenCaptureContextSignature` and `isv_tokenVerificationContext` custom fields.
44-
Set the `isv_tokenCaptureContextSignature` custom field value to the captureContext of flex object which will load Cybersource Microform
45-
46-
flexInstance = new Flex(captureContext);
47-
48-
3. Use the Microform Integration v2 to tokenize card details. See <https://github.com/CyberSource/cybersource-flex-samples-node> for an example of how to use the captureContext obtained above and the Microform JS to tokenize a Card
49-
50-
4. After the card details are entered by the customer, ask the customer to add billing address for the card and update the customer by populating the following
51-
52-
| Property | Value | Required | Notes |
53-
| ------------------------------------- | ------------------------------------------------ | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
54-
| custom.fields.isv_token | Cybersource flex token | Yes | This is the token parameter passed into the callback for the microform.createToken call |
55-
| custom.fields.isv_tokenAlias | Alias for saved token | Yes | When this is specified the token will be saved as a subscription for later use. Merchant can either provide a input text field asking for the customer to provide value for this field or a checkbox to select if the token needs be saved as a subscription for later use. In the latter case, Merchant should provide a unique value upon selecting the checkbox |
56-
| custom.fields.isv_maskedPan | Masked Card number | No | Can be obtained from the token parameter passed into the callback for the microform.createToken call. The token is a JWT which when decoded has a `flexData.content.paymentInformation.card.number.bin + flexData.content.paymentInformation.card.number.maskedValue` field containing the masked card number <br><br> Not required by extension but can be used for display |
57-
| custom.fields.isv_cardType | Card type | No | Can be obtained from the token parameter passed into the callback for the microform.createToken call. The token is a JWT which when decoded has a `flexData.content.paymentInformation.card.number.detectedCardTypes[0]` field containing the card type <br><br> Not required by extension but can be used for display |
58-
| custom.fields.isv_cardExpiryMonth | Card expiry month | No | Can be obtained from the token parameter passed into the callback for the microform.createToken call. The token is a JWT which when decoded has a `flexData.content.paymentInformation.card.expirationMonth.value` field containing the card expiration month <br><br> Not required by extension but can be used for display |
59-
| custom.fields.isv_cardExpiryYear | Card expiry year | No | Can be obtained from the token parameter passed into the callback for the microform.createToken call. The token is a JWT which when decoded has a `flexData.content.paymentInformation.card.expirationYear.value` field containing the card expiration year <br><br> Not required by extension but can be used for display |
60-
| custom.fields.isv_addressId | Id of the address added by customer for the card | Yes | |
61-
| custom.fields.isv_currencyCode | Currency code of the store | Yes | |
62-
| custom.fields.isv_deviceFingerprintId | Customer device fingerprint Id | Yes | Refer [Device Fingerprinting](Decision-Manager.md#device-fingerprinting) to generate this value |
63-
64-
5. Wait for the updated response and verify the `custom.fields.isv_tokens` field
65-
66-
6. If token is created successfully, `custom.fields.isv_tokens` field will have updated tokens along with `custom.fields.is_customerId` with the customer id returned in response.
67-
68-
7. If there was an error, `custom.fields.isv_token`s field either be empty if there were no tokens available or will have the old tokens which were available before adding the new token. Also `custom.fields.isv_failedTokens` field will have all the failed card records if there was an error while adding the token
69-
7022
# Tokenization with UnifiedCheckout
7123

7224
1. Use the client library asset path returned by the capture context response to invoke Unified Checkout on your page. To invoke the Unified Checkout JavaScript library using the JWT response from the capture context request, follow the instructions in the document [Unified Checkout Setup](UnifiedCheckout-setup.md)

docs/unified-checkout/UnifiedCheckout-setup.md

+22-15
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,41 @@ Unified Checkout provides a single interface with which you can accept numerous
44

55
## Unified Checkout Processing Sequence Diagram
66

7-
![Unified Checkout Processing flow](../images/Flow-Diagram-UnifiedCheckout.svg)
7+
![Unified Checkout Processing flow](./Flow-Diagram-UnifiedCheckout.svg)
88

99

1010
## Setting Up the Client Side
1111

12-
- To obtain the capture context, send a `GET` request to `{baseUrl}/captureContext`. This request requires authentication and must include an authentication header, which can be generated by making a `GET` request to `{baseUrl}/generateHeader`.
12+
- To obtain the `captureContextData`, `clientLibrary`, and `clientLibraryIntegrity`, you must first generate an authentication header. This is accomplished by sending a `GET` request to `{baseUrl}/generateHeader` and using the response to include the required authentication header for subsequent requests.
1313

14-
- Use the client library asset path returned by the capture context response to invoke Unified Checkout on your page.
14+
- Once the header is generated, send a `GET` request to `{baseUrl}/captureContext`, ensuring that the request includes the previously generated authentication header. The response will contain the `captureContextData` provided by CyberSource.
1515

16-
Get the JavaScript library URL dynamically from the capture context response. When decoded, it appears in the JSON parameter clientLibrary as:
17-
https://apitest.cybersource.com/up/v1/assets/x.y.z/SecureAcceptance.js
16+
- The `captureContextData` is decoded to extract the `clientLibrary` and `clientLibraryIntegrity` fields.
1817

19-
When you load the library, the capture context that you received from your initial server‑side request is used to invoke the accept function.
18+
- A sample response typically contains the `captureContextData`, `clientLibrary`, and `clientLibraryIntegrity` fields in JSON format, as shown below.
19+
20+
Example Response:
21+
22+
{
23+
"captureContextData": "xxxx",
24+
"clientLibrary": "xxxx",
25+
"clientLibraryIntegrity": "xxxx"
26+
}
27+
28+
- Use the `clientLibrary` and `clientLibraryIntegrity` values from the capture context response to invoke Unified Checkout on your page.
29+
30+
When you load the library, use the capture context obtained from the GET request to `{baseUrl}/captureContext` as a parameter for invoking the accept function.
2031

2132
Example: Initializing the SDK
2233

23-
<script src="https://apitest.cybersource.com/up/v1/assets/0.19.0/SecureAcceptance.js"></script>
34+
<script src="[INSERT clientLibrary VALUE HERE]" integrity="[INSERT clientLibraryIntegrity VALUE HERE]" crossorigin="anonymous"></script>
2435
<script>
2536
Accept('header.payload.signature').then(function(accept) {
2637
// use accept object
2738
});
2839
</script>
2940

30-
header.payload.signature refers to the capture context JWT
41+
header.payload.signature refers to the `captureContextData`.
3142

3243

3344
- Adding the Payment Application and Payment Acceptance
@@ -38,14 +49,12 @@ Unified Checkout provides a single interface with which you can accept numerous
3849

3950
var authForm = document.getElementById("authForm");
4051
var transientToken = document.getElementById("transientToken");
41-
42-
var cc = document.getElementById("captureContext").value;
4352
var showArgs = {
4453
containers: {
4554
paymentSelection: "#buttonPaymentListContainer"
4655
}
4756
};
48-
Accept(cc)
57+
Accept(captureContextData)
4958
.then(function(accept) {
5059
return accept.unifiedPayments();
5160
})
@@ -63,15 +72,13 @@ Unified Checkout provides a single interface with which you can accept numerous
6372

6473
var authForm = document.getElementById("authForm");
6574
var transientToken = document.getElementById("transientToken");
66-
67-
var cc = document.getElementById("captureContext").value;
6875
var showArgs = {
6976
containers: {
7077
paymentSelection: "#buttonPaymentListContainer",
7178
paymentScreen: "#embeddedPaymentContainer"
7279
}
7380
};
74-
Accept(cc)
81+
Accept(captureContextData)
7582
.then(function(accept) {
7683
// Gets the UC instance (e.g. what card brands I requested, any address information I pre-filled etc.)
7784
return accept.unifiedPayments(false);
@@ -100,4 +107,4 @@ The response to a successful customer interaction with Unified Checkout is a tra
100107
| Default | creditCard or creditCardWithPayerAuthentication (depending on the payerAuth flag) |
101108

102109

103-
**_NOTE:_** For more details, refer [Unified Checkout Cybersource Documentation](https://developer.cybersource.com/docs/cybs/en-us/digital-accept-flex/developer/all/rest/digital-accept-flex/uc-intro.html).
110+
**_NOTE:_** For more details, refer [Unified Checkout Cybersource Documentation](https://developer.cybersource.com/docs/cybs/en-us/digital-accept-flex/developer/all/rest/digital-accept-flex/uc-intro.html).

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "commercetools-extension",
3-
"version": "24.3.1",
3+
"version": "25.1.0",
44
"description": "Payment Services Commercetools Extension",
55
"main": "build/main/index.js",
66
"typings": "build/main/index.d.ts",
@@ -103,7 +103,7 @@
103103
"@typescript-eslint/eslint-plugin": "^4.0.1",
104104
"@typescript-eslint/parser": "^4.0.1",
105105
"ava": "^6.1.3",
106-
"eslint": "^7.8.0",
106+
"eslint": "^7.32.0",
107107
"eslint-config-prettier": "^6.11.0",
108108
"eslint-plugin-eslint-comments": "^3.2.0",
109109
"eslint-plugin-functional": "^3.0.2",

0 commit comments

Comments
 (0)