-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'refs/heads/main' into feature/AD-288
- Loading branch information
Showing
13 changed files
with
258 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,51 @@ | ||
# AdyenSpartacus | ||
# SAP Composable Storefront - Adyen Payments Library ( 0.3 Alpha) | ||
|
||
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 17.3.6. | ||
This repository contains an Angular library that integrates Adyen payments into the SAP Composable Storefront, specifically designed for the Spartacus framework. Please note that this is an **unstable alpha version**, and it is still under development. Use it at your own risk and in testing environments only. | ||
|
||
## Development server | ||
## Requirements | ||
|
||
Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The application will automatically reload if you change any of the source files. | ||
- Angular version: `17.3.0` | ||
- Spartacus version: `2211.23.0-1` | ||
|
||
## Code scaffolding | ||
## Installation | ||
|
||
Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`. | ||
### Prerequisites | ||
|
||
## Build | ||
Before installing the Adyen Payments library, ensure that you have a local npm registry running. If not, you can start one with [Verdaccio](https://verdaccio.org/). | ||
|
||
Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. | ||
### Build and Publish the Library | ||
|
||
## Running unit tests | ||
1. **Clone the repository**: | ||
```bash | ||
git clone https://github.com/Adyen/adyen-spartacus/ | ||
cd adyen-spartacus/projects/adyen-payments | ||
``` | ||
2. **Build the package**: | ||
|
||
Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io). | ||
```bash | ||
npm run build | ||
``` | ||
3. **Publish the package to the local npm registry**: | ||
|
||
## Running end-to-end tests | ||
```bash | ||
npm --registry http://localhost:4873 publish --access public | ||
``` | ||
### Installation on SAP Composable Storefront | ||
|
||
Run `ng e2e` to execute the end-to-end tests via a platform of your choice. To use this command, you need to first add a package that implements end-to-end testing capabilities. | ||
**Install the Adyen Payments library**: | ||
|
||
## Further help | ||
ng add adyen-payments --registry http://localhost:4873 | ||
|
||
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page. | ||
This will automatically configure your storefront to include Adyen Payments functionality if it is a clean installation. | ||
|
||
### Manual Configuration (Non-clean Installations): | ||
|
||
If your Spartacus storefront already has modifications, you might need to manually update the **checkout-feature.module.ts** and **order-feature.module.ts** files. | ||
Refer to the templates provided in the schematics directory of the Adyen Payments library for the correct configurations. | ||
|
||
## Known Issues | ||
This is an alpha release and may contain bugs. Please report any issues you encounter. | ||
The library has been tested with the specified versions of Angular and Spartacus only. Compatibility with other versions is not guaranteed. | ||
|
||
## License | ||
This project is licensed under the MIT License - see the LICENSE file for details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
107 changes: 107 additions & 0 deletions
107
projects/adyen-payments/schematics/adyen-payment-step/files/checkout-feature.module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
import {NgModule} from '@angular/core'; | ||
import {checkoutTranslationChunksConfig, checkoutTranslations} from "@spartacus/checkout/base/assets"; | ||
import {CHECKOUT_CORE_FEATURE, CHECKOUT_FEATURE, CheckoutStepType} from "@spartacus/checkout/base/root"; | ||
import {CmsConfig, I18nConfig, provideConfig,provideDefaultConfigFactory} from "@spartacus/core"; | ||
import {AdyenPaymentsModule} from "adyen-payments"; | ||
import {CART_BASE_FEATURE} from '@spartacus/cart/base/root'; | ||
|
||
|
||
export const CHECKOUT_BASE_CMS_COMPONENTS: string[] = [ | ||
'CheckoutOrchestrator', | ||
'CheckoutOrderSummary', | ||
'CheckoutProgress', | ||
'CheckoutProgressMobileBottom', | ||
'CheckoutProgressMobileTop', | ||
'CheckoutDeliveryMode', | ||
'CheckoutAdyenPaymentDetails', | ||
'CheckoutPlaceOrder', | ||
'CheckoutReviewOrder', | ||
'CheckoutReviewPayment', | ||
'CheckoutReviewShipping', | ||
'CheckoutReviewOverview', | ||
'CheckoutDeliveryAddress', | ||
'GuestCheckoutLoginComponent', | ||
]; | ||
|
||
export function adyenCheckoutComponentsConfig() { | ||
const config: CmsConfig = { | ||
featureModules: { | ||
[CHECKOUT_FEATURE]: { | ||
cmsComponents: CHECKOUT_BASE_CMS_COMPONENTS, | ||
dependencies: [CART_BASE_FEATURE], | ||
}, | ||
// by default core is bundled together with components | ||
[CHECKOUT_CORE_FEATURE]: CHECKOUT_FEATURE, | ||
}, | ||
}; | ||
return config; | ||
} | ||
|
||
export const translationOverwrites = { | ||
en: { // lang | ||
checkout: { // chunk | ||
checkoutProgress: { // keys (nested) | ||
deliveryModePaymentDetails: 'Delivery Mode Payment Details', | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
@NgModule({ | ||
declarations: [], | ||
imports: [ | ||
AdyenPaymentsModule | ||
], | ||
providers: [ | ||
provideDefaultConfigFactory(adyenCheckoutComponentsConfig), | ||
provideConfig(<CmsConfig>{ | ||
featureModules: { | ||
[CHECKOUT_FEATURE]: { | ||
module: () => | ||
import('@spartacus/checkout/base').then((m) => m.CheckoutModule), | ||
}, | ||
} | ||
}), | ||
provideConfig({ | ||
i18n: {resources: translationOverwrites}, | ||
}), | ||
provideConfig(<I18nConfig>{ | ||
i18n: { | ||
resources: checkoutTranslations, | ||
chunks: checkoutTranslationChunksConfig, | ||
}, | ||
routing: { | ||
routes: { | ||
// Add a new route for the combined step | ||
checkoutAdyenPaymentDetails: { | ||
paths: ['checkout/adyen-payment-details'], | ||
}, | ||
}, | ||
}, | ||
checkout: { | ||
steps: [ | ||
{ | ||
id: 'deliveryAddress', | ||
name: 'checkoutProgress.deliveryAddress', | ||
routeName: 'checkoutDeliveryAddress', | ||
type: [CheckoutStepType.DELIVERY_ADDRESS], | ||
}, | ||
{ | ||
id: 'deliveryMode', | ||
name: 'checkoutProgress.deliveryMode', | ||
routeName: 'checkoutDeliveryMode', | ||
type: [CheckoutStepType.DELIVERY_MODE], | ||
}, | ||
{ | ||
id: 'adyenPaymentDetails', | ||
name: 'checkoutProgress.paymentDetails', | ||
routeName: 'checkoutAdyenPaymentDetails', | ||
type: [CheckoutStepType.PAYMENT_DETAILS], | ||
}, | ||
], | ||
}, | ||
}) | ||
] | ||
}) | ||
export class CheckoutFeatureModule { | ||
} |
33 changes: 33 additions & 0 deletions
33
projects/adyen-payments/schematics/adyen-payment-step/files/order-feature.module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import {NgModule} from '@angular/core'; | ||
import {CmsConfig, I18nConfig, provideConfig} from "@spartacus/core"; | ||
import {orderTranslationChunksConfig, orderTranslations} from "@spartacus/order/assets"; | ||
import {ORDER_FEATURE, OrderFacade, OrderRootModule} from "@spartacus/order/root"; | ||
import {AdyenOrderService, OrderConfirmationPaymentStatusModule} from "adyen-payments"; | ||
|
||
@NgModule({ | ||
declarations: [], | ||
imports: [ | ||
OrderRootModule, | ||
OrderConfirmationPaymentStatusModule | ||
], | ||
providers: [provideConfig(<CmsConfig>{ | ||
featureModules: { | ||
[ORDER_FEATURE]: { | ||
module: () => | ||
import('@spartacus/order').then((m) => m.OrderModule), | ||
}, | ||
} | ||
}), | ||
provideConfig(<I18nConfig>{ | ||
i18n: { | ||
resources: orderTranslations, | ||
chunks: orderTranslationChunksConfig, | ||
}, | ||
}), | ||
{ | ||
provide: OrderFacade, | ||
useExisting: AdyenOrderService, | ||
} | ||
] | ||
}) | ||
export class OrderFeatureModule { } |
30 changes: 30 additions & 0 deletions
30
projects/adyen-payments/schematics/adyen-payment-step/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { Rule, SchematicContext, url, apply, template, mergeWith, chain, MergeStrategy, move } from '@angular-devkit/schematics'; | ||
import { strings } from '@angular-devkit/core'; | ||
|
||
function applyTemplateAndMerge(sourcePath: string, destinationPath: string, _options: any): Rule { | ||
const sourceTemplates = url(sourcePath); | ||
const sourceParameterizedTemplate = apply(sourceTemplates, [ | ||
template({ | ||
..._options, | ||
...strings, | ||
}), | ||
move(destinationPath), | ||
]); | ||
|
||
return mergeWith(sourceParameterizedTemplate, MergeStrategy.Overwrite); | ||
} | ||
|
||
export function adyenPaymentStep(_options: any): Rule { | ||
return (_: any, _context: SchematicContext) => { | ||
const checkoutDestinationPath = 'src/app/spartacus/features/checkout/checkout-feature.module.ts'; | ||
const checkoutSourcePath = './files/checkout-feature.module.ts'; | ||
|
||
const orderDestinationPath = 'src/app/spartacus/features/order/order-feature.module.ts'; | ||
const orderSourcePath = './files/order-feature.module.ts'; | ||
|
||
return chain([ | ||
applyTemplateAndMerge(checkoutSourcePath, checkoutDestinationPath, _options), | ||
applyTemplateAndMerge(orderSourcePath, orderDestinationPath, _options) | ||
]); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,9 @@ | ||
import { Rule } from '@angular-devkit/schematics'; | ||
import { addRootImport } from '@schematics/angular/utility'; | ||
import {Schema} from "../payment-step/schema"; | ||
import { chain, Rule, schematic, SchematicContext, Tree } from '@angular-devkit/schematics'; | ||
|
||
|
||
export function ngAdd(options: Schema): Rule { | ||
// Add an import `AdyenPayments` from `adyen-payments` to the root of the user's project. | ||
return addRootImport(options.project, ({code, external}) => | ||
code`${external('AdyenPayments', 'adyen-payments')}`); | ||
|
||
export function ngAdd(options: any): Rule { | ||
return (tree: Tree, _context: SchematicContext) => { | ||
return chain([schematic('adyen-payment-step', options)])(tree, _context); | ||
}; | ||
} |
28 changes: 0 additions & 28 deletions
28
projects/adyen-payments/schematics/payment-step/schema.json
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.