Skip to content

Commit

Permalink
apm: change the way apm redirects work
Browse files Browse the repository at this point in the history
  • Loading branch information
jlejoux committed Oct 31, 2019
1 parent b53a5b2 commit b66b393
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void onSuccess(JSONObject json) {
e.printStackTrace();
return;
}
p.fetchGatewayConfigurations(invoiceResult.getId(), ProcessOut.GatewaysListingFilter.AlternativePaymentMethodWithTokenization, new FetchGatewaysConfigurationsCallback() {
p.fetchGatewayConfigurations(ProcessOut.GatewaysListingFilter.AlternativePaymentMethodWithTokenization, new FetchGatewaysConfigurationsCallback() {
@Override
public void onSuccess(ArrayList<GatewayConfiguration> gateways) {
signal.countDown();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,6 @@ public class GatewayConfiguration {
@SerializedName("gateway")
private Gateway gateway;

private String invoiceId;
private String projectId;
private Context context;

public void redirect() {
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(Network.CHECKOUT_URL + "/" + this.projectId + "/" + this.invoiceId + "/redirect/" + this.id));
this.context.startActivity(browserIntent);
}

public String getId() {
return id;
}
Expand All @@ -47,16 +38,4 @@ public String getDefaultCurrency() {
public Gateway getGateway() {
return gateway;
}

public void setInvoiceId(String invoiceId) {
this.invoiceId = invoiceId;
}

public void setProjectId(String projectId) {
this.projectId = projectId;
}

public void setContext(Context context) {
this.context = context;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -132,16 +132,10 @@ public enum GatewaysListingFilter {
/**
* Retrieves the list of gateway configurations
*
* @param invoiceId Invoice ID that should be used for charging (this needs to be generated on your backend).
* Keep in mind that you should set the return_url to "your_app://processout.return".
* Check https://www.docs.processsout.com for more details
* @param filter Filter for gateway configurations
* @param callback Callback for listing gateway configurations
* @param filter Filter for gateway configurations
* @param callback Callback for listing gateway configurations
*/
public void fetchGatewayConfigurations(@NonNull final String invoiceId, @NonNull GatewaysListingFilter filter, @NonNull final FetchGatewaysConfigurationsCallback callback) {
final Context context = this.context;
final String projectId = this.projectId;

public void fetchGatewayConfigurations(@NonNull GatewaysListingFilter filter, @NonNull final FetchGatewaysConfigurationsCallback callback) {

String filterValue;
switch (filter) {
Expand Down Expand Up @@ -172,9 +166,6 @@ public void onSuccess(JSONObject json) {
for (int i = 0; i < configs.length(); i++) {
GatewayConfiguration g = gson.fromJson(
configs.getJSONObject(i).toString(), GatewayConfiguration.class);
g.setContext(context);
g.setProjectId(projectId);
g.setInvoiceId(invoiceId);
gways.add(g);
}

Expand All @@ -188,16 +179,29 @@ public void onSuccess(JSONObject json) {
}

/**
* @param apm
* @param customerId
* @param tokenId
* Redirects the user to an alternative payment method payment page to authorize a token
*
* @param apm Gateway previously retrieved
* @param customerId Customer ID created on your backend
* @param tokenId Customer token ID created on your backend with empty source
*/
public void makeAPMToken(@NonNull GatewayConfiguration apm, @NonNull String customerId, @NonNull String tokenId) {
Intent browserIntent = new Intent(Intent.ACTION_VIEW,
Uri.parse(Network.CHECKOUT_URL + "/" + this.projectId + "/" + customerId + "/" + tokenId + "/redirect/" + apm.getId()));
this.context.startActivity(browserIntent);
}

/**
* Redirects the user to an alternative payment method payment page to complete a payment
*
* @param apm Gateway previously retrieved
* @param invoiceId Invoice created on your backend
*/
public void makeAPMPayment(@NonNull GatewayConfiguration apm, @NonNull String invoiceId) {
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(Network.CHECKOUT_URL + "/" + this.projectId + "/" + invoiceId + "/redirect/" + apm.getId()));
this.context.startActivity(browserIntent);
}

/**
* Allow card payments authorization (with 3DS2 support)
*
Expand Down

0 comments on commit b66b393

Please sign in to comment.