GitHub – SagePayments/-Archived-PaymentsJS

Important Note: This project has been archived. The PaymentsJS product is still being supported, but no longer receiving any maintenance or updates. Please reach out to sdksupport@paya.com with any questions. If you are looking for a hosted solution for use with the legacy Paya Gateway (formerly Sage Payments/Sage Exchange) we recommend Paya Exchange Virtual Desktop (PEVD) 2.0.
PaymentsJS is a JavaScript library that enables developers to quickly start processing credit cards on their web site. The library includes a pre-built user interface, while besides exposing the underlie methods for function in applications with more nonindulgent UI/UX requirements. And whichever road you go, the credit card data never touches your server .

Quick Start

Add the library :

 <  script  type=" text/javascript"  src=" hypertext transfer protocol : //www.sagepayments.net/pay/1.0.2/js/pay.min.js" > < /p 

script

>

And a button :

 < clitoris  id=" paymentButton" >Pay Now < /p 

button

>

then initialize the UI :

 < handwriting  type=" text/javascript" >
     PayJS ( [ 'PayJS/UI ' ],  // loading the UI faculty ...
     routine ( $ UI )  {  // ... and assigning it to a variable
         $ UI. Initialize ( {
             elementId:  `` paymentButton '' ,
             // identifiers ( no key ! ) :
             clientId:  `` myClientId '',  // hypertext transfer protocol : //developer.sagepayments.com/user/register
             merchantId:  `` 999999999997 '' ,
             // auth, covered late :
             authKey:  `` ABCD== '' ,
             salt:  `` DEFG== '' ,
             // config :
             requestType:  `` requital '',  // or `` vault '' to tokenize a card for subsequently
             come:  `` 1.00 '' ,
             orderNumber:  `` Invoice12345 '' ,
             // convenience :
             addFakeData:  true ,
         } ) ;
     } ) ;
 < /p 

script

>

Clicking on paymentButton will make the payment windowpane appear. You can submit the transaction, but it wo n’t succeed — so our adjacent pace is to calculate the authKey .

Authentication & Verification

Credit calling card datum moves immediately between the user ‘s browser and Sage Payment Solutions ‘ plug requital gateway. This is great news for your server, which does n’t have to touch any sensible data ; but, as with any client-side code, it means we have to be wary of malicious users .

authKey

The authKey is an code interpretation of the shape settings that you pass into UI.Initialize() or CORE.Initialize(). We ‘ll decrypt the authKey and compare it to the request body, to make sure that what we received matches what you were expecting. This is besides how you send us your merchantKey, which should never be exposed to the node browser .
The adopt code snippets show the encoding in PHP ; check out the samples in this depository for other languages. If we do n’t have a sample in your speech, the Developer Forums are a great resource for information and support .
inaugural, we need a salt and an initialization vector :

 

$

intravenous feeding = openssl_random_pseudo_bytes( 16);

$

salt = base64_encode( bin2hex(

$

four));

next, we ‘re going to create an array that contains our configuration settings, plus our merchantKey :

 

$

req = [ `` clientId '' => `` 7SMmEF02WyC7H5TSdG1KssOQlwOOCagb '', `` merchantId '' => `` 999999999997 '', `` merchantKey '' => `` K3QD6YWyhfD '', `` requestType '' => `` payment '', `` orderNumber '' => ( string) clock time(), `` total '' => `` 1.00 '', `` salt '' =>

$

salt, ];

We convert it to JSON …

 

$

jsonReq = json_encode(

$

req);

… and then use our node key to encrypt it :

 

$

clientKey = `` wtC5Ns0jbtiNA8sP '';

$

passwordHash = hash_pbkdf2( `` sha1 '',

$

clientKey,

$

salt, 1500, 32, dependable);

$

authKey = openssl_encrypt(

$

jsonReq, `` aes-256-cbc '',

$

passwordHash, 0,

$

intravenous feeding);

now that we have our authKey, we initialize the UI with the same values :

 PayJS ( [ 'PayJS/UI ' ] ,
 officiate ( $ UI )  {
     $ UI. Initialize ( {
         clientId:  `` php repeat $ req [ 'clientId ' ] ? `` ,
         merchantId:  `` php resound $ req [ 'merchantId ' ] ? `` ,
         requestType:  `` php echo $ req [ 'requestType ' ] ? `` ,
         orderNumber:  `` php echo $ req [ 'orderNumber ' ] ? `` ,
         total:  `` php echo $ req [ 'amount ' ] ? `` ,
         authKey:  `` php resound $ authKey ? `` ,
         salt:  `` php echo $ salt ? `` ,
         elementId:  `` paymentButton '' ,
         addFakeData:  true
     } ) ;
     $ UI. setCallback ( function ( $ RESP )  {  // fires after the payment
         console table. log ( $ RESP. getResponse ( ) ) ;
     } ) ;
 } ) ;

The payment now goes through !

What needs to be included in the authKey?

The following fields should constantly be included in the authKey encoding :

  • merchantId
  • merchantKey
  • requestType
  • orderNumber (aka requestId)
  • salt (aka nonce)

These optional fields need to be included in the authKey only if they are used :

  • amount
  • taxAmount
  • shippingAmount
  • preAuth
  • postbackUrl
  • token
  • data
  • doVault

Response Hash

The reply body that is returned to the customer library ( and, optionally, to the postbackUrl ) includes the gateway reaction and the original requestId ( orderNumber ). If the request included custom data, this is besides echoed in the response body :

 {
     `` requestId '': `` Invoice12345 '' ,
     `` gatewayResponse '': `` { \ '' status\ '' : \ '' Approved\ '', \ '' reference\ '' : \ '' A12BCdeFG0\ '', ... } '' ,
     `` data '': `` Some business-specific data. '' ,
 }

The reply headers contain a responseHash, which is a SHA-512 HMAC of the reply soundbox .

Important Note

You are required to use your node key to verify this hashish on your server before shipping any orders, updating any databases, etc. Additional details can be found here within our forums. This is a prerequisite for your output API credentials. Please let us know if you have any questions .

Modules

PaymentsJS uses RequireJS to manage its components. Your page will only load the modules that you specify ( plus any unspecified dependencies ) .
The comply modules contain methods that you may want to use in your project :

Name Description
“jquery” Version 2.0 of the common JavaScript library.
“PayJS/Core” Manages configuration settings and other shared values.
“PayJS/UI” Configures and manages the user interface.
“PayJS/Request” Sends transaction and vault requests to the gateway.
“PayJS/Response” Reads information from gateway responses.
“PayJS/Formatting” Converts credit card data into standardized strings.
“PayJS/Validation” Checks credit card data for acceptable values.

RequireJS

If you ‘re already using RequireJS on your page, add a path to PaymentsJS —

requirejs.config({
    paths: {
        "PayJS": 'https://www.sagepayments.net/pay/1.0.2/js/build'
    },
});

— and then use it like you would any other module .
Please keep in mind that you ‘ll besides need to provide your own jQuery dependence if you do n’t already have one .

API Reference

Loading Modules – PayJS()

The entire PaymentsJS library is accessed through the PayJS affair, which takes two arguments :

 PayJS (
     // foremost, a chain array containing the names of the modules you want to use
     [ 'moduleOne ',  'moduleTwo ' ] ,
     // and second a serve, inside which you can use those modules
     function ( m1,  m2 ) {  // moduleOne is assigned to m1, moduleTwo to m2
         m1. doSomething ( ) ;
         m2. doSomethingElse ( ) ;
     }
 ) ;

Or, less generically :

 PayJS ( [ 'PayJS/Core ',  'PayJS/Request ' ] ,
 function ( kernel,  REQ ) {
     core. Initialize ( /* ... */ ) ;
     REQ. doPayment ( /* ... */ ) ;
 } ) ;

The Core module ‘s main role is to share common settings among the other modules .

Initialize

Configures the library for a gateway request. If you ‘re running payments using the PayJS/Request module, use this alternatively of UI.Initialize() .
This method acting takes a single argumentation :

 // pass this method acting an object literal containing your configuration settings
 core. Initialize ( {
     someValue:  `` 123456 '' ,
     mySetting:  dependable
 } ) ;

The shape object can contain :

Name Description Values Required
clientId your developer id alphanumeric string yes
merchantId identifies your gateway account numeric 12-character string yes
authKey see Authentication & Verification base64 string yes
salt the encryption salt; see Authentication & Verification base64 string yes
orderNumber an identifier of your choosing string yes
requestType chooses between charging or tokenizing a card “payment” or “vault” yes
amount the total amount to charge the card “1.00”, etc. when requestType == “payment”
taxAmount the amount charged as tax “1.00”, etc. no
shippingAmount the amount charged for shipping “1.00”, etc. no
preAuth toggles between authorization-only (true) and authorization & capture (false) boolean no, default false
allowAmex causes VALIDATION.isValidCreditCard() to return false if it is passed an American Express card; when using the UI module, this also prevents submission boolean no, default true
allowDiscover behaves like allowAmex, but for Discover boolean no, default true
postbackUrl a URL that will receive a copy of the gateway response valid URI with https scheme no
billing add billing information (address/etc.) to the transaction request see CORE.setBilling() no
shipping add shipping information (address/etc.) to the transaction request see CORE.setShipping() no
customer add customer contact information (email/phone) to the transaction request see CORE.setCustomer() no
level2 add level2 data to the transaction request see CORE.setLevel2() no
level3 add level3 to the transaction request see CORE.setLevel3() no
isRecurring indicate that a payment should also create a recurring transaction boolean no, default false
recurringSchedule add customer contact information (email/phone) to the transaction request see CORE.setRecurringSchedule() when isRecurring == true
debug enable verbose logging to browser console boolean no, default false
environment choose between the certification and production environments “cert” or “prod” no, default “cert”
data add custom data that is echoed in the response string no
token the vault token being passed to REQUEST.doTokenPayment() alphanumeric string when running a token payment
doVault when processing a payment, also tokenize the card boolean no, default false

isInitialized

Returns a boolean that represents whether the module has been successfully initialized .
This method acting does not take any arguments :

 effect. isInitialized ( ) ;
 // = > fake
 core. Initialize ( validSettings )
 core. isInitialized ( ) ;
 // = > dependable

setBilling

Adds billing information to a requital request .
This method acting takes a single argument :

 core. setBilling ( {
     list:  `` John Smith '' ,
     address:  `` 123 Address St '' ,
     city:  `` denver '' ,
     state of matter:  `` conscientious objector '' ,
     postalCode:  `` 12345 '' ,
     nation:  `` USA ''
 } ) ;

Notes :

  • Billing information can also be set during initialization.

setShipping

Adds shipping information to a requital request .
This method takes a single argument :

 core. setShipping ( {
     name:  `` John Smith '' ,
     address:  `` 123 Address St '' ,
     city:  `` denver '' ,
     express:  `` carbon monoxide '' ,
     postalCode:  `` 12345 '' ,
     nation:  `` USA ''
 } ) ;

Notes :

  • Shipping information can also be set during initialization.

setCustomer

Adds customer information to a requital request .
This method takes a individual argument :

 core. setCustomer ( {
     electronic mail:  `` none @ example.com '' ,
     telephone:  `` 7035551234 '' ,
     fax:  `` 8041239999 ''
 } ) ;

Notes :

  • Customer information can also be set during initialization.

setLevel2

Adds Level II data to a payment request .
This method acting takes a unmarried argumentation :

 core. setLevel2 ( {
     customerNumber:  `` 123456789 ''
 } ) ;

Notes :

  • Level II data can also be set during initialization.

setLevel3

Adds Level III data to a requital request .
This method takes a one argumentation :

 core. setLevel3 ( {
     destinationCountryCode:  `` 840 '' ,
     amounts:  {
         deduction:  1 ,
         duty:  1 ,
         nationalTax:  1
     } ,
     vat:  {
         idNumber:  `` 123456789 '' ,
         invoiceNumber:  `` Invoice12345 '' ,
         total:  1 ,
         rate:  1
     } ,
     customerNumber:  `` 123456789 ''
 } ) ;

Notes :

  • Level III data can also be set during initialization.
  • Level III processing requires additional API calls.

setIsRecurring

Indicates that a payment should besides create a recurring transaction that processes mechanically on a define schedule .
This method takes a single argumentation :

 core. setIsRecurring ( truthful ) ;

Notes :

  • When setting this to true, don’t forget to define the recurring schedule.

setRecurringSchedule

Defines the action agenda for a recurring transaction .
This method takes a single controversy :

 core. setRecurringSchedule ( {
     `` amount '':  100 ,
     `` interval '':  3 ,
     `` frequency '':  `` monthly '' ,
     `` totalCount '':  4 ,
     `` nonBusinessDaysHandling '':  `` After '' ,
     `` startDate '':  `` 2016-10-21T21:06:44.385Z '' ,
     `` groupId '':  `` 123456 ''    
 } ) ;

Notes :

  • When defining a recurring schedule, don’t forget to set the isRecurring flag.

getters

These methods return information about the module express :

 // auth :
 effect. getClientId ( )
 core. getAuthKey ( )
 kernel. getSalt ( )
 // merchant :
 core. getMerchantId ( )
 core. getPhoneNumber ( )
 // environments/targets :
 core. getApiUrl ( )
 congress of racial equality. getClientUrl ( )
 congress of racial equality. getEnvironment ( )
 core. getPostbackUrl ( )
 core. getLanguage ( )
 // gateway :
 core. getOrderNumber ( )
 core. getRequestType ( )
 core. getDoVault ( )
 // transaction :
 congress of racial equality. getPreAuth ( )
 core. getAmount ( )
 core. getTaxAmount ( )
 core. getShippingAmount ( )
 core. getLevel2 ( )
 core. getLevel3 ( )
 core. getIsRecurring ( )
 core. getRecurringSchedule ( )
 // customer/cardholder :
 core. getBilling ( )
 core. getCustomer ( )
 congress of racial equality. getShipping ( )
 // backwards-compatibility :
 core. getRequestId ( )  // getOrderNumber ( )
 effect. getApiKey ( )  // getClientId ( )
 core. getNonce ( )  // getSalt ( )
 // misc/other :
 core. getCustomData ( )

The UI module adds a pre-built requital shape to your web site .

Initialize

Configures the library for a gateway request. If you ‘re using the pre-built payment form, use this rather of CORE.Initialize() .
This method takes a individual controversy :

 // pass this method an object misprint containing your shape settings
 UI. Initialize ( {
     someValue:  `` 123456 '' ,
     mySetting:  true
 } ) ;

In addition to the information outlined in CORE.Initialize(), this shape object can contain :

Name Description Values Required
elementId the id of the html element to which the UI will attach string yes
suppressResultPage hide the approved/declined pages that show after a gateway request boolean no, default false
restrictInput limits user entry to acceptable characters boolean no, default true
formatting after the user enters their credit card number, the form will remove invalid characters and add dashes boolean no, default true
phoneNumber displayed as a support number for declined transactions string no
show automatically show the modal UI when ready boolean no, default false
addFakeData adds fake credit card data to the form, for testing boolean no, default false

Notes :

  • If targetElement refers to a , , or , the UI will appear as a modal dialog when that element is clicked. If it refers to a

    , the UI will be put inside the element.

  • If suppressResultPage is enabled, the UI will never move past the processing bar. This can be used in conjunction with UI.setCallback() to customize response handling (eg, redirecting to another page).
  • We do not recommend changing restrictInput or formatting to false. (These options may be deprecated in a future release.)

isInitialized

Returns a boolean that represents whether the module has been successfully initialized .
This method does not take any arguments :

 UI.  isInitialized ( ) ;
 // = > false
 UI. Initialize ( validSettings )
 UI. isInitialized ( ) ;
 // = > true

setCallback

Sets a function that executes after a request completes .
This method acting takes up to four arguments :

 volt-ampere  myCallback  =  function ( RESP,  data | jqXHR,  textStatus,  jqXHR | errorThrown ) {
     SendResultToServer ( RESP. getResponse ( {  json:  genuine  } ) )
     volt-ampere  wasApproved  =  RESP. getTransactionSuccess ( ) ;
     RedirectUser ( wasApproved ?  `` approved.html '' :  `` declined.html '' ) ;
 } ;
 UI. setCallback ( myCallback ) ;

Notes :

  • The first argument to your callback function is the PayJS/Response module.
    • You do not need to call RESPONSE.tryParse() yourself.
  • The final three arguments are passed through from jQuery’s ajax method; please refer to the jQuery documentation for more information.
  • Always check the response hash server-side to verify the integrity of the response.

The Request module sends transaction and vault requests to the requital gateway .

doPayment

Charges a credit rating card .
This method takes four arguments :

 request. doPayment ( cardNumber,  expirationDate,  cvv,  callbackFunction ) ;

Notes :

  • The arguments to your callback are passed through from jQuery’s ajax method; please refer to the jQuery documentation for more information.
    • Pass the response string into RESPONSE.tryParse() to initialize the PayJS/Response module’s getters.
  • Always check the response hash server-side to verify the integrity of the response.

doVault

Tokenizes a recognition card without charging it. The nominal can be used late to charge the tease .
This method takes three arguments ( CVVs can not be stored ) :

 request. doVault ( cardNumber,  expirationDate,  callbackFunction ) ;

Notes :

  • The arguments to your callback are passed through from jQuery’s ajax method; please refer to the jQuery documentation for more information.
    • Pass the response string into RESPONSE.tryParse() to initialize the PayJS/Response module’s getters.
  • Always check the response hash server-side to verify the integrity of the response.

doTokenPayment

Charges a credit card using a vault token .
This method takes three arguments :

 request. doTokenPayment ( token,  cvv,  callbackFunction ) ;

Notes :

  • The token must be specified in the authKey.
  • An empty string is an acceptable CVV value; however, to maximize the chances of the cardholder’s bank approving the transaction, it is always preferable to collect and include a CVV whenever possible.
  • The arguments to your callback are passed through from jQuery’s ajax method; please refer to the jQuery documentation for more information.
    • Pass the response string into RESPONSE.tryParse() to initialize the PayJS/Response module’s getters.
  • Always check the response hash server-side to verify the integrity of the response.

getLastCard

Get payment details for the last credit rating card charged or stored through PaymentsJS .
This method acting does not take any arguments :

 request. doPayment ( `` 5424180279791732 '',  `` 1017 '',  `` 123 '',  function ( )  {
     comfort. log (  request. getLastCard ( )  ) ;
     // = > Object { maskedNumber : `` XXXXXXXXXXXX1732 '', cardType : `` 5 '', BIN : `` 542418 '', lastFourDigits : `` 1732 '', expirationDate : `` 1017 '' }
 } ) ;

Notes :

  • For convenience, this method has the alias RESPONSE.getPaymentDetails().
  • The BIN identifies the bank that issued the card. For more, please see this article.
  • The card type is represented by the first digit of that card type.
    • 3 — American Express
    • 4 — Visa
    • 5 — MasterCard
    • 6 — Discover

The Response module exposes methods for traversing transaction results .

tryParse

Attempts to initialize this faculty ‘s getters from an AJAX reception .
This method takes up to three arguments :

 response. tryParse ( data | jqXHR,  textStatus,  jqXHR | errorThrown ) ;
 // = > true

Notes :

  • The arguments are passed through from jQuery’s ajax method; please refer to the jQuery documentation for more information.
  • This method is used in the callback functions of the PayJS/Request module’s methods.
    • Use RESPONSE.tryParse() to initialize the PayJS/Response module’s getters.
    • You do not need to use this method in UI.setCallback().

These methods return unlike layers of the data :
They do not take any arguments :

 // returns the jqXHR object returned by the AJAX request :
 answer. getAjaxResponse ( ) ;
 // = > Object {
 // readyState : 4 ,
 // responseText : `` { `` requestId '' : '' Invoice12345 '', '' gatewayResponse '' : { `` status '' : '' Approved '', `` orderNumber '' : '' Invoice12345 '', ( ... )
 // ( ... )
 // }

 // returns the json string that the library received from the proxy api :
 answer. getApiResponse ( ) ;
 // = > `` { `` requestId '' : '' Invoice12345 '', '' gatewayResponse '' : { `` status '' : '' Approved '', `` orderNumber '' : '' Invoice12345 '', ( ... )

 // returns the deserialized inner response from the payment gateway :
 answer. getGatewayResponse ( ) ;
 // = > Object {
 // status : `` Approved '' ,
 // orderNumber : `` Invoice12345 '' ,
 // ( ... )
 // }

Notes :

  • When using the PayJS/Request module’s methods, you must call RESPONSE.tryParse() before these methods are available. The PayJS/UI module does this for you.
  • Always check the response hash server-side to verify the integrity of the response.

getResponseHash

Returns the API reaction and its hashish. Send these values server-side for hash confirmation .
This method acting does not take any arguments :

 reception. getResponseHash ( ) ;
 // = > Object {
 // reply : `` { `` requestId '' : '' Invoice12345 '', '' gatewayResponse '' : { `` condition '' : '' Approved '', `` orderNumber '' : '' Invoice12345 '', ( ... ) '' ,
 // hashish : `` ABCD== '' ,
 // }

Notes :

  • Always check the response hash server-side to verify the integrity of the response.

getters

This faculty has diverse getters that return information about the gateway request .
These methods do not take any arguments :

 // returns true if the payment request was approved ; otherwise, false
 response. getTransactionSuccess ( ) ;
 // = > true

 // returns true if the vault request was approved ; differently, delusive
 reply. getVaultSuccess ( ) ;
 // = > true

 // returns the token representing the credit rating poster in the vault
 response. getVaultToken ( ) ;
 // = > `` d01a3475-42ad-4d7e-b0a6-76e4ea1abec6 ''

 // returns the approval or decline code
 response. getCode ( ) ;
 // = > `` 123456 ''

 // returns the blessing or decay message
 reply. getMessage ( ) ;
 // = > `` APPROVED ''

 // returns the unique gateway identifier for the requital
 reception. getReference ( ) ;
 // = > `` 123456789123 ''

 // returns the requital 's rate count
 reception. getOrderNumber ( ) ;
 // = > `` 123456789123 ''

 // returns information about the recognition poster
 answer. getPaymentDetails ( ) ;
 // = > Object { maskedNumber : `` XXXXXXXXXXXX1732 '', cardType : `` 5 '', BIN : `` 542418 '', lastFourDigits : `` 1732 '', expirationDate : `` 1017 '' }

These methods can take a configuration object as a individual optional argument :

 // without any shape, this method acting returns a individual character representing the consequence of an AVS discipline
 // ( see : hypertext transfer protocol : //en.wikipedia.org/wiki/Address_Verification_System )
 reaction. getAVS ( ) ;
 // = > `` Z ''

 // use the `` ask '' choice to test whether the actual AVS consequence meets a certain horizontal surface ( or higher )
 reaction. getAVS ( {  necessitate:  `` none ''  } ) ;  // no catch
 // = > truthful
 response. getAVS ( {  want:  `` partial ''  } ) ;  // partial catch ( cover OR nothing )
 // = > on-key
 response. getAVS ( {  want:  `` claim ''  } ) ;  // claim match ( address AND zip code )
 // = > false

 // use the `` want '' option with the `` test '' choice to test the given code for a certain match-level, regardless of the actual AVS solution
 answer. getAVS ( {  want:  `` none '',  test:  `` megabyte ''  } ) ;
 // = > true
 reply. getAVS ( {  command:  `` overtone '',   test:  `` megabyte ''  } ) ;
 // = > on-key
 reply. getAVS ( {  command:  `` claim '',  test:  `` molarity ''  } ) ;
 // = > true
 // without any configuration, this method returns a individual character representing the solution of a CVV control
 answer. getCVV ( ) ;
 // = > `` M ''

 // use the `` command '' option to determine whether it was a couple or not
 response. getCVV ( {  ask:  `` equal ''  } ) ;  // no match
 // = > true

The Formatting module converts strings into default or specified formats .

formatCardNumberInput

Converts a string into a formatted credit rating calling card number .
This method acting can take one or two arguments :

 // travel by the drawstring to format
 format. formatCardNumberInput ( `` 5454545454545454 '' ) ;
 // = > `` 5454-5454-5454-5454 ''
 format. formatCardNumberInput ( `` 371449635392376 '' ) ;
 // = > `` 3714-496353-92376 ''

 // die a delimiter to use alternatively of a hyphen
 format. formatCardNumberInput ( `` 4111111111111111 '',  `` $ '' ) ;
 // = > `` 4111 $ 1111 $ 1111 $ 1111 ''

 // non-numeric characters are removed :
 format. formatCardNumberInput ( `` 4111-1111_1111a1111 '',  `` `` ) ;
 // = > `` 4111111111111111 ''

formatExpirationDateInput

Converts a chain into a format exhalation date .
This method can take one or two arguments :

 // pass the string to format
 format. formatExpirationDateInput ( `` 1216 '' ) ;
 // = > `` 12/16 ''

 // authorize a delimiter to use rather of a slash
 format. formatExpirationDateInput ( `` 1216 '',  `` ~ '' ) ;
 // = > `` 12~16 ''

Notes :

  • See VALIDATION.getExpArray() for more on expiration date string parsing.

maskCreditCardNumber

Masks a credit batting order phone number, so that only the last four digits are visible .
This method requires a single argument :

 format. maskCreditCardNumber ( `` 5454545454545454 '' ) ;
 // = > `` XXXXXXXXXXXX5454 ''

 format. maskCreditCardNumber ( `` 371449635392376 '' ) ;
 // = > `` XXXXXXXXXXX2376 ''

optionally, pass a shape object :

 // include the first base six digits ( BIN/IIN )
 format. maskCreditCardNumber ( `` 5454545454545454 '',  {  showBin:  true  } ) ;
 // = > `` 545454XXXXXX5454 ''

 // use something other than 'X '
 format. maskCreditCardNumber ( `` 5454545454545454 '',  {  maskChar:  ' $ '  } ) ;
 // = > `` $ $ $ $ $ $ $ $ $ $ $ $ 5454 ''

stripNonNumeric

Removes from a string any characters early than digits .
This method acting takes a individual argument :

 format. stripNonNumeric ( `` abcd1234 ! @ # $ '' ) ;
 // = > `` 1234 ''

stripNonAlphanumeric

Removes from a string any characters other than digits, letters, and underscores .
This method acting takes a single argument :

 format. stripNonAlphanumeric ( `` abcd1234 ! @ # $ '' ) ;
 // = > `` abcd1234 ''

The Validation module tests that strings meet certain robustness criteria .

isValidCreditCard

Tests a credit batting order string for invalid characters, allow distance, and mod10 .
This method acting can take one or two arguments :

 // pass the string to validate
 validation. isValidCreditCard ( `` 5454545454545454 '' ) ;
 // = > true

 // pas a circuit board type to check validity for that particular type
 establishment. isValidCreditCard ( `` 5454545454545454 '',  `` 3 '' ) ;
 // = > false

Notes :

  • This method will allow dashes; all other non-numeric characters will result in false.
  • This method expects American Express cards to have 15-digit cardnumbers; all other cardnumbers are expected to be 16 digits.
  • The card type is represented by the first digit of that card type.
    • 3 — American Express
    • 4 — Visa
    • 5 — MasterCard
    • 6 — Discover

isValidExpirationDate

Tests an termination date string for invalid characters, impossible calendar month, or past date .
This method acting takes a single argument :

 validation. isValidExpirationDate ( `` 1220 '' ) ;
 // = > genuine

 // expired
 validation. isValidExpirationDate ( `` 1215 '' ) ;
 // = > false

 // impossible date
 validation. isValidExpirationDate ( `` 1320 '' ) ;
 // = > delusive

Notes :

  • This method will allow slashes; all other non-numeric characters will result in false.
  • See VALIDATION.getExpArray() for more on expiration date string parsing.

isValidCvv

Tests a CVV string for invalid characters and appropriate length .
This method acting takes two arguments :

 // pass the string to validate, and a card type to check robustness for that detail type
 establishment. isValidCvv ( `` 123 '',  `` 4 '' ) ;
 // = > on-key
 establishment. isValidCvv ( `` 1234 '',  `` 4 '' ) ;
 // = > false
 validation. isValidCvv ( `` 1234 '',  `` 3 '' ) ;
 // = > genuine

Notes :

  • This method expects American Express cards to have 4-digit CVVs (“CIDs”); all other CVVs are expected to be 3 digits.
  • The card type is represented by the first digit of that card type.
    • 3 — American Express
    • 4 — Visa
    • 5 — MasterCard
    • 6 — Discover

getExpArray

Returns a string array containing an passing date as ["MM", "YY"] .
This method acting takes a one argument :

 // with a slash
 validation. getExpArray ( `` 01/18 '' ) ;  // MM/YY
 // = > [ `` 01 '', `` 18 '' ] ;
 validation. getExpArray ( `` 1/18 '' ) ;  // M/YY
 // = > [ `` 01 '', `` 18 '' ] ;
 validation. getExpArray ( `` 01/2018 '' ) ;  // MM/YYYY
 // = > [ `` 01 '', `` 18 '' ] ;
 validation. getExpArray ( `` 1/2018 '' ) ;  // M/YYYY
 // = > [ `` 01 '', `` 18 '' ] ;

 // without a flog
 validation. getExpArray ( `` 0118 '' ) ;  // MMYY
 // = > [ `` 01 '', `` 18 '' ] ;
 establishment. getExpArray ( `` 118 '' ) ;  // MYY
 // = > [ `` 01 '', `` 18 '' ] ;
 validation. getExpArray ( `` 012018 '' ) ;  // MMYYYY
 // = > [ `` 01 '', `` 18 '' ] ;
 validation. getExpArray ( `` 12018 '' ) ;  // MYYYY
 // = > [ `` 01 '', `` 18 '' ] ;

Notes :

  • Despite its parent module, this method does not validate the string.
    • VALIDATION.isValidExpirationDate() calls this method before validating.

Changelog

ENHANCEMENTS :

  • The API now returns a single response hash in the header.
  • All callback functions now receive all of jQuery’s ajax/jqXHR arguments.
  • The RESPONSE module has four new methods:
    • getAjaxResponse: returns the AJAX response object
    • getApiResponse: returns the API response string
    • getGatewayResponse: returns the inner gateway response, deserialized
    • getResponseHash: returns an object with the API response and its hash
      -Documentation and Samples have been updated accordingly.

BUG FIXES :

  • User is no longer able to hide the modal dialog while a request is pending.
  • Better support for overflow when the modal dialog is open on small, landscape screens.
  • Explicated certain CSS rules to avoid being overriden by parent styles; redundant in most cases.
  • The response sent to the postbackUrl now includes a Content-Type header.
  • The vault token is no longer an exception to authKey validation.
  • The response data now echoes the requestId/orderNumber, with a hash.

ENHANCEMENTS :

  • User can now set allowAmex and allowDiscover.
  • The library can now be initialized with a ‘data’ field.
    • This field is echoed back in the response, with a hash.
  • New method: FORMATTING.maskCreditCardNumber().
  • New method: REQUEST.getLastCard().
    • This method also exists under the alias RESPONSE.getPaymentDetails().

MISC/OTHER :

  • Changes to JSON de/serialization.
    • The API now returns the gateway response as a string, rather than an object.
    • The ajax requests in the REQUEST module now return JSON strings, rather than an object.
    • RESPONSE.tryParse() has been adjusted to expect a JSON string.
    • RESPONSE.getResponse() returns a completely-deserialized object, as before.
    • RESPONSE.getResponse() no longer has a json option.
    • RESPONSE.getRawResponse() now returns the original AJAX response, before any de/serialization.
  • API requests now include a version header.
  • Pre-patch for Kount integration.
  • Payments no longer automatically vault the card.
    • This functionality is now available via a ‘doVault’ option.

BUG FIXES :

  • Billing data no longer required.
    • (Note: transactions processed without address data may incur additional fees.)
  • Server now includes appropriate Cache-Control headers.
    • “no-store” for contents of /js, “no-cache” for /css and /img
  • UI now updates card type when using addFakeData option.
  • When authKey decryption fails, server response now includes CORS headers.
  • When authKey validation fails, server response now includes CORS headers.
  • When authKey validation fails, server response now 401 instead of 400.
  • When authKey validation fails, server response now specifies failures.
  • When preAuth defaults (or is set) to false, it is ignored during authKey validation.
  • When postbackUrl is not provided, it is ignored during authKey validation.

ENHANCEMENTS :

  • Developer can now set customer data.
  • Developer can now set shipping data.
  • Developer can now set level2 data.
  • Developer can now set level3 data.
  • Developer can now set taxAmount.
  • Developer can now set shippingAmount.
  • Developer can now set isRecurring + recurringSchedule.
  • Token payments now pass CVV.

MISC/OTHER :

  • The ‘requestId’ is now named ‘orderNumber’.
  • The ‘apiKey’ is now named ‘clientId’.
  • The ‘nonce’ is now named ‘salt’.
    • (Note: renamed fields retain their old aliases and getters/setters, for backwards compatibility.)
  • UI text abstracted out to separate module.
  • Added a language option; value currently hard-coded to “en”.
  • UI.Initialize() is now more closely aligned to CORE.Initialize() in terms of return values and exceptions.
  • Added this changelog to the GitHub readme.
  • Created changelog.
  • Added a build version.
  • Fixed bug where PaymentsJS failed to pass address and zip to the gateway.
    • UI module no longer forces billing data into an incorrect format.
  • Initial Release
beginning : https://enrolldetroit.org
category : Social

Trả lời

Email của bạn sẽ không được hiển thị công khai.