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

Import http post & pkcs7 encryption classes

<?php
    include_once('HTTP.php');
    include_once('pkcs7.php');

Set account credentials.

    //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>";
    $data = base64_encode($xml);        //Convert payload to base64
    $payload = urlencode($data);        //Url encode

Submit payment request & read payment response message.

    //Send authorization request
    $http = new HTTP();
    $response = $http->post("https://demo2.2c2p.com/2C2PFrontEnd/SecurePayment/Payment.aspx","paymentRequest=".$payload);

    //Decrypt response and display
    $pkcs7 = new pkcs7();
    $response = $pkcs7->decrypt($response,"./keys/demo2.crt","./keys/demo2.pem","2c2p");
    echo "Response:<br/><textarea style='width:100%;height:80px'>". $response."</textarea>";
?>

Complete Code

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

/payment_non3d.php
<?php
    include_once('HTTP.php');
    include_once('pkcs7.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
    $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>";
    $data = base64_encode($xml);        //Convert payload to base64
    $payload = urlencode($data);        //Url encode

    //Send authorization request
    $http = new HTTP();
    $response = $http->post("https://demo2.2c2p.com/2C2PFrontEnd/SecurePayment/Payment.aspx","paymentRequest=".$payload);

    //Decrypt response and display
    $pkcs7 = new pkcs7();
    $response = $pkcs7->decrypt($response,"./keys/demo2.crt","./keys/demo2.pem","2c2p");
    echo "Response:<br/><textarea style='width:100%;height:80px'>". $response."</textarea>";
?>
/HTTP.php show
/pkcs7.php show

Full Request elements and data type check here.
Full Response elements and data type check here.

Download full demo: PHP code / .Net code