Embedded Withdrawals Using iFrames

What are Embedded Withdrawals?

In order for WePay to settle collected funds to a merchant, we'll need the merchant to verify their identity and add their bank account info. Once they have done this, we can automatically deposit any money they collect into their bank account.

To make this easier, we provide a simple flow that can be embedded in an iframe on your website. The merchant can set up all of their settlement details without ever leaving your site!

Note that merchants typically only need to complete this step once. After they have completed this step, all funds will be automatically settled to their bank account on a regular basis. The merchant can choose how often these withdrawals happen (daily, weekly, or monthly).


A crowdfunding site helps fundraisers collect donations. They want to make it easy for the fundraiser to receive any donations into their bank account. On the donations settings page, they embed the iframe withdrawal flow so the fundraiser can easily set up automatic deposits into their bank account.

At WePay, the fundraiser is the merchant and we'll use that term below.

How does it work?

There are two steps for embedding the withdrawal flow in an iframe:

  1. Make the /account/get_update_uri call
  2. Embed the update uri in an iframe on your site

Step 1:

The first step is to get the uri you need to embed in the iframe. You can do this with the /account/get_update_uri call.

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

    // application settings
    $account_id = 123456789;
    $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 the withdrawal
    $response = $wepay->request('account/get_update_uri', array(
        'account_id'    => $account_id,
        'redirect_uri'  => 'http://example.com/withdraw/success/',
        'mode'          => 'iframe'

    // display the response
curl https://stage.wepayapi.com/v2/account/get_update_uri \
	-H "Authorization: Bearer STAGE_8a19aff55b85a436dad5cd1386db1999437facb5914b494f4da5f206a56a5d20" \
	-d "account_id=123456789" \
    -d "mode=iframe" \
	-d "redirect_id=http://example.com/withdraw/success/"
# WePay Ruby SDK - http://git.io/a_c2uQ
require 'WePay_API_v2_Ruby_SDK.rb'

# application settings
account_id = 123456789
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 the withdrawal
response = wepay.call('/account/get_update_uri', access_token, {
    :account_id     => account_id,
    :mode   => 'iframe',
    :redirect_uri   => 'http://example.com/withdraw/success/'

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

# application settings
account_id = 123456789
access_token = 'STAGE_8a19aff55b85a436dad5cd1386db1999437facb5914b494f4da5f206a56a5d20'
production = False

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

# create the withdrawal
response = wepay.call('/account/get_update_uri', {
    'account_id': account_id,
    'mode': 'iframe',
    'redirect_uri': 'http://example.com/withdraw/success/'

# display the response
print response

Step 2:

Now that you have the uri, you can embed it in an iframe on your site. Here is some sample code that shows you how to do that:

<div id="withdrawal_div"><div>
<script type="text/javascript" src="https://www.wepay.com/min/js/iframe.wepay.js">

<script type="text/javascript">
    WePay.iframe_checkout("withdrawal_div", "https://stage.wepay.com/api/withdrawal/12345");

The merchant will be shown a flow where they will verify their identity, add their bank account information, and choose how often they want withdrawals made (daily, weekly, monthly, quarterly): Once they have done this, and WePay has verified their information, payments will automatically be deposited into the merchant's bank account when they clear. To learn more about how often this will happen, read the settlement guide.