Redirect Workflow
Using the Redirect payment flow allows a customer to be redirected to the gateway payment page to select a payment option that is supported by the gateway. When the payment is processed by the gateway, the customer is redirected back to the CloudBlue Commerce website.
From the Billing perspective, a Redirect plugin is a plugin that implements the Redirect method. Once the Redirect plugin is registered, Billing creates a new Payment System ($(PLUGIN_NAME).Redirect
) of the External Payment Site type (for details, refer to Plugin Registration).
The Redirect workflow is the following:
-
A customer creates an Order in CloudBlue Commerce and proceeds to pay it.
-
A browser receives the request and calls Billing initiating the payment flow.
-
Billing detects that the payment method selected by the customer is the Redirect flow.
-
Billing calls the Redirect method in the plugin associated with the payment method.
-
The plugin processes the Redirect request.
-
Depending on the plugin implementation, it may perform an API call to the payment gateway. The payment gateway may require the callbackURL1 (that is, the URL that the payment gateway will redirect to the customer when it finishes processing) to be informed at this point.
-
-
The plugin responds with the
REDIRECT
status and parameters, which includes the URL to redirect to the customer (for details, refer to the Redirect method description). -
Billing processes the Redirect method response.
-
Billing responds with a URL and parameters.
-
The browser calls the URL through a
HTTP POST
request. In this HTTP request, parameters received from the plugin will be sent to the payment gateway. These parameters include the callbackURL. -
The customer fills out a payment form with the desired payment method and data in the gateway payment page.
-
The payment gateway processes the request.
-
The payment gateway calls the callbackURL2, sending the process resulting data.
-
Billing calls the Callback method in the plugin passing the parameters received in the request.
-
The plugin completes transactions with the payment gateway.
-
The plugin responds with the result status and transaction details (for details, refer to the Callback method description).
-
Billing completes the transaction and updates the Payment and Order status and details.
-
Billing responds with the URL to redirect back to CloudBlue Commerce.
-
The customer is redirected back to CloudBlue Commerce. This redirect request is usually a
HTTP GET
request with the302 Found
status and thelocation
header of the CloudBlue Commerce URL.1 Billing provides three callback URLs: return_url, return_url_ok, and return_url_fail. Billing sends those URLs in the Environment array when calling the Redirect and Callback methods.
2 Note that the callbackURL can be sent to the payment gateway in two ways:
-
During the plugin request method execution, through some payment gateway API call, or
-
In the parameters sent on request.
The best way depends on how the payment gateway works.
-