diff --git a/src/pages/friends-photo/index.tsx b/src/pages/friends-photo/index.tsx index 3f03b8d..9a1f92f 100644 --- a/src/pages/friends-photo/index.tsx +++ b/src/pages/friends-photo/index.tsx @@ -55,9 +55,16 @@ export default function FriendsPhoto() { try { // 将两个图片URL用逗号分隔 + const { hostname, protocol, port } = window.location; + let baseUrl = `${protocol}//${hostname}` + if (hostname === 'localhost') { + baseUrl = `${protocol}//${hostname}:${port}` + } + const cbUrl = `${baseUrl}/result` const checkout = await serverSdk.createCheckoutSession({ templateCode: templateCode, metadata: { + cb_url: cbUrl, imageUrls: [ image1, image2 ] diff --git a/src/sdk/sdk-server.ts b/src/sdk/sdk-server.ts index f18b743..7929a42 100644 --- a/src/sdk/sdk-server.ts +++ b/src/sdk/sdk-server.ts @@ -83,6 +83,7 @@ export interface CreateCheckoutParams { templateCode: string; // 模板代码 metadata: { imageUrls: string[]; // 图片URL + cb_url: string; [key: string]: any; // 其他元数据 }; } @@ -371,13 +372,13 @@ export class SdkServer { /** * 如果多图的话 images.join(',') */ - async payTemplateCode(templateCode: string, imageUrl: string, cbUrl: string) { + async payTemplateCode(templateCode: string, imageUrls: string[], cbUrl: string) { try { const response = await this.request(`/payment/checkout/${templateCode}`, 'POST', { - imageUrl: imageUrl, + imageUrls: imageUrls, // 图片URL cb_url: cbUrl }) - return response.data as {url: string}; + return response.data as { url: string }; } catch (error) { throw error; } @@ -661,10 +662,7 @@ export class SdkServer { */ async createCheckoutSession(params: CreateCheckoutParams): Promise { try { - const response = await this.request(`/payment/checkout/${params.templateCode}`, 'POST', { - customer: params.customer, - metadata: params.metadata - }); + const response = await this.request(`/payment/checkout/${params.templateCode}`, 'POST', params.metadata); return response.data; } catch (error) { throw error;