support faster payments

This commit is contained in:
woodser 2022-06-22 13:17:00 -04:00
parent b46ac11453
commit 65135f46a9

View File

@ -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", "SEPA_INSTANT", "TRANSFERWISE", "CLEAR_X_CHANGE", "SWIFT", "F2F", "STRIKE", "MONEY_GRAM"]; const expectedPaymentMethods = ["REVOLUT", "SEPA", "SEPA_INSTANT", "TRANSFERWISE", "CLEAR_X_CHANGE", "SWIFT", "F2F", "STRIKE", "MONEY_GRAM", "FASTER_PAYMENTS"];
// get payment methods // get payment methods
const paymentMethods = await alice.getPaymentMethods(); const paymentMethods = await alice.getPaymentMethods();
@ -2380,7 +2380,7 @@ function getValidFormInput(fieldId: PaymentAccountFormField.FieldId, form: Payme
case PaymentAccountFormField.FieldId.ACCOUNT_NAME: case PaymentAccountFormField.FieldId.ACCOUNT_NAME:
return form.getId().toString() + " " + GenUtils.getUUID(); // TODO: rename to form.getPaymentMethodId() return form.getId().toString() + " " + GenUtils.getUUID(); // TODO: rename to form.getPaymentMethodId()
case PaymentAccountFormField.FieldId.ACCOUNT_NR: case PaymentAccountFormField.FieldId.ACCOUNT_NR:
return "1234567890"; return "12345678";
case PaymentAccountFormField.FieldId.ACCOUNT_OWNER: case PaymentAccountFormField.FieldId.ACCOUNT_OWNER:
throw new Error("Not implemented"); throw new Error("Not implemented");
case PaymentAccountFormField.FieldId.ACCOUNT_TYPE: case PaymentAccountFormField.FieldId.ACCOUNT_TYPE:
@ -2473,6 +2473,8 @@ function getValidFormInput(fieldId: PaymentAccountFormField.FieldId, form: Payme
throw new Error("Not implemented"); throw new Error("Not implemented");
case PaymentAccountFormField.FieldId.SALT: case PaymentAccountFormField.FieldId.SALT:
return ""; return "";
case PaymentAccountFormField.FieldId.SORT_CODE:
return "123456";
case PaymentAccountFormField.FieldId.SPECIAL_INSTRUCTIONS: case PaymentAccountFormField.FieldId.SPECIAL_INSTRUCTIONS:
return "asap plz"; return "asap plz";
case PaymentAccountFormField.FieldId.STATE: { case PaymentAccountFormField.FieldId.STATE: {
@ -2501,7 +2503,7 @@ function getInvalidFormInput(form: PaymentAccountForm, fieldId: PaymentAccountFo
case PaymentAccountFormField.FieldId.ACCOUNT_NAME: case PaymentAccountFormField.FieldId.ACCOUNT_NAME:
return ""; return "";
case PaymentAccountFormField.FieldId.ACCOUNT_NR: case PaymentAccountFormField.FieldId.ACCOUNT_NR:
throw new Error("Not implemented"); return "123457A";
case PaymentAccountFormField.FieldId.ACCOUNT_OWNER: case PaymentAccountFormField.FieldId.ACCOUNT_OWNER:
throw new Error("Not implemented"); throw new Error("Not implemented");
case PaymentAccountFormField.FieldId.ACCOUNT_TYPE: case PaymentAccountFormField.FieldId.ACCOUNT_TYPE:
@ -2598,6 +2600,8 @@ function getInvalidFormInput(form: PaymentAccountForm, fieldId: PaymentAccountFo
throw new Error("Not implemented"); throw new Error("Not implemented");
case PaymentAccountFormField.FieldId.SALT: case PaymentAccountFormField.FieldId.SALT:
return "abc"; return "abc";
case PaymentAccountFormField.FieldId.SORT_CODE:
return "12345A";
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: {
@ -2677,6 +2681,11 @@ function testFiatAccount(account: PaymentAccount, form: PaymentAccountForm) {
expect(account.getPaymentAccountPayload().getMoneyGramAccountPayload().getEmail()).toEqual(getFormField(form, PaymentAccountFormField.FieldId.EMAIL).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()); expect(account.getTradeCurrenciesList().map(currency => currency.getCode()).join(",")).toEqual(getFormField(form, PaymentAccountFormField.FieldId.TRADE_CURRENCIES).getValue());
break; break;
case PaymentAccountForm.FormId.FASTER_PAYMENTS:
expect(account.getPaymentAccountPayload().getFasterPaymentsAccountPayload().getHolderName()).toEqual(getFormField(form, PaymentAccountFormField.FieldId.HOLDER_NAME).getValue());
expect(account.getPaymentAccountPayload().getFasterPaymentsAccountPayload().getSortCode()).toEqual(getFormField(form, PaymentAccountFormField.FieldId.SORT_CODE).getValue());
expect(account.getPaymentAccountPayload().getFasterPaymentsAccountPayload().getAccountNr()).toEqual(getFormField(form, PaymentAccountFormField.FieldId.ACCOUNT_NR).getValue());
break;
default: default:
throw new Error("Unhandled payment method type: " + form.getId()); throw new Error("Unhandled payment method type: " + form.getId());
} }