Difference between revisions of "X-Payments:Redirecting a customer to the cardholder data entering page"

From X-Payments Help
Jump to: navigation, search
(Created page with "A POST form is created that sends data to the URL <XPayments_web_root>/payment.php; the form contains the following fields: * target - has the value "main"; * token - uses th...")
 
m
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
A POST form is created that sends data to the URL <XPayments_web_root>/payment.php; the form contains the following fields:
+
<noinclude>{{XP_API_TOC}}</noinclude>
 +
A form is created that sends data to the URL https://example.com/xpayments/payment.php, where "https://example.com/xpayments/" is the X-Payments web root directory.<br />
 +
<br />
 +
The form must be POST-ed via HTTPS and must contain the following fields:
  
* target - has the value "main";
+
* '''target''': should be "main";<br /><br />
* token - uses the value from the token field received in the response to the payment initialisation request.
+
* '''action''': should be "start";<br /><br />
 +
* '''token''': uses the value from the token field received in the response to the [[X-Payments:Payment_initialisation_request|payment initialization request]]);<br /><br />
 +
* '''allow_save_card''': optional field that instructs X-Payments regarding tokenization. The allowed values for this field are:
 +
:* "Y" - The card must be tokenized (if all the conditions in X-Payments are met: i.e., if the payment gateway allows tokenization and if tokenization is enabled in the payment configuration settings). Common use case: The very first payment in a series of subscription payments during which the card is saved for further subscription payments.<br /><br />
 +
:* "O" - Allow the customer to choose whether they want to save the card or not. A special checkbox will be added to the payment form. Again, all the conditions must be met: the payment gateway must allow tokenization and tokenization must be enabled in the payment configuration settings. Common use case: A regular payment by a customer who is registered (or has an account) with the store. So the card is associated with this account.<br /><br />
 +
:* "N" - Do not save the card. Common use case: payment by an anonymous customer, who is not registered or does not have an account with the store.
 +
<br />
 +
<br />
 +
<br />
 +
<br />
 +
<br />
 +
===Example of the form===
  
Request protocol - HTTPS <br />
+
This is the sample code of the form that redirects the customer to the X-Payments page where the credit card form is displayed. The form is auto-submitted.
The form must be sent by the POST method. All data must also be sent as POST variables.
+
 
 +
<pre>
 +
<html>
 +
<head></head>
 +
<body>
 +
    <form action="https://demo.x-checkout.com/payment.php" method="post" id="payment-form">
 +
        <input type="hidden" name="target" value="main" />
 +
        <input type="hidden" name="action" value="start" />
 +
        <input type="hidden" name="token" value="73787ac787fc5659199f5a98cd99ed6f" />
 +
        <input type="hidden" name="allow_save_card" value="O" />
 +
    </form>
 +
    <script type="text/javascript">
 +
    //<![CDATA[
 +
        var paymentform = document.getElementById('payment-form');
 +
        window.onload = function() {
 +
            paymentform.submit();
 +
        }
 +
    //]]>
 +
    </script>
 +
</body>
 +
</html>
 +
</pre>

Latest revision as of 08:45, 15 November 2016

X-Payments API
  1. API versions supported
  2. Samples
  3. API requests
  4. API Requests from the store to X-Payments
    1. Admin area/X-Payments configuration
    2. Payment creation (Regular payment and tokenization)
    3. Payment information
    4. Actions on payments (secondary actions)
  5. Callback requests (web-hooks) from X-Payments to the store
  6. Browser-related
  7. Appendix A. Status codes.
  8. See also

A form is created that sends data to the URL https://example.com/xpayments/payment.php, where "https://example.com/xpayments/" is the X-Payments web root directory.

The form must be POST-ed via HTTPS and must contain the following fields:

  • target: should be "main";

  • action: should be "start";

  • token: uses the value from the token field received in the response to the payment initialization request);

  • allow_save_card: optional field that instructs X-Payments regarding tokenization. The allowed values for this field are:
  • "Y" - The card must be tokenized (if all the conditions in X-Payments are met: i.e., if the payment gateway allows tokenization and if tokenization is enabled in the payment configuration settings). Common use case: The very first payment in a series of subscription payments during which the card is saved for further subscription payments.

  • "O" - Allow the customer to choose whether they want to save the card or not. A special checkbox will be added to the payment form. Again, all the conditions must be met: the payment gateway must allow tokenization and tokenization must be enabled in the payment configuration settings. Common use case: A regular payment by a customer who is registered (or has an account) with the store. So the card is associated with this account.

  • "N" - Do not save the card. Common use case: payment by an anonymous customer, who is not registered or does not have an account with the store.






Example of the form

This is the sample code of the form that redirects the customer to the X-Payments page where the credit card form is displayed. The form is auto-submitted.

<html>
<head></head>
<body>
    <form action="https://demo.x-checkout.com/payment.php" method="post" id="payment-form">
        <input type="hidden" name="target" value="main" />
        <input type="hidden" name="action" value="start" />
        <input type="hidden" name="token" value="73787ac787fc5659199f5a98cd99ed6f" />
        <input type="hidden" name="allow_save_card" value="O" />
    </form>
    <script type="text/javascript">
    //<![CDATA[
        var paymentform = document.getElementById('payment-form');
        window.onload = function() {
            paymentform.submit();
        }
    //]]>
    </script>
</body>
</html>