WePay

Custom Account Creation

What is Custom Creation?

Custom Account Creation uses our /user/register call and allows you 100% control of the payment experience and gets merchants processing payments immediately. With the /user/register API calls, you create an account for the merchant literally behind the scenes. Then WePay completes account creation later through an email authorization from the merchant but the merchant can get going with accepting payments immediately. This also gives you the ability to do things on behalf of a merchant, including viewing their account balance and refunding payments. The goal of /user/register is getting an access_token, which is a secret parameter that lets you act on a specific merchant's behalf.

Example

An invoicing application wants to be able to let their users create invoices and start collecting money immediately upon registration. When a new user registers, they make the /user/register call and get back an access_token which they can use to create a payment account for the user and start accepting payments for that user.

At WePay, users are merchants and their customers are payers and we'll use those terms below.

How does it work?

There are 4 steps to /user/register:

  1. You make the /user/register call for a merchant and get back an access_token.
  2. Make the /account/create call with the access_token from step 1 to get an account_id.
  3. Use the /user/send_confirmation call to send the user an email asking them to confirm.
  4. The merchant clicks on a link in the email, confirms their new account, and sets a password.

Step 1:

Make the /user/register call and pass the merchant's details. The merchant will be registered on WePay and you will receive an access_token for that merchant.

Note that the access_token you receive is *temporary* unless confirmed. See -below- for more details.

  • PHP
  • cURL
  • Ruby
  • Python
<?php

// WePay PHP SDK - http://git.io/mY7iQQ
require 'wepay.php';

// application settings
$client_id = 123456789;
$client_secret = "1a3b5c7d9";

// change to useProduction for live environments
Wepay::useStaging($client_id, $client_secret);

$wepay = new WePay();

// register new merchant
$response = $wepay->request('user/register/', array(
    'client_id'        => $client_id,
    'client_secret'    => $client_secret,
    'email'            => 'api@wepay.com',
    'scope'            => 'manage_accounts,collect_payments,view_user,manage_subscriptions,preapprove_payments,send_money',
    'first_name'       => 'Bill',
    'last_name'        => 'Clerico',
    'original_ip'      => '74.125.224.84"',
    'original_device'  => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_6;
                             en-US) AppleWebKit/534.13 (KHTML, like Gecko)
                             Chrome/9.0.597.102 Safari/534.13'
));

// display the response
print_r($response);

?>
curl https://stage.wepayapi.com/v2/user/register \
    -d "client_id=123456789" \
    -d "client_secret=1a3b5c7d9" \
    -d "email=api@wepay.com" \
    -d "scope=manage_accounts,collect_payments,view_user,manage_subscriptions,preapprove_payments,send_money" \
    -d "first_name=Bill" \
    -d "last_name=Clerico" \
    -d "original_ip=74.125.224.84" \
    -d "original_device=Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_6;en-US) \
        AppleWebKit/534.13 (KHTML, like Gecko)Chrome/9.0.597.102 Safari/534.13"
# WePay Ruby SDK - http://git.io/a_c2uQ
require 'WePay_API_v2_Ruby_SDK.rb'

# application settings
client_id = 123456789
client_secret = '1a3b5c7d9'

# set _use_stage to false for live environments
wepay = WePay.new(client_id, client_secret, _use_stage = true)

# create an account for a user
response = wepay.call('/user/register', false, {
    :client_id        => client_id,
    :client_secret    => client_secret,
    :email            => 'api@wepay.com',
    :scope            => 'manage_accounts,collect_payments,view_user,manage_subscriptions,preapprove_payments,send_money',
    :first_name       => 'Bill',
    :last_name        => 'Clerico',
    :original_ip      => '74.125.224.84',
    :original_device  => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_6;en-US)
                           AppleWebKit/534.13 (KHTML, like Gecko)Chrome/9.0.597.102 Safari/534.13'
})

# display the response
p response
# WePay Python SDK - http://git.io/v7Y1jA
from wepay import WePay

# application settings
client_id = '123456789'
client_secret = '1a3b5c7d9'
production = False

# set production to True for live environments
wepay = WePay(production)

# create an account for a user
response = wepay.call('/user/register', {
    'client_id':       client_id,
    'client_secret':   client_secret,
    'email':           'api@wepay.com',
    'scope':           'manage_accounts,collect_payments,view_user,manage_subscriptions,preapprove_payments,send_money',
    'first_name':      'Bill',
    'last_name':       'Clerico',
    'original_ip':     '74.125.224.84',
    'original_device': 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_6;en-US)
                       AppleWebKit/534.13 (KHTML, like Gecko)Chrome/9.0.597.102 Safari/534.13'
})

# display the response
print response

Step 2:

Each merchant requires a payment account in order to start processing payments. A payment account has its own transaction history and account balance. Once you have an access_token for each merchant, you'll want to create a payment account for each merchant.

All you need to do is make the /account/create call with the merchant's access_token. The account name that you specify will be used on receipts and on the credit card statement for payments made to this account.

You will receive back an account_id which you should store in your database. You will use the merchant's account_id and access_token when processing payments with the /checkout/create call (for example). You can also use the account_id to look up the account balance and status.

  • PHP
  • cURL
  • Ruby
  • Python
<?php

// WePay PHP SDK - http://git.io/mY7iQQ
require 'wepay.php';

// application settings
$client_id = 123456789;
$client_secret = "1a3b5c7d9";
$access_token = "STAGE_8a19aff55b85a436dad5cd1386db1999437facb5914b494f4da5f206a56a5d20";

// change to useProduction for live environments
Wepay::useStaging($client_id, $client_secret);

$wepay = new WePay($access_token);

// create an account for a user
$response = $wepay->request('account/create/', array(
    'name'         => 'Account Name',
    'description'  => 'A description for your account.'
));

// display the response
print_r($response);

?>
curl https://stage.wepayapi.com/v2/account/create \
    -H "Authorization: Bearer STAGE_8a19aff55b85a436dad5cd1386db1999437facb5914b494f4da5f206a56a5d20" \
    -d "name=Account name" \
    -d "description=A description for your account."
# WePay Ruby SDK - http://git.io/a_c2uQ
require 'WePay_API_v2_Ruby_SDK.rb'

# application settings
client_id = 123456789
client_secret = '1a3b5c7d9'
access_token = 'STAGE_8a19aff55b85a436dad5cd1386db1999437facb5914b494f4da5f206a56a5d20'

# set _use_stage to false for live environments
wepay = WePay.new(client_id, client_secret, _use_stage = true)

# create an account for a user
response = wepay.call('/account/create', access_token, {
    :name         => 'Account Name',
    :description  => 'A description for your account.'
})

# display the response
p response
# WePay Python SDK - http://git.io/v7Y1jA
from wepay import WePay

# application settings
access_token = 'STAGE_8a19aff55b85a436dad5cd1386db1999437facb5914b494f4da5f206a56a5d20'
production = False

# set production to True for live environments
wepay = WePay(production, access_token)

# create an account for a user
response = wepay.call('/account/create', {
    'name':        'Account Name',
    'description': 'A description for your account.'
})

# display the response
print response

Step 3:

Now that the user is registered and an account has been setup, you can send the user a co-branded email letting them know that your app is going to start processing payments for them on WePay.

To do so, make the /user/send_confirmation call.

  • PHP
  • cURL
  • Ruby
  • Python
<?php

    // WePay PHP SDK - http://git.io/mY7iQQ
    require 'wepay.php';

    // application settings
    $client_id = 123456789;
    $client_secret = "1a3b5c7d9";
    $access_token = "STAGE_8a19aff55b85a436dad5cd1386db1999437facb5914b494f4da5f206a56a5d20";

    // change to useProduction for live environments
    Wepay::useStaging($client_id, $client_secret);

    $wepay = new WePay($access_token);

    // create an account for a user
    $response = $wepay->request('user/send_confirmation/', array());

    // display the response
    print_r($response);

    ?>
    curl https://stage.wepayapi.com/v2/user/send_confirmation \
        -H "Authorization: Bearer STAGE_8a19aff55b85a436dad5cd1386db1999437facb5914b494f4da5f206a56a5d20" \
    
# WePay Ruby SDK - http://git.io/a_c2uQ
    require 'WePay_API_v2_Ruby_SDK.rb'

    # application settings
    client_id = 123456789
    client_secret = '1a3b5c7d9'
    access_token = 'STAGE_8a19aff55b85a436dad5cd1386db1999437facb5914b494f4da5f206a56a5d20'

    # set _use_stage to false for live environments
    wepay = WePay.new(client_id, client_secret, _use_stage = true)

    # create an account for a user
    response = wepay.call('/user/send_confirmation', access_token, {})

    # display the response
    p response
# WePay Python SDK - http://git.io/v7Y1jA
    from wepay import WePay

    # application settings
    access_token = 'STAGE_8a19aff55b85a436dad5cd1386db1999437facb5914b494f4da5f206a56a5d20'
    production = False

    # set production to True for live environments
    wepay = WePay(production, access_token)

    # create an account for a user
    response = wepay.call('/user/send_confirmation', {})

    # display the response
    print response

Step 4:

The merchant will click on the call to action in the email and will be taken to a page where they can confirm this process. They will choose a password that will let them log into WePay at a later date. They will then be returned to the redirect_uri you set in step 1.

What happens if the merchant doesn't confirm?

The temporary access token will expire 90 days after its creation if not approved. You can send the user an email to confirm their WePay account using the /user/send_confirmation call.

Accounts created with a temporary access token have a few restrictions.

  • They will deleted when the temporary access token expires.
  • They will also be deleted 14 days after they accept their first payment.
  • They can only accept $5,000.

Once an account created with a temporary access token is deleted, all accepted payments will be refunded.

Next Steps

Now that you have an account_id and an access_token, you can help the merchant accept payments. Read the process payments overview for information on how to do that.