Shell Python Node PHP C# Ruby

Integrated Processing Account Plugin

To integrate the processing account setup process into your app or platform, you can use the Processing Account embeddable javascript plugin to capture the details for a new processing account.

Example

Below is an example of the Processing Account Form. Click the button to view.


Create an Intent Token

curl -X POST "https://api.payload.co/access_tokens" \
  -u secret_key_3bW9JMZtPVDOfFNzwRdfE: \
  -H 'Content-Type: application/json'
  -d '{
    "intent": {
      "type": "processing_account_plugin"
    }
  }'
import payload
pl = payload.Session('secret_key_3bW9JMZtPVDOfFNzwRdfE')

@app.route('/form-token', method='post')
def checkout_redirect():

  client_token = pl.ClientToken.create(
    intent=dict(
      type='processing_account_plugin'
    )
  )

  return jsonify({'client_token': client_token['id']})
require 'payload'
pl = Payload::Session.new('secret_key_3bW9JMZtPVDOfFNzwRdfE')

get '/form-token/' do

  client_token = Payload::ClientToken.create(
    intent: {
      type: 'processing_account_plugin'
    }
  )

  json({ client_token: client_token['id'] })
end
<?php

$pl_transaction_id = $_GET['pl_transaction_id'];


$clientToken = Payload\ClientToken::create([
  "intent"=>[
    "type"=>"processing_account_plugin"
  ]
]);

header('Content-Type: application/json; charset=utf-8');
echo json_encode(["client_token": $clientToken->id]);
?>
import payload from 'payload-api'
const pl = payload.Session('secret_key_3bW9JMZtPVDOfFNzwRdfE');

app.get('/form-token', (req, res) => {
  const clientToken = pl.ClientToken.create({
    intent: {
      type: 'processing_account_plugin'
    }
  });

  res.json({ client_token: clientToken.id });
})
using Payload;

[Route("form-token")]
public IHttpActionResult CheckoutRedirect() {
  var pl = new Payload.Session("secret_key_3bW9JMZtPVDOfFNzwRdfE");

  var client_token = await new pl.ClientToken.create(new {
    intent=new {
      type="processing_account_plugin"
    }
  });

  return Json(new { client_token = client_token.id });
}

To use the processing account plugin you need to generate processing_account_plugin intent object. To create an intent, create a ClientToken with a type of processing_account_plugin.

Once the client token is generated, return that to the client and pass that the token value Payload function.


Open the Processing Form

Javascript example

<script src="https://payload.co/Payload.js"></script>
<script>
Payload('generated_client_token')

new Payload.ProcessingAccount()
    .on('success', function(evt) {
        console.log(evt.account.id)
    })
</script>

The Processing Account Form can be opened using the JavaScript interface by creating a new instance of Payload.ProcessingAccount, as seen in the example.

Events

The processing form has a few different events that you can watch for. To watch for an event, use the on method on the ProcessingAccount object. The on method accepts an event name and an event function as the parameters.

Event Description
success Event triggered after the form has been successfully completed.
account_created Event triggered after the form has been successfully completed.
loaded Event triggered after the form has loaded
closed Event triggered after the form has been closed

Configuration

Attribute Description
client_key
required
Your client key
inline Draw the form in-line instead of in a modal.
container Specify a containing element to embed the inline form.
form Specify a form element to auto-submit after completion