@test-org122/merchant-iframe
Version:
Mediator iFrame package. This is used to sandbox the connector code away from the running hypernet core.
32 lines (28 loc) • 1.2 kB
text/typescript
import { IMerchantConnectorRepository } from "@merchant-iframe/interfaces/data";
import { IAjaxUtils } from "@test-org122/utils";
import { PublicKey } from "@test-org122/hypernet-core";
import { okAsync, ResultAsync } from "neverthrow";
export class MerchantConnectorRepository implements IMerchantConnectorRepository {
constructor(protected ajaxUtils: IAjaxUtils) {}
public getMerchantSignature(merchantUrl: URL): ResultAsync<string, Error> {
const url = new URL(merchantUrl.toString());
url.pathname = "signature";
return this.ajaxUtils.get<string, Error>(url).andThen((response) => {
return okAsync(response);
});
}
public getMerchantAddress(merchantUrl: URL): ResultAsync<string, Error> {
const url = new URL(merchantUrl.toString());
url.pathname = "publicKey";
return this.ajaxUtils.get<string, Error>(url).andThen((response) => {
return okAsync(response);
});
}
public getMerchantCode(merchantUrl: URL): ResultAsync<string, Error> {
const url = new URL(merchantUrl.toString());
url.pathname = "connector";
return this.ajaxUtils.get<string, Error>(url).andThen((response) => {
return okAsync(response);
});
}
}