Developer Portal

Credit Card Payments

Follow these steps to take credit card payments using your language of choice.

Prepare to Charge a Credit Card

For the below sections, the code samples will reference the following objects:

Prepare to charge a credit card

using GlobalPayments.Api.Entities;
using GlobalPayments.Api.PaymentMethods;

var card = new CreditCardData {
    Token = "single- or multi-use token"
};

var address new Address {
    PostalCode = "12345"
};
<?php
use GlobalPayments\Api\Entities\Address;
use GlobalPayments\Api\PaymentMethods\CreditCardData;

$card = new CreditCardData();
$card->token = "single- or multi-use token";

$address = new Address();
$address->postalCode = "12345";
import com.global.api.entities.Address;
import com.global.api.paymentMethods.CreditCardData;

CreditCardData card = new CreditCardData();
card.setToken("single- or multi-use token");

Address address = new Address();
address.setCode("12345");
# coming soon
from globalpayments.api.entities import Address
from globalpayments.api.payment_methods import CreditCardData

card = CreditCardData()
card.token = 'single- or multi-use token'

address = Address()
address.postal_code = '12345'
import { Address, CreditCardData } from "globalpayments-api";

const card = new CreditCardData();
card.token = "single- or multi-use token";

const address = new Address();
address.code = "12345";

Not using tokens?

Our SDKs support using tokens in place of card data, but using tokens is an option for you. You can also pass raw card data to us:

Manual Entry credit card data

using GlobalPayments.Api.PaymentMethods;

var card = new CreditCardData {
    Number = "4111111111111111",
    ExpMonth = "12",
    ExpYear = "2025",
    Cvn = "123"
};
<?php
use GlobalPayments\Api\PaymentMethods\CreditCardData;

$card = new CreditCardData();
$card->number = "4111111111111111";
$card->expMonth = "12";
$card->expYear = "2025";
$card->cvn = "123";
import com.global.api.paymentMethods.CreditCardData;

CreditCardData card = new CreditCardData();
card.setNumber("4111111111111111");
card.setExpMonth("12");
card.setExpYear("2025");
card.setCvn("123");
# coming soon
from globalpayments.api.payment_methods import CreditCardData

card = CreditCardData()
card.number = '4111111111111111'
card.exp_month = '12'
card.exp_year = '2025'
card.cvn = '123'
import { CreditCardData } from "globalpayments-api";

const card = new CreditCardData();
card.number = "4111111111111111";
card.expMonth = "12";
card.expYear = "2025";
card.cvn = "123";

Credit card track data

using GlobalPayments.Api.Entities;
using GlobalPayments.Api.PaymentMethods;

var card = new CreditTrackData {
    Value = "%B401200******0016^VI TEST CREDIT ...",
    EntryMethod = EntryMethod.Swipe
};
<?php
use GlobalPayments\Api\PaymentMethods\CreditTrackData;
use GlobalPayments\Api\Entities\Enums\EntryMethod;

$card = new CreditTrackData();
$card->value = "%B401200******0016^VI TEST CREDIT ...";
$card->entryMethod = EntryMethod::SWIPE;
import com.global.api.paymentMethods.CreditTrackData;
import com.global.api.entities.enums.EntryMethod;

CreditTrackData card = new CreditTrackData();
card.setValue("%B401200******0016^VI TEST CREDIT ...");
card.setEntryMethod(EntryMethod.Swipe);
# coming soon
from globalpayments.api.payment_methods import CreditTrackData
from globalpayments.api.entities.enums import EntryMethod

card = CreditTrackData()
card.value = '%B401200******0016^VI TEST CREDIT ...'
card.entry_method = EntryMethod.Swipe
import { CreditTrackData, EntryMethod } from "globalpayments-api";

const card = new CreditTrackData();
card.value = "%B401200******0016^VI TEST CREDIT ...";
card.entryMethod = EntryMethod.Swipe;

Encrypted credit card track data

using GlobalPayments.Api.Entities;
using GlobalPayments.Api.PaymentMethods;

var card = new CreditTrackData {
    Value = "<E1050711%B401200******0016^VI TEST CREDIT ...",
    EntryMethod = EntryMethod.Swipe,
    EncryptionData = new EncryptionData {
        Version = "01"
    }
};
<?php
use GlobalPayments\Api\Entities\EncryptionData;
use GlobalPayments\Api\Entities\Enums\EntryMethod;
use GlobalPayments\Api\PaymentMethods\CreditTrackData;

$card = new CreditTrackData();
$card->value = "<E1050711%B401200******0016^VI TEST CREDIT ...";
$card->entryMethod = EntryMethod::SWIPE;
$card->encryptionData = new EncryptionData();
$card->encryptionData->version = "01";
import com.global.api.entities.EncryptionData;
import com.global.api.entities.enums.EntryMethod;
import com.global.api.paymentMethods.CreditTrackData;

EncryptionData encryptionData = new EncryptionData();
encryptionData.setVersion("01");

CreditTrackData card = new CreditTrackData();
card.setValue("<E1050711%B401200******0016^VI TEST CREDIT ...");
card.setEntryMethod(EntryMethod.Swipe);
card.setEncryptionData(encryptionData);
# coming soon
from globalpayments.api.entities import EncryptionData
from globalpayments.api.entities.enums import EntryMethod
from globalpayments.api.payment_methods import CreditTrackData

card = CreditTrackData()
card.value = '<E1050711%B401200******0016^VI TEST CREDIT ...'
card.entry_method = EntryMethod.Swipe
card.encryption_data = EncryptionData()
card.encryption_data.version = '01'
import {
  CreditTrackData,
  EncryptionData,
  EntryMethod
} from "globalpayments-api";

const card = new CreditTrackData();
card.value = "<E1050711%B401200******0016^VI TEST CREDIT ...";
card.entryMethod = EntryMethod.Swipe;
card.encryptionData = new EncryptionData();
card.encryptionData.version = "01";

Charge a Credit Card

The credit sale transaction authorizes a sale purchased with a credit card. The authorization is placed in the current open batch (should auto-close for e-commerce transactions). If a batch is not open, this transaction will create an open batch.

Charge a credit card

var response = card.Charge(10.00m)
    .WithCurrency("USD")
    .WithAddress(address)
    .Execute();
<?php
$response = $card->charge(10)
    ->withCurrency("USD")
    ->withAddress($address)
    ->execute();
import com.global.api.entities.Transaction;
import java.math.BigDecimal;

Transaction response = card.charge(new BigDecimal("10"))
    .withCurrency("USD")
    .withAddress(address)
    .execute();
# coming soon
response = card.charge(10) \
    .with_currency('USD') \
    .with_address(address) \
    .execute()
const response = await card.charge(10)
  .withCurrency("USD")
  .withAddress(address)
  .execute();

Verify a Credit Card

A credit account verify transaction is used to verify that the account is in good standing with the issuer. This is a zero dollar transaction with no associated authorization. Since VISA and other issuers have started assessing penalties for one dollar authorizations when verifying credit cards, this provides a way for merchants to accomplish the same task while avoiding these penalties.

Verify Card Token

var response = card.Verify()
    .WithCurrency("USD")
    .WithAddress(address)
    .Execute();
<?php
$response = $card->verify()
    ->withCurrency("USD")
    ->withAddress($address)
    ->execute();
import com.global.api.entities.Transaction;

Transaction response = card.verify()
    .withCurrency("USD")
    .withAddress(address)
    .execute();
# coming soon
response = card.verify() \
    .with_currency('USD') \
    .with_address(address) \
    .execute()
const response = await card.verify()
  .withCurrency("USD")
  .withAddress(address)
  .execute();

Authorize a Credit Card

A credit authorization transaction authorizes a credit card transaction. The authorization is not placed in the batch. The credit authorization transaction can be added to a batch by using the capture method.

Authorize Card

var response = card.Authorize(10.00m)
    .WithCurrency("USD")
    .WithAddress(address)
    .Execute();
<?php
$response = $card->authorize(10)
    ->withCurrency("USD")
    ->withAddress($address)
    ->execute();
import com.global.api.entities.Transaction;
import java.math.BigDecimal;

Transaction response = card.authorize(new BigDecimal("10"))
    .withCurrency("USD")
    .withAddress(address)
    .execute();
# coming soon
response = card.authorize(10) \
    .with_currency('USD') \
    .with_address(address) \
    .execute()
const response = await card.authorize(10)
  .withCurrency("USD")
  .withAddress(address)
  .execute();

Using Multi-Use Tokens

Multi-Use Tokenization allows a secure and PCI friendly way to store credit card information within your system. A multi-use token can be generated as part of any of our initial gateway calls: charge, verify, or authorize.

Requesting a multi-use token

var response = card.Verify()
    .WithAddress(address)
    .WithRequestMultiUseToken(true)
    .Execute();
<?php
$response = $card->verify()
    ->withAddress($address)
    ->withRequestMultiUseToken(true)
    ->execute();
import com.global.api.entities.Transaction;

Transaction response = card.verify()
    .withAddress(address)
    .withRequestMultiUseToken(true)
    .execute();
# coming soon
response = card.verify() \
    .with_address(address) \
    .with_request_multi_use_token(True) \
    .execute()
const response = await card.verify()
  .withAddress(address)
  .withRequestMultiUseToken(true)
  .execute();

Charging a multi-use token

var response = card.Charge(10.00m)
    .WithCurrency("USD")
    .WithAddress(address)
    .Execute();
<?php
$response = $card->charge(10)
    ->withCurrency("USD")
    ->withAddress($address)
    ->execute();
import com.global.api.entities.Transaction;
import java.math.BigDecimal;

Transaction response = card.charge(new BigDecimal("10"))
    .withCurrency("USD")
    .withAddress(address)
    .execute();
# coming soon
repsonse = card.charge(10) \
    .with_currency('USD') \
    .with_address(address) \
    .execute()
const response = await card.charge(10)
  .withCurrency("USD")
  .withAddress(address)
  .execute();

Authorizing a multi-use token

var response = card.Authorize(10.00m)
    .WithCurrency("USD")
    .WithAddress(address)
    .Execute();
<?php
$response = $card->authorize(10)
    ->withCurrency("USD")
    ->withAddress($address)
    ->execute();
import com.global.api.entities.Transaction;
import java.math.BigDecimal;

Transaction response = card.authorize(new BigDecimal("10"))
    .withCurrency("USD")
    .withAddress(address)
    .execute();
# coming soon
repsonse = card.authorize(10) \
    .with_currency('USD') \
    .with_address(address) \
    .execute()
const response = await card.authorize(10)
  .withCurrency("USD")
  .withAddress(address)
  .execute();

Capture an Authorization

A capture transaction adds a previous authorization transaction to the current open batch. If a batch is not open, this transaction will create one.

Capture Authorization

using GlobalPayments.Api.Entities;

var response = card.Authorize(10.00m)
    .WithCurrency("USD")
    .WithAddress(address)
    .Execute();

Transaction.FromId(response.TransactionId)
    .Capture(10.00m)
    .Execute();
<?php
use GlobalPayments\Api\Entities\Transaction;

$response = $card->authorize(10)
    ->withCurrency("USD")
    ->withAddress($address)
    ->execute();

Transaction::fromId($response->transactionId)
    ->capture(10)
    ->execute();
import com.global.api.entities.Transaction;
import java.math.BigDecimal;

Transaction response = card.authorize(new BigDecimal("10"))
    .withCurrency("USD")
    .withAddress(address)
    .execute();

Transaction.fromId(response.getTransactionId())
    .capture(new BigDecimal("10"))
    .execute();
# coming soon
from globalpayments.api.entities import Transaction

response = card.authorize(10) \
    .with_currency('USD') \
    .with_address(address) \
    .execute()

Transaction.from_id(response.transaction_id) \
    .capture(10) \
    .execute()
import { Transaction } from "globalpayments-api";

const response = await card.authorize(10)
  .withCurrency("USD")
  .withAddress(address)
  .execute();

await Transaction.fromId(response.transactionId)
  .capture(10)
  .execute();

Refund a Transaction

The credit return transaction returns funds to the cardholder’s account. The transaction is generally used as a counterpart to a credit card transaction that needs to be reversed when the batch containing the original transaction has already been closed. The credit return transaction is placed in the current open batch. If a batch is not open, this transaction will create an open batch.

Refund Transaction

using GlobalPayments.Api.Entities;

var response = card.Charge(10.00m)
    .WithCurrency("USD")
    .WithAddress(address)
    .Execute();

Transaction.FromId(response.TransactionId)
    .Refund(10.00m)
    .Execute();
<?php
use GlobalPayments\Api\Entities\Transaction;

$response = $card->charge(10)
    ->withCurrency("USD")
    ->withAddress($address)
    ->execute();

Transaction::fromId($response->transactionId)
    ->refund(10)
    ->execute();
import com.global.api.entities.Transaction;
import java.math.BigDecimal;

Transaction response = card.charge(new BigDecimal("10"))
    .withCurrency("USD")
    .withAddress(address)
    .execute();

Transaction.fromId(response.getTransactionId())
    .refund(new BigDecimal("10"))
    .execute();
# coming soon
from globalpayments.api.entities import Transaction

response = card.authorize(10) \
    .with_currency('USD') \
    .with_address(address) \
    .execute()

Transaction.from_id(response.transaction_id) \
    .refund(10) \
    .execute()
import { Transaction } from "globalpayments-api";

const response = await card.charge(10)
  .withCurrency("USD")
  .withAddress(address)
  .execute();

await Transaction.fromId(response.transactionId)
  .refund(10)
  .execute();

Reverse a Transaction

A reverse transaction reverses a charge or authorize transaction from the active open authorizations or current open batch.

Reverse Transaction

using GlobalPayments.Api.Entities;

var response = card.Authorize(10.00m)
    .WithCurrency("USD")
    .WithAddress(address)
    .Execute();

Transaction.FromId(response.TransactionId)
    .Reverse(10.00m)
    .Execute();
<?php
use GlobalPayments\Api\Entities\Transaction;

$response = $card->authorize(10)
    ->withCurrency("USD")
    ->withAddress($address)
    ->execute();

Transaction::fromId($response->transactionId)
    ->reverse(10)
    ->execute();
import com.global.api.entities.Transaction;
import java.math.BigDecimal;

Transaction response = card.authorize(new BigDecimal("10"))
    .withCurrency("USD")
    .withAddress(address)
    .execute();

Transaction.fromId(response.getTransactionId())
    .reverse(new BigDecimal("10"))
    .execute();
# coming soon
from globalpayments.api.entities import Transaction

response = card.authorize(10) \
    .with_currency('USD') \
    .with_address(address) \
    .execute()

Transaction.from_id(response.transaction_id) \
    .reverse(10) \
    .execute()
import { Transaction } from "globalpayments-api";

const response = await card.authorize(10)
  .withCurrency("USD")
  .withAddress(address)
  .execute();

await Transaction.fromId(response.transactionId)
  .reverse(10)
  .execute();

Void a Transaction

A credit void transaction is used to inactivate a transaction. The transaction must be an authorize, charge or return. The transaction must be active in order to be voided. Authorize transactions do not have to be associated with a batch to be voided. Transactions may be voided after they are associated with a batch as long as the batch is not closed.

Void Transaction

using GlobalPayments.Api.Entities;

var response = card.Authorize(10.00m)
    .WithCurrency("USD")
    .WithAddress(address)
    .Execute();

Transaction.FromId(response.TransactionId)
    .Void()
    .Execute();
<?php
use GlobalPayments\Api\Entities\Transaction;

$response = $card->authorize(10)
    ->withCurrency("USD")
    ->withAddress($address)
    ->execute();

Transaction::fromId($response->transactionId)
    ->void()
    ->execute();
import com.global.api.entities.Transaction;
import java.math.BigDecimal;

Transaction response = card.authorize(new BigDecimal("10"))
    .withCurrency("USD")
    .withAddress(address)
    .execute();

Transaction.fromId(response.getTransactionId())
    .void()
    .execute();
# coming soon
from globalpayments.api.entities import Transaction

response = card.authorize(10) \
    .with_currency('USD') \
    .with_address(address) \
    .execute()

Transaction.from_id(response.transaction_id) \
    .void() \
    .execute()
import { Transaction } from "globalpayments-api";

const response = await card.authorize(10)
  .withCurrency("USD")
  .withAddress(address)
  .execute();

await Transaction.fromId(response.transactionId)
  .void()
  .execute();

Edit a Transaction

An edit transaction changes the data on a previously approved charge or authorize transaction.

Edit Transaction

using GlobalPayments.Api.Entities;

var response = card.Authorize(10.00m)
    .WithCurrency("USD")
    .WithAddress(address)
    .Execute();

Transaction.FromId(response.TransactionId)
    .Edit()
    .WithAmount(15.00m)
    .WithGratuity(5.00m)
    .Execute();
<?php
use GlobalPayments\Api\Entities\Transaction;

$response = $card->authorize(10)
    ->withCurrency("USD")
    ->withAddress($address)
    ->execute();

Transaction::fromId($response->transactionId)
    ->edit()
    ->withAmount(15.00)
    ->withGratuity(5.00)
    ->execute();
import com.global.api.entities.Transaction;
import java.math.BigDecimal;

Transaction response = card.authorize(new BigDecimal("10"))
    .withCurrency("USD")
    .withAddress(address)
    .execute();

Transaction.fromId(response.getTransactionId())
    .edit()
    .withAmount(new BigDecimal("15.00"))
    .withGratuity(new BigDecimal("5.00"))
    .execute();
# coming soon
from globalpayments.api.entities import Transaction

response = card.authorize(10) \
    .with_currency('USD') \
    .with_address(address) \
    .execute()

Transaction.from_id(response.transaction_id) \
    .edit() \
    .with_amount(15) \
    .with_gratuity(5) \
    .execute()
import { Transaction } from "globalpayments-api";

const response = await card.authorize(10)
  .withCurrency("USD")
  .withAddress(address)
  .execute();

await Transaction.fromId(response.transactionId)
  .edit()
  .withAmount(15.00)
  .withGratuity(5.00)
  .execute();