Payment API BETA - Control your checkout experience from pixel to payout

With the new Payment API BETA, 2Checkout empowers you to include our payment processing power directly into your website.

Accepting BETA ApplicationsPayment API Documentation

Do you sell more than $50,000 a month online?

Client

Client-side

(tokenization)

Our client-side javascript safely tokenizes your customer’s credit card information so no sensitive data touches your server. This lets you focus on designing a unique checkout experience, while 2Checkout handles all of your transactions, greatly reducing your PCI burden.

HTML Form Code
<form id="tcoCCForm" action="https://www.mysite.com/examplescript.php" onsubmit="return false" method="post">
  <input id="sellerId" type="hidden" value="1817037" />
  <input id="publishableKey" type="hidden" value="087F9356-39A3-4CEC-AAEE-0694E4B619EE" />
  <input id="token" name="token" type="hidden" value="" />
  <div>
    <label>
      <span>Card Number</span>
      <input id="ccNo" type="text" value="" autocomplete="off" required />
    </label>
  </div>
  <div>
    <label>
      <span>Expiration Date (MM/YYYY)</span>
      <input type="text" size="2" id="expMonth" required />
    </label>
    <span> / </span>
    <input type="text" size="4" id="expYear" required />
  </div>
  <div>
    <label>
      <span>CVC</span>
      <input id="cvv" type="text" value="" autocomplete="off" required />
    </label>
  </div>
  <input type="submit" value="Submit Payment" onclick="retrieveToken()" />
</form>
JavaScript Code
<script>
function successCallback(data) {
var myForm = document.getElementById('tcoCCForm');
myForm.token.value = data.response.token.token;
myForm.submit();
}

function errorCallback(data) {
alert(data.errorMsg);
}

function retrieveToken() {
TCO.requestToken(successCallback, errorCallback, 'tcoCCForm');
}
</script>
Server

Server-side

(payment processing)

Charge your customers using the token created by our client-side Javascript library, creating a seamless checkout process in minutes.

Server Code Snippet
curl -X POST https://www.2checkout.com/checkout/api/1/1817037/rs/authService \
-d '{"sellerId": "1817037", "privateKey": "BiAWsn228tDCKUMldUw8", "merchantOrderId": "123", "token": "ODAxZjUzMDEtOWU0MC00NzA3LWFmMDctYmY1NTQ3MDhmZDFh", "currency": "USD", "lineItems": [{"name": "Demo Item", "price": "4.99", "type": "product", "quantity": "1", "recurrence": "4 Year", "startupFee": "9.99"} ], "billingAddr": {"name": "testing tester", "addrLine1": "123 test blvd", "city": "columbus", "state": "Ohio", "zipCode": "43123", "country": "USA", "email": "example@2co.com", "phoneNumber": "123456789"} }' \
-H 'Accept: application/json' -H 'Content-Type: application/json'
Twocheckout.privatekey = "BiAWsn228tDCKUMldUw8";

try {
HashMap<String, String> billing = new HashMap<String, String>();
billing.put("name", "Testing Tester");
billing.put("addrLine1", "123 test blvd");
billing.put("city", "Columbus");
billing.put("state", "Ohio");
billing.put("country", "USA");
billing.put("zipCode", "43230");
billing.put("email", "example@2co.com");
billing.put("phone", "555-555-5555");

HashMap<String, Object> request = new HashMap<String, Object>();
request.put("sellerId", "1817037");
request.put("merchantOrderId", "test123");
request.put("token", "MGI4OTU0OTQtMDIxNi00YThlLTliOTctZjg1YmJiMzg0MjA3");
request.put("currency", "USD");
request.put("total", "1.00");
request.put("billing", billing);

Authorization response = TwocheckoutCharge.authorize(request);
String message = response.getResponseMessage();
} catch (Exception e) {
String message = e.toString();
}
TwoCheckoutConfig.SellerID = "1817037"; TwoCheckoutConfig.PrivateKey = "8CE03B2D-FE41-4C53-9156-52A8ED5A0FA3"; //TwoCheckoutConfig.Sandbox = true; <-- Set Mode to use your 2Checkout sandbox account try { var Billing = new AuthBillingAddress(); Billing.addrLine1 = "123 test st"; Billing.city = "Columbus"; Billing.zipCode = "43123"; Billing.state = "OH"; Billing.country = "USA"; Billing.name = "Testing Tester"; Billing.email = "example@2co.com"; Billing.phone = "5555555555"; var Customer = new ChargeAuthorizeServiceOptions(); Customer.total = (decimal)1.00; Customer.currency = "USD"; Customer.merchantOrderId = "123"; Customer.billingAddr = Billing; Customer.token = "MzIwNzI3ZWQtMjdiNy00NTVhLWFhZTEtZGUyZGQ3MTk1ZDMw"; var Charge = new ChargeService(); var result = Charge.Authorize(Customer); Console.Write(result); } catch (TwoCheckoutException e) { Console.Write(e); }Twocheckout::setApiCredentials("1817037", "BiAWsn228tDCKUMldUw8");
try {
$charge = Twocheckout_Charge::auth(array(
"sellerId" => "1817037",
"merchantOrderId" => "123",
"token" => $_POST['token'],
"currency" => 'USD',
"total" => '10.00',
"billingAddr" => array(
"name" => 'Testing Tester',
"addrLine1" => '123 Test St',
"city" => 'Columbus',
"state" => 'OH',
"zipCode" => '43123',
"country" => 'USA',
"email" => 'example@2co.com',
"phoneNumber" => '555-555-5555'
)
));

if ($charge['response']['responseCode'] == 'APPROVED') {
echo "Thanks for your Order!";
}
} catch (Twocheckout_Error $e) {
$e->getMessage();
}
twocheckout.Api.auth_credentials({
'private_key': 'BiAWsn228tDCKUMldUw8',
'seller_id': '1817037',
'mode': 'production'
})

params = {
'merchantOrderId': '123',
'token': 'ODAxZjUzMDEtOWU0MC00NzA3LWFmMDctYmY1NTQ3MDhmZDFh',
'currency': 'USD',
'total': '1.00',
'billingAddr': {
'name': 'Testing Tester',
'addrLine1': '123 Test St',
'city': 'Columbus',
'state': 'OH',
'zipCode': '43123',
'country': 'USA',
'email': 'example@2co.com',
'phoneNumber': '555-555-5555'
}
}

try:
result = twocheckout.Charge.authorize(params)
print result.responseCode
except TwocheckoutError as error:
print error.msg
Twocheckout::API.credentials = {
:seller_id => '1817037',
:private_key => 'BiAWsn228tDCKUMldUw8'
}

params = {
:merchantOrderId => '123',
:token => 'ZmYyMzMyZGMtZTY2NS00NDAxLTlhYTQtMTgwZWIyZTgwMzQx',
:currency => 'USD',
:total => '1.00',
:billingAddr => {
:name => 'Testing Tester',
:addrLine1 => '123 Test St',
:city => 'Columbus',
:state => 'OH',
:zipCode => '43123',
:country => 'USA',
:email => 'example@2co.com',
:phoneNumber => '555-555-5555'
}
}

begin
result = Twocheckout::Checkout.authorize(params)
rescue Exception => e
puts e.message
end
var tco = new Twocheckout({ sellerId: "1817037", privateKey: "3508079E-5383-44D4-BF69-DC619C0D9811", sandbox: false }); authorize = { "merchantOrderId": "123", "token": "MWQyYTI0ZmUtNjhiOS00NTIxLTgwY2MtODc3MWRlNmZjY2Jh", "currency": "USD", "total": "10.00", "billingAddr": { "name": "Testing Tester", "addrLine1": "123 Test St", "city": "Columbus", "state": "Ohio", "zipCode": "43123", "country": "USA", "email": "example@2co.com", "phoneNumber": "5555555555" } }; tco.checkout.authorize(authorize, function (error, data) { if (error) { console.log(error); } else { console.log(data.response.responseCode); } });
Sandbox Shovel Icon
Ready to test integration? Try our sandbox

Explore our documentation to find out everything you need to know about the Payment API, or test the Payment API in our Sandbox. Try out all of the API Keys and the Instant Notification System to discover everything your checkout can accomplish.

Integrate in Minutes

Integration

Simple, intuitive implementation

Library

Payment API libraries available in PHP, PYTHON, RUBY, .NET, JAVA, cURL

Cart

Modules for the most popular open-source carts

Notifications

Enhance your integration further with our Instant Notification Service and Admin API

Premier Security Trusted by 50,000 Merchants

Secure

Client-to-server API integration encrypts sensitive credit card data, reducing your PCI liability. And a free TrustWave PCI Portal assures your site is safe with a custom seal to advertise your status and boost customer confidence

2Checkout holds PCI Level 1 Certification, a guarantee to you and your customers that your information is safe and secure. In addition we have first rate fraud prevention tracks every transaction and sale, constantly monitoring for unnatural activity.

Global Access with Ease

Credit Card

Accept credit cards directly on your site for a seamless experience

Currencies

Process payments in 26 currencies from customers around the world

Recurring Billing

Flexible recurring billing: receive customer payments on a weekly, monthly, or yearly schedule

Star

Plus, gain access to all of the other robust features from 2Checkout

Interested in joining our API BETA?

Gain access before it’s released to the public. Fill out the information below and one of our team members will respond shortly.