-
Notifications
You must be signed in to change notification settings - Fork 416
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Reformat storefront service to use apiClientService --------- Co-authored-by: Tuan Nguyen Trong Anh <tuan.nguyentronganh@nashtechglobal.com>
- Loading branch information
Showing
4 changed files
with
44 additions
and
58 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import { PaymentProvider } from '../models/PaymentProvider'; | ||
import apiClientService from '@/common/services/ApiClientService'; | ||
|
||
export const getEnabledPaymentProviders = async (): Promise<PaymentProvider[]> => { | ||
const response = await fetch('/api/payment/storefront/payment-providers'); | ||
const response = await apiClientService.get('/api/payment/storefront/payment-providers'); | ||
return response.json(); | ||
}; |
15 changes: 7 additions & 8 deletions
15
storefront/modules/paymentPaypal/services/PaymentPaypalService.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,25 +1,24 @@ | ||
import { InitPaymentPaypalRequest } from '@/modules/paymentPaypal/models/InitPaymentPaypalRequest'; | ||
import { InitPaymentPaypalResponse } from '@/modules/paymentPaypal/models/InitPaymentPaypalResponse'; | ||
import { CapturePaymentPaypalResponse } from '@/modules/paymentPaypal/models/CapturePaymentPaypalResponse'; | ||
import apiClientService from '@/common/services/ApiClientService'; | ||
|
||
const baseUrl = '/api/payment-paypal'; | ||
|
||
export async function initPaymentPaypal( | ||
paymentPaypalRequest: InitPaymentPaypalRequest | ||
): Promise<InitPaymentPaypalResponse> { | ||
const res = await fetch('/api/payment-paypal/init', { | ||
method: 'POST', | ||
body: JSON.stringify(paymentPaypalRequest), | ||
headers: { 'Content-type': 'application/json; charset=UTF-8' }, | ||
}); | ||
const res = await apiClientService.post(`${baseUrl}/init`, JSON.stringify(paymentPaypalRequest)); | ||
if (res.ok) { | ||
return res.json(); | ||
} | ||
return Promise.reject(res.status); | ||
throw new Error(res.statusText); | ||
} | ||
|
||
export async function capturePaymentPaypal(token?: string): Promise<CapturePaymentPaypalResponse> { | ||
const res = await fetch(`/api/payment-paypal/capture?token=${token}`); | ||
const res = await apiClientService.get(`${baseUrl}/capture?token=${token}`); | ||
if (res.ok) { | ||
return res.json(); | ||
} | ||
return Promise.reject(res.status); | ||
throw new Error(res.statusText); | ||
} |