Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

POSSIBLE PROBLEM (these masses of data are prod-voucherify)

...

Technical Frontend analysis

...

Currently to show the promo code field, we need to configure the sanity with CBA offers (and the CBA offers is deprecated).

When we applied the promo code on whitelabelWhitelabel, we receive an error: Something went wrong. Please try again.

...

request:

Besides that we have a possible problem: these masses of data are prod-voucherify

This is the example of the request/response when applying a promotional code:

Request:

Code Block
languagejson
{
    "code": "8B9IKPQK",
    "cognitoId": "ec5cec01-b41b-509b-9111-310ab5a18154",
    "shouldRedeem": true,
    "offers": [
        "7bf2c11c-ec68-4d44-abd3-597b3967fcef"
    ]
}

responseResponse:

Code Block
languagejson
{
    "data": {
        "validatePromoCode": {
            "code": "8B9IKPQK",
            "reason": "misconfiguredCode",
            "message": "missing offerId",
            "isValid": false,
            "isRedeemed": false,
            "offerId": "",
            "__typename": "CBACouponResponse"
        }
    }
}

Attention

...

point

  • We are always sending cognitoId attribute (cognitoId is like user id);

  • The promo code is CBACoupon type;

  • We sent a send an available offer "7bf2c11c-ec68-4d44-abd3-597b3967fcef";

...

Technical Backend analysis

On backend , they use the intl-promotion-service repository receive this call.

There is a method validateCoupon that receive receives the frontend call

  • path: intl-promotion-service/src/providers/vendors/voucherify.ts

This flow , is create a customers datas on voucherity will create customer data on Voucherity with metadata:

Code Block
languagejson
{
    metadata: {
      userIdType: "cognitoId",
    },
    source_id: "ec5cec01-b41b-509b-9111-310ab5a18154",
  }

...

  • if userIdType: "cognitoId" so, the promo code is CBA type.

  • if userIdType: "loyaltyId" so, the promo code is loyalty type.

  • On As frontend always send sends the attributecognitoId on backend, in other words, the promo code at checkout will be always CBA type.

after that is validated After validating the voucher with voucherify Voucherify API (client.validations.validateVoucher(), this return is) the return will be:

Code Block
languagejson
{
  valid: true,
  applicable_to: { data: [], total: 0, data_ref: 'data', object: 'list' },
  inapplicable_to: { data: [], total: 0, data_ref: 'data', object: 'list' },
  tracking_id: 'track_ECpOaiQwipBVhSIEWGSfgmnjgtme+FQfW97lzOopYE6W1FvVYiEk7A==',
  code: 'INBIIT5F',
  discount: { type: 'AMOUNT', effect: 'APPLY_TO_ORDER', amount_off: 5000 },
  start_date: '2023-08-28T07:00:00.000Z',
  metadata: { configId: '7bf2c11c-ec68-4d44-abd3-597b3967fcef' },
  campaign: 'TEST VOUCHERIFY',
  campaign_id: 'camp_bHKpj7ruZxRPLoq2BqfCx0H2'
}

The problem start starts here, : because the attribute metadata contains { configId: ‘7bf2c11c-ec68-4d44-abd3-597b3967fcef' }, this value is for loyalty code types, in other words, this return is worng, wrong and should be return returned an offerId attribute.

...

...

Possibility Solution

...

With the analysis above and as CBA promo code is deprecated : (https://rbidigital.slack.com/archives/C04FZ5HTH35/p1693855082030399We will ) we'll need to change the frontend flow to send loyaltyId instead of cognitoId.Currently on

  • The method

...

  • onSubmitPromoCode calls the mutation

...

  • promotionValidatePromoCodeMutation that will send the cognitoId

...

  • There is a mutation redeemMutation that send the loyaltyId, so we will add this mutation with

...

  • some condition to send loyaltyId (to markets that

...

  • want to use promo code at checkout, or to market that

...

  • doesn’t use it and impact other markets).

    • This condition can be a flag on sanity maybe.

...

...

Attention point

...

Is possible on voucherifyVoucherify, configure a promo code with expiryDate undefined, but on backend validate it and can receive a an error, so if it will need to use a an “infinity“ expiryDate, that don’t doesn’t have an end date finish, so we will change a validate date loyalty flow.

currency Currency code:

...

We will change this condition to validate the expiry date just there is a valide date.

After

...

these changes on frontend and backend

...

  • OBS:. This test was done, mocking de the codes and apis APIs responses, using apollo studio

...

Code Block
{
  "data": {
    "loyaltyValidatePromoCode": {
      "code": "8B9IKPQK",
      "configId": "7bf2c11c-ec68-4d44-abd3-597b3967fcef",
      "isRedeemed": true,
      "isValid": true,
      "message": "",
      "personalizedOfferId": null,
      "reason": null,
      "shouldRedeem": null
    }
  }
}

Configuration Promo code

...

How to calculate the discount value

  • Send the offer sanityId to Winrest

    • They will register these sanityId on their system, and after that, we’ll use some offers with these sanityId registered, and Winrest will return the calculated offers correctly

      • We already sent the sanityId offer to the backend (intl-partners-service)

    • When the intl-partners-service calls the Winrest API, the integration will know how much will be the discount

    • The discount is always on the total value of the cart

...

How to configure a promotional code

To show the feature on checkout:

To create the promotional codes, we need to access from Voucherify, this vendor is used current by PLK ES in production to create another other promo codes on offers page;

...