To start off, we are going to work in “staging” mode. What this means is its for testing only and when you run a transaction it will not actually charge anything it will just let you test everything out.

“Production” mode is when everything is running live and you want to charge cards.

When registering applications with WePay you have to understand staging and production are completely separate. This also means your API credentials are 100% completely different from staging to production. So when moving from one to the other you need to change your information as well as the account id!

This how to assumes you already have an account. Again if you registered at www.wepay.com you still have to register at stage.wepay.com because they are separate sites.

1. Go to stage.wepay.com and login.

2. Once logged in go to https://stage.wepay.com/developer

3. Click on “Register an Application”

4.  Fill in the account information

5. Submit and you will be brought to a page like I have below. For security reasons I have blanked out the account information.

 

As you can see you have the account id, access token, client id and client secret. This should be all the information you need to get your plugin working.

This how to is the same when you want to register for  production API credentials, but instead of going to http://stage.wepay.com, go to http://www.wepay.com

Due to the recent storms where I’m located, updates to the upcoming plugins and current ones have been delayed. Currently I reset all the updates to the 30th.We had 80mph straight line winds, some people reported 100mph, rain totals from 14 to 20 inches in 24 hours from two storms. It was coming down so hard I couldn’t see no more then 10 feet at most when the storm was at its peak. Power of course went out along with internet. So work got delayed. When the storm ended at 4:30AM it was like another place, a lot of the neighbors trees as well as ours were down. Lucky everyone was okay. Since then I was cutting up not only our trees put our neighbors as well. We had 4 spruce trees 30 years old taken down like twigs, Which I never thought I would see go while I was here. Funny thing about the whole deal was all the trees I wanted gone or I thought would have gone didn’t. All the ones I knew where healthy and I wanted them to stay, pretty much are gone at this point. Not much structural damage in town, few homes but not many. Honestly were really lucky.

The new WordPress WePay API is released and now available through the WordPress Plugin Directory. That plugin is extremely powerful and can do all the API calls to WePay from simple WordPress shortcodes. Meaning no writing code. I also included an IPN that can be customized to update the database. For more information see the WordPress WePay API Plugin.

I will be working as much as I can to get these updates and new plugins out asap.

 

If you are looking to get WePay integrated into your system I would be glad to help. I have integrated the WePay payment system into many systems from shopping carts to Kickstarter fund raising style sites. I also have written plugins for the major open source applications such as WordPress, OsCommerce, Zencart, and soon OpenCart. If you are looking for integration contact me.

 

Updates:

WordPress Plugin – Version 2.0 rolling out no later then 6/30/12 (Massive update, Includes a billing system, recurring invoicing, MU integration, Its huge!)

OpenCart Plugin – Version 1.0 rolling out 6/30/12

Zencart & OsCommerce Plugin – Version 1.5 rolling out 6/30/12 (Minor update, nothing big, Saves the cart if they leave WePay, Taxes as long as they are set in the WePay account)

 

Announcements:

Magento Plugin – No set release date yet but there will be a plugin rolling out.

ZeusCart Plugin – No set release date yet but there will be a plugin rolling out.

Prestashop Plugin – No set release date yet but there will be a plugin rolling out.

Ubercart Plugin – No set release date yet but there will be a plugin rolling out.

nopCommerce Plugin – No set release date yet but there will be a plugin rolling out.

Spree Plugin – No set release date yet but there will be a plugin rolling out.

jcart Plugin – No set release date yet but there will be a plugin rolling out.

Ecwid Plugin – No set release date yet but there will be a plugin rolling out.

S2member plugin – No set release date yet but there will be a plugin rolling out.

Thecartpress plugin – No set release date yet but there will be a plugin rolling out.

And the most important news, A custom fund raising application. I have been slowly working on this one. More info will roll out as I have some time to write up about it. Its pretty powerful stuff. Also I have a classified application that will be on Hotscripts.com soon with full integration into WePay.

 

Contact me if you have plugin requests, need integration, or want some help with current plugins.

 

If your looking for a Wepay Plugin to your application, whatever it may be. Please feel free to contact me, I would be glad to help you build it or I can build it for you. Contact Me.

As you can tell I have already release 3 open source plugins into Wepay.

WordPress Wepay Plugin

OsCommerce Wepay Plugin

Zen-Cart Wepay Plugin

And I have more I’m working on! 🙂 Let me know if I can be of assistance.

Alright to get the OsCommerce Wepay Plugin working you will need API Access to Wepay. I decided to split this tutorial into part 1 and Part 2, Part 1 is how to get your API information and account id. Part 2 is the setup of the plugin. I’m only going into production mode. I don’t see the need to test it since the plugin has been tested. Also your plugin will not work till Wepay activates your API, if its pending, you will not be able to process transactions.

Lets get started.

 

Part 1. Getting your API information

1. First you will need to goto https://www.wepay.com/developer. That is the production site, which means you can start collecting money today.

2. Once you register you will need to go to the developer section again, click on “Your Apps”

3. Click on “Create an application”, fill out all the fields, and hit submit.

4. You now have registered a app with wepay, which will give you your client secret, access token.

5 . You will now need to create an account you want your money to go into. Click on the “Home” link at the top of the screen. This will bring you to your account home page. You can ether use an account you have created or create a new one. In this case I will use one I already have, so click on the one you want to use.

Once you have clicked on it, in the address bar on your browser will tell you your account number.

Example: https://www.wepay.com/group/view/<YOUR ACCOUNT NUMBER HERE>

Copy that number you have in your browser, you will need it later.

 

Part 2. Setting up the Plugin

1. Copy the folders “includes” and “ext” directly into your OsCommerce Installation.

2. Login to your admin and activate the payment module.

3. Once activated you will need to fill in all the data you got in step 1, your client id, client secret, account id, and access token.

4. Once you have filled in all the fields, you should now be using the payment module and it should be working with Wepay.

 

If you have issues contact me or post a comment.

Alright to get the WordPress Wepay Plugin working you will need API Access to Wepay. I decided to split this tutorial into part 1 and Part 2, Part 1 is how to get your API information and account id. Part 2 is the setup of the plugin. I’m only going into production mode. I don’t see the need to test it since the plugin has been tested. Also your plugin will not work till Wepay activates your API, if its pending, you will not be able to process transactions.

Lets get started.

 

Part 1. Getting your API information

1. First you will need to goto https://www.wepay.com/developer. That is the production site, which means you can start collecting money today.

2. Once you register you will need to go to the developer section again, click on “Your Apps”

3. Click on “Create an application”, fill out all the fields, and hit submit.

4. You now have registered a app with wepay, which will give you your client secret, access token.

5 . You will now need to create an account you want your money to go into. Click on the “Home” link at the top of the screen. This will bring you to your account home page. You can ether use an account you have created or create a new one. In this case I will use one I already have, so click on the one you want to use.

Once you have clicked on it, in the address bar on your browser will tell you your account number.

Example: https://www.wepay.com/group/view/<YOUR ACCOUNT NUMBER HERE>

Copy that number you have in your browser, you will need it later.

 

Part 2. Setting up the Plugin

1. Copy the folder “wepay-wordpress-plugin” into the plugin directory on your wordpress site.

2. Login and activate the WordPress Wepay Plugin

3. Once activated, you will see a new tab on your sidebar in the admin. Goto Wepay Manager > Wepay Settings

4. Set the follow:

  • Production mode to Production
  • Fill in your account ID, client id, client secret, and access token.
  • Thank you page – this has to be the direct link to the page you want your end users to see after the transaction has been completed. (i.e. http://www.mysite.com/thankqpage/)

Hit “Save Changes”

5. Now your hooked up to Wepay. Go to “Wepay Manager > Wepay Manager”

6. Read the information on how to use the short codes.

[wepay text="Buy Now" amount="1.00" sdesc="testing" css="buttoncss" feepayer="Payee"]

-With the short code we call on “wepay” as the short code itself.
“Text” is the value or what you want the button to say.
“amount” is amount you want to charge.
“sdesc” a short description of what you want to sell or the payee is donating for.
“css” is the css property you want to call on, otherwise if you do not it will just look like a link.
“feepayer” specifies who is going to pay for the fees for this transaction, you (Payee) or the purchaser (Payer). You must use “Payee” or “Payer”, anything else and it will not work.

7. Take your new short code and paste it on the page or post you want it on. Update the post or page and you should now have a Wepay Payment Button.

 

If you have any questions, post a comment.

Just about done with the WordPress Plugin, should be out this weekend yet.
What version 1.0 will do:

  • See you account balance
  • Create buttons for your users to make payments on using shortcodes. (Totally customizable, make the button any type.)
  • Settings Menu to control API information

IPN integration will not be in this version. Feel free to ask questions.

Its official, version 1.0 for both OsCommerce and Zen-Cart have been released. Both are designed to drag and drop right into the web installation. All you need is your API information and account ID.

You can download the OsCommerce version here: http://addons.oscommerce.com/info/8408

The Zen-Cart version is currently unavailable until they approve it from the add-ons site. For now you can download it from here directly. Download Zen-Cart Wepay Plugin

The regular checkout with Wepay is very simple and a little bit easier then the iframe method. You will need to download the Wepay SDK to use this method. Scroll to the end of this post and you will find a zip file with all the code in this tutorial plus the sdk file. This includes an IPN I wrote, it is identical to the one used in the iframe checkout. If you already have setup everything on Wepay (I.e. access token, client id, etc) go to step 6, otherwise start at the top.

Alright lets start with the checkout.

1. First you will need to go to https://stage.wepay.com/register. That is the staging site, which means you can run as many transactions through it for testing purposes only. You have to test your code in the staging environment before you can go live! You can also login if you already have login credentials to the staging site.

2. Once you register on the staging site you will want to go to this page: https://stage.wepay.com/developer/register

 

3. Select “Test Enviroment” to create an app for testing purposes only.

4. Now you will need to fill out the form with Application Name, Your home url (website url), and description of what your app will do when interacting with WePay. Read the entire terms of service before you check the box and submit.

5 . You should have a page with your API credentials which include:

– Account ID

– Access Token

– Client ID

– Client Secret

 

6. (This is only in PHP.) You will need the Wepay SDK. You can download it below. You will also need your client id, client secret, account id, and access token. All can be found on your applications registration page on WePay’s staging site. See the API Reference to find out what is required and what you can add to the call https://stage.wepay.com/developer/reference/checkout#create

<?php
//// Wepay API regular checkout
//// written by Alan Pinnt www.alanpinnt.com
//// 2012
 
require 'wepay.php';
 
$client_id = "<Your Client ID>";
$client_secret = "<Your Client Secret>";
$access_token = "<Your Client Token>";
$account_id = "<Your Accout ID>"; 
 
Wepay::useStaging($client_id, $client_secret);
$wepay = new WePay($access_token);
 
try {
$checkout = $wepay->request('/checkout/create', array(
'account_id' => $account_id, // ID of the account that you want the money to go to
'amount' => "1.00", // dollar amount you want to charge the user
'short_description' => "Short product description", // a short description of what the payment is for
'reference_id' => "123456", // A reference id for your application to use.
'type' => "GOODS", // the type of the payment - choose from GOODS SERVICE DONATION or PERSONAL
'mode' => "regular", // put iframe here if you want the checkout to be in an iframe, regular if you want the user to be sent to WePay
'fee_payer' => "Payee", // Here you put who is paying the fees you or your client. Payee = client, Payer = account holder
'redirect_uri' => "http://www.mysite.com/thanks.php", // The page where you want clients to go after the transaction is completed.
'callback_uri' => "http://www.mysite.com/wepayipn.php", // Location of the file that handles IPN requests
)
);
} catch (WePayException $e) { // if the API call returns an error, get the error message for display later
$error = $e->getMessage();}
header("Location: $checkout->checkout_uri"); ///redirect user to the payment page
?>

Make sure you put your access token, client id, client secret, and account id in the proper areas.

 

Step 7. The IPN file

<?php
//// Wepay IPN
//// written by Alan Pinnt www.alanpinnt.com
//// 2012
require 'wepay.php';
 
if (!empty($_POST['checkout_id'])) {$thecheckoutid = $_POST['checkout_id'];}
 
$client_id = "<Your Client ID>";
$client_secret = "<Your Client Secret>";
$access_token = "<Your Client Token>";
$account_id = "<Your Accout ID>"; 
 
/**
* Initialize the WePay SDK object
*/
Wepay::useStaging($client_id, $client_secret);
$wepay = new WePay($access_token);
 
/**
* Make the API request to get the checkout_uri
*
*/
try {
$checkout = $wepay->request('checkout', array(
'checkout_id' => $thecheckoutid, // ID of the account that you want the money to go to
)
);
} catch (WePayException $e) { // if the API call returns an error, get the error message for display later
$error = $e->getMessage();
}
 
///some things you might want to use. Delete this stuff otherwise///
print '<br /><br />';
print $checkout->short_description;
print '<br /><br />';
print $checkout->checkout_id;
print '<br /><br />';
print $checkout->reference_id;
print '<br /><br />';
print $checkout->gross;
print '<br /><br />';
print $checkout->payer_name;
////stop deleteing here///
 
	if ($checkout->state == "captured") {
	///do something here
        } elseif ($checkout->state == "authorized") {
	///do something here
        } elseif ($checkout->state == "cancelled") {
	///do something here
        } elseif ($checkout->state == "refunded") {
	///do something here
        } elseif ($checkout->state == "expired") {
	///do something here
        }
?>

You should now have working checkout with Wepay and have an IPN to update the payment status on your application.

Also if you have an error on your checkout that is similar to this:

SSL certificate problem, verify that the CA cert is OK. Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

Please see this post here to fix this issue.

All the code in this tutorial, click here to download all the files in this tutorial (Wepay SDK, checkout, and IPN)

SDK Download (wepay.php) : https://github.com/wepay/PHP-SDK/blob/master/wepay.php

Wepay API Reference Pages:

API Object States

Checkout API Calls

API Change Log

Feel free to comment and let me know if you need help.

*** UPDATED – 3/8/13 – Made changes since the site has changed so much since this was originally written. Also updated the downloadable zip of files with the latest WePay SDK.  ***

I have received a lot of email because of the wepay API tutorial I posted. To let everyone know, I’m working on posting a normal checkout as well. I have had a ton of requests for this and I will make sure I get it out this weekend.

As for the Oscommerce plugin, I’m almost done with it. I have some testing to do to confirm but it looks like it will release sooner then expected. I will post here as soon as the v1.0 rolls out.

Now that you have tested a working application in the staging environment its time to switch to production and go live. This is a fairly simple process but some things you have done in the staging environment you have to do again in the live environment. I’m assuming you already have signed up an production user account with Wepay, if not go do that first and setup an account for funds to go into.

1. In your account get the account number by clicking on the account.

Once you have clicked on it, in the address bar on your browser will tell you your account number.

Example: https://stage.wepay.com/group/view/<YOUR ACCOUNT NUMBER HERE>

Copy that number and save it for later.

2. Goto the developer section of wepay.com, https://www.wepay.com/developer

3 . Click on create an application just like you did on the staging site.

4. Fill in the form fields and submit the app. You will most likely wait a bit to get approval for your app. Not long but you can’t go live till its approved.

5. On the app page you will see, client id, client secret, and access token. Copy it and save it.

6. Go into your code where you have your access token, client id, and client secret. Swap out the staging stuff with the production stuff.

Example:

$client_id = "<SWAP HERE>";
$client_secret = "<SWAP HERE>";
$access_token = "<SWAP HERE>";
$account_id = "<SWAP HERE>";

If you used my iframe tutorial code make use you change the credentials on the iframe code and the IPN file.

7. Alright one more thing, assuming your using the SDK from wepay or you used the example tutorial I posted which uses Wepay’s SDK you will need to switch out some code. Find these lines:

Wepay::useStaging($client_id, $client_secret);
$wepay = new WePay($access_token);

And switch it to production by doing so:

Wepay::useProduction($client_id, $client_secret);
$wepay = new WePay($access_token);

You should now have a live working Wepay checkout. Feel free to contact me with questions.

When I was setting up a wepay Iframe checkout I got an error similar to this:

Failed: Error Number: 60. Reason: SSL certificate problem, verify that the CA cert is OK. Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

So I updated curl and restarted apache to find out that didn’t work. This is what I did, I set the CURLOPT_CAINFO parameter in the wepay.php SDK file. I added it in two places and downloaded the .pem file from here

curl_setopt($ch, CURLOPT_USERAGENT, 'WePay v2 PHP SDK v' . self::VERSION);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
		curl_setopt($ch, CURLOPT_TIMEOUT, 5); // 5-second timeout, adjust to taste
		curl_setopt($ch, CURLOPT_POST, TRUE);
		curl_setopt($ch, CURLOPT_CAINFO,  'to/this/file/cacert.pem');

And here:

curl_setopt($this->ch, CURLOPT_USERAGENT, 'WePay v2 PHP SDK v' . self::VERSION);
			curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, true);
			curl_setopt($this->ch, CURLOPT_HTTPHEADER, array("Authorization: Bearer $this->token", "Content-Type: application/json"));
			curl_setopt($this->ch, CURLOPT_CAINFO,  '/to/this/file/cacert.pem');

By doing this the error went away and it worked perfectly.

Download cacert.pem file