Skip to content
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

SDK-101 added additional method for submitPayment with param tokenOnly #62

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 61 additions & 6 deletions src/main/java/me/figo/FigoSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import java.util.Collections;
import java.util.List;

import me.figo.models.*;
import me.figo.internal.ModifyStandingOrderRequest;
import me.figo.internal.SetupAccountRequest;
import me.figo.internal.SubmitPaymentRequest;
Expand All @@ -43,15 +42,19 @@
import me.figo.models.Account;
import me.figo.models.AccountBalance;
import me.figo.models.Bank;

import me.figo.models.BankLoginSettings;
import me.figo.models.CatalogBank.CatalogBanksResponse;
import me.figo.models.LoginSettings;

import me.figo.models.Notification;
import me.figo.models.Payment;
import me.figo.models.PaymentContainer;
import me.figo.models.PaymentProposal;
import me.figo.models.PaymentProposal.PaymentProposalResponse;
import me.figo.models.Security;
import me.figo.models.Service;
import me.figo.models.ServiceLoginSettings;
import me.figo.models.StandingOrder;
import me.figo.models.Transaction;
import me.figo.models.User;

/**
* Main entry point to the data access-part of the figo connect java library.
Expand Down Expand Up @@ -1172,6 +1175,26 @@ public String submitPayment(Payment payment, String tanSchemeId, String state) t
return submitPayment(payment, tanSchemeId, state, null);
}

/**
* Submit payment to bank server
*
* @param payment
* payment to be submitted
* @param tanSchemeId
* TAN scheme ID of user-selected TAN scheme
* @param state
* Any kind of string that will be forwarded in the callback response message
* @param tokenOnly
* whether a complete URL or only the task token should be returned
* @return the URL to be opened by the user for the TAN process or the task token only (depending on param tokenOnly)
*
* @exception FigoException Base class for all figoExceptions
* @exception IOException IOException
*/
public String submitPayment(Payment payment, String tanSchemeId, String state, boolean tokenOnly) throws FigoException, IOException {
return submitPayment(payment, tanSchemeId, state, null, tokenOnly);
}

/**
* Submit payment to bank server
*
Expand All @@ -1189,11 +1212,43 @@ public String submitPayment(Payment payment, String tanSchemeId, String state) t
* @exception IOException IOException
*/
public String submitPayment(Payment payment, String tanSchemeId, String state, String redirectUri) throws FigoException, IOException {
TaskTokenResponse response = this.queryApi("/rest/accounts/" + payment.getAccountId() + "/payments/" + payment.getPaymentId() + "/submit",
new SubmitPaymentRequest(tanSchemeId, state, redirectUri), "POST", TaskTokenResponse.class);
TaskTokenResponse response = submitPaymentApiCall(payment, tanSchemeId, state, redirectUri);
return getApiEndpoint() + "/task/start?id=" + response.task_token;
}

/**
* Submit payment to bank server
*
* @param payment
* payment to be submitted
* @param tanSchemeId
* TAN scheme ID of user-selected TAN scheme
* @param state
* Any kind of string that will be forwarded in the callback response message
* @param redirectUri
* At the end of the submission process a response will be sent to this callback URL
* @param tokenOnly
* whether a complete URL or only the task token should be returned
* @return the URL to be opened by the user for the TAN process or the task token only (depending on param tokenOnly)
*
* @exception FigoException Base class for all figoExceptions
* @exception IOException IOException
*/
public String submitPayment(Payment payment, String tanSchemeId, String state, String redirectUri, boolean tokenOnly) throws FigoException, IOException {
TaskTokenResponse response = submitPaymentApiCall(payment, tanSchemeId, state, redirectUri);
if(tokenOnly)
return response.task_token;
else
return getApiEndpoint() + "/task/start?id=" + response.task_token;
}

private TaskTokenResponse submitPaymentApiCall(Payment payment, String tanSchemeId, String state,
String redirectUri) throws IOException, FigoException {
TaskTokenResponse response = this.queryApi("/rest/accounts/" + payment.getAccountId() + "/payments/" + payment.getPaymentId() + "/submit",
new SubmitPaymentRequest(tanSchemeId, state, redirectUri), "POST", TaskTokenResponse.class);
return response;
}

/**
* URL to trigger a synchronization. The user should open this URL in a web browser to synchronize his/her accounts with the respective bank servers. When
* the process is finished, the user is redirected to the provided URL.
Expand Down