mirror of
https://github.com/haveno-dex/haveno-ts.git
synced 2025-06-29 09:07:11 -04:00
support MoneyGram form api
This commit is contained in:
parent
b5d4de3528
commit
e70a928d2d
1 changed files with 17 additions and 5 deletions
|
@ -857,7 +857,7 @@ test("Can get payment accounts", async () => {
|
||||||
test("Can validate payment account forms", async () => {
|
test("Can validate payment account forms", async () => {
|
||||||
|
|
||||||
// supported payment methods
|
// supported payment methods
|
||||||
const expectedPaymentMethods = ["REVOLUT", "SEPA", "TRANSFERWISE", "CLEAR_X_CHANGE", "SWIFT", "F2F", "STRIKE"];
|
const expectedPaymentMethods = ["REVOLUT", "SEPA", "TRANSFERWISE", "CLEAR_X_CHANGE", "SWIFT", "F2F", "STRIKE", "MONEY_GRAM"];
|
||||||
|
|
||||||
// get payment methods
|
// get payment methods
|
||||||
const paymentMethods = await alice.getPaymentMethods();
|
const paymentMethods = await alice.getPaymentMethods();
|
||||||
|
@ -2475,8 +2475,10 @@ function getValidFormInput(fieldId: PaymentAccountFormField.FieldId, form: Payme
|
||||||
return "";
|
return "";
|
||||||
case PaymentAccountFormField.FieldId.SPECIAL_INSTRUCTIONS:
|
case PaymentAccountFormField.FieldId.SPECIAL_INSTRUCTIONS:
|
||||||
return "asap plz";
|
return "asap plz";
|
||||||
case PaymentAccountFormField.FieldId.STATE:
|
case PaymentAccountFormField.FieldId.STATE: {
|
||||||
throw new Error("Not implemented");
|
const country = HavenoUtils.getFormValue(PaymentAccountFormField.FieldId.COUNTRY, form);
|
||||||
|
return GenUtils.arrayContains(field.getRequiredForCountriesList(), country) ? "My state" : "";
|
||||||
|
}
|
||||||
case PaymentAccountFormField.FieldId.TRADE_CURRENCIES:
|
case PaymentAccountFormField.FieldId.TRADE_CURRENCIES:
|
||||||
return field.getSupportedCurrenciesList().map(currency => currency.getCode()).join(',');
|
return field.getSupportedCurrenciesList().map(currency => currency.getCode()).join(',');
|
||||||
case PaymentAccountFormField.FieldId.USER_NAME:
|
case PaymentAccountFormField.FieldId.USER_NAME:
|
||||||
|
@ -2490,6 +2492,7 @@ function getValidFormInput(fieldId: PaymentAccountFormField.FieldId, form: Payme
|
||||||
|
|
||||||
// TODO: improve invalid inputs
|
// TODO: improve invalid inputs
|
||||||
function getInvalidFormInput(form: PaymentAccountForm, fieldId: PaymentAccountFormField.FieldId): string {
|
function getInvalidFormInput(form: PaymentAccountForm, fieldId: PaymentAccountFormField.FieldId): string {
|
||||||
|
const field = getFormField(form, fieldId);
|
||||||
switch (fieldId) {
|
switch (fieldId) {
|
||||||
case PaymentAccountFormField.FieldId.ACCEPTED_COUNTRY_CODES:
|
case PaymentAccountFormField.FieldId.ACCEPTED_COUNTRY_CODES:
|
||||||
return "US,XX";
|
return "US,XX";
|
||||||
|
@ -2597,8 +2600,10 @@ function getInvalidFormInput(form: PaymentAccountForm, fieldId: PaymentAccountFo
|
||||||
return "abc";
|
return "abc";
|
||||||
case PaymentAccountFormField.FieldId.SPECIAL_INSTRUCTIONS:
|
case PaymentAccountFormField.FieldId.SPECIAL_INSTRUCTIONS:
|
||||||
throw new Error("Special instructions have no invalid input");
|
throw new Error("Special instructions have no invalid input");
|
||||||
case PaymentAccountFormField.FieldId.STATE:
|
case PaymentAccountFormField.FieldId.STATE: {
|
||||||
throw new Error("Not implemented");
|
const country = HavenoUtils.getFormValue(PaymentAccountFormField.FieldId.COUNTRY, form);
|
||||||
|
return GenUtils.arrayContains(field.getRequiredForCountriesList(), country) ? "" : "My state";
|
||||||
|
}
|
||||||
case PaymentAccountFormField.FieldId.TRADE_CURRENCIES:
|
case PaymentAccountFormField.FieldId.TRADE_CURRENCIES:
|
||||||
return "abc,def";
|
return "abc,def";
|
||||||
case PaymentAccountFormField.FieldId.USER_NAME:
|
case PaymentAccountFormField.FieldId.USER_NAME:
|
||||||
|
@ -2659,6 +2664,13 @@ function testFiatAccount(account: PaymentAccount, form: PaymentAccountForm) {
|
||||||
case PaymentAccountForm.FormId.STRIKE:
|
case PaymentAccountForm.FormId.STRIKE:
|
||||||
expect(account.getPaymentAccountPayload().getCountryBasedPaymentAccountPayload()!.getStrikeAccountPayload().getHolderName()).toEqual(getFormField(form, PaymentAccountFormField.FieldId.HOLDER_NAME).getValue());
|
expect(account.getPaymentAccountPayload().getCountryBasedPaymentAccountPayload()!.getStrikeAccountPayload().getHolderName()).toEqual(getFormField(form, PaymentAccountFormField.FieldId.HOLDER_NAME).getValue());
|
||||||
break;
|
break;
|
||||||
|
case PaymentAccountForm.FormId.MONEY_GRAM:
|
||||||
|
expect(account.getPaymentAccountPayload().getMoneyGramAccountPayload().getCountryCode()).toEqual(getFormField(form, PaymentAccountFormField.FieldId.COUNTRY).getValue()); // TODO: ok to not be CountryBasedPaymentAccountPayload?
|
||||||
|
expect(account.getPaymentAccountPayload().getMoneyGramAccountPayload().getState()).toEqual(getFormField(form, PaymentAccountFormField.FieldId.STATE).getValue());
|
||||||
|
expect(account.getPaymentAccountPayload().getMoneyGramAccountPayload().getHolderName()).toEqual(getFormField(form, PaymentAccountFormField.FieldId.HOLDER_NAME).getValue());
|
||||||
|
expect(account.getPaymentAccountPayload().getMoneyGramAccountPayload().getEmail()).toEqual(getFormField(form, PaymentAccountFormField.FieldId.EMAIL).getValue());
|
||||||
|
expect(account.getTradeCurrenciesList().map(currency => currency.getCode()).join(",")).toEqual(getFormField(form, PaymentAccountFormField.FieldId.TRADE_CURRENCIES).getValue());
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
throw new Error("Unhandled payment method type: " + form.getId());
|
throw new Error("Unhandled payment method type: " + form.getId());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue