2click.js || API Reference

Once 2click.js is installed on a webpage, an 'atpay' object becomes available. The page lists all the methods available on 'atpay' object and how they can be used.


Config

This configures 2click.js for use. It must be called before using any of the other methods.

atpay.config(settings)

Attribute Description
organization_sid The Organization SID found in your Orgnaization Dashboard under 'API Settings'
default_gatway The SID of the Gateway that you want to assign to all Offers to (optional)
test_mode Creates all Invoices and Offers with a test Gateway. Will take precedence over any other gateway configuration. (optional)

Offer

The offer call uses a provided name, description, amount and other arguments to create an @Pay offer.

atpay.offer(amount, title, options, callback)

Attribute Description
options A Javascript Object with additional parameters. See options table below.
callback A Javascript Object with additional parameters, ‘card’ is a required value, and ‘referrer_context’ is a value you wish to store with the transaction data
Option Description
amount A numeric amount of the transaction in dollars
title A function to call when the sale has succeeded or failed.
desctription A string value that sets the details or description of generated Offer
gateway The Gateway SID you would like to assign to the Offer. Use "test_gatway" for a test Offer. If not set, the Organization's default Gateway will be used.
expiration The number of days the Offer will expire after generated.
url A valid url that will be used for a custom Payment Capture Page.
requires_shipping_address A boolean value that sets whether or not to require shipping info
requires_billing_address A boolean value that sets whether or not to require billing info
request_custom_data A JS object containing ‘name’ and ‘required’ that will generate custom fields if using the hosted payment page. ex {name:”custom_field”, required: true}

On a transaction success, you will receive the following information in the response argument to your callback function.

1
2
3
4
5
6
7
8
9
10
  {
    id:   "950F68EF-C0FD-4679-83E1-119F43F867BF",
    title:   "Donate $25.00",
    amount: 25.00,
    mail_to:  "mailto:payment-id-950F68EF-C0FD-4679-83E1-119F43F867BF@payments.atpay.com?subject=Press%20...".
    payment_capture_page:  "http://test_organization.atpay.com/950F68EF-C0FD-4679-83E1-119F43F867BF",
    qr_code: "https://dashboard.atpay.com/offers/950F68EF-C0FD-4679-83E1-119F43F867BF.png"
    button_html: " <!— begin @Pay button —>....",
    created_at: "2013-03-15T14:19:35-06:00"
  }
Attribute Description
id The @Pay identifier for this Offer
title The name of the Offer
amount The amount of the Offer in dollars
mail_to The @Pay Mailto Link associated with the Offer
payment_capture_page The url to the Payment Capture Page for the Offer
qr_code The url for the @Pay QR image associated with the Offer
button_html The markup for the @Pay Button associated with the Offer
created_at The timestamp when the transaction was updated