Use the widget to store custom information for retrieval after payment (aka pass through)

Follow

Use case

  • A merchant wishes to add custom fields to the payment form to be passed through for processing post-payment

Solution

  •  Add the script to provide the fields to the var cnp_Options function Javascript as described in the following page COPYandPAY Options & API

Let’s walk through the steps

Start with step 1:

Simply execute step number 1 'Generate a token for payment' as it is described in the Integration Guide.

Go to step 2:

Add the new, custom field:

  • First, integrate the COPYandPAY Javascript and HTML form (where the COPYandPAY elements are attached) into your page as described in the Integration Guide.
  • Add the field
    • A list of standard fields are available in the following list of Transaction Parameters
    • Specify the field to be added as a CRITERION (as in the use case above);  the parameter's name must start with CRITERION (ex: CRITERION.Username)
    • In this example, the name of the field is 'CRITERION.Username'.
  • Working with cnp_Options is further described in the COPYandPAY Options & API document

Example:

COPYandPAY: Add new field Collapse source
<script src="https://code.jquery.com/jquery.js" ></script>
<script type="text/javascript">
    var cnp_Options = {
        onLoad: function(){
            var usernameHtml = '<div class="customLabel">Username</div><div class="customInput"><input autocomplete="off" type="input" name="CRITERION.Username" class="customInputField" placeholder="Username"></div>';
            $('.cnpForm.card').find('.submitInput').before(usernameHtml);
        }
    }  
</script>

The above change returns the following result when using the "plain" COPYandPAY skin.

Step 3:

After the payment is done, call GetStatus as described in step 3 of the Integration Guide.

The name / value pairs of the custom field will be returned in the GetStatus-Response (in the example "BestPayerEver" was entered as a Username).

Example:

Custom Criterion in GetStatus Response Collapse source
criterions: [
    {
        name: "Username",
        value: "BestPayerEver"
    }
],

 

Have more questions? Submit a request

Comments

Powered by Zendesk