refactor: update payment platform to support multiple image URLs
This commit is contained in:
parent
399935d2ef
commit
5453c79197
|
|
@ -1,7 +1,7 @@
|
||||||
import { useServerSdk } from "../../hooks";
|
import { useServerSdk } from "../../hooks";
|
||||||
import { Payment } from "../types/payment";
|
import { Payment } from "../types/payment";
|
||||||
export class H5Payment extends Payment {
|
export class H5Payment extends Payment {
|
||||||
async pay(templateCode: string, imageUrl: string) {
|
async pay(templateCode: string, imageUrls: string[]) {
|
||||||
const sdk = useServerSdk()
|
const sdk = useServerSdk()
|
||||||
const { hostname, protocol, port } = window.location;
|
const { hostname, protocol, port } = window.location;
|
||||||
let baseUrl = `${protocol}//${hostname}`
|
let baseUrl = `${protocol}//${hostname}`
|
||||||
|
|
@ -9,7 +9,7 @@ export class H5Payment extends Payment {
|
||||||
baseUrl = `${protocol}//${hostname}:${port}`
|
baseUrl = `${protocol}//${hostname}:${port}`
|
||||||
}
|
}
|
||||||
const cbUrl = `${baseUrl}`
|
const cbUrl = `${baseUrl}`
|
||||||
const response = await sdk.payTemplateCode(templateCode, imageUrl, cbUrl)
|
const response = await sdk.payTemplateCode(templateCode, imageUrls, cbUrl)
|
||||||
if (response.url) {
|
if (response.url) {
|
||||||
window.location.href = response.url;
|
window.location.href = response.url;
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -2,5 +2,5 @@
|
||||||
|
|
||||||
export abstract class Payment{
|
export abstract class Payment{
|
||||||
|
|
||||||
abstract pay(templateCode: string, imageUrl: string): Promise<any>;
|
abstract pay(templateCode: string, imageUrls: string[]): Promise<any>;
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue