3.11. /api/v2/preauth

Introduction

Preauth is initiated through HTTPS POST request by using URLs and the parameters specified below. Use SHA-1 for authentication. See Statuses.

API URLs

IntegrationProduction
https://sandbox.billblend.com/checkout/api/v2/preauth/ENDPOINTIDhttps://pay.billblend.com/checkout/api/v2/preauth/ENDPOINTID
https://sandbox.billblend.com/checkout/api/v2/preauth/group/ENDPOINTGROUPIDhttps://pay.billblend.com/checkout/api/v2/preauth/group/ENDPOINTGROUPID

Request Parameters

Note

Request must have content-type=application/x-www-form-urlencoded.

Parameter NameDescriptionValue
client_orderidUnique order identifier assigned by Connecting Party.Necessity: RequiredType: StringLength: 128
order_descBrief order description.Necessity: RequiredType: StringLength: 125
amountAmount to be charged. The amount has to be specified in the highest units with . delimiter. For instance, 10.5 for USD means 10 US Dollars and 50 Cents.Necessity: RequiredType: NumericLength: 10
currencyCurrency the transaction is charged in (See: Currency codes). Sample values are: USD for US Dollar EUR for European Euro.Necessity: RequiredType: StringLength: 3
address1Payer’s address line 1.Necessity: RequiredType: StringLength: 50
cityPayer’s city.Necessity: RequiredType: StringLength: 50
zip_codePayer’s ZIP code.Necessity: RequiredType: StringLength: 10
countryPayer’s country. Please see Country codes for a list of valid country codes.Necessity: RequiredType: StringLength: 2
phonePayer’s full international phone number, including country code.Necessity: RequiredType: StringLength: 15
emailPayer’s e-mail address.Necessity: RequiredType: StringLength: 50
ipaddressPayer’s IP address, included for fraud screening purposes.Necessity: RequiredType: StringLength: 45
controlChecksum generated by SHA-1. Control string is represented as concatenation of the following parameters:1. <ENDPOINTID | ENDPOINTGROUPID> (See: Request URL).2. Request parameter: client_orderid.3. Request parameter: amount in minor units (if sent).4. Request parameter: email.5. merchant_control (Control key assigned to Connecting Party account in the Billblend gateway system).Necessity: RequiredType: StringLength: 40
cvv2Payer’s CVV2 code. CVV2 (Card Verification Value) is a three- or four-digit number printed on the back of the card in the signature area.Necessity: RequiredType: NumericLength: 3-4
credit_card_numberPayer’s bank card number (also known as PAN – Primary Account Number).Necessity: RequiredType: NumericLength: 20
card_recurring_payment_idPayer’s tokenized cardholder’s data ID. Send either card_recurring_payment_id or combination of credit_card_number, card_printed_name, expire_month and expire_year, not all. To create card_recurring_payment_id see /api/v2/create-card-ref.Necessity: RequiredType: LongLength: 20
card_printed_nameCardholder name, printed on the bank card.Necessity: RequiredType: StringLength: 64k
expire_monthBank card expiration month.Necessity: RequiredType: NumericLength: 2
expire_yearBank card expiration year.Necessity: RequiredType: NumericLength: 4
first_namePayer’s first name.Necessity: RequiredType: StringLength: 50
last_namePayer’s last name.Necessity: RequiredType: StringLength: 50
statePayer’s state. Please see Mandatory State codes for a list of valid state codes. Required for USA, Canada and Australia.Necessity: ConditionalType: StringLength: 2-3
redirect_urlURL, where the Payer is redirected to upon completion of the transaction. Please note that redirection is performed in any case, no matter whether transaction is approveddeclined in any other final status.Connecting Party must not use the parameters come along with the redirect HTTP Request to treat the status of the transaction. Instead Connecting Party can utilize server_callback_url or status API command. Pass https://doc.billblend.com/ if you have no need to return payer anywhere. Use either redirect_url or combination of redirect_success_url and redirect_fail_url, not both.Necessity: OptionalType: StringLength: 1024
redirect_success_urlURL, where the Payer is redirected to when transaction status is approved (See status list).Connecting Party must not use the parameters come along with the redirect HTTP Request to treat the status of the transaction. Instead Connecting Party can utilize server_callback_url or status API command. Otherwise put https://doc.billblend.com/ if there is no need to redirect Payer anywhere. Use either combination of redirect_success_url and redirect_fail_url or redirect_url, not both.Necessity: OptionalType: StringLength: 1024
redirect_fail_urlURL, where the Payer is redirected to when transaction status is not approved (See status list).Connecting Party must not use the parameters come along with the redirect HTTP Request to treat the status of the transaction. Instead Connecting Party can utilize server_callback_url or status API command. Pass https://doc.billblend.com/ if there is no need to redirect Payer anywhere. Use either combination of redirect_fail_url and redirect_success_url or redirect_url, not both.Necessity: OptionalType: StringLength: 1024
ssnLast four digits of the payer’s social security number.Necessity: OptionalType: NumericLength: 32
birthdayPayer’s date of birth, in the format YYYYMMDD.Necessity: OptionalType: NumericLength: 8
cell_phonePayer’s full international cell phone number, including country code.Necessity: OptionalType: StringLength: 15
site_urlThe URL of the E-commerce entity, where the payment is originated from.Necessity: OptionalType: StringLength: 128
purposeDestination to where the payment goes. It is useful for the Connecting Partys who let their payers to top up their accounts with bank card (Mobile phone accounts, game accounts etc.). Sample values are: +7123456789gamer0001@ereality.com etc. This value can be used by the fraud monitoring system.Necessity: OptionalType: StringLength: 128
server_callback_urlURL, where the transaction status is sent to.Connecting Party may use server callback URL for custom processing of the transaction completion, e.g. to collect payment data in the Connecting Party’s information system. For the list of parameters which come along with server callback to server_callback_url refer to Connecting Party callback parameters. This parameter can be sent instead of notify_url. If server_callback_url is sent, Payment Gateway sends callback notification only when original transaction receives final status. If notify_url is sent, Payment Gateway sends callback notification once the original transaction receives final status, and about every future update for this original transaction (reversal, chargeback, etc).Necessity: OptionalType: StringLength: 1024
notify_urlURL, where the transaction status is sent to.Connecting Party may use notify URL for custom processing of the transaction completion, e.g. to collect payment data in the Connecting Party’s information system. For the list of parameters which come along with server callback to notify_url refer to Connecting Party callback parameters. This parameter can be sent instead of server_callback_url. If notify_url is sent, Payment Gateway sends callback notification once the original transaction receives final status, and about every future update for this original transaction (reversal, chargeback, etc). If server_callback_url is sent, Payment Gateway sends callback notification only when original transaction receives final status.Necessity: OptionalType: StringLength: 1024
merchant_dataCustom Connecting Party details, which can be attached to the transaction and passed back in the status response, Connecting Party callback parameters or server_callback_url. Additional information of transaction which may be useful in Connecting Party’s external system, e.g. VIP customerTV promo campaign lead.Information returns in Status response and Connecting Party Callback.Necessity: OptionalType: StringLength: 64k
minimum_transaction_amountThis parameter can be used to limit the minimum transaction amount, if transaction amount is submitted by Payer on the form. Contact support manager to enable this feature. Value format is the same as in the amount parameter.Necessity: OptionalType: NumericLength: 10
maximum_transaction_amountThis parameter can be used to limit the maximum transaction amount, if transaction amount is submitted by Payer on the form. Contact support manager to enable this feature. Value format is the same as in the amount parameter.Necessity: OptionalType: NumericLength: 10
customer_levelCustomer level in CMS systemNecessity: OptionalType: VarcharLength: 32
customer_idCustomer ID in CMS system. Required if transaction goes via CMS (Payment Gateway mode)Necessity: OptionalType: IntLength: 10
merchant_customer_identifierMerchant Customer ID in CMS system. Required if transaction goes via CMS (CRM mode)Necessity: OptionalType: VarcharLength: 64
recurring-payment-idRecurring Payment ID can be sent instead of cardholder data. CVV for native is not needed. Customer Data can be updated via /api/v4/update-recurring-payment/. Recurring Payment ID creation is initiated through HTTPS POST request by using URLs and the parameters specified below. Use OAuth RSA-SHA256 for authentication.Necessity: ConditionalType: Long

Additional Fields for Preauth Transactions

For Connecting Party

Note

Browser data for 3DS 2.X is gathered by Billblend system on 3DS authentication stage. For some processing channels, however, the browser data and/or Connecting Party URL for 3DS challenge results must be provided in initial transaction request. Please contact Support manager to clarify if these parameters should be included in request parameters.

The Connecting Party’s site needs to accurately populate the browser information for each transaction. This data can be obtained by Connecting Party’s servers. Ensure that the data is not altered or hard-coded, and that it is unique to each transaction.

Parameter NameDescriptionValue
ipaddressIP address of the browser as returned by the HTTP headers to the 3DS Requestor.Necessity: RequiredType: StringLength: 45
customer_browser_accept_headerExact content of the HTTP accept headers as sent to the 3DS Requestor from the Cardholder’s browser.Necessity: RequiredType: StringLength: 2048
customer_browser_javascript_enabledBoolean that represents the ability of the cardholder browser to execute JavaScript.Necessity: RequiredType: BooleanLength: –
customer_browser_accept_languageValue representing the browser language as defined in IETF BCP47.Necessity: RequiredType: StringLength: 8
customer_browser_user_agentExact content of the HTTP user-agent header.Necessity: RequiredType: StringLength: 2048
tds_areq_notification_url, alias tds_cres_notification_urlFully qualified URL of Connecting Party system that will receive the CRes message or Error Message. This CRes message must be sent to Billblend. See details here Upload CRes Result.Necessity: OptionalType: StringLength: 256
customer_browser_infoIf true, then the fields below must be present.Necessity: OptionalType: BooleanLength: –
customer_browser_color_depthValue representing the bit depth of the colour palette for displaying images, in bits per pixel. Becomes required when browser_javaScript_enabled = true.Necessity: OptionalType: StringLength: 2
customer_browser_java_enabledBoolean that represents the ability of the cardholder browser to execute Java. Becomes required when browser_javaScript_enabled = true.Necessity: OptionalType: BooleanLength: –
customer_browser_screen_heightTotal height of the Cardholder’s screen in pixels. Becomes required when browser_javaScript_enabled = true.Necessity: OptionalType: NumericLength: 6
customer_browser_screen_widthTotal width of the cardholder’s screen in pixels. Becomes required when browser_javaScript_enabled = true.Necessity: OptionalType: NumericLength: 6
customer_browser_time_zoneTime-zone offset in minutes between UTC and the Cardholder browser local time. Note that the offset is positive if the local time zone is behind UTC and negative if it is ahead. Becomes required when browser_javaScript_enabled = true.Necessity: OptionalType: StringLength: 5

For Payment Institutions

The PSP or Acquirer can fill the 3DS results for each transaction, if 3DS authentication is performed on their side.

Parameter NameDescriptionValue
tds_authentication_result_typeType of result. Possible values are:- SIMPLEType: StringLength: 6
tds_authentication_result_authentication_typeAuthentication Type. Indicates the type of authentication method the Issuer will use to challenge the Cardholder, whether in the ARes message or what was used by the ACS when in the RReq message. Possible values are:- 01 = Static- 02 = Dynamic- 03 = OOB- 04 = Decoupled- 05-79 = Reserved for EMVCo future use (values invalid until defined by EMVCo)- 80-99 = Reserved for DS useType: StringLength: 2
tds_authentication_result_authentication_valueAuthentication Value. Payment System-specific value provided by the ACS or the DS using an algorithm defined by Payment System. Authentication Value may be used to provide proof of authentication. A 20-byte value that has been Base64 encoded, giving a 28-byte resultType: StringLength: 19-28
tds_authentication_result_transaction_idxid for 1.0.2 or dsTransID for 2.1.0/2.2.0Type: StringLength: 19-36
tds_authentication_result_transaction_statusTransaction Status. Indicates whether a transaction qualifies as an authenticated transaction or account verification. Possible values are:- Y = Authentication Verification Successful- N = Not Authenticated/Account Not Verified, Transaction denied- U = Authentication/Account Verification Could Not Be Performed, Technical or other problem, as indicated in ARes or RReq- A = Attempts Processing Performed, Not Authenticated/Verified, but a proof of attempted authentication/verification is provided- C = Challenge Required, Additional authentication is required using the CReq/CRes- D = Challenge Required, Decoupled Authentication confirmed- R = Authentication/ Account Verification Rejected, Issuer is rejectingType: StringLength: 1
tds_authentication_result_message_versionMessage Version Number. Protocol version identifier This shall be the Protocol Version Number of the specification utilised by the system creating this message. The Message Version Number is set by the 3DS Server which originates the protocol with the AReq message. The Message Version Number does not change during a 3DS transaction. Possible values are:- 1.0.2- 2.1.0- 2.2.0Type: StringLength: 5

Response Parameters

Note

Response has Content-Type: text/html;charset=utf-8 header. All fields are x-www-form-urlencoded, with (0xA) character at the end of each parameter’s value.

Response ParametersDescription
typeThe type of response. May be async-responsevalidation-errorerror etc.If type equals validation-error or errorerror-message and error-code parameters contain error details.
paynet-order-idOrder id assigned to the order by Billblend.
merchant-order-idConnecting Party order id.
serial-numberUnique number assigned by Billblend server to particular request from the Connecting Party.
error-messageIf status is error this parameter contains the reason for decline or error details.
error-codeThe error code is case of error status.
end-point-idEndpoint id used for the transaction.

Request with Cardholder Data Example

POST /checkout/api/v2/preauth/39549 HTTP/1.1
User-Agent: curl/7.83.0
Accept: */*
Content-Length: 314
Content-Type: application/x-www-form-urlencoded
Connection: close

credit_card_number=4538977399606732
&card_printed_name=CARD HOLDER
&expire_month=12
&expire_year=2099
&cvv2=123
&client_orderid=902B4FF5
&order_desc=Test Order Description
&first_name=John
&last_name=Smith
&ssn=1267
&birthday=19820115
&address1=100 Main st
&city=Seattle
&state=WA
&zip_code=98102
&country=US
&phone=%2B12063582043
&cell_phone=%2B19023384543
&email=john.smith@gmail.com
&currency=USD
&amount=10.42
&ipaddress=65.153.12.232
&site_url=https://doc.billblend.com/
&purpose=user_account1
&redirect_url=https://doc.billblend.com//doc/dummy.htm
&server_callback_url=https://httpstat.us/200
&merchant_data=VIP customer
&control=768eb8162fc361a3e14150ec46e9a6dd8fbfa483

Request with Card Recurring Payment ID Example

POST /checkout/api/v2/preauth/39549 HTTP/1.1
User-Agent: curl/7.83.0
Accept: */*
Content-Length: 314
Content-Type: application/x-www-form-urlencoded
Connection: close

card_recurring_payment_id=1491927
&cvv2=123
&client_orderid=34T43R77N
&order_desc=Test Order Description
&amount=777
&currency=USD
&ipaddress=65.153.12.232
&redirect_url=https://doc.billblend.com//doc/dummy.htm
&server_callback_url=https://httpstat.us/200
&control=218d377897ce25c2ac69d99de42bc6902eb5bcd8

Success Response Example

HTTP/1.1 200 OK
Server: server
Date: Mon, 05 Sep 2022 10:43:57 GMT
Content-Type: text/html;charset=utf-8
Connection: close
Vary: Accept-Encoding
X-XSS-Protection: 1
X-Content-Type-Options: nosniff
Strict-Transport-Security: max-age=31536000
Content-Language: en-US
Strict-Transport-Security: max-age=31536000
Content-Length: 139

type=async-response
&serial-number=00000000-0000-0000-0000-000002ddb018
&merchant-order-id=123
&paynet-order-id=6863073
&end-point-id=39914

Fail Response Example

HTTP/1.1 200 OK
Server: server
Date: Mon, 05 Sep 2022 10:51:14 GMT
Content-Type: text/html;charset=utf-8
Connection: close
Vary: Accept-Encoding
X-XSS-Protection: 1
X-Content-Type-Options: nosniff
Strict-Transport-Security: max-age=31536000
Content-Language: en-US
Strict-Transport-Security: max-age=31536000
Content-Length: 208

type=validation-error
&serial-number=00000000-0000-0000-0000-000002ddb019
&merchant-order-id=123
&error-message=Validate+card+number+failed.+Card+Number+length+must+be+between+16+and+19+digits..
&error-code=8

Postman Collection

Postman Collection is available at this link – https://doc.billblend.com/integration/API_commands/api_v2_preauth.html#postman-collection

Request Builder

Request Builder is available at this link – https://doc.billblend.com/integration/API_commands/api_v2_preauth.html#request-builder

endpointid or groupidinput ENDPOINTID or ENDPOINTGROUPID
client_orderidmake it  or use internal invoice ID
order_desc
first_name
last_name
ssn
birthday
address1
city
state
zip_code
country
phone
cell_phone
amount
email
currency
ipaddress
site_url
credit_card_number
card_printed_name
expire_month
expire_year
cvv2
purpose
merchant_controlinput Control Key
redirect_url
redirect_success_url
redirect_fail_url
server_callback_url
merchant_data
merchant_form_data
curl --data "client_orderid=902B4FF5&order_desc=Test Order Description&first_name=John&last_name=Smith&ssn=1267&birthday=19820115&address1=100 Main st&city=Seattle&state=WA&zip_code=98102&country=US&phone=+12063582043&cell_phone=+19023384543&amount=10.42&email=john.smith@gmail.com&currency=USD&ipaddress=65.153.12.232&site_url=www.google.com&credit_card_number=4538977399606732&card_printed_name=CARD HOLDER&expire_month=12&expire_year=2099&cvv2=123&purpose=user_account1&redirect_url=https://doc.billblend.com//doc/dummy.htm&server_callback_url=https://httpstat.us/200&merchant_data=VIP customer&merchant_form_data=testparam%3Dtest1%26mynewparam%3Dtest2&control=768eb8162fc361a3e14150ec46e9a6dd8fbfa483" https://sandbox.billblend.com/checkout/api/v2/preauth/1
<?php

/**
 * Executes request
 *
 * @param       string      $url                Url for payment method
 * @param       array       $requestFields      Request data fields
 *
 * @return      array                           Host response fields
 *
 * @throws      RuntimeException                Error while executing request
 */
function sendRequest($url, array $requestFields)
{
    $curl = curl_init($url);

    curl_setopt_array($curl, array
    (
        CURLOPT_HEADER         => 0,
        CURLOPT_USERAGENT      => 'Billblend-Client/1.0',
        CURLOPT_SSL_VERIFYHOST => 0,
        CURLOPT_SSL_VERIFYPEER => 0,
        CURLOPT_POST           => 1,
        CURLOPT_RETURNTRANSFER => 1
    ));

    curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($requestFields));

    $response = curl_exec($curl);

    if(curl_errno($curl))
    {
        $error_message  = 'Error occurred: ' . curl_error($curl);
        $error_code     = curl_errno($curl);
    }
    elseif(curl_getinfo($curl, CURLINFO_HTTP_CODE) != 200)
    {
        $error_code     = curl_getinfo($curl, CURLINFO_HTTP_CODE);
        $error_message  = "Error occurred. HTTP code: '{$error_code}'";
    }

    curl_close($curl);

    if (!empty($error_message))
    {
        throw new RuntimeException($error_message, $error_code);
    }

    if(empty($response))
    {
        throw new RuntimeException('Host response is empty');
    }

    $responseFields = array();

    parse_str($response, $responseFields);

    return $responseFields;
}

function signString($s, $merchantControl)
{
    return sha1($s . $merchantControl);
}

/**
 * Signs payment (sale/auth/transfer) request
 *
 * @param 	array		$requestFields		request array
 * @param	string		$endpointOrGroupId	endpoint or endpoint group ID
 * @param	string		$merchantControl	merchant control key
 */
function signPaymentRequest($requestFields, $endpointOrGroupId, $merchantControl)
{
    $base = '';
    $base .= $endpointOrGroupId;
    $base .= $requestFields['client_orderid'];
    $base .= $requestFields['amount'] * 100;
    $base .= $requestFields['email'];

    return signString($base, $merchantControl);
}

/**
 * Signs status request
 *
 * @param 	array		$requestFields		request array
 * @param	string		$login			merchant login
 * @param	string		$merchantControl	merchant control key
 */
function signStatusRequest($requestFields, $login, $merchantControl)
{
    $base = '';
    $base .= $login;
    $base .= $requestFields['client_orderid'];
    $base .= $requestFields['orderid'];

    return signString($base, $merchantControl);
}


function signAccountVerificationRequest($requestFields, $endpointOrGroupId, $merchantControl)
{
    $base = '';
    $base .= $endpointOrGroupId;
    $base .= $requestFields['client_orderid'];
    $base .= $requestFields['email'];
    return signString($base, $merchantControl);
}

$endpointId = 1;
$merchantControl = 'B17F59B4-A7DC-41B4-8FF9-37D986B43D20';


$requestFields = array(
    'client_orderid' => '902B4FF5', 
    'order_desc' => 'Test Order Description', 
    'first_name' => 'John', 
    'last_name' => 'Smith', 
    'ssn' => '1267', 
    'birthday' => '19820115', 
    'address1' => '100 Main st', 
    'city' => 'Seattle', 
    'state' => 'WA', 
    'zip_code' => '98102', 
    'country' => 'US', 
    'phone' => '+12063582043', 
    'cell_phone' => '+19023384543', 
    'amount' => '10.42', 
    'email' => 'john.smith@gmail.com', 
    'currency' => 'USD', 
    'ipaddress' => '65.153.12.232', 
    'site_url' => 'www.google.com', 
    'credit_card_number' => '4538977399606732', 
    'card_printed_name' => 'CARD HOLDER', 
    'expire_month' => '12', 
    'expire_year' => '2099', 
    'cvv2' => '123', 
    'purpose' => 'user_account1', 
    'redirect_url' => 'https://doc.billblend.com//doc/dummy.htm', 
    'server_callback_url' => 'https://httpstat.us/200', 
    'merchant_data' => 'VIP customer', 
    'merchant_form_data' => 'testparam%3Dtest1%26mynewparam%3Dtest2', 

);

$requestFields['control'] = signPaymentRequest($requestFields, $endpointId, $merchantControl);

$responseFields = sendRequest('https://sandbox.billblend.com/checkout/api/v2/preauth/1', $requestFields);

print_r($responseFields);

?>
require 'net/http'
require 'uri'
require 'cgi'
require 'digest/sha1'

##
# Executes request
#
# @param    url               [String]    Url for payment method
# @param    request_fields    [Hash]      Request data fields
#
# @return   [Hash]    Host response fields
def send_request(url, request_fields)
  begin
    uri = URI url

    response = Net::HTTP.start uri.hostname, uri.port, :use_ssl => uri.scheme == 'https' do |http|
      post = Net::HTTP::Post.new uri.request_uri
      post.set_form_data request_fields
      http.request post
    end
  rescue Exception => e
    raise RuntimeError, "Error occurred. #{e.message}"
  end

  unless Net::HTTPOK === response
    raise RuntimeError, "Error occurred. HTTP code: '#{response.code}'. Server message: '#{response.message}'"
  end

  unless response.body
    raise RuntimeError, 'Host response is empty'
  end

  # Change hash format from {'key' => ['value']} to {'key' => 'value'} in map block
  Hash[CGI.parse(response.body).map {|key, value| [key, value.first]}]
end

def sign_string(str, merchant_control)
  Digest::SHA1.hexdigest(str + merchant_control)
end

def sign_payment_request(request_fields, endpoint_or_group_id, merchant_control)
  base = ''
  base += endpoint_or_group_id
  base += request_fields['client_orderid']
  base += (request_fields['amount'].to_f * 100).to_i
  base += request_fields['email']
  sign_string(base, merchant_control)
end

def sign_status_request(request_fields, login, merchant_control)
  base = ''
  base += login
  base += request_fields['client_orderid']
  base += request_fields['orderid'].nil? ? '' : request_fields['orderid']
  sign_string(base, merchant_control)
end

request_fields = {
    'client_orderid' => '902B4FF5', 
    'order_desc' => 'Test Order Description', 
    'first_name' => 'John', 
    'last_name' => 'Smith', 
    'ssn' => '1267', 
    'birthday' => '19820115', 
    'address1' => '100 Main st', 
    'city' => 'Seattle', 
    'state' => 'WA', 
    'zip_code' => '98102', 
    'country' => 'US', 
    'phone' => '+12063582043', 
    'cell_phone' => '+19023384543', 
    'amount' => '10.42', 
    'email' => 'john.smith@gmail.com', 
    'currency' => 'USD', 
    'ipaddress' => '65.153.12.232', 
    'site_url' => 'www.google.com', 
    'credit_card_number' => '4538977399606732', 
    'card_printed_name' => 'CARD HOLDER', 
    'expire_month' => '12', 
    'expire_year' => '2099', 
    'cvv2' => '123', 
    'purpose' => 'user_account1', 
    'redirect_url' => 'https://doc.billblend.com//doc/dummy.htm', 
    'server_callback_url' => 'https://httpstat.us/200', 
    'merchant_data' => 'VIP customer', 
    'merchant_form_data' => 'testparam%3Dtest1%26mynewparam%3Dtest2', 

    'control' => '768eb8162fc361a3e14150ec46e9a6dd8fbfa483'
};

response_fields = send_request('https://sandbox.billblend.com/checkout/api/v2/preauth/1', request_fields);

require 'pp'
pp response_fields
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class Main {
    //Transactions are initiated by using URL in the following format: /checkout/api/v2/TRANSACTION_TYPE/ENDPOINTID or /checkout/api/v2/TRANSACTION_TYPE/ENDPOINTGROUPID (if group is supported)
    //Use "gate" for production purposes or "sandbox" for integration needs
    private static String targetURL = "https://sandbox.billblend.com/checkout/api/v2/preauth/1";
    //Request parameters
    private static String urlParameters = "client_orderid=902B4FF5&order_desc=Test Order Description&first_name=John&last_name=Smith&ssn=1267&birthday=19820115&address1=100 Main st&city=Seattle&state=WA&zip_code=98102&country=US&phone=+12063582043&cell_phone=+19023384543&amount=10.42&email=john.smith@gmail.com&currency=USD&ipaddress=65.153.12.232&site_url=www.google.com&credit_card_number=4538977399606732&card_printed_name=CARD HOLDER&expire_month=12&expire_year=2099&cvv2=123&purpose=user_account1&redirect_url=https://doc.billblend.com//doc/dummy.htm&server_callback_url=https://httpstat.us/200&merchant_data=VIP customer&merchant_form_data=testparam%3Dtest1%26mynewparam%3Dtest2&";
    //String for calculating control code parameter
    private static String controlParameters = "1902B4FF51042john.smith@gmail.comB17F59B4-A7DC-41B4-8FF9-37D986B43D20";

    public static void main(String[] args) throws NoSuchAlgorithmException, UnsupportedEncodingException {
        //Sending POST request to the specified URL with request parameters and SHA1-encrypted control parameter
        System.out.println(executePost(targetURL, urlParameters + "control= " + sha1(controlParameters)));
    }

    static String sha1(String input) throws NoSuchAlgorithmException, UnsupportedEncodingException {
        MessageDigest mDigest = MessageDigest.getInstance("SHA1");
        byte[] result = mDigest.digest(input.getBytes("utf-8"));
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < result.length; i++) {
            sb.append(Integer.toString((result[i] & 0xff) + 0x100, 16).substring(1));
        }

        return sb.toString();
    }

    public static String executePost(String targetURL, String urlParameters)
    {
        URL url;
        HttpURLConnection connection = null;
        try {
            //Create connection
            url = new URL(targetURL);
            connection = (HttpURLConnection)url.openConnection();
            connection.setDoOutput(true);


            //Send request
            DataOutputStream wr = new DataOutputStream (
                    connection.getOutputStream ());
            wr.writeBytes (urlParameters);
            wr.flush ();
            wr.close ();


            //Get Response
            InputStream is = connection.getInputStream();
            BufferedReader rd = new BufferedReader(new InputStreamReader(is));
            String line;
            StringBuffer response = new StringBuffer();
            while((line = rd.readLine()) != null) {
                response.append(line);
                response.append('\n');
            }
            rd.close();
            return response.toString();

        } catch (Exception e) {

            e.printStackTrace();
            return null;

        } finally {

            if(connection != null) {
                connection.disconnect();
            }
        }
    }
}

Contact us

By clicking on the button, you agree to the data protection policy

Complete the quiz

By clicking on the button, you agree to the data protection policy