2C2Pv1.8.0

Submit Payment Request

Backend code will receive credit card details encrypted.

"encryptedCardInfo"=> "00acTPCs4oy2P52nolDsjc9FabG5/p6OqMzISvh8glP+qb5YgD7z7wCayBp9QW66CtAFENvqW/zZTgDBSKM8qz0W6sFx4TO6Uww58ar//VvDc5+OUz+JIAlQCPhewZN8IznxlyaBFvFLpvi+VugaUWo/Eow6kYalVuIj0MYg8OAccgU=U2FsdGVkX18jR/eUn9PmDT3MSuD3cmgWSovAztlaIPaE52l+fl3SJkU2+UhgJxZL"

POST Data Info

Variable Description
encryptedCardInfo Encrypted Card data that need to send to 2c2p with XML format.
maskedCardInfo masked card number
expMonthCardInfo card expire month
expYearCardInfo card expire year

Prepare Payment Request

Set account credentials.

<?php
    //Merchant Account Information
    $merchantID = "JT01";        //Get MerchantID when opening account with 2C2P
    $secretKey  = "7jYcp4FxFdf0";    //Get SecretKey from 2C2P PGW Dashboard

Set transaction information.

    //Transaction Information
    $uniqueTransactionCode = "Invoice".time();
    $desc = "1 room for 2 nights";
    $amt  = "000000000010";        //12 digit format
    $currencyCode = "702";        //Ref: http://en.wikipedia.org/wiki/ISO_4217

Set cardholder information.

    //Customer Information
    $cardholderName = "John Doe";
    $country = "SG";

Set payment request information.

    //Request Information
    $apiVersion   = "9.3";
    $encryptedCardInfo = $_POST['encryptedCardInfo']; //Retrieve encrypted credit card data
	
    $maskedCardNo = $_POST['maskedCardInfo']; //Masked card number (first 6 and last 4 digit of credit card number)
    $expMonth = $_POST['expMonthCardInfo']; //Card expiry month
    $expYear = $_POST['expYearCardInfo']; //Card expiry Year

    //Construct signature string
    $stringToHash = $apiVersion . $timeStamp . $merchantID . $uniqueTransactionCode . $desc . $amt . $currencyCode . $paymentChannel . $storeCardUniqueID . $panBank .
        $country . $cardholderName . $cardholderEmail . $payCategoryID . $userDefined1 . $userDefined2 . $userDefined3 . $userDefined4 . $userDefined5 . $storeCard .
        $ippTransaction . $installmentPeriod . $interestType . $recurring . $invoicePrefix . $recurringAmount . $allowAccumulate . $maxAccumulateAmt . $recurringInterval . 
        $recurringCount . $chargeNextDate . $promotion . $request3DS . $statementDescriptor . $agentCode . $channelCode . $paymentExpiry . $mobileNo . $tokenizeWithoutAuthorization . $encryptedCardInfo;
    $hash = strtoupper(hash_hmac('sha1', $stringToHash ,$secretKey, false));      //Calculate Hash Value
                   

Construct payment request message.

    //Construct payment request message
    $xml = "<PaymentRequest>
    <version>$apiVersion</version>
    <timeStamp>$timeStamp</timeStamp>
    <merchantID>$merchantID</merchantID>
    <uniqueTransactionCode>$uniqueTransactionCode</uniqueTransactionCode>
    <desc>$desc</desc>
    <amt>$amt</amt>
    <currencyCode>$currencyCode</currencyCode>  
    <panCountry>$country</panCountry> 
    <cardholderName>$cardholderName</cardholderName>   
    <secureHash>$hash</secureHash>
    <encCardData>$encryptedCardInfo</encCardData>
    </PaymentRequest>";
    $payload = base64_encode($xml);        //Convert payload to base64
?>

Submit payment request form.

<!-- POST method to submit the form -->
<form action='https://demo2.2c2p.com/2C2PFrontEnd/SecurePayment/PaymentAuth.aspx' method='POST' name='paymentRequestForm'>
    Processing payment request, Do not close the browser, press back or refresh the page.
    <?php echo "<input type='hidden' name='paymentRequest' value='".$payload."'>"; ?>
</form>
<script language="JavaScript">
    document.paymentRequestForm.submit();
</script>

Complete Code

Copy & Paste below code to 'payment_3d.php' file, and put this file in your Web Server.

/payment_3d.php
<?php
    //Merchant Account Information
    $merchantID = "JT01";        //Get MerchantID when opening account with 2C2P
    $secretKey  = "7jYcp4FxFdf0";    //Get SecretKey from 2C2P PGW Dashboard
    //Transaction Information
    $uniqueTransactionCode = "Invoice".time();
    $desc = "1 room for 2 nights";
    $amt  = "000000000010";        //12 digit format
    $currencyCode = "702";        //Ref: http://en.wikipedia.org/wiki/ISO_4217
    //Cardholder Information
    $cardholderName = "John Doe";
    $country = "SG";
    
        //Request Information
    $timeStamp = time();
    $apiVersion = "9.3";
  
    $encryptedCardInfo = $_POST['encryptedCardInfo'];                            //Retrieve encrypted credit card data
    
    //available in js v1.6.7:
    $maskedCardNo = $_POST['maskedCardInfo'];                                    //Masked card number (first 6 and last 4 digit of credit card number)
    $expMonth = $_POST['expMonthCardInfo'];                                      //Card expiry month
    $expYear = $_POST['expYearCardInfo'];                                        //Card expiry Year
 
    //Construct signature string
    $stringToHash = $apiVersion . $timeStamp . $merchantID . $uniqueTransactionCode . $desc . $amt . $currencyCode . $paymentChannel . $storeCardUniqueID . $panBank .
        $country . $cardholderName . $cardholderEmail . $payCategoryID . $userDefined1 . $userDefined2 . $userDefined3 . $userDefined4 . $userDefined5 . $storeCard .
        $ippTransaction . $installmentPeriod . $interestType . $recurring . $invoicePrefix . $recurringAmount . $allowAccumulate . $maxAccumulateAmt . $recurringInterval . 
        $recurringCount . $chargeNextDate . $promotion . $request3DS . $statementDescriptor . $agentCode . $channelCode . $paymentExpiry . $mobileNo . $tokenizeWithoutAuthorization . $encryptedCardInfo;
    $hash = strtoupper(hash_hmac('sha1', $stringToHash ,$secretKey, false));      //Calculate Hash Value
   
    //Construct payment request message
    $xml = "<PaymentRequest>
    <version>$apiVersion</version>
    <timeStamp>$timeStamp</timeStamp>
    <merchantID>$merchantID</merchantID>
    <uniqueTransactionCode>$uniqueTransactionCode</uniqueTransactionCode>
    <desc>$desc</desc>
    <amt>$amt</amt>
    <currencyCode>$currencyCode</currencyCode>  
    <panCountry>$country</panCountry> 
    <cardholderName>$cardholderName</cardholderName>   
    <secureHash>$hash</secureHash>
    <encCardData>$encryptedCardInfo</encCardData>
    </PaymentRequest>";

    $payload = base64_encode($xml);    //Convert payload to base64
    ?>
    <!-- POST method to submit the form -->
    <form action='https://demo2.2c2p.com/2C2PFrontEnd/SecurePayment/PaymentAuth.aspx' method='POST' name='paymentRequestForm'>
        Processing payment request, Do not close the browser, press back or refresh the page.
        <?php echo "<input type='hidden' name='paymentRequest' value='".$payload."'>"; ?>
    </form>
    <script language="JavaScript">
        document.paymentRequestForm.submit();
    </script>

Full Request elements and data type check here.
Download full demo: PHP code / .Net code