Cardknox is now Sola
Learn More
LogoLogo
Contact Us
  • Introduction
  • 🔗API
    • Transaction API
      • Credit Card
      • Check (ACH)
      • EBT
      • Gift Card
      • Fraud
    • Customer and Recurring API
    • Reporting API
    • Account Boarding API
      • Account Boarding Merchant Agreement
      • Account Boarding Swagger UI
    • Code Samples
    • Error Codes
  • 📦SDK
    • .NET SDK
      • Transaction Workflow
    • iOS SDK
      • iOS SDK - Technical Guide
      • Workflow
    • Android SDK
      • Android SDK - Technical Guide
  • 🧰 Cardknox Products
    • 3D Secure 2.0
      • Client-Side Integration
        • Client-Side Integration (Non-iFields)
      • Server-Side Integration
    • Account Updater
    • Batch Processing
    • Browser-Based POS systems (BBPOS)
    • CloudIM Developer Guide
    • Deep Linking
      • Deep Linking Integration for Third-Party Websites
    • EBT Online
    • Gateway Emulators
    • iFields
      • Angular iFields
    • Merchant Portal
      • FAQ
    • Mobile App
    • Split Capture
    • Tap to Phone - Android
    • Partner Portal
    • PaymentSITE
      • QR Codes for PaymentSITE
    • Webhooks
  • 📱Mobile Wallets
    • Apple Pay Hosted Checkout
      • Apple Pay Hosted Checkout Initial Setup
      • Apple Pay Prerequisites
      • Apple Pay Hosted Checkout Objects Reference (Request)
      • Apple Pay Hosted Checkout Objects Reference (Response)
      • Apple Pay iFields Integration
      • Apple Pay Hosted Checkout Sample Code
      • Apple Pay Features
      • Set up Apple Pay Merchant ID with Cardknox
    • Click-To-Pay - Hosted Checkout
      • Click-To-Pay Initial Setup
      • Click-To-Pay Sample Code
      • Click-To-Pay iFields Integration
      • Click-To-Pay Objects Reference (Request)
      • Click-To-Pay Objects Reference (Response)
    • Google Pay Hosted Checkout
      • Google Pay Control Object
      • Google Pay Request Objects
      • Google Pay Response Objects
      • Google Pay Sample Code
      • iFields Integration
      • Google Pay FAQ
  • 🔌Plugins
    • Netsuite
      • NetSuite Features and Demo
    • WooCommerce
    • Magento Plugin
    • RMH (Retail Management Hero)
    • RMS (Retail Management Systems)
  • 📖Articles
    • Frequently Asked Questions
    • How to Build POS Integration Flows
    • Card Present Integration Guide
  • Glossary of Terms
Powered by GitBook
On this page
  • Available dictionary objects
  • Request objects

Was this helpful?

Export as PDF
  1. Mobile Wallets
  2. Click-To-Pay - Hosted Checkout

Click-To-Pay Objects Reference (Request)

Last updated 2 years ago

Was this helpful?

For complete sample code please refer

Available dictionary objects

iStatus

const iStatus = {
    success: 100,
    unsupported: -100,
    error: -200
}

Use: iStatus.success

c2pEnvironment

const c2pEnvironment = {
    sandbox: 0,
    production: 1
}

Use: c2pEnvironment.sandbox

c2pReviewAction

const c2pReviewAction = {
    pay: "PAY",
    continue: "CONTINUE"
}

Use: c2pReviewAction.pay

Request objects

ClickToPayRequest

The Main object that contains all the information necessary to communicate with Click-To-Pay API.

Name

Type

Required

Description

environment

Yes

Can be either c2pEnvironment.sandbox or c2pEnvironment.production

externalClientId

String

Yes

ID assigned to your merchant by Click-To-Pay Registration

click2payContainer

String

Yes

ID of the main div that will host the Click-To-Pay experience

mainCssClass

String

No

Default: c2p-def To override default styling, use this field to provide the name of your own css class

displayWaitScreenAfterCheckout

Boolean

No

Default: true After checkout Click-To-Pay control will be automatically reloaded. This controls if “Wait“ screen is set during that operation

reviewAction

No

Default: c2pReviewAction.pay Controls final Button caption consumer clicks to make the payment

onButtonLoaded

Function

No

onPaymentPrefill

Function

Yes

onPaymentValidate

Function

No

onPaymentSuccess

Function

Yes

onPaymentCancel

Function

No

onPaymentError

Function

No

onCPButtonLoaded callback example

onCPButtonLoaded: function(resp) {
    if (!resp) return;
    if (resp.status === iStatus.success) {
        showHide("click2payContainer", true);
    } else if (resp.reason) {
        console.log(resp.reason);
    }
}

onPaymentPrefill callback example

onPaymentPrefill: function(){
  const result = {
    merchantRequestId: "Merchant defined request ID",
    currencyCode: "USD",
    description: "...corp Product",
    orderId: "Merchant defined order ID",
    promoCode: "Merchant defined promo code",
    subtotal: roundTo(getAmount(), 2),
    shippingHandling: "2.00",
    tax: "2.00",
    discount: "1.00",
    giftWrap: "2.00",
    misc: "1.00",
    setTotal:  function() {
        this.total = roundTo(
            roundToNumber(this.subtotal, 2)
            + roundToNumber(this.shippingHandling, 2)
            + roundToNumber(this.tax, 2)
            + roundToNumber(this.giftWrap, 2)
            + roundToNumber(this.misc, 2)
            - roundToNumber(this.discount, 2)
        , 2);
        delete this.setTotal;
        return this;
    }
  }.setTotal();
  return result;
}

onPaymentValidate callback example

onPaymentValidate: function () {
    return new Promise(function (resolve, reject) {
        try {
            //Do some validation here
            resolve(iStatus.success);
        } catch (err) {
            reject(err);
        }
    });
}

onPaymentSuccess callback example

onPaymentSuccess: async function(clickToPayResponse) {
    return new Promise((resolve, reject) => {
        try {
            const response = await this.authorize(clickToPayResponse);
            console.log(response);
            const resp = JSON.parse(response);
            if (!resp)
                throw "Invalid response: "+ response;
            if (resp.xError) {
                throw resp;
            }
            resolve(response);
        } catch (err) {
            console.error("paymentSuccess error.", JSON.stringify(err));
            reject(err);
        }
    });
}

onPaymentCancel callback example

onPaymentCancel: function (payload) {
    logError("Click-To-Pay Cancelled", payload);
    //Do some custom logic here
}

onPaymentError callback example

onPaymentCancel: function (payload) {
    logError("Click-To-Pay Error", payload);
    //Do some custom logic here
}

CPButtonLoadedResult Object

Name

Type

Description

status

There are be 3 possible cases:

  • Click-To-Pay Button loaded successfully: status = iStatus.success

  • An error occurred while loading Click-To-Pay Button: status = iStatus.error

reason

String

If Click-To-Pay Button failed to load this field will be populated with the reason.


A callback function to be called when Click-To-Pay button is loaded. Accepts an object of type Please click for the sample code

A callback function that returns the final price and tax calculations. Please click for the sample code

A callback function to be called before Payment is made. Usually used to make custom validations before the payment. Please click for the sample code

A callback function to be called when Click-To-Pay Payment is authorized for the completion of the transaction. This function accepts a parameter of . Please click for the sample code

A callback function to be called when user cancels. Please click for the sample code

A callback function to be called when payment errors out. Please click for the sample code

📱
here
c2pEnvironment
c2pReviewAction
here
CPButtonLoadedResult
here
here
here
here
iStatus
here
ClickToPayResponse