Skip to content

Instantly share code, notes, and snippets.

@mrezentes
Last active August 17, 2016 13:33
Show Gist options
  • Save mrezentes/ce6d53f5bf3704a709cb884b9324fff5 to your computer and use it in GitHub Desktop.
Save mrezentes/ce6d53f5bf3704a709cb884b9324fff5 to your computer and use it in GitHub Desktop.
Spreedly iFrame now supports recache

Spreedly iFrame now supports the ability to recache a cvv (verification value). The only required piece of information is the payment method's token. The API calls to use this new functionality can be found below. Recache functionality is supported in version v1 of the iFrame library.

Configuring the iFrame for recache allows card holders to update their CVV with minimal PCI scope.

Recache API documentation

Spreedly functions:

Spreedly.recache() - causes the iframe to recache the cvv of the provided payment method token.

Spreedly.setRecache(token, options) - configures the iframe to recache the cvv of an existing, retained payment method

  • token - the token of the payment method
  • options - optional parameters affecting the display of a masked card number
    • last_four_digits - default is 'XXXX'
    • card_type - default is visa. The card type determines the layout of the masked number. American Express numbers display as "XXXX-XXXXXX-XXXXX" all other card types display as "XXXX-XXXX-XXXX-XXXX"

Events emitted:

recache - triggered when recache completes. Passes two parameters to the handler, we will refer to them as token and paymentMethodData.

recacheReady - triggered when the iframes are configured for recache. No parameters are passed.

Sample Usage:

// configure the iframe for recache
 Spreedly.on('ready', function(){
   Spreedly.setRecache( paymentMethodToken , {'card_type': 'visa','last_four_digits': '1234'}
 })
 
// register a handler for the recache event
Spreedly.on('recache', function(token, paymentMethod){
  console.log("Recache completed")
  console.log(paymentMethod)
  // Send results to the server
})

// init the iFrame normally
Spreedly.init("ENVIRONMENT-KEY", options);

To recache the CVV, simply call Spreedly.recache();

For example, if you are using a submit button:

<button onclick="Spreedly.recache()">Submit</button>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment