use of org.structr.payment.api.PaymentProvider in project structr by structr.
the class PaymentNode method beginCheckout.
public static GraphObject beginCheckout(final PaymentNode thisNode, final String providerName, final String successUrl, final String cancelUrl) throws FrameworkException {
final PaymentProvider provider = PaymentNode.getPaymentProvider(providerName);
if (provider != null) {
final BeginCheckoutResponse response = provider.beginCheckout(thisNode, successUrl, cancelUrl);
if (CheckoutState.Success.equals(response.getCheckoutState())) {
final GraphObjectMap data = new GraphObjectMap();
data.put(StructrApp.key(PaymentNode.class, "token"), response.getToken());
return data;
} else {
throwErrors("Unable to begin checkout.", response);
}
} else {
throw new FrameworkException(422, "Payment provider " + providerName + " not found.");
}
return null;
}
Aggregations