WePay

Charge app fees

Before reading this tutorial...

You should be familiar with the following concepts:

Platforms and marketplaces can make money by adding their own fees to the payments they facilitate through WePay.

Adding the app fee parameter

The /checkout/create call includes an optional app_fee parameter, which is the dollar amount you'd like to charge for facilitating a payment. Your app fees go directly to your application's WePay account.

API Call:

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

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

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

    $wepay = new WePay($access_token);

    // create the checkout
    $response = $wepay->request('checkout/create', array(
        'account_id'        => $account_id,
        'amount'            => '24.95',
        'short_description' => 'A brand new soccer ball',
        'type'              => 'GOODS',
        'app_fee'          => '1.99',
        'redirect_uri'      => 'http://example.com/success/'
    ));

    // display the response
    print_r($response);
?>
curl https://stage.wepayapi.com/v2/checkout/create \
	-H "Authorization: Bearer STAGE_8a19aff55b85a436dad5cd1386db1999437facb5914b494f4da5f206a56a5d20" \
	-d "account_id=123456789" \
	-d "amount=24.95" \
	-d "short_description=A brand new soccer ball" \
	-d "type=GOODS" \
	-d "app_fee=1.99" \
	-d "redirect_uri=http://example.com/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 = '1a3b5c7d9'

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

# create the checkout
response = wepay.call('/checkout/create', access_token, {
    :account_id         => account_id,
    :amount             => '24.95',
    :short_description  => 'A brand new soccer ball',
    :type               => 'GOODS',
    :app_fee           => '1.99',
    :redirect_uri       => 'http://example.com/success/'
})

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

# application settings
account_id = 123456789
access_token = '1a3b5c7d9'
production = False

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

# create the checkout
response = wepay.call('/checkout/create', {
    'account_id': account_id,
    'amount': '24.95',
    'short_description': 'A brand new soccer ball',
    'type': 'GOODS',
    'app_fee': '1.99',
    'redirect_uri': 'http://example.com/success/'
})

# display the response
print response

App fee as percentage

As mentioned above, the app_fee is a dollar amount. However, in many cases your app might want to take a percentage of the total amount. WePay charges 2.9% + 30¢ for credit card payments and 1% + 30¢ for bank payments. The WePay fee is charged on the gross amount that end payer pays. WePay always rounds to the lower amount.

Payee pays the fees

Set parameter 'fee_payer' = "payee" in /checkout/create call

Example: Your app wants to take 20% of the total amount charged to the customer. Part of this 20% is used to pay WePay fees, the rest is taken by your app. For percentage 'P' expressed as ratio (example 20% => P = 0.20) general formula would be as follows:

WePay fee for credit card or bank payments -

  • wepay_fee = 0.029 * amount + 0.30 //Round Lower
  • or
  • wepay_fee = 0.01 * amount + 0.30 //Round Lower

App fee calculation -

  • app_fee = P * amount - wepay_fee

Using above formula for 20% split and $100 amount credit card payment, we get the following:

  • Payer will pay $100
  • Payee (account holder) will get $80
  • Your app will get app_fee = $16.80
  • WePay will get wepay_fee = $3.20

Payer pays the fees

Set parameter 'fee_payer' = "payer" in /checkout/create call

Example: Your app wants to add 20% fees to the total amount charged to the customer. Part of this 20% is used to pay WePay fees, the rest is taken by your app. In this case, the payer will pay gross = amount + app_fee. The WePay fee will be charged on the gross. For percentage 'P' expressed as ratio (example 20% => P = 0.20) general formula would be as follows:

WePay fee for credit card or bank payments -

App fee calculation -

  • 1.029 * app_fee = (P - 0.029) * amount - 0.30 //Round Higher
  • or
  • 1.01 * app_fee = (P - 0.01) * amount - 0.30 //Round Higher
  • wepay_fee = 0.029 * (amount + app_fee) + 0.30 //Round Lower
  • or
  • wepay_fee = 0.01 * (amount + app_fee) + 0.30 //Round Lower

Using above formula for 20% split and $100 amount credit card payment, we get the following:

  • Payer will pay $120
  • Payee (account holder) will get $100
  • Your app will get app_fee = $16.326... ~= $16.33
  • WePay will get wepay_fee = $3.673... ~= $3.67
What's
Next?