Configuration
For configuration code samples, see our Configuration Code for SDKs article.
Authorization
We highly recommend sanitizing the cardholder data before sending it in the request. For example, check if the card number is valid and the expiry date is in the future. Our JavaScript Library on GitHub contains a handy set of functions to help you do this.
info
// create the card object
CreditCardData card = new CreditCardData();
card.setNumber("4263970000005262");
card.setExpMonth(12);
card.setExpYear(2025);
card.setCvn("131");
card.setCardHolderName("James Mason");
try {
// process an auto-settle authorization
Transaction response =
card
.charge(new BigDecimal("19.99"))
.withCurrency("EUR")
.execute();
String result = response.getResponseCode(); // SUCCESS
String message = response.getResponseMessage(); // CAPTURED
// get the details to save to the DB for future requests
String orderId = response.getOrderId();
String authCode = response.getAuthorizationCode(); // 00
String paymentsReference = response.getTransactionId();
} catch (ApiException ex) {
// TODO: add your error handling here
}
<?php
// create the card object
$card = new CreditCardData();
$card->number = "4263970000005262";
$card->expMonth = 12;
$card->expYear = 2025;
$card->cvn = "131";
$card->cardHolderName = "James Mason";
try {
// process an auto-capture authorization
$response = $card->charge(19.99)
->withCurrency("EUR")
->execute();
} catch (ApiException $e) {
// TODO: Add your error handling here
}
if (isset($response)) {
$result = $response->responseCode; // SUCCESS
$message = $response->responseMessage; // CAPTURED
// get the details to save to the DB for future requests
$authCode = $response->authorizationCode; // 12345
$paymentsReference = $response->transactionId; // TRN_VEeXGQkOxvNv6dvxYwAmnhkMy79vc7_87e11bc6b4dd
}
// create the card object
CreditCardData card = new CreditCardData();
card.Number = "4263970000005262";
card.ExpMonth = 12;
card.ExpYear = 2025;
card.Cvn = "131";
card.CardHolderName = "John Doe";
try
{
// process an auto-settle authorization
Transaction response = card.Charge(19.99m)
.WithCurrency("EUR")
.Execute();
string result = response.ResponseCode; //SUCCESS
string message = response.ResponseMessage; //CAPTURED
// get the details to save to the DB for future requests
string orderId = response.OrderId;
string authCode = response.AuthorizationCode; //00
string paymentsReference = response.TransactionId;
}
catch (ApiException ex)
{
// TODO: add your error handling here
}
Validate (Open To Buy)
// create the card object
CreditCardData card = new CreditCardData();
card.setNumber("4263970000005262");
card.setExpMonth(12);
card.setExpYear(2025);
card.setCvn("131");
card.setCardHolderName("James Mason");
try {
// check that a card is valid and active without charging an amount
Transaction response =
card
.verify()
.withCurrency("EUR")
.execute();
// get the details to save to the DB for future requests
String result = response.getResponseCode(); // SUCCESS
String message = response.getResponseMessage(); // CAPTURED
} catch (ApiException ex) {
// TODO: add your error handling here
}
<?php
// create the card object
$card = new CreditCardData();
$card->number = "4263970000005262";
$card->expMonth = 12;
$card->expYear = 2025;
$card->cvn = "131";
$card->cardHolderName = "James Mason";
try {
// check that a card is valid and active without charging an amount
$response = $card->verify()
->withCurrency('EUR')
->execute();
} catch (ApiException $e) {
// TODO: Add your error handling here
}
if (isset($response)) {
$result = $response->responseCode; // SUCCESS
$message = $response->responseMessage; // VERIFIED
// TODO: save the card to Card Storage
}
// create the card object
CreditCardData card = new CreditCardData();
card.Number = "4263970000005262";
card.ExpMonth = 12;
card.ExpYear = 2025;
card.Cvn = "131";
card.CardHolderName = "James Mason";
try
{
// check that a card is valid and active without charging an amount
Transaction response = card.Verify()
.WithCurrency("EUR")
.Execute();
// get the response details to update the DB
string result = response.ResponseCode; //SUCCESS
string message = response.ResponseMessage; //VERIFIED
// TODO: save the card to Card Storage
}
catch (ApiException ex)
{
// TODO: add your error handling here
}
Credit
For security reasons this request type is not enabled by default. It must be requested by one of the listed contacts on your account with us.
info
// create the card object
CreditCardData card = new CreditCardData();
card.setNumber("4263970000005262");
card.setExpMonth(12);
card.setExpYear(2025);
card.setCvn("131");
card.setCardHolderName("James Mason");
try {
// process a refund to the card
Transaction response =
card
.refund(129.99)
.withCurrency("EUR")
.execute();
// get the details to save to the DB for future requests
String result = response.getResponseCode(); // SUCCESS
String message = response.getResponseMessage(); // CAPTURED
} catch (ApiException ex) {
// TODO: add your error handling here
}
<?php
// create the card object, security code not required for Refunds
$card = new CreditCardData();
$card->number = "4263970000005262";
$card->expMonth = 12;
$card->expYear = 2025;
$card->cardHolderName = "James Mason";
try {
// process a refund to the card
$response = $card->refund(19.99)
->withCurrency("EUR")
->execute();
} catch (ApiException $e) {
// TODO: Add your error handling here
}
if (isset($response)) {
$result = $response->responseCode; // SUCCESS
$message = $response->responseMessage; // CAPTURED
// get the details to save to the DB for future requests
$authCode = $response->authorizationCode; // 12345
$paymentsReference = $response->transactionId; // TRN_USX1ogySquO6ZTsjrbI9k0lBrf4670_eec76119e6c5
}
// create the card object
CreditCardData card = new CreditCardData();
card.Number = "4263970000005262";
card.ExpMonth = 12;
card.ExpYear = 2025;
card.Cvn = "131";
card.CardHolderName = "James Mason";
try
{
// process a refund to the card
Transaction response = card.Refund(129.99m)
.WithCurrency("EUR")
.Execute();
// get the response details to update the DB
string result = response.ResponseCode; //SUCCESS
string message = response.ResponseMessage; //CAPTURED
}
catch (ApiException ex)
{
// TODO: add your error handling here
}
Internal Title
GP-API, SDK
Show Content Nav
On
Tags