SDK Credit

Document created by gjsissons on May 6, 2016Last modified by swapnil.hande on Nov 26, 2018
Version 3Show Document
  • View in full screen mode

You can use a Credit transaction to refund money to a customer, even if the original transaction occurred outside of Vantiv’s systems. You can submit refunds against any of the following payment transactions:

 

 

 

 

PHP example

 

<?php

require __DIR__ . "/path/to/vendor/autoload.php";

use cnp\sdk\CnpOnlineRequest;
use cnp\sdk\XmlParser;

$hash_in = array(
'card' => array('type' => 'VI', 'id' => 'id',
'number' => '4100000000000000',
'expDate' => '1213',
'cardValidationNum' => '1213'),
'id' => '1211',
'orderId' => '2111',
'reportGroup' => 'Planets',
'orderSource' => 'ecommerce',
'amount' => '123');

$initialize = new CnpOnlineRequest();
$creditResponse = $initialize->creditRequest($hash_in);
$response = XmlParser::getDomDocumentAsString($creditResponse);

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();
Credit credit = new Credit();
credit.setAmount(106L);
credit.setOrderId("12344");
credit.setOrderSource(OrderSourceType.ECOMMERCE);
CardType card = new CardType();
card.setType(MethodOfPaymentTypeEnum.VI);
card.setNumber("4100000000000001");
card.setExpDate("1210");
credit.setCard(card);
credit.setId("id");
CreditResponse response = cnp.credit(credit);

System.out.println("Response:"+response.getResponse());
System.out.println("Message:"+response.getMessage());
System.out.println("Transaction ID:"+response.getCnpTxnId());
}
}

 

.NET example

 

using Cnp.Sdk;
using System;

namespace CNP_Examples
{
class Program
{
public static void SimpleCreditWithCard()
{
CnpOnline _cnp = new CnpOnline();
var creditObj = new credit
{
id = "1",
reportGroup = "planets",
amount = 106,
orderId = "2111",
orderSource = orderSourceType.ecommerce,
card = new cardType
{
type = methodOfPaymentTypeEnum.VI,
number = "4100000000000001",
expDate = "1210"
}
};

var response = _cnp.Credit(creditObj);
}

static void Main(string[] args)
{
SimpleCreditWithCard();
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' =>'4100000000000001',
'expDate' =>'1210'
}}
response= CnpOnlineRequest.new.credit(hash)

puts response.message

 

Python Example

 

from vantivsdk import fields, online, utils

conf = utils.Configuration()

transaction = fields.credit()
transaction.reportGroup = 'Planets'
transaction.orderId = '12344'
transaction.amount = 106
transaction.orderSource = 'ecommerce'
transaction.id = 'ThisIsID'

card = fields.cardType()
card.number = '4100000000000000'
card.expDate = '1210'
card.type = 'VI'

transaction.card = card

response = online.request(transaction, conf)

Attachments

    Outcomes