Simplify Link with OAuth 2.0
How to access Simplify Link using OAuth 2.0
With Simplify Link, Simplify Commerce APIs support OAuth 2.0 through endpoints for your application. We have also added it into the SDKs for easy setup and use. With user approval, your application may access Simplify Commerce APIs when the user is present or not
The documentation below describes how to use Simplify Link when accessing Simplify Commerce APIs from your application.
Simplify Link uses OAuth 2.0 so you can interact with Simplify Commerce without having to store sensitive credentials. Our simple authentication flow makes it easy for your customers to connect their Simplify Commerce accounts while giving you the ability to request several levels of permissions. Users can manage and revoke access to their third-party authorizations using the Simplify Commerce dashboard.
With Simplify Link, OAuth developers can request:
- Read and Write access to the full Simplify Commerce API
- Read and Write access to the Payments and Refunds API
- Read Only permission to the full Simplify Commerce API
Overview
First you will need to go to the apps management section of Simplify Commerce to upload a logo, key pair name, and redirect uri. You will get a public key that will be used for the client_id in the authorization request
The next part of the flow begins with redirecting a browser (popup or full page if needed) to a Simplify Commerce endpoint with the client_id and a response_type of code. Simplify Commerce then responds with an authorization code to the application per the redirect_uri query parameter registered with the account
After the application receives the authorization code, the application can redeem the code for an access token. The application will send the authorization code, the grant type of code, and the redirect uri. You will receive an access token and a refresh token. We recommend using one of our SDKs for ease of use
With the access token you now may access protected Simplify Commerces APIs.
You can also use the SDKs to refresh the access token if the token has expired or revoke a token.
Register Your Application
Applications that wish to utilize Simplify Link to access Simplify Commerces APIs must be registered through the apps setting screen
On this screen, you will upload the company logo (guideline dimensions: 128px x 128px) you wish to appear during authorization, the name of the application, the key type (sandbox or live), and a redirect url
A new private key, public key, and confirmation of the redirect url will then be displayed. Copy down the keys, you will need this for the next step
Creating the URL for Obtaining Authorization Token
Next you will want to request an authorization grant. As the client you will do this by issuing a GET request from the user's user-agent browser to https://www.simplify.com/commerce/oauth/authorize with the following query parameters:
code
is required.
required
full
, payments
, or readall
.- - Payments
- - Refunds
- - Customers
- - Plans
- - Coupons
- - Subscriptions
- - Payments
- - Refunds
- - Payments
- - Refunds
- - Customers
- - Plans
- - Coupons
- - Subscriptions
Users who have not previously registered with Simplify Commerce or users that are still in sandbox (or test) mode will be required to on-board & create a new merchant account in order to complete the oauth authorization.
In order to do so, we require personal, business and other details from the user. In order to facilitate an easier & speedier process for the user, you can optionally pass these details (urlencoded) to us and we'll pre-fill the form for them.
CCorporation
, SCorporation
, SoleProprietor
, NotForProfit
, LLC_LLP
, Government
Simplify Commerce then authenticates the user confirming their access to the Sandbox/Live account and requested permissions.
Assuming that proper authorization is given, Simplify Commerce will redirect to the redirect url (registered with the application) with the code and state.
Below is an example URL.
https://www.simplify.com/commerce/oauth/authorize?response_type=code&scope=full&client_id=lvpb_ThisIsYourOAuthPublicKey&state=some_value
Authorization Response
If the user approves the access request, then the response will contain the authorization and the state parameter (if you sent it in the request). If the user does not grant access the request will contain an error message. The message will be sent on the response query string. Example responses are below:
Error response
https://www.yourapp.com/code?error=access_denied&error_description=User has denied the oauth authorization request&state=some_value
Authorization response
https://www.yourapp.com/code?code=LWJeou0349SLKEJr&state=some_value
Obtaining an Access Token
The client is now able to use the provided code to redeem an access token.
In the SDKs the following parameters are needed:
Below are the SDK examples:
import com.simplify.payments.AccessToken;
import com.simplify.payments.Authentication;
import com.simplify.payments.PaymentsApi;
try{
PaymentsApi.PUBLIC_KEY="YOUR OAUTH PUBLIC_KEY";
PaymentsApi.PRIVATE_KEY="YOUR OAUTH PRIVATE_KEY";
String REDIRECT_URI="YOUR OAUTH REDIRECT URI";
AccessToken accessToken=AccessToken.create(code,REDIRECT_URI);
}
catch(Exception ex){
ex.printStackTrace();
}
require 'simplify'
Simplify::public_key = "YOUR OAUTH PUBLIC_KEY"
Simplify::private_key = "YOUR OAUTH PRIVATE_KEY"
CODE = 'OAUTH AUTHORIZATION CODE'
REDIRECT_URI = 'YOUR OAUTH REDIRECT URI';
token = Simplify::AccessToken.create(CODE, REDIRECT_URI)
import simplify
simplify.public_key = "YOUR OAUTH PUBLIC_KEY"
simplify.private_key = "YOUR OAUTH PRIVATE_KEY"
CODE = 'OAUTH AUTHORIZATION CODE'
REDIRECT_URI = 'YOUR OAUTH REDIRECT URI'
token = simplify.AccessToken.create(CODE, REDIRECT_URI)
<?php
require_once("./lib/Simplify.php");
Simplify::$publicKey = 'YOUR OAUTH PUBLIC_KEY';
Simplify::$privateKey = 'YOUR OAUTH PRIVATE_KEY';
$code = 'OAUTH AUTHORIZATION CODE';
$redirect_uri = 'YOUR OAUTH REDIRECT URI';
$accessToken = Simplify_AccessToken::create($code, $redirect_uri);
?>
use Net::Simplify;
$Net::Simplify::public_key = "YOUR OAUTH PUBLIC_KEY";
$Net::Simplify::private_key = "YOUR OAUTH PRIVATE_KEY";
$CODE = 'OAUTH AUTHORIZATION CODE';
$REDIRECT_URI = 'YOUR OAUTH REDIRECT URI';
$token = Net::Simplify::AccessToken->create($CODE, $REDIRECT_URI);
using SimplifyCommerce.Payments;
try
{
PaymentsApi api = new PaymentsApi();
PaymentsApi.PublicApiKey = "YOUR OAUTH PUBLIC_KEY";
PaymentsApi.PrivateApiKey = "YOUR OAUTH PRIVATE_KEY";
string code = "iBxx7c";
OauthAccessTokenRequest req = new OauthAccessTokenRequest();
req.RedirectUri = "YOUR OAUTH REDIRECT URI";
req.Code = code;
OauthAccessToken token = api.RequestAccessToken(req);
}
catch (ApiException e)
{
Console.WriteLine("Message: " + e.Message);
}
var Simplify = require("simplify-commerce"),
client = Simplify.getClient({
publicKey: 'YOUR_OAUTH_PUBLIC_KEY',
privateKey: 'YOUR_OAUTH_PRIVATE_KEY'
});
client.accesstoken.create({
authCode: 'OAUTH_AUTHORIZATION_CODE',
redirectUri: 'YOUR_OAUTH_REDIRECT_URI'
}, function(errData, data){
if(errData){
console.error("Error Message: " + errData.data.error_description);
// handle the error
return;
}
console.log("Access Token: " + data.access_token);
console.log("Refresh Token: " + data.refresh_token);
});
A success response will contain the access_token, when the access token expires, and the refresh token.
A success response is returned as a JSON array in accordance with the OAuth 2.0 specification. Below is an example.
{
"access_token":"WOIHJFFW(f80ijvw3wij",
"expires_in":43200,
"refresh_token":"WlskjweIWnffw154",
"refresh_expires_id":86400
}
Using the Simplify Commerce API
After you have obtained an access token, your application can now access a Simplify Commerce API.
Below are the SDK examples:
import com.simplify.payments.AccessToken;
import com.simplify.payments.Authentication;
import com.simplify.payments.PaymentsApi;
try {
PaymentsApi.PUBLIC_KEY = "YOUR OAUTH PUBLIC_KEY";
PaymentsApi.PRIVATE_KEY = "YOUR OAUTH PRIVATE_KEY";
String REDIRECT_URI = "YOUR OAUTH REDIRECT URI";
AccessToken accessToken = AccessToken.create(code, REDIRECT_URI);
ResourceList payments = Payment.list(new Authentication(accessToken.get("access_token")));
}
catch (Exception ex) {
log.error(ex)
}
require 'simplify'
Simplify::public_key = "YOUR OAUTH PUBLIC_KEY"
Simplify::private_key = "YOUR OAUTH PRIVATE_KEY"
CODE = 'OAUTH AUTHORIZATION CODE'
REDIRECT_URI = 'YOUR OAUTH REDIRECT URI';
token = Simplify::AccessToken.create(CODE, REDIRECT_URI);
auth = Simplify::Authentication.new(:access_token => token['access_token'])
payments = Simplify::Payment.list(nil, auth)
puts "Total: #{payments['total']}"
payments['list'].each do |o|
puts o.inspect
end
import simplify
simplify.public_key = "YOUR OAUTH PUBLIC_KEY"
simplify.private_key = "YOUR OAUTH PRIVATE_KEY"
CODE = 'OAUTH AUTHORIZATION CODE'
REDIRECT_URI = 'YOUR OAUTH REDIRECT URI'
token = simplify.AccessToken.create(CODE, REDIRECT_URI)
auth = simplify.Authentication(access_token = token.access_token)
payments = simplify.Payment.list(None, auth)
<?php
require_once("./lib/Simplify.php");
Simplify::$publicKey = 'YOUR OAUTH PUBLIC_KEY';
Simplify::$privateKey = 'YOUR OAUTH PRIVATE_KEY';
$code = 'OAUTH AUTHORIZATION CODE';
$redirect_uri = 'YOUR OAUTH REDIRECT URI';
$accessToken = Simplify_AccessToken::create($code, $redirect_uri);
$ret = Simplify_Payment::listPayment(array("max" => 30), new Simplify_Authentication($accessToken->access_token));
?>
use Net::Simplify;
$Net::Simplify::public_key = "YOUR OAUTH PUBLIC_KEY";
$Net::Simplify::private_key = "YOUR OAUTH PRIVATE_KEY";
$CODE = 'OAUTH AUTHORIZATION CODE';
$REDIRECT_URI = 'YOUR OAUTH REDIRECT URI';
$token = Net::Simplify::AccessToken->create($CODE, $REDIRECT_URI);
$auth = Net::Simplify::Authentication->create(access_token => $token->access_token);
$payments = Net::Simplify::Payment->list({}, $auth);
print "Total: ", $payments->total, "\n";
foreach $payment ($payments->list) {
print "payment ", $payment->{id}, "\n";
}
using SimplifyCommerce.Payments;
try
{
PaymentsApi api = new PaymentsApi();
PaymentsApi.PublicApiKey = "YOUR OAUTH PUBLIC_KEY";
PaymentsApi.PrivateApiKey = "YOUR OAUTH PRIVATE_KEY";
string code = "iBxx7c";
OauthAccessTokenRequest req = new OauthAccessTokenRequest();
req.RedirectUri = "YOUR OAUTH REDIRECT URI";
req.Code = code;
OauthAccessToken token = api.RequestAccessToken(req);
ResourceList<Payment> list = (ResourceList<Payment>)api.List(typeof(Payment), null, null, 20, 0, token);
}
catch (ApiException e)
{
Console.WriteLine("Message: " + e.Message);
}
var Simplify = require("simplify-commerce"),
client = Simplify.getClient({
publicKey: 'YOUR_OAUTH_PUBLIC_KEY',
privateKey: 'YOUR_OAUTH_PRIVATE_KEY'
});
client.accesstoken.create({
authCode: 'OAUTH_AUTHORIZATION_CODE',
redirectUri: 'YOUR_OAUTH_REDIRECT_URI'
}, function(errData, data){
if(errData){
console.error("Error Message: " + errData.data.error_description);
// handle the error
return;
}
console.log("Access Token: " + data.access_token);
// Get a list of payments with the access token
client.payment.list({
accessToken: data.access_token,
max: 30,
offset: 3
}, function(paymentErrData, paymentData){
if(paymentErrData){
console.error("Error Message: " + paymentErrData.data.error.message);
// handle the error
return;
}
console.log("Total: " + paymentData.total);
});
});
Using the Refresh Token
As stated earlier, a refresh token is returned along with the access token and when the access token expires. You will need to refresh the access token after the expiration time. You may obtain a new access token by sending the refresh token to Simplify Commerce
Below are the SDK examples:
import com.simplify.payments.AccessToken;
import com.simplify.payments.Authentication;
import com.simplify.payments.PaymentsApi;
try {
PaymentsApi.PUBLIC_KEY = "YOUR OAUTH PUBLIC_KEY";
PaymentsApi.PRIVATE_KEY = "YOUR OAUTH PRIVATE_KEY";
String REDIRECT_URI = "YOUR OAUTH REDIRECT URI";
AccessToken accessToken = AccessToken.create(code, REDIRECT_URI);
accessToken = AccessToken.refreshToken();
}
catch (Exception ex) {
log.error(ex)
}
require 'simplify'
Simplify::public_key = "YOUR OAUTH PUBLIC_KEY"
Simplify::private_key = "YOUR OAUTH PRIVATE_KEY"
CODE = 'OAUTH AUTHORIZATION CODE'
REDIRECT_URI = 'YOUR OAUTH REDIRECT URI';
token = Simplify::AccessToken.create(CODE, REDIRECT_URI);
token.refresh()
import simplify
simplify.public_key = "YOUR OAUTH PUBLIC_KEY"
simplify.private_key = "YOUR OAUTH PRIVATE_KEY"
CODE = 'OAUTH AUTHORIZATION CODE'
REDIRECT_URI = 'YOUR OAUTH REDIRECT URI'
token = simplify.AccessToken.create(CODE, REDIRECT_URI)
token.refresh()
<?php
require_once("./lib/Simplify.php");
Simplify::$publicKey = 'YOUR OAUTH PUBLIC_KEY';
Simplify::$privateKey = 'YOUR OAUTH PRIVATE_KEY';
$code = 'OAUTH AUTHORIZATION CODE';
$redirect_uri = 'YOUR OAUTH REDIRECT URI';
$accessToken = Simplify_AccessToken::create($code, $redirect_uri);
$accessToken.refresh();
?>
use Net::Simplify;
$Net::Simplify::public_key = "YOUR OAUTH PUBLIC_KEY";
$Net::Simplify::private_key = "YOUR OAUTH PRIVATE_KEY";
$CODE = 'OAUTH AUTHORIZATION CODE';
$REDIRECT_URI = 'YOUR OAUTH REDIRECT URI';
$token = Net::Simplify::AccessToken->create($CODE, $REDIRECT_URI);
$token->refresh();
using SimplifyCommerce.Payments;
try
{
PaymentsApi api = new PaymentsApi();
PaymentsApi.PublicApiKey = "YOUR OAUTH PUBLIC_KEY";
PaymentsApi.PrivateApiKey = "YOUR OAUTH PRIVATE_KEY";
string code = "iBxx7c";
OauthAccessTokenRequest req = new OauthAccessTokenRequest();
req.RedirectUri = "YOUR OAUTH REDIRECT URI";
req.Code = code;
OauthAccessToken token = api.RequestAccessToken(req);
token = api.RefreshAccessToken(token);
}
catch (ApiException e)
{
Console.WriteLine("Message: " + e.Message);
}
var Simplify = require("simplify-commerce"),
client = Simplify.getClient({
publicKey: 'YOUR_OAUTH_PUBLIC_KEY',
privateKey: 'YOUR_OAUTH_PRIVATE_KEY'
});
client.accesstoken.refresh('OAUTH_REFRESH_TOKEN', function(errData, data){
if(errData){
console.error("Error Message: " + errData.data.error_description);
// handle the error
return;
}
console.log("Access Token: " + data.access_token);
console.log("Refresh Token: " + data.refresh_token);
});
Revoking a Token
When a user wants to revoke access to their application, they can do so through the apps setting in the Simplify Commerce app. In Simplify Commerce, the access token will be revoked with the corresponding refresh token
You can also revoke the token programmatically using one of Simplify Commerces SDKs.
Below are the SDK examples:
import com.simplify.payments.AccessToken;
import com.simplify.payments.Authentication;
import com.simplify.payments.PaymentsApi;
try {
PaymentsApi.PUBLIC_KEY = "YOUR OAUTH PUBLIC_KEY";
PaymentsApi.PRIVATE_KEY = "YOUR OAUTH PRIVATE_KEY";
String REDIRECT_URI = "YOUR OAUTH REDIRECT URI";
AccessToken accessToken = AccessToken.create(code, REDIRECT_URI);
accessToken = AccessToken.revokeToken();
}
catch (Exception ex) {
log.error(ex)
}
require 'simplify'
Simplify::public_key = "YOUR OAUTH PUBLIC_KEY"
Simplify::private_key = "YOUR OAUTH PRIVATE_KEY"
CODE = 'OAUTH AUTHORIZATION CODE'
REDIRECT_URI = 'YOUR OAUTH REDIRECT URI';
token = Simplify::AccessToken.create(CODE, REDIRECT_URI);
token.revoke()
import simplify
simplify.public_key = "YOUR OAUTH PUBLIC_KEY"
simplify.private_key = "YOUR OAUTH PRIVATE_KEY"
CODE = 'OAUTH AUTHORIZATION CODE'
REDIRECT_URI = 'YOUR OAUTH REDIRECT URI'
token = simplify.AccessToken.create(CODE, REDIRECT_URI)
token.revoke()
<?php
require_once("./lib/Simplify.php");
Simplify::$publicKey = 'YOUR OAUTH PUBLIC_KEY';
Simplify::$privateKey = 'YOUR OAUTH PRIVATE_KEY';
$code = 'OAUTH AUTHORIZATION CODE';
$redirect_uri = 'YOUR OAUTH REDIRECT URI';
$accessToken = Simplify_AccessToken::create($code, $redirect_uri);
$accessToken.revoke();
?>
use Net::Simplify;
$Net::Simplify::public_key = "YOUR OAUTH PUBLIC_KEY";
$Net::Simplify::private_key = "YOUR OAUTH PRIVATE_KEY";
$CODE = 'OAUTH AUTHORIZATION CODE';
$REDIRECT_URI = 'YOUR OAUTH REDIRECT URI';
$token = Net::Simplify::AccessToken->create($CODE, $REDIRECT_URI);
$token->revoke();
using SimplifyCommerce.Payments;
try
{
PaymentsApi api = new PaymentsApi();
PaymentsApi.PublicApiKey = "YOUR OAUTH PUBLIC_KEY";
PaymentsApi.PrivateApiKey = "YOUR OAUTH PRIVATE_KEY";
string code = "iBxx7c";
OauthAccessTokenRequest req = new OauthAccessTokenRequest();
req.RedirectUri = "YOUR OAUTH REDIRECT URI";
req.Code = code;
OauthAccessToken token = api.RequestAccessToken(req);
token = api.RevokeAccessToken(token);
}
catch (ApiException e)
{
Console.WriteLine("Message: " + e.Message);
}
var Simplify = require("simplify-commerce"),
client = Simplify.getClient({
publicKey: 'YOUR_OAUTH_PUBLIC_KEY',
privateKey: 'YOUR_OAUTH_PRIVATE_KEY'
});
client.accesstoken.revoke('OAUTH_ACCESS_TOKEN', function(errData, data){
if(errData){
console.error("Error Message: " + errData.data.error_description);
// handle the error
return;
}
console.log("Revoked Token: " + data.token_revoked);
});
Create a Payment With Simplify Link
Now lets put it all together. Below are examples using the Simplify Commerce SDKs to create a payment using Simplify Link. The examples assume you have already created your OAuth keys in the app management screen of Simplify Commerce and you have obtained an authorization code
PaymentsApi.PUBLIC_KEY = "YOUR OAUTH PUBLIC_KEY";
PaymentsApi.PRIVATE_KEY = "YOUR OAUTH PRIVATE_KEY";
String REDIRECT_URI = "YOUR OAUTH REDIRECT URI";
AccessToken accessToken = AccessToken.create(code, REDIRECT_URI);
Payment payment = Payment.create(new PaymentsMap()
.set("currency", "USD")
.set("card.cvc", "123")
.set("card.expMonth", 11)
.set("card.expYear", 99)
.set("card.number", "5555555555554444")
.set("amount", 1000) // In cents e.g. $10.00
.set("description", "prod description"),
new Authentication(accessToken.get("access_token"));
if ("APPROVED".equals(payment.get("paymentStatus"))) {
System.out.println("Payment approved");
}
require 'simplify'
Simplify::public_key = "YOUR OAUTH PUBLIC_KEY"
Simplify::private_key = "YOUR OAUTH PRIVATE_KEY"
CODE = 'OAUTH AUTHORIZATION CODE'
REDIRECT_URI = 'YOUR OAUTH REDIRECT URI';
token = Simplify::AccessToken.create(CODE, REDIRECT_URI);
auth = Simplify::Authentication.new(:access_token => token['access_token'])
payment = Simplify::Payment.create({
"card" => {
"number" => "5555555555554444",
"expMonth" => 11,
"expYear" => 99,
"cvc" => "123"
},
"amount" => 1000,
"currency" => "USD",
"description" => "Description"
}, auth)
if payment['paymentStatus'] == 'APPROVED'
puts "Payment approved"
end
import simplify
simplify.public_key = "YOUR OAUTH PUBLIC_KEY"
simplify.private_key = "YOUR OAUTH PRIVATE_KEY"
CODE = 'OAUTH AUTHORIZATION CODE'
REDIRECT_URI = 'YOUR OAUTH REDIRECT URI'
token = simplify.AccessToken.create(CODE, REDIRECT_URI)
auth = simplify.Authentication(access_token = token.access_token)
payment = simplify.Payment.create({
"card" : {
"number": "5555555555554444",
"expMonth": 11,
"expYear": 99,
"cvc": "123"
},
"amount" : 1000,
"description" : "prod description",
"currency" : "USD"
}, auth)
if payment.paymentStatus == 'APPROVED':
print("Payment approved")
<?php
require_once("./lib/Simplify.php");
Simplify::$publicKey = 'YOUR OAUTH PUBLIC_KEY';
Simplify::$privateKey = 'YOUR OAUTH PRIVATE_KEY';
$code = 'OAUTH AUTHORIZATION CODE';
$redirect_uri = 'YOUR OAUTH REDIRECT URI';
$accessToken = Simplify_AccessToken::create($code, $redirect_uri);
$payment = Simplify_Payment::createPayment(array(
"card" => array(
"number" => "5555555555554444",
"expMonth" => 11,
"expYear" => 99,
"cvc" => "123"
),
'amount' => '1000',
'description' => 'prod description',
'currency' => 'USD'
) new Simplify_Authentication($accessToken->access_token));
if ($payment->paymentStatus == 'APPROVED') {
echo "Payment approved\n";
}
?>
use Net::Simplify;
$Net::Simplify::public_key = "YOUR OAUTH PUBLIC_KEY";
$Net::Simplify::private_key = "YOUR OAUTH PRIVATE_KEY";
$CODE = 'OAUTH AUTHORIZATION CODE';
$REDIRECT_URI = 'YOUR OAUTH REDIRECT URI';
$token = Net::Simplify::AccessToken->create($CODE, $REDIRECT_URI);
$auth = Net::Simplify::Authentication->create(access_token => $token->access_token);
$payment = Net::Simplify::Payment->create({
card => {
number => "5555555555554444",
expMonth => 11,
expYear => 99,
cvc => "123"
},
amount => 1000,
currency => "USD",
description => "Description"
}, $auth);
print "Payment status: ", $payment->{paymentStatus}, "\n";
using SimplifyCommerce.Payments;
PaymentsApi api = new PaymentsApi();
PaymentsApi.PublicApiKey = "YOUR OAUTH PUBLIC_KEY";
PaymentsApi.PrivateApiKey = "YOUR OAUTH PRIVATE_KEY";
string code = "iBxx7c";
OauthAccessTokenRequest req = new OauthAccessTokenRequest();
req.RedirectUri = "YOUR OAUTH REDIRECT URI";
req.Code = code;
OauthAccessToken token = api.RequestAccessToken(req);
Payment payment = new Payment();
payment.Amount = 123123;
Card card = new Card();
card.Cvc = "123";
card.ExpMonth = 11;
card.ExpYear = 99;
card.Number = "5555555555554444";
payment.Card = card;
payment.Currency = "USD";
payment.Description = "payment description";
try
{
payment = (Payment)api.Create(payment, token);
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
var Simplify = require("simplify-commerce"),
client = Simplify.getClient({
publicKey: 'YOUR_OAUTH_PUBLIC_KEY',
privateKey: 'YOUR_OAUTH_PRIVATE_KEY'
});
client.accesstoken.create({
authCode: 'OAUTH_AUTHORIZATION_CODE',
redirectUri: 'YOUR_OAUTH_REDIRECT_URI'
}, function(errData, data){
if(errData){
console.error("Error Message: " + errData.data.error_description);
// handle the error
return;
}
console.log("Access Token: " + data.access_token);
// Create a payment with an access token
client.payment.create({
accessToken: data.access_token,
"card" : {
"number": "5555555555554444",
"expMonth": 11,
"expYear": 99,
"cvc": "123"
},
"amount" : "1000",
"description" : "prod description",
"currency" : "USD"
}, function(paymentErrData, paymentData){
if(paymentErrData){
console.error("Error Message: " + paymentErrData.data.error.message);
// handle the error
return;
}
console.log("Total: " + JSON.stringify(paymentData));
});
});