@spartacus/checkout
Version:
Checkout feature library for Spartacus
575 lines (559 loc) • 35.9 kB
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@spartacus/core'), require('@angular/common/http'), require('@spartacus/checkout/core'), require('rxjs/operators'), require('@angular/common')) :
typeof define === 'function' && define.amd ? define('@spartacus/checkout/occ', ['exports', '@angular/core', '@spartacus/core', '@angular/common/http', '@spartacus/checkout/core', 'rxjs/operators', '@angular/common'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.spartacus = global.spartacus || {}, global.spartacus.checkout = global.spartacus.checkout || {}, global.spartacus.checkout.occ = {}), global.ng.core, global.core, global.ng.common.http, global.spartacus.checkout.core, global.rxjs.operators, global.ng.common));
}(this, (function (exports, i0, i2, i1, core, operators, common) { 'use strict';
function _interopNamespace(e) {
if (e && e.__esModule) return e;
var n = Object.create(null);
if (e) {
Object.keys(e).forEach(function (k) {
if (k !== 'default') {
var d = Object.getOwnPropertyDescriptor(e, k);
Object.defineProperty(n, k, d.get ? d : {
enumerable: true,
get: function () {
return e[k];
}
});
}
});
}
n['default'] = e;
return Object.freeze(n);
}
var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
var i2__namespace = /*#__PURE__*/_interopNamespace(i2);
var i1__namespace = /*#__PURE__*/_interopNamespace(i1);
var OccReplenishmentOrderFormSerializer = /** @class */ (function () {
function OccReplenishmentOrderFormSerializer() {
}
OccReplenishmentOrderFormSerializer.prototype.convert = function (source, target) {
if (target === undefined) {
target = Object.assign({}, source);
}
if (source.replenishmentStartDate) {
target.replenishmentStartDate = this.convertDate(source.replenishmentStartDate);
}
return target;
};
/**
* Adds the current timestamp (including timezone offset) to a date string in the format YYYY-mm-dd
* @Example
* Converts 2021-10-15 to 2021-10-15T15:38:05-05:00
*/
OccReplenishmentOrderFormSerializer.prototype.convertDate = function (date) {
var localTime = new Date().toLocaleTimeString([], {
hour: '2-digit',
minute: '2-digit',
hourCycle: 'h23',
});
return date + "T" + localTime + ":00" + i2.TimeUtils.getLocalTimezoneOffset();
};
return OccReplenishmentOrderFormSerializer;
}());
OccReplenishmentOrderFormSerializer.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.0.5", ngImport: i0__namespace, type: OccReplenishmentOrderFormSerializer, deps: [], target: i0__namespace.ɵɵFactoryTarget.Injectable });
OccReplenishmentOrderFormSerializer.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.0.5", ngImport: i0__namespace, type: OccReplenishmentOrderFormSerializer });
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.0.5", ngImport: i0__namespace, type: OccReplenishmentOrderFormSerializer, decorators: [{
type: i0.Injectable
}] });
var OccCheckoutCostCenterAdapter = /** @class */ (function () {
function OccCheckoutCostCenterAdapter(http, occEndpoints, converter) {
this.http = http;
this.occEndpoints = occEndpoints;
this.converter = converter;
}
OccCheckoutCostCenterAdapter.prototype.setCostCenter = function (userId, cartId, costCenterId) {
return this.http
.put(this.getSetCartCostCenterEndpoint(userId, cartId, costCenterId), {})
.pipe(this.converter.pipeable(i2.CART_NORMALIZER));
};
OccCheckoutCostCenterAdapter.prototype.getSetCartCostCenterEndpoint = function (userId, cartId, costCenterId) {
return this.occEndpoints.buildUrl('setCartCostCenter', {
urlParams: { userId: userId, cartId: cartId },
queryParams: { costCenterId: costCenterId },
});
};
return OccCheckoutCostCenterAdapter;
}());
OccCheckoutCostCenterAdapter.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.0.5", ngImport: i0__namespace, type: OccCheckoutCostCenterAdapter, deps: [{ token: i1__namespace.HttpClient }, { token: i2__namespace.OccEndpointsService }, { token: i2__namespace.ConverterService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
OccCheckoutCostCenterAdapter.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.0.5", ngImport: i0__namespace, type: OccCheckoutCostCenterAdapter });
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.0.5", ngImport: i0__namespace, type: OccCheckoutCostCenterAdapter, decorators: [{
type: i0.Injectable
}], ctorParameters: function () { return [{ type: i1__namespace.HttpClient }, { type: i2__namespace.OccEndpointsService }, { type: i2__namespace.ConverterService }]; } });
var OccCheckoutDeliveryAdapter = /** @class */ (function () {
function OccCheckoutDeliveryAdapter(http, occEndpoints, converter) {
this.http = http;
this.occEndpoints = occEndpoints;
this.converter = converter;
}
OccCheckoutDeliveryAdapter.prototype.getCreateDeliveryAddressEndpoint = function (userId, cartId) {
return this.occEndpoints.buildUrl('createDeliveryAddress', {
urlParams: {
userId: userId,
cartId: cartId,
},
});
};
OccCheckoutDeliveryAdapter.prototype.getSetDeliveryAddressEndpoint = function (userId, cartId, addressId) {
return this.occEndpoints.buildUrl('setDeliveryAddress', {
urlParams: { userId: userId, cartId: cartId },
queryParams: { addressId: addressId },
});
};
OccCheckoutDeliveryAdapter.prototype.getDeliveryModeEndpoint = function (userId, cartId) {
return this.occEndpoints.buildUrl('deliveryMode', {
urlParams: {
userId: userId,
cartId: cartId,
},
});
};
OccCheckoutDeliveryAdapter.prototype.getSetDeliveryModeEndpoint = function (userId, cartId, deliveryModeId) {
return this.occEndpoints.buildUrl('setDeliveryMode', {
urlParams: {
userId: userId,
cartId: cartId,
},
queryParams: { deliveryModeId: deliveryModeId },
});
};
OccCheckoutDeliveryAdapter.prototype.getDeliveryModesEndpoint = function (userId, cartId) {
return this.occEndpoints.buildUrl('deliveryModes', {
urlParams: { userId: userId, cartId: cartId },
});
};
OccCheckoutDeliveryAdapter.prototype.createAddress = function (userId, cartId, address) {
address = this.converter.convert(address, i2.ADDRESS_SERIALIZER);
return this.http
.post(this.getCreateDeliveryAddressEndpoint(userId, cartId), address, {
headers: new i1.HttpHeaders().set('Content-Type', 'application/json'),
})
.pipe(this.converter.pipeable(i2.ADDRESS_NORMALIZER));
};
OccCheckoutDeliveryAdapter.prototype.setAddress = function (userId, cartId, addressId) {
return this.http.put(this.getSetDeliveryAddressEndpoint(userId, cartId, addressId), {});
};
OccCheckoutDeliveryAdapter.prototype.setMode = function (userId, cartId, deliveryModeId) {
return this.http.put(this.getSetDeliveryModeEndpoint(userId, cartId, deliveryModeId), {});
};
OccCheckoutDeliveryAdapter.prototype.getMode = function (userId, cartId) {
return this.http
.get(this.getDeliveryModeEndpoint(userId, cartId))
.pipe(this.converter.pipeable(core.DELIVERY_MODE_NORMALIZER));
};
OccCheckoutDeliveryAdapter.prototype.getSupportedModes = function (userId, cartId) {
return this.http
.get(this.getDeliveryModesEndpoint(userId, cartId))
.pipe(operators.pluck('deliveryModes'), operators.map(function (modes) { return modes !== null && modes !== void 0 ? modes : []; }), this.converter.pipeableMany(core.DELIVERY_MODE_NORMALIZER));
};
return OccCheckoutDeliveryAdapter;
}());
OccCheckoutDeliveryAdapter.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.0.5", ngImport: i0__namespace, type: OccCheckoutDeliveryAdapter, deps: [{ token: i1__namespace.HttpClient }, { token: i2__namespace.OccEndpointsService }, { token: i2__namespace.ConverterService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
OccCheckoutDeliveryAdapter.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.0.5", ngImport: i0__namespace, type: OccCheckoutDeliveryAdapter });
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.0.5", ngImport: i0__namespace, type: OccCheckoutDeliveryAdapter, decorators: [{
type: i0.Injectable
}], ctorParameters: function () { return [{ type: i1__namespace.HttpClient }, { type: i2__namespace.OccEndpointsService }, { type: i2__namespace.ConverterService }]; } });
var OccCheckoutPaymentTypeAdapter = /** @class */ (function () {
function OccCheckoutPaymentTypeAdapter(http, occEndpoints, converter) {
this.http = http;
this.occEndpoints = occEndpoints;
this.converter = converter;
}
OccCheckoutPaymentTypeAdapter.prototype.loadPaymentTypes = function () {
return this.http
.get(this.getPaymentTypesEndpoint())
.pipe(operators.map(function (paymentTypeList) { var _a; return (_a = paymentTypeList.paymentTypes) !== null && _a !== void 0 ? _a : []; }), this.converter.pipeableMany(core.PAYMENT_TYPE_NORMALIZER));
};
OccCheckoutPaymentTypeAdapter.prototype.setPaymentType = function (userId, cartId, paymentType, purchaseOrderNumber) {
return this.http
.put(this.getSetCartPaymentTypeEndpoint(userId, cartId, paymentType, purchaseOrderNumber), {})
.pipe(this.converter.pipeable(i2.CART_NORMALIZER));
};
OccCheckoutPaymentTypeAdapter.prototype.getPaymentTypesEndpoint = function () {
return this.occEndpoints.buildUrl('paymentTypes');
};
OccCheckoutPaymentTypeAdapter.prototype.getSetCartPaymentTypeEndpoint = function (userId, cartId, paymentType, purchaseOrderNumber) {
var queryParams = purchaseOrderNumber
? { paymentType: paymentType, purchaseOrderNumber: purchaseOrderNumber }
: { paymentType: paymentType };
return this.occEndpoints.buildUrl('setCartPaymentType', {
urlParams: { userId: userId, cartId: cartId },
queryParams: queryParams,
});
};
return OccCheckoutPaymentTypeAdapter;
}());
OccCheckoutPaymentTypeAdapter.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.0.5", ngImport: i0__namespace, type: OccCheckoutPaymentTypeAdapter, deps: [{ token: i1__namespace.HttpClient }, { token: i2__namespace.OccEndpointsService }, { token: i2__namespace.ConverterService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
OccCheckoutPaymentTypeAdapter.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.0.5", ngImport: i0__namespace, type: OccCheckoutPaymentTypeAdapter });
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.0.5", ngImport: i0__namespace, type: OccCheckoutPaymentTypeAdapter, decorators: [{
type: i0.Injectable
}], ctorParameters: function () { return [{ type: i1__namespace.HttpClient }, { type: i2__namespace.OccEndpointsService }, { type: i2__namespace.ConverterService }]; } });
var OccCheckoutPaymentAdapter = /** @class */ (function () {
function OccCheckoutPaymentAdapter(http, occEndpoints, converter) {
this.http = http;
this.occEndpoints = occEndpoints;
this.converter = converter;
if (typeof DOMParser !== 'undefined') {
this.domparser = new DOMParser();
}
}
OccCheckoutPaymentAdapter.prototype.getSetPaymentDetailsEndpoint = function (userId, cartId, paymentDetailsId) {
return this.occEndpoints.buildUrl('setCartPaymentDetails', {
urlParams: { userId: userId, cartId: cartId },
queryParams: { paymentDetailsId: paymentDetailsId },
});
};
OccCheckoutPaymentAdapter.prototype.getPaymentProviderSubInfoEndpoint = function (userId, cartId) {
return this.occEndpoints.buildUrl('paymentProviderSubInfo', {
urlParams: {
userId: userId,
cartId: cartId,
},
});
};
OccCheckoutPaymentAdapter.prototype.getCreatePaymentDetailsEndpoint = function (userId, cartId) {
return this.occEndpoints.buildUrl('createPaymentDetails', {
urlParams: {
userId: userId,
cartId: cartId,
},
});
};
OccCheckoutPaymentAdapter.prototype.getCardTypesEndpoint = function () {
return this.occEndpoints.buildUrl('cardTypes');
};
OccCheckoutPaymentAdapter.prototype.create = function (userId, cartId, paymentDetails) {
var _this = this;
paymentDetails = this.converter.convert(paymentDetails, core.PAYMENT_DETAILS_SERIALIZER);
return this.getProviderSubInfo(userId, cartId).pipe(operators.map(function (data) {
var labelsMap = _this.convertToMap(data.mappingLabels.entry);
return {
url: data.postUrl,
parameters: _this.getParamsForPaymentProvider(paymentDetails, data.parameters.entry, labelsMap),
mappingLabels: labelsMap,
};
}), operators.mergeMap(function (sub) {
// create a subscription directly with payment provider
return _this.createSubWithProvider(sub.url, sub.parameters).pipe(operators.map(function (response) { return _this.extractPaymentDetailsFromHtml(response); }), operators.mergeMap(function (fromPaymentProvider) {
var _a;
fromPaymentProvider['defaultPayment'] =
(_a = paymentDetails.defaultPayment) !== null && _a !== void 0 ? _a : false;
fromPaymentProvider['savePaymentInfo'] = true;
return _this.createDetailsWithParameters(userId, cartId, fromPaymentProvider).pipe(_this.converter.pipeable(i2.PAYMENT_DETAILS_NORMALIZER));
}));
}));
};
OccCheckoutPaymentAdapter.prototype.set = function (userId, cartId, paymentDetailsId) {
return this.http.put(this.getSetPaymentDetailsEndpoint(userId, cartId, paymentDetailsId), {});
};
OccCheckoutPaymentAdapter.prototype.loadCardTypes = function () {
return this.http.get(this.getCardTypesEndpoint()).pipe(operators.map(function (cardTypeList) { var _a; return (_a = cardTypeList.cardTypes) !== null && _a !== void 0 ? _a : []; }), this.converter.pipeableMany(core.CARD_TYPE_NORMALIZER));
};
OccCheckoutPaymentAdapter.prototype.getProviderSubInfo = function (userId, cartId) {
return this.http.get(this.getPaymentProviderSubInfoEndpoint(userId, cartId));
};
OccCheckoutPaymentAdapter.prototype.createSubWithProvider = function (postUrl, parameters) {
var headers = new i1.HttpHeaders({
'Content-Type': 'application/x-www-form-urlencoded',
Accept: 'text/html',
});
var httpParams = new i1.HttpParams({ encoder: new i2.HttpParamsURIEncoder() });
Object.keys(parameters).forEach(function (key) {
httpParams = httpParams.append(key, parameters[key]);
});
return this.http.post(postUrl, httpParams, {
headers: headers,
responseType: 'text',
});
};
OccCheckoutPaymentAdapter.prototype.createDetailsWithParameters = function (userId, cartId, parameters) {
var httpParams = new i1.HttpParams({ encoder: new i2.HttpParamsURIEncoder() });
Object.keys(parameters).forEach(function (key) {
httpParams = httpParams.append(key, parameters[key]);
});
var headers = new i1.HttpHeaders({
'Content-Type': 'application/x-www-form-urlencoded',
});
return this.http.post(this.getCreatePaymentDetailsEndpoint(userId, cartId), httpParams, { headers: headers });
};
OccCheckoutPaymentAdapter.prototype.getParamsForPaymentProvider = function (paymentDetails, parameters, mappingLabels) {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
var params = this.convertToMap(parameters);
params[mappingLabels['hybris_account_holder_name']] =
paymentDetails.accountHolderName;
params[mappingLabels['hybris_card_type']] = (_a = paymentDetails.cardType) === null || _a === void 0 ? void 0 : _a.code;
params[mappingLabels['hybris_card_number']] = paymentDetails.cardNumber;
if (mappingLabels['hybris_combined_expiry_date'] === 'true') {
params[mappingLabels['hybris_card_expiry_date']] =
paymentDetails.expiryMonth +
mappingLabels['hybris_separator_expiry_date'] +
paymentDetails.expiryYear;
}
else {
params[mappingLabels['hybris_card_expiration_month']] =
paymentDetails.expiryMonth;
params[mappingLabels['hybris_card_expiration_year']] =
paymentDetails.expiryYear;
}
params[mappingLabels['hybris_card_cvn']] = paymentDetails.cvn;
// billing address
params[mappingLabels['hybris_billTo_country']] =
(_c = (_b = paymentDetails.billingAddress) === null || _b === void 0 ? void 0 : _b.country) === null || _c === void 0 ? void 0 : _c.isocode;
params[mappingLabels['hybris_billTo_firstname']] =
(_d = paymentDetails.billingAddress) === null || _d === void 0 ? void 0 : _d.firstName;
params[mappingLabels['hybris_billTo_lastname']] =
(_e = paymentDetails.billingAddress) === null || _e === void 0 ? void 0 : _e.lastName;
params[mappingLabels['hybris_billTo_street1']] =
((_f = paymentDetails.billingAddress) === null || _f === void 0 ? void 0 : _f.line1) +
' ' +
((_g = paymentDetails.billingAddress) === null || _g === void 0 ? void 0 : _g.line2);
params[mappingLabels['hybris_billTo_city']] =
(_h = paymentDetails.billingAddress) === null || _h === void 0 ? void 0 : _h.town;
if ((_j = paymentDetails.billingAddress) === null || _j === void 0 ? void 0 : _j.region) {
params[mappingLabels['hybris_billTo_region']] =
paymentDetails.billingAddress.region.isocodeShort;
}
else {
params[mappingLabels['hybris_billTo_region']] = '';
}
params[mappingLabels['hybris_billTo_postalcode']] =
(_k = paymentDetails.billingAddress) === null || _k === void 0 ? void 0 : _k.postalCode;
return params;
};
OccCheckoutPaymentAdapter.prototype.extractPaymentDetailsFromHtml = function (html) {
var domdoc = this.domparser.parseFromString(html, 'text/xml');
var responseForm = domdoc.getElementsByTagName('form')[0];
var inputs = responseForm.getElementsByTagName('input');
var values = {};
for (var i = 0; inputs[i]; i++) {
var input = inputs[i];
var name = input.getAttribute('name');
var value = input.getAttribute('value');
if (name && name !== '{}' && value && value !== '') {
values[name] = value;
}
}
return values;
};
OccCheckoutPaymentAdapter.prototype.convertToMap = function (paramList) {
return paramList.reduce(function (result, item) {
var key = item.key;
result[key] = item.value;
return result;
}, {});
};
return OccCheckoutPaymentAdapter;
}());
OccCheckoutPaymentAdapter.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.0.5", ngImport: i0__namespace, type: OccCheckoutPaymentAdapter, deps: [{ token: i1__namespace.HttpClient }, { token: i2__namespace.OccEndpointsService }, { token: i2__namespace.ConverterService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
OccCheckoutPaymentAdapter.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.0.5", ngImport: i0__namespace, type: OccCheckoutPaymentAdapter });
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.0.5", ngImport: i0__namespace, type: OccCheckoutPaymentAdapter, decorators: [{
type: i0.Injectable
}], ctorParameters: function () { return [{ type: i1__namespace.HttpClient }, { type: i2__namespace.OccEndpointsService }, { type: i2__namespace.ConverterService }]; } });
var OccCheckoutReplenishmentOrderAdapter = /** @class */ (function () {
function OccCheckoutReplenishmentOrderAdapter(http, occEndpoints, converter) {
this.http = http;
this.occEndpoints = occEndpoints;
this.converter = converter;
}
OccCheckoutReplenishmentOrderAdapter.prototype.getScheduleReplenishmentOrderEndpoint = function (userId, cartId, termsChecked) {
return this.occEndpoints.buildUrl('scheduleReplenishmentOrder', {
urlParams: {
userId: userId,
},
queryParams: { cartId: cartId, termsChecked: termsChecked },
});
};
OccCheckoutReplenishmentOrderAdapter.prototype.scheduleReplenishmentOrder = function (cartId, scheduleReplenishmentForm, termsChecked, userId) {
scheduleReplenishmentForm = this.converter.convert(scheduleReplenishmentForm, core.REPLENISHMENT_ORDER_FORM_SERIALIZER);
var headers = new i1.HttpHeaders().set('Content-Type', 'application/json');
return this.http
.post(this.getScheduleReplenishmentOrderEndpoint(userId, cartId, termsChecked.toString()), scheduleReplenishmentForm, { headers: headers })
.pipe(this.converter.pipeable(i2.REPLENISHMENT_ORDER_NORMALIZER));
};
return OccCheckoutReplenishmentOrderAdapter;
}());
OccCheckoutReplenishmentOrderAdapter.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.0.5", ngImport: i0__namespace, type: OccCheckoutReplenishmentOrderAdapter, deps: [{ token: i1__namespace.HttpClient }, { token: i2__namespace.OccEndpointsService }, { token: i2__namespace.ConverterService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
OccCheckoutReplenishmentOrderAdapter.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.0.5", ngImport: i0__namespace, type: OccCheckoutReplenishmentOrderAdapter });
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.0.5", ngImport: i0__namespace, type: OccCheckoutReplenishmentOrderAdapter, decorators: [{
type: i0.Injectable
}], ctorParameters: function () { return [{ type: i1__namespace.HttpClient }, { type: i2__namespace.OccEndpointsService }, { type: i2__namespace.ConverterService }]; } });
var OccCheckoutAdapter = /** @class */ (function () {
function OccCheckoutAdapter(http, occEndpoints, converter) {
this.http = http;
this.occEndpoints = occEndpoints;
this.converter = converter;
}
OccCheckoutAdapter.prototype.getPlaceOrderEndpoint = function (userId, cartId, termsChecked) {
return this.occEndpoints.buildUrl('placeOrder', {
urlParams: { userId: userId },
queryParams: { cartId: cartId, termsChecked: termsChecked },
});
};
OccCheckoutAdapter.prototype.getRemoveDeliveryAddressEndpoint = function (userId, cartId) {
return this.occEndpoints.buildUrl('removeDeliveryAddress', {
urlParams: {
userId: userId,
cartId: cartId,
},
});
};
OccCheckoutAdapter.prototype.getClearDeliveryModeEndpoint = function (userId, cartId) {
return this.occEndpoints.buildUrl('clearDeliveryMode', {
urlParams: { userId: userId, cartId: cartId },
});
};
OccCheckoutAdapter.prototype.getLoadCheckoutDetailsEndpoint = function (userId, cartId) {
return this.occEndpoints.buildUrl('loadCheckoutDetails', {
urlParams: {
userId: userId,
cartId: cartId,
},
});
};
OccCheckoutAdapter.prototype.placeOrder = function (userId, cartId, termsChecked) {
var headers = new i1.HttpHeaders({
'Content-Type': 'application/x-www-form-urlencoded',
});
if (userId === i2.OCC_USER_ID_ANONYMOUS) {
headers = i2.InterceptorUtil.createHeader(i2.USE_CLIENT_TOKEN, true, headers);
}
return this.http
.post(this.getPlaceOrderEndpoint(userId, cartId, termsChecked.toString()), {}, { headers: headers })
.pipe(this.converter.pipeable(i2.ORDER_NORMALIZER));
};
OccCheckoutAdapter.prototype.loadCheckoutDetails = function (userId, cartId) {
return this.http.get(this.getLoadCheckoutDetailsEndpoint(userId, cartId));
};
OccCheckoutAdapter.prototype.clearCheckoutDeliveryAddress = function (userId, cartId) {
return this.http.delete(this.getRemoveDeliveryAddressEndpoint(userId, cartId));
};
OccCheckoutAdapter.prototype.clearCheckoutDeliveryMode = function (userId, cartId) {
return this.http.delete(this.getClearDeliveryModeEndpoint(userId, cartId));
};
return OccCheckoutAdapter;
}());
OccCheckoutAdapter.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.0.5", ngImport: i0__namespace, type: OccCheckoutAdapter, deps: [{ token: i1__namespace.HttpClient }, { token: i2__namespace.OccEndpointsService }, { token: i2__namespace.ConverterService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
OccCheckoutAdapter.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.0.5", ngImport: i0__namespace, type: OccCheckoutAdapter });
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.0.5", ngImport: i0__namespace, type: OccCheckoutAdapter, decorators: [{
type: i0.Injectable
}], ctorParameters: function () { return [{ type: i1__namespace.HttpClient }, { type: i2__namespace.OccEndpointsService }, { type: i2__namespace.ConverterService }]; } });
var defaultOccCheckoutConfig = {
backend: {
occ: {
endpoints: {
/* eslint-disable max-len */
setDeliveryAddress: 'users/${userId}/carts/${cartId}/addresses/delivery',
placeOrder: 'users/${userId}/orders?fields=FULL',
cardTypes: 'cardtypes',
paymentTypes: 'paymenttypes',
createDeliveryAddress: 'users/${userId}/carts/${cartId}/addresses/delivery',
removeDeliveryAddress: 'users/${userId}/carts/${cartId}/addresses/delivery',
deliveryMode: 'users/${userId}/carts/${cartId}/deliverymode',
setDeliveryMode: 'users/${userId}/carts/${cartId}/deliverymode',
clearDeliveryMode: 'users/${userId}/carts/${cartId}/deliverymode',
deliveryModes: 'users/${userId}/carts/${cartId}/deliverymodes',
setCartCostCenter: 'users/${userId}/carts/${cartId}/costcenter?fields=DEFAULT,potentialProductPromotions,appliedProductPromotions,potentialOrderPromotions,appliedOrderPromotions,entries(totalPrice(formattedValue),product(images(FULL),stock(FULL)),basePrice(formattedValue,value),updateable),totalPrice(formattedValue),totalItems,totalPriceWithTax(formattedValue),totalDiscounts(value,formattedValue),subTotal(formattedValue),deliveryItemsQuantity,deliveryCost(formattedValue),totalTax(formattedValue, value),pickupItemsQuantity,net,appliedVouchers,productDiscounts(formattedValue),user',
setCartPaymentType: 'users/${userId}/carts/${cartId}/paymenttype?fields=DEFAULT,potentialProductPromotions,appliedProductPromotions,potentialOrderPromotions,appliedOrderPromotions,entries(totalPrice(formattedValue),product(images(FULL),stock(FULL)),basePrice(formattedValue,value),updateable),totalPrice(formattedValue),totalItems,totalPriceWithTax(formattedValue),totalDiscounts(value,formattedValue),subTotal(formattedValue),deliveryItemsQuantity,deliveryCost(formattedValue),totalTax(formattedValue, value),pickupItemsQuantity,net,appliedVouchers,productDiscounts(formattedValue),user',
setCartPaymentDetails: 'users/${userId}/carts/${cartId}/paymentdetails',
paymentProviderSubInfo: 'users/${userId}/carts/${cartId}/payment/sop/request?responseUrl=sampleUrl',
createPaymentDetails: 'users/${userId}/carts/${cartId}/payment/sop/response',
loadCheckoutDetails: 'users/${userId}/carts/${cartId}?fields=deliveryAddress(FULL),deliveryMode,paymentInfo(FULL)',
/* eslint-enable */
},
},
},
};
var CheckoutOccModule = /** @class */ (function () {
function CheckoutOccModule() {
}
return CheckoutOccModule;
}());
CheckoutOccModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.0.5", ngImport: i0__namespace, type: CheckoutOccModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
CheckoutOccModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.0.5", ngImport: i0__namespace, type: CheckoutOccModule, imports: [common.CommonModule] });
CheckoutOccModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.0.5", ngImport: i0__namespace, type: CheckoutOccModule, providers: [
i2.provideDefaultConfig(defaultOccCheckoutConfig),
OccReplenishmentOrderFormSerializer,
{
provide: core.CheckoutAdapter,
useClass: OccCheckoutAdapter,
},
{
provide: core.CheckoutDeliveryAdapter,
useClass: OccCheckoutDeliveryAdapter,
},
{
provide: core.CheckoutPaymentAdapter,
useClass: OccCheckoutPaymentAdapter,
},
{
provide: core.PaymentTypeAdapter,
useClass: OccCheckoutPaymentTypeAdapter,
},
{
provide: core.CheckoutCostCenterAdapter,
useClass: OccCheckoutCostCenterAdapter,
},
{
provide: core.CheckoutReplenishmentOrderAdapter,
useClass: OccCheckoutReplenishmentOrderAdapter,
},
{
provide: core.REPLENISHMENT_ORDER_FORM_SERIALIZER,
useExisting: OccReplenishmentOrderFormSerializer,
multi: true,
},
], imports: [[common.CommonModule]] });
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.0.5", ngImport: i0__namespace, type: CheckoutOccModule, decorators: [{
type: i0.NgModule,
args: [{
imports: [common.CommonModule],
providers: [
i2.provideDefaultConfig(defaultOccCheckoutConfig),
OccReplenishmentOrderFormSerializer,
{
provide: core.CheckoutAdapter,
useClass: OccCheckoutAdapter,
},
{
provide: core.CheckoutDeliveryAdapter,
useClass: OccCheckoutDeliveryAdapter,
},
{
provide: core.CheckoutPaymentAdapter,
useClass: OccCheckoutPaymentAdapter,
},
{
provide: core.PaymentTypeAdapter,
useClass: OccCheckoutPaymentTypeAdapter,
},
{
provide: core.CheckoutCostCenterAdapter,
useClass: OccCheckoutCostCenterAdapter,
},
{
provide: core.CheckoutReplenishmentOrderAdapter,
useClass: OccCheckoutReplenishmentOrderAdapter,
},
{
provide: core.REPLENISHMENT_ORDER_FORM_SERIALIZER,
useExisting: OccReplenishmentOrderFormSerializer,
multi: true,
},
],
}]
}] });
/**
* Generated bundle index. Do not edit.
*/
exports.CheckoutOccModule = CheckoutOccModule;
exports.OccCheckoutAdapter = OccCheckoutAdapter;
exports.OccCheckoutCostCenterAdapter = OccCheckoutCostCenterAdapter;
exports.OccCheckoutDeliveryAdapter = OccCheckoutDeliveryAdapter;
exports.OccCheckoutPaymentAdapter = OccCheckoutPaymentAdapter;
exports.OccCheckoutPaymentTypeAdapter = OccCheckoutPaymentTypeAdapter;
exports.OccCheckoutReplenishmentOrderAdapter = OccCheckoutReplenishmentOrderAdapter;
exports.OccReplenishmentOrderFormSerializer = OccReplenishmentOrderFormSerializer;
Object.defineProperty(exports, '__esModule', { value: true });
})));
//# sourceMappingURL=spartacus-checkout-occ.umd.js.map