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.

Wepay, a great alternative to PayPal. They’re support at Wepay is phenomenal which in itself is a great reason to work with wepay. The API at wepay is very simple to use. In this case I have been using their SDK which makes the development much faster! In this tutorial I will show you the code to setup a iframe wepay checkout and an IPN to update your application database. I have attached a zip file of all the code ready to be used.

Alright lets start with the checkout.

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

2. Once you register on the staging site 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://stage.wepay.com/group/view/<YOUR ACCOUNT NUMBER HERE>

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

6. Alright now to the code. I have only set this up in PHP so when I get a chance I will do it in other languages. Keep in mind, you will need the Wepay SDK. You can download it below. You will also need your client id, client secret and access token. All can be found on your applications registration page on Wepay’s staging site. Your account id is the account you want to have the funds into, which you should have that account number from a minute ago.

require 'includes/wepay.php';
 
$client_id = "<YOUR CLIENT ID>";
$client_secret = "<YOUR CLIENT SECRET>";
$access_token = "<YOUR ACCESS TOKEN";
$account_id = "<YOUR ACCOUNT 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' => "Order id you want", // A reference id for your application to use.
'type' => "GOODS", // the type of the payment - choose from GOODS SERVICE DONATION or PERSONAL
'mode' => "iframe", // 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();
}

Where ever you want to display your Wepay iframe, here is the additional code you will need.

<div id="checkout_div"></div>

Before the </body> Place this javascript there.

<script type="text/javascript" src="https://stage.wepay.com/js/iframe.wepay.js"> </script>
<script type="text/javascript"> WePay.iframe_checkout("checkout_div", "<?php echo $checkout->checkout_uri ?>"); </script>

You now have a working Iframe checkout from Wepay. Next we will work on the IPN.

7. Here is the code you will need for your IPN:

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
        }

Pretty self explanatory, if you need more API object states, click here to see them all with explainations.

Now you have a working IPN and Iframe checkout in the staging environment. In my next tutorial I will post how to switch from staging to production.

Also if you have an error on your iframe 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 the IPN and Iframe Checkout with the SDK wepay file.

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.