feat: support multiple payment gateway#21374
Conversation
spartacus
|
||||||||||||||||||||||||||||
| Project |
spartacus
|
| Branch Review |
multi-payment-gateway
|
| Run status |
|
| Run duration | 04m 22s |
| Commit |
|
| Committer | ijitendrasap |
| View all properties for this run ↗︎ | |
| Test results | |
|---|---|
|
|
0
|
|
|
3
|
|
|
0
|
|
|
0
|
|
|
101
|
| View all changes introduced in this branch ↗︎ | |
There was a problem hiding this comment.
Please make sure this stays backward compatible. Changing APIs from a single OpfActiveConfiguration to OpfActiveConfiguration[] (and similar signature changes like activeConfiguration → activeConfigurations) is a breaking change for existing consumers.
We’d like this to be strictly backward compatible and preserve the exact old behavior when a single OpfActiveConfiguration is provided. Only when an array is passed should we execute the new multi-config logic.
Concretely, please add explicit branching everywhere the new logic is used, e.g.:
@Input() activeConfiguration: OpfActiveConfiguration | OpfActiveConfiguration[];
if (Array.isArray(this.activeConfiguration)) {
// here TS knows: OpfActiveConfiguration[]
// run NEW multi-config logic
} else {
// here TS knows: OpfActiveConfiguration
// keep OLD single-config logic
}
Same principle for any helpers/services that changed from activeConfiguration → activeConfigurations: keep the old single-config path intact, and only use the new code when an array is actually provided.
| @@ -37,7 +37,7 @@ export class OpfQuickBuyButtonsComponent implements OnInit { | |||
|
|
|||
| isPaymentMethodEnabled( | |||
| provider: OpfQuickBuyProviderType, | |||
| activeConfiguration: OpfActiveConfiguration | |||
| activeConfiguration: OpfActiveConfiguration[] | |||
| ): boolean { | |||
| return this.opfQuickBuyButtonsService.isQuickBuyProviderEnabled( | |||
| provider, | |||
There was a problem hiding this comment.
If we change @Input() activeConfiguration from OpfActiveConfiguration to OpfActiveConfiguration[], that’s a breaking change: existing consumers binding [activeConfiguration]="config" (single object) will no longer type-check/compile and would have to pass an array instead.
Can we avoid/omit this API change (e.g., keep the input as a single OpfActiveConfiguration and derive what we need internally), or provide a backwards-compatible input shape?
@Input() activeConfiguration:
| OpfActiveConfiguration
| OpfActiveConfiguration[];
get activeConfigurations(): OpfActiveConfiguration[] {
const value = this.activeConfiguration;
return Array.isArray(value) ? value : value ? [value] : [];
}
There was a problem hiding this comment.
I’ve kept the input variable as a single OpfActiveConfiguration and used a getter to normalize it into an array internally.
Merge Checks Failed |
No description provided.