-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/hw 51305 create pay pal account #12
Changes from 1 commit
2759617
99be7db
2406595
4ec1edf
7119435
12c299b
f6cbbbc
4746965
97e2640
d32ad9b
c48753c
977d4df
fc1530b
58d3892
0d22d7e
ef97fcc
d9fd285
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -95,7 +95,7 @@ final class AddTransferMethodPresenter { | |
else { | ||
return | ||
} | ||
var hyperwalletTransferMethod: HyperwalletTransferMethod | ||
var hyperwalletTransferMethod = HyperwalletTransferMethod() | ||
switch transferMethodType { | ||
case "BANK_ACCOUNT": | ||
hyperwalletTransferMethod = HyperwalletBankAccount.Builder(transferMethodCountry: country, | ||
|
@@ -115,11 +115,7 @@ final class AddTransferMethodPresenter { | |
.build() | ||
|
||
default: | ||
hyperwalletTransferMethod = HyperwalletTransferMethod() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can keep this line. |
||
hyperwalletTransferMethod.setField(key: "transferMethodCountry", value: country) | ||
hyperwalletTransferMethod.setField(key: "transferMethodCurrency", value: currency) | ||
hyperwalletTransferMethod.setField(key: "type", value: transferMethodType) | ||
hyperwalletTransferMethod.setField(key: "profileType", value: profileType) | ||
return | ||
} | ||
for field in view.fieldValues() { | ||
hyperwalletTransferMethod.setField(key: field.name, value: field.value) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,6 +79,8 @@ final class ListTransferMethodPresenter { | |
deactivateBankAccount(token) | ||
case "BANK_CARD": | ||
deactivateBankCard(token) | ||
case "PAYPAL_ACCOUNT": | ||
deactivatePayPalAccount(token) | ||
|
||
default: | ||
break | ||
|
@@ -117,6 +119,12 @@ final class ListTransferMethodPresenter { | |
completion: deactivateTransferMethodHandler()) | ||
} | ||
|
||
private func deactivatePayPalAccount(_ token: String) { | ||
Hyperwallet.shared.deactivatePayPalAccount(transferMethodToken: token, | ||
notes: "Deactivating the PayPal Account", | ||
completion: deactivateTransferMethodHandler()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. indentation. |
||
} | ||
|
||
private func deactivateTransferMethodHandler() | ||
-> (HyperwalletStatusTransition?, HyperwalletErrorType?) -> Void { | ||
return { [weak self] (result, error) in | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -144,6 +144,24 @@ class ListTransferMethodPresenterTests: XCTestCase { | |
XCTAssertTrue(mockView.isShowConfirmationPerformed, "The showConfirmation should be performed") | ||
} | ||
|
||
func testDeactivatePayPalAccount_success() { | ||
// Given | ||
loadMockTransfermethods() | ||
HyperwalletTestHelper.setUpMockServer(request: setUpDeactivateTransferMethodRequest("/paypal-accounts/")) | ||
|
||
let expectation = self.expectation(description: "deactivate a PayPal account") | ||
mockView.expectation = expectation | ||
|
||
// When | ||
presenter.deactivateTransferMethod(at: 2) | ||
wait(for: [expectation], timeout: 1) | ||
|
||
// Then | ||
XCTAssertTrue(mockView.isShowProcessingPerformed, "The showProcessing should be performed") | ||
XCTAssertFalse(mockView.isShowErrorPerformed, "The showError should not be performed") | ||
XCTAssertTrue(mockView.isShowConfirmationPerformed, "The showConfirmation should be performed") | ||
} | ||
|
||
func testDeactivateBankCard_failureWithError() { | ||
// Given | ||
loadMockTransfermethods() | ||
|
@@ -178,7 +196,13 @@ class ListTransferMethodPresenterTests: XCTestCase { | |
transferMethodProfileType: "INDIVIDUAL") | ||
.build() | ||
bankCard.setField(key: "token", value: "trm-123456789") | ||
let transferMethods = [bankAccount, bankCard] | ||
|
||
let payPalAccount = HyperwalletPayPalAccount.Builder(transferMethodCountry: "US", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can't. We need country and currency as well |
||
transferMethodCurrency: "USD") | ||
.build() | ||
payPalAccount.setField(key: "token", value: "trm-123456789") | ||
|
||
let transferMethods = [bankAccount, bankCard, payPalAccount] | ||
presenter.transferMethods = transferMethods | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we still can leave it because for most of the cases we don't need to initialize a hyperwalletTransferMethod.