You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
import apiService from './apiClient';
|
|
|
|
|
|
|
|
// 支付方式类型定义
|
|
|
|
export interface PaymentMethod {
|
|
|
|
key: string;
|
|
|
|
value: string | string[];
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface CountryPaymentMethods {
|
|
|
|
country?: number;
|
|
|
|
country_name?: string;
|
|
|
|
payment_methods: PaymentMethod[];
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface PaymentMethodsResponse {
|
|
|
|
current_country_code: number;
|
|
|
|
current_country_methods: PaymentMethod[];
|
|
|
|
other_country_methods: CountryPaymentMethods[];
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface PaymentInfoResponse {
|
|
|
|
success: boolean;
|
|
|
|
payment_url: string;
|
|
|
|
msg: string;
|
|
|
|
}
|
|
|
|
export interface PayInfoBody {
|
|
|
|
order_id: number;
|
|
|
|
method: string;
|
|
|
|
amount: number;
|
|
|
|
currency: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface ConvertCurrencyBody {
|
|
|
|
from_currency: string;
|
|
|
|
to_currency: string;
|
|
|
|
amounts: {
|
|
|
|
total_amount?: number;
|
|
|
|
domestic_shipping_fee?: number;
|
|
|
|
shipping_fee?: number;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export const payApi = {
|
|
|
|
// 获取当前国家支付方式
|
|
|
|
getCountryPaymentMethods: () => {
|
|
|
|
return apiService.get<PaymentMethodsResponse>('/api/payment/country_payment_methods/');
|
|
|
|
},
|
|
|
|
|
|
|
|
// 获取支付信息
|
|
|
|
getPayInfo: (data: PayInfoBody) => {
|
|
|
|
return apiService.post<PaymentInfoResponse>(`/api/payment/initiate/`, data);
|
|
|
|
},
|
|
|
|
|
|
|
|
// 货币转换
|
|
|
|
convertCurrency: (data: ConvertCurrencyBody) => {
|
|
|
|
return apiService.post<any>(`/api/currency/convert/`, data);
|
|
|
|
},
|
|
|
|
};
|