Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/ Retrieve saved cards for at Profile System for PII accounts #664

Merged
merged 6 commits into from
Jun 28, 2024

Conversation

beatrizmaselli
Copy link
Contributor

@beatrizmaselli beatrizmaselli commented Jun 13, 2024

What problem is this solving?

Cards saved at a profile using PII are not retrieved at my account.

The first problem is that the API to retrieve the purchase-info does not accept the alternativeKey param and it was calling the API with the unmasked path twice like unmasked/unmasked. So when this API was being called it was returning 404 even when the profile had already purchase infos saved to it.

Ex:
http://portal.vtexcommercestable.com.br/api/storage/profile-system/profiles/beatriz.maselli@vtex.com/purchase-info/unmask?alternativeKey=email&useCase=MyAcocunts&onBehalfOf=user&an=dunnesstoresqa

This will return 404. ❌

Calling using the userId:
http://portal.vtexcommercestable.com.br/api/storage/profile-system/profiles/5f2e2bf9-13ba-4679-9ce4-5877fee681e6/purchase-info/unmask?useCase=MyAcocunts&onBehalfOf=user&an=dunnesstoresqa

The information is retrieve as expected. ✅

The second problem is that the service was not ready to deal with the format of the paymentsRawData for PII accounts.

Example PV1 account:

{
    "isToSavePersonalData": "True",
    "lastPurchasesAddressId": "4835155269459",
    "paymentData": "{\"availableAccounts\":[{\"accountId\":\"DD4354CC8DB548E1B028F72E9A7FCEBF\",\"paymentSystem\":\"1\",\"paymentSystemName\":\"American Express\",\"cardNumber\":\"***********7888\",\"bin\":\"34671646\",\"availableAddresses\":[\"4835155269459\"],\"expirationDate\":\"01/2024\",\"isExpired\":true,\"accountStatus\":null},{\"accountId\":\"F827E1BCEAC1492FBDD6F52739CE8A69\",\"paymentSystem\":\"4\",\"paymentSystemName\":\"Mastercard\",\"cardNumber\":\"************7888\",\"bin\":\"34671646\",\"availableAddresses\":[\"4835155269459\"],\"expirationDate\":\"02/2025\",\"isExpired\":false,\"accountStatus\":null}],\"availableTokens\":[],\"transactions\":null,\"giftCards\":[],\"giftCardMessages\":[],\"numberOfPaymentErrors\":0,\"numberOfDeniedTransactions\":0,\"lastDeniedTransaction\":null}",
    "lastUserPurchases": "[{\"creationDate\":\"2024-06-04T15:39:45.5388461Z\",\"orderId\":\"1437360501958-01\",\"orderGroup\":\"1437360501958\",\"value\":20000},{\"creationDate\":\"2024-03-12T10:53:00.5054088Z\",\"orderId\":\"1417150501913-01\",\"orderGroup\":\"1417150501913\",\"value\":40000},{\"creationDate\":\"2023-12-20T14:11:13.7651013Z\",\"orderId\":\"1384860501905-01\",\"orderGroup\":\"1384860501905\",\"value\":39400},{\"creationDate\":\"2023-12-14T14:09:21.1929986Z\",\"orderId\":\"1383420501883-01\",\"orderGroup\":\"1383420501883\",\"value\":19400},{\"creationDate\":\"2023-12-14T13:58:13.7113096Z\",\"orderId\":\"1383420501879-01\",\"orderGroup\":\"1383420501879\",\"value\":19400},{\"creationDate\":\"2023-12-14T13:21:31.5775552Z\",\"orderId\":\"1383410501869-01\",\"orderGroup\":\"1383410501869\",\"value\":19400},{\"creationDate\":\"2023-12-12T19:04:14.6377626Z\",\"orderId\":\"1382990501841-01\",\"orderGroup\":\"1382990501841\",\"value\":19400},{\"creationDate\":\"2023-12-12T18:01:21.325243Z\",\"orderId\":\"1382980501817-01\",\"orderGroup\":\"1382980501817\",\"value\":19400},{\"creationDate\":\"2023-12-12T14:03:20.8774738Z\",\"orderId\":\"1382940501783-01\",\"orderGroup\":\"1382940501783\",\"value\":19400},{\"creationDate\":\"2023-12-12T13:12:34.42901Z\",\"orderId\":\"1382930501781-01\",\"orderGroup\":\"1382930501781\",\"value\":19400}]",
    "orderFormIds": "[\"37a8b179fb164939bbb1fe70475d1687\",\"9dc2468651684a32a34bb76279cd8650\",\"e16a6b3f0f434e1b869c895424c0f5f1\",\"6bd22358885a46f68f9d787c8d127617\",\"14170452dad740e2bf27d683ee1daa74\",\"0839c92dadb047fdaae2b92388d421f0\",\"932aaea211d24a4985b8d7ee52f952be\",\"3e76e495c5c3495db3e1a7be460732fa\",\"de991c72c31b4992913739a2405502a8\"]"
}

Example PV2 account:

[
    {
        "id": "0170399a-8c34-43b9-9ce5-2100928ba0b7",
        "document": {
            "paymentData": {
                "availableAccounts": [
                    {
                        "accountId": "08DAFBCB5FAD4E9588CB256DFB7FC8D3",
                        "paymentSystem": "2",
                        "paymentSystemName": "Visa",
                        "cardNumber": "************1111",
                        "bin": "44443333",
                        "availableAddresses": [
                            "8576750372220"
                        ],
                        "expirationDate": "02/2025",
                        "isExpired": false,
                        "accountStatus": null
                    }
                ],
                "availableTokens": [],
                "transactions": null,
                "giftCards": [],
                "giftCardMessages": [],
                "numberOfPaymentErrors": 0,
                "numberOfDeniedTransactions": 0,
                "lastDeniedTransaction": null
            },
            "clientPreferences": {
                "userId": "0170399a-8c34-43b9-9ce5-2100928ba0b7",
                "localeDefault": "en-GB"
            },
            "isToSavePersonalData": true,
            "lastUserPurchases": [
                {
                    "creationDate": "2024-06-13T10:06:40.2879449Z",
                    "orderId": "50503313-01",
                    "orderGroup": "50503313",
                    "value": 1895
                }
            ],
            "lastPurchasesAddressId": "8576750372220",
            "orderFormIds": [
                "545ba44c44464a43a33d882ba8db36f3",
                "9452e44849414698970255646adc7e8a",
                "5269474e0b8f4da2b2f173e62d1bad85",
                "27205d679bde42299d9d7e7d4799f993",
                "e2970555551a43dba96ef4858b108485",
                "b0e5176471984ec683bc6c011fe6b049",
                "3bd5b70f03a14c21af4020e5bd145c8c",
                "a4c3f3f7f7e544fba2616b6cf8ff9ffd",
                "d2da5e7f53834280bb4a28608e310307",
                "ac19b3c72e2f4db98513063dd002f473"
            ]
        },
        "meta": {
            "version": "f7b5cac4-f1c0-4b40-95b3-6f008e8bfa7b",
            "author": "d6d8269f-e7cc-4e4b-8b89-3b46a1407937",
            "creationDate": "2024-05-28T16:50:57.9119321+00:00",
            "lastUpdateDate": "2024-06-13T10:21:27.9809752+00:00",
            "expirationDate": null
        }
    }
]

To deal with this I added a new call to the LM to check if the context is PII or not to differentiate the format for the paymentsRawData.

How to test it?

Workspace

Screenshots or example usage:

image

Graphql returning payments:

image

How does this PR make you feel? 🔗

@beatrizmaselli beatrizmaselli requested a review from a team as a code owner June 13, 2024 20:37
@beatrizmaselli beatrizmaselli requested review from emersonlaurentino, eduardoformiga and GusGuerra and removed request for a team June 13, 2024 20:37
Copy link
Contributor

vtex-io-ci-cd bot commented Jun 13, 2024

Hi! I'm VTEX IO CI/CD Bot and I'll be helping you to publish your app! 🤖

Please select which version do you want to release:

  • Patch (backwards-compatible bug fixes)

  • Minor (backwards-compatible functionality)

  • Major (incompatible API changes)

And then you just need to merge your PR when you are ready! There is no need to create a release commit/tag.

  • No thanks, I would rather do it manually 😞

@beatrizmaselli beatrizmaselli changed the title Fix/retrieve saved cards pii accounts Fix/ Retrieve saved cards for PII accounts Jun 13, 2024
@beatrizmaselli beatrizmaselli changed the title Fix/ Retrieve saved cards for PII accounts Fix/ Retrieve saved cards for at Profile System for PII accounts Jun 13, 2024
Copy link
Contributor

@vmourac-vtex vmourac-vtex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@beatrizmaselli, retornei com alguns comentários para ver o que você acha.
Se quiser pode me chamar e avaliamos juntos

node/clients/profile/profileV2.ts Show resolved Hide resolved
node/resolvers/profile/services.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@vmourac-vtex vmourac-vtex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@beatrizmaselli conversei com o @GusGuerra ontem. Demos uma olhada no PR juntos e achamos que a correção está basicamente OK

Só será mesmo necessário corrigir um bug que ocorre quando o usuário não possui cartão cadastrado. São as sugestões que deixei ativas ainda

Dá uma olhada e me fala!

node/resolvers/profile/services.ts Outdated Show resolved Hide resolved
node/resolvers/profile/services.ts Outdated Show resolved Hide resolved
beatrizmaselli and others added 2 commits June 26, 2024 17:06
Co-authored-by: vmourac-vtex <victor.moura@vtex.com>
Co-authored-by: vmourac-vtex <victor.moura@vtex.com>
vmourac-vtex
vmourac-vtex previously approved these changes Jun 26, 2024
@vmourac-vtex vmourac-vtex merged commit 1988ea3 into master Jun 28, 2024
5 checks passed
@vmourac-vtex vmourac-vtex deleted the Fix/retrieve-saved-cards-PII-accounts branch June 28, 2024 16:54
Copy link
Contributor

vtex-io-ci-cd bot commented Jun 28, 2024

Your PR has been merged! App is being published. 🚀
Version 2.170.4 → 2.171.0

After the publishing process has been completed (check #vtex-io-releases) and doing A/B tests with the new version, you can deploy your release by running:

vtex deploy vtex.store-graphql@2.171.0

After that your app will be updated on all accounts.

For more information on the deployment process check the docs. 📖

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants