The Authorization transaction enables you to confirm that customers have submitted a valid payment method with their order and have sufficient funds to purchase goods or services. Setting the <allowPartialAuth> element to true in the Authorization request enables the system to return Authorizations for a portion of the order amount for cases where the card does not have an adequate credit limit or balance available for the full amount.
An approved Authorization reduces the customer's credit limit (or bank balance, in the case of a debit card) by the amount of the approval by placing the amount on hold. If you have the Prepaid Indicator feature enabled, the Authorization response also includes an element that indicates if the card is Prepaid, as well as an element indicating the available balance on the card.
PHP Example
<?php
require __DIR__ . "/path/to/vendor/autoload.php";
use cnp\sdk\CnpOnlineRequest;
use cnp\sdk\XmlParser;
$hash_in = array('id' => 'id',
'card' => array('type' => 'VI',
'number' => '4100000000000000',
'expDate' => '1213',
'cardValidationNum' => '1213'),
'id' => '1211',
'orderId' => '22@33',
'reportGroup' => 'Planets',
'orderSource' => 'ecommerce',
'amount' => '0');
$initialize = new CnpOnlineRequest();
$authorizationResponse = $initialize->authorizationRequest($hash_in);
$response = XmlParser::getDomDocumentAsString($authorizationResponse);
print_r($response);
?>
Java Example
package com.cnp.sdk;
import com.cnp.sdk.generate.*;
public class Example {
public static void main(String[] args){
CnpOnline cnp = new CnpOnline();
Authorization authorization = new Authorization();
authorization.setReportGroup("Planets");
authorization.setOrderId("12344");
authorization.setAmount(106L);
authorization.setOrderSource(OrderSourceType.ECOMMERCE);
authorization.setId("id");
CardType card = new CardType();
card.setType(MethodOfPaymentTypeEnum.VI);
card.setNumber("4100000000000000");
card.setExpDate("1210");
authorization.setCard(card);
AuthorizationResponse response = cnp.authorize(authorization);
System.out.println("Response:"+response.getResponse());
System.out.println("Message:"+response.getMessage());
System.out.println("Transaction ID:"+response.getNetworkTransactionId());
}
}
.NET Example
using Cnp.Sdk;
using System;
namespace CNP_Examples
{
class Program
{
static void Main(string[] args)
{
CnpOnline _cnp;
_cnp = new CnpOnline();
var authorization = new authorization
{
id = "1",
reportGroup = "Planets",
orderId = "12344",
amount = 106,
orderSource = orderSourceType.ecommerce,
card = new cardType
{
type = methodOfPaymentTypeEnum.VI,
number = "414100000000000000",
expDate = "1210"
},
customBilling = new customBilling { phone = "1112223333" }
};
var response = _cnp.Authorize(authorization);
Console.ReadLine();
}
}
}
Ruby Example
require 'CnpOnline'
include CnpOnline
hash = {
'merchantId' => '101',
'id' => 'test',
'version'=>'8.8',
'reportGroup'=>'Planets',
'orderId'=>'12344',
'amount'=>'106',
'orderSource'=>'ecommerce',
'card'=>{
'type'=>'VI',
'number' =>'4100000000000000',
'expDate' =>'1210'
}}
response= CnpOnlineRequest.new.authorization(hash)
puts response.authorizationResponse.response
Python Example
from vantivsdk import fields, online, utils
conf = utils.Configuration()
authorization = fields.authorization()
authorization.reportGroup = 'Planets'
authorization.orderId = '12344'
authorization.amount = 106
authorization.orderSource = 'ecommerce'
authorization.id = 'thisisid'
card = fields.cardType()
card.number = '4100000000000000'
card.expDate = '1210'
card.type = 'VI'
authorization.card = card
response = online.request(authorization, conf)