Skip to content

Commit

Permalink
ISREST-1006: adjust hosted payment page parameters mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
skoch-intershop committed Mar 27, 2020
1 parent 0179ee8 commit a2f7e65
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions src/app/core/models/payment-method/payment-method.mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class PaymentMethodMapper {
if (!body.data.length) {
return [];
}
const paymentMethods = body.data
return body.data
.filter(data => PaymentMethodMapper.isPaymentMethodValid(data))
.map(data => ({
id: data.id,
Expand All @@ -40,14 +40,11 @@ export class PaymentMethodMapper {
? data.paymentInstruments.map(id => included.paymentInstruments[id])
: undefined,
parameters: data.parameterDefinitions ? PaymentMethodMapper.mapParameter(data.parameterDefinitions) : undefined,
hostedPaymentPageParameters: data.hostedPaymentPageParameters,
hostedPaymentPageParameters:
data.id === 'Concardis_DirectDebit'
? PaymentMethodMapper.mapSEPAMandateInformation(data.hostedPaymentPageParameters)
: data.hostedPaymentPageParameters,
}));

// map sepa mandate information only for concardis direct debit
paymentMethods
.filter(pm => pm.id === 'Concardis_DirectDebit')
.forEach(pm => PaymentMethodMapper.mapSEPAMandateInformation(pm));
return paymentMethods;
}

// is needed for getting a user's eligible payment methods
Expand Down Expand Up @@ -199,9 +196,9 @@ export class PaymentMethodMapper {
/**
* convenience method to restructure concardis sepa mandate hosted payment page parameter
*/
private static mapSEPAMandateInformation(pm: PaymentMethod) {
const hostedPaymentPageParameters = pm.hostedPaymentPageParameters;

private static mapSEPAMandateInformation(
hostedPaymentPageParameters: { name: string; value: string }[]
): { name: string; value: string }[] {
hostedPaymentPageParameters
.filter(hppp => hppp.name === 'Concardis_SEPA_Mandate')
.forEach(mandateEntry => {
Expand All @@ -216,5 +213,6 @@ export class PaymentMethodMapper {
hostedPaymentPageParameters.push({ name: 'directDebitType', value: sepaMandateArray.directDebitType });
}
});
return hostedPaymentPageParameters;
}
}

0 comments on commit a2f7e65

Please sign in to comment.