-
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 pull request #20 from Adyen/feature/AD-315
AD-315 I can't pay with any method if the first payment attempt is ca…
- Loading branch information
Showing
9 changed files
with
131 additions
and
66 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
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
1 change: 0 additions & 1 deletion
1
projects/adyen-payments/src/lib/core/connectors/additional-details.connector.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
10 changes: 7 additions & 3 deletions
10
...b/core/connectors/placeorder.connector.ts → ...nnectors/adyen-order-connector.service.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 |
---|---|---|
@@ -1,13 +1,17 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { Observable } from 'rxjs'; | ||
import { OccPlaceOrderAdapter } from '../occ/adapters/occ-placeorder.adapter'; | ||
import {PlaceOrderRequest, PlaceOrderResponse} from "../models/occ.order.models"; | ||
import {OccAdyenOrderAdapter} from "../occ/adapters/occ-adyen-order.adapter"; | ||
|
||
@Injectable() | ||
export class PlaceOrderConnector { | ||
constructor(protected adapter: OccPlaceOrderAdapter) {} | ||
export class AdyenOrderConnector { | ||
constructor(protected adapter: OccAdyenOrderAdapter) {} | ||
|
||
placeOrder(userId: string, cartId: string, orderData: PlaceOrderRequest): Observable<PlaceOrderResponse> { | ||
return this.adapter.placeOrder(userId, cartId, orderData); | ||
} | ||
|
||
paymentCanceled(userId: string, cartId: string, orderCode: string): Observable<void> { | ||
return this.adapter.cancelPayment(userId, cartId, orderCode); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
projects/adyen-payments/src/lib/core/occ/adapters/occ-adyen-order.adapter.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,43 @@ | ||
import {Injectable} from '@angular/core'; | ||
import {HttpClient} from '@angular/common/http'; | ||
import {OccEndpointsService} from '@spartacus/core'; | ||
import {Observable} from 'rxjs'; | ||
import {PlaceOrderRequest, PlaceOrderResponse} from "../../models/occ.order.models"; | ||
|
||
@Injectable() | ||
export class OccAdyenOrderAdapter { | ||
|
||
constructor( | ||
protected http: HttpClient, | ||
protected occEndpoints: OccEndpointsService | ||
) { | ||
} | ||
|
||
public placeOrder(userId: string, cartId: string, orderData: PlaceOrderRequest): Observable<PlaceOrderResponse> { | ||
return this.http.post<PlaceOrderResponse>(this.getPlaceOrderEndpoint(userId, cartId), orderData); | ||
} | ||
|
||
protected getPlaceOrderEndpoint(userId: string, cartId: string): string { | ||
return this.occEndpoints.buildUrl('users/${userId}/carts/${cartId}/adyen/place-order', { | ||
urlParams: { | ||
userId, | ||
cartId, | ||
} | ||
}); | ||
} | ||
|
||
public cancelPayment(userId: string, cartId: string, orderCode: string): Observable<void> { | ||
return this.http.post<void>(this.getPaymentCanceledEndpoint(userId, cartId, orderCode), {}) | ||
} | ||
|
||
protected getPaymentCanceledEndpoint(userId: string, cartId: string, orderCode: string): string { | ||
return this.occEndpoints.buildUrl('users/${userId}/adyen/payment-canceled/${orderCode}', { | ||
urlParams: { | ||
userId, | ||
cartId, | ||
orderCode | ||
} | ||
}); | ||
} | ||
|
||
} |
27 changes: 0 additions & 27 deletions
27
projects/adyen-payments/src/lib/core/occ/adapters/occ-placeorder.adapter.ts
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.