Skip to content

Commit

Permalink
Sync develop into stage (#231)
Browse files Browse the repository at this point in the history
* 24PW: New Template - Paid Blog  (#219)

* WIP on feature/paid-blog-landing-page

* WIP on feature/paid-blog-landing-page

* WIP on feature/paid-blog-landing-page

* WIP on feature/paid-blog-landing-page

* WIP on feature/paid-blog-landing-page

* WIP on feature/paid-blog-landing-page

* WIP on feature/paid-blog-landing-page

* WIP on feature/paid-blog-landing-page

* WIP on feature/paid-blog-landing-page

* WIP on feature/paid-blog-landing-page

* WIP on feature/paid-blog-landing-page

* 24PW: Pawpack Page - EDS Build (#215)

* WIP on feature/pawpack-page

* WIP on feature/pawpack-page

* Fix lint issues on feature/pawpack-page

* WIP on feature/pawpack-page

* Added Shipping of Tag to the summary page (#221)

* 24PW: Pawpack Page - EDS Build - QA Feedback (#222)

* WIP on feature/pawpack-page

* WIP on feature/pawpack-page

* Fix lint issues on feature/pawpack-page

* WIP on feature/pawpack-page

* QA feedback on feature/pawpack-page

* QA feedback on feature/pawpack-page

* QA feedback on feature/pawpack-page

* QA feedback on feature/pawpack-page

* WIP on bugfix/mobile-nav-redirect-visibility (#224)

* 24PW: Pet Insurance - Aggregator Widget (#225)

* Adding widget aggregator block from petplace to 24petwatch

* updating css media query at point iframe size changes, updated id refs

* Revert decorateButtons function, apply callout cta styling (#226)

* Adding thank you page dataLayer object (#230)

* WIP on feature/PM-56724-dl-thank-you

* WIP on feature/PM-56724-dl-thank-you

* WIP on feature/PM-56724-dl-thank-you

* WIP on feature/PM-56724-dl-thank-you

* Adding product_type value to DL object

* Fixing lint reported formatting issues

* reverting eslint rule changes

---------

Co-authored-by: Daniel O'Kane <daniel.okane@herodigital.com>

---------

Co-authored-by: hero-dokane <46008504+hero-dokane@users.noreply.github.com>
Co-authored-by: Bohdan Korablov <korablov@adobe.com>
Co-authored-by: Daniel O'Kane <daniel.okane@herodigital.com>
  • Loading branch information
4 people authored Oct 11, 2024
1 parent d5d7dbe commit 1b08b7c
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 2 deletions.
37 changes: 36 additions & 1 deletion blocks/thank-you/thank-you.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
COOKIE_NAME_SAVED_OWNER_ID,
deleteCookie,
} from '../../scripts/24petwatch-utils.js';
import { trackGTMEvent } from '../../scripts/lib-analytics.js';

// prep for API calls
const apiBaseUrl = await getAPIBaseUrl();
Expand Down Expand Up @@ -70,6 +71,18 @@ async function postEmailReceipt(ownerId) {
}
}

// Step 7 - get transaction details
async function getTransaction(paymentProcessorId) {
try {
const data = await APIClientObj.getTransaction(paymentProcessorId);
return data;
} catch (status) {
// eslint-disable-next-line no-console
console.log('Failed to get the transaction details:', status);
return [];
}
}

export default async function decorate() {
// delete cookie with customer id
deleteCookie(COOKIE_NAME_SAVED_OWNER_ID);
Expand All @@ -88,8 +101,13 @@ export default async function decorate() {

await postEmailReceipt(getOwnerDetails.id);

const transactionDetails = await getTransaction(paymentProcessorId);
const { externalTransactionID, paymentMethod } = transactionDetails;

const h1 = document.querySelector('h1');
const { firstName, lastName } = getOwnerDetails;
const {
cartFlow, firstName, lastName, nonInsPromoCode,
} = getOwnerDetails;
const { petSummaries } = getPurchaseSummaryDetails;
const contentColumn = document.querySelector('.thank-you-purchase .columns > div:nth-child(1) > div');

Expand Down Expand Up @@ -138,6 +156,23 @@ export default async function decorate() {

contentColumn.appendChild(totals);

const trackingData = {
microchip_number: petSummaries[0].microChipNumber,
product_type: petSummaries[0].membershipName,
transaction_id: externalTransactionID,
affiliation: '24petwatch',
tax: summary.salesTaxes,
payment_type: paymentMethod,
value: summary.totalDueToday,
shipping: petSummaries[0].nonInsurancePetSummary.shipping,
coupon: nonInsPromoCode,
flow: cartFlow,
customerid: getOwnerDetails.id,
};

// send the GTM event
trackGTMEvent('purchase', trackingData);

const printButton = document.createElement('button');
printButton.classList.add('button');
printButton.innerHTML = 'Print <span class="visually-hidden">this page</span>';
Expand Down
10 changes: 9 additions & 1 deletion scripts/24petwatch-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export default class APIClient {
}

getPaymentCustomerIDFromUUID(customerUUID) {
const path = '/Transaction/GetPaymentCustomerIDFromUUID';
const path = 'Transaction/GetPaymentCustomerIDFromUUID';
const body = { CustomerUUID: customerUUID };
return new Promise((resolve, reject) => {
APIClient.callAPI(`${this.basePath}/${path}`, APIClient.METHOD_POST, body, null, resolve, reject, 'json');
Expand All @@ -131,6 +131,14 @@ export default class APIClient {
});
}

getTransaction(customerUUID) {
const path = 'Product/NonInsurance/GetTransaction';
const body = { CustomerUUID: customerUUID };
return new Promise((resolve, reject) => {
APIClient.callAPI(`${this.basePath}/${path}`, APIClient.METHOD_GET, body, null, resolve, reject, 'json');
});
}

/** Creates or Updates an owner, depending on whether the ownerId is provided.
* @param ownerId - if provided, the owner will be updated, otherwise a new owner will be created
* @param email - string
Expand Down

0 comments on commit 1b08b7c

Please sign in to comment.