IPN

218 views
Skip to first unread message

Chase McAleese

unread,
Jan 28, 2012, 4:39:45 PM1/28/12
to wepay-api
Hi again,

I have almost completely integrated WePay into my site, but the last
thing I need to do is set up a checkout IPN so that when the status
changes to "captured" I can update my database.

The checkout json that I am sending with curl sends me to the checkout
page, and when I return I have all the information I need, but the
problem is that when the checkout status changes, the uri I supplied
for callback doesn't get visited. I use the php mail function on the
page that is supposed to be visited on callback, but the mail never
sends and my database never gets updated when the status changes.

Here is the code I use to send the checkout/create/:

//this is the array that I will JSON encode and send with curl
$arr = array('account_id'=>172777, "short_description"=>"This payment
will add $$amount to your business account balance.",
"type"=>"SERVICE", "reference_id"=>"$referenceId",
"amount"=>"$amount", "redirect_uri"=>"http://www.mysite.com/
process.php", "callback_uri"=>"http://www.mysite.com/callback/
businessCallback.php", "auto_capture"=>"true");


$sendThis = json_encode($arr);
//create a new disbursement call
$ch = curl_init('https://stage.wepayapi.com/v2/checkout/create'); //
the URL of the call


curl_setopt($ch, CURLOPT_HTTPHEADER,array('Authorization: Bearer
myToken', 'Content-Type: application/json'));

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);

curl_setopt($ch, CURLOPT_POSTFIELDS, $sendThis);

// execute the api call
$result = curl_exec($ch);
// echo the json response
$decoded = json_decode($result, true);

$redirect = $decoded['checkout_uri'];


header("Location: $redirect");



========================================================================

Here is the code I use on the page that is supposed to be posted to
when the status changes:

//I use mail to see if the page is visited
mail("m...@myemail.com","payment callback", "callback has happened");

// am i supposed to use GET or POST here?
$checkoutId = $_GET['checkout_id'];

$ch = curl_init('https://stage.wepayapi.com/v2/checkout');

$arguments = array(
"checkout_id"=>$checkoutId
);


$sendThis = json_encode($arguments);



curl_setopt($ch, CURLOPT_HTTPHEADER,array('Authorization: Bearer
myToken', 'Content-Type: application/json'));

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);

curl_setopt($ch, CURLOPT_POSTFIELDS, $sendThis);

// execute the api call
$result = curl_exec($ch);
// echo the json response
$decoded = json_decode($result, true);



$state = $decoded['state'];
$referenceId = $decoded['reference_id'];

//I then update my database here





Does anyone have any idea why the callback never seems to happen?

Thanks so much,
Chase

Andrew LeBlanc

unread,
Jan 28, 2012, 8:44:59 PM1/28/12
to wepay-api
Hi Chase,

I see us making the IPN requests to the callback_uri that you
specified, but we are receiving 408 HTTP status code as a response,
which indicates that the request timed out. This could be caused by
any number of things on your end. Also note that if your callback_uri
isn't publicly accessible on the internet, we won't be able to send
IPNs to it.

To try and diagnose the problem, you can simulate IPNs by putting the
callback_uri in your browser with the checkout_id as a url parameter.

Andrew

Chase McAleese

unread,
Jan 29, 2012, 3:02:30 AM1/29/12
to wepay-api
Hi Andrew,

Thanks for the reply.

I have tested the callback_uri by putting in a checkout_id in the url,
and the page works as expected. However, I still don't seem to be
getting any callbacks. I have checked everything I can think of and it
just isn't working. The page is on a server connected to the internet,
there are no passwords/sessions required to reach the page, and
everything works if I do it manually. The uri I am sending is
definitely the correct one, but it just seems like it is never
accessed unless I do it manually.

Any other ideas? Could it be because I am doing this on stage.wepay?

I'm stuck.

Thanks for the help,
Chase

Alan Pinnt

unread,
Apr 5, 2012, 3:21:43 AM4/5/12
to wepa...@googlegroups.com
Still looking for help on that IPN?

I have a working IPN with wepay in PHP. Respond and Ill post the solution.

steve blackwood

unread,
Apr 5, 2012, 7:45:20 AM4/5/12
to wepa...@googlegroups.com
hi alan,

i'd love to test it. i have a live site i have not built yet (zencart)
so i can play with it..

steve

Alan Pinnt

unread,
Apr 6, 2012, 8:44:47 PM4/6/12
to wepay-api
I have a working iframe in php with the IPN.

I will have a oscommerce and probably a zencart plugin this weekend.
Not 100% sure the difference between the payment modules with os and
zencart. I know zencart is based off of oscommerce, so I would assume
its identical or needs little work. I will have a Oscommerce plugin by
the end of this weekend for sure.

For now see my blog, I have a 100% complete tutorial on how to set up
a iframe checkout with wepay and the IPN. I'm currently in production
use, so I know it works.

http://www.alanpinnt.com/2012/04/06/wepay-iframe-checkout-api-tutorial/

Alan


On Apr 5, 6:45 am, steve blackwood <nowne...@gmail.com> wrote:
> hi alan,
>
> i'd love to test it. i have a live site i have not built yet (zencart)
> so i can play with it..
>
> steve
>

Alan Pinnt

unread,
Apr 9, 2012, 7:46:16 PM4/9/12
to wepay-api
Hey Steve,

I posted version 1.0 plugin to wepay. Its on OsCommerce contribuitions
site. Ill have a zencart version tonight yet.

http://www.alanpinnt.com/wepay-oscommerce-plugin/

Or

http://addons.oscommerce.com/info/8408

Alan

On Apr 5, 6:45 am, steve blackwood <nowne...@gmail.com> wrote:
> hi alan,
>
> i'd love to test it. i have a live site i have not built yet (zencart)
> so i can play with it..
>
> steve
>

aakash

unread,
Sep 6, 2012, 4:02:42 AM9/6/12
to wepa...@googlegroups.com



Hi everyone,

I have almost completely integrated WePay into my site, but the last
thing I need to do is set up a checkout IPN so that when the status
changes to "captured" I can update my database.
 
this is my codefor checkout.php
<?php
//// Wepay API regular checkout
//// written by Alan Pinnt www.alanpinnt.com
//// 2012

require 'wepay.php';
 
$client_id = "13589";
$client_secret = "1ad42c2dfd";
$access_token = "29d9018a124745d8df4c1062a49b9395517a4e705ef70559e2ea8f638419d6e8";
$account_id = "1791406";
 
Wepay::useStaging($client_id, $client_secret);
$wepay = new WePay($access_token);
 
try {
$checkout = $wepay->request('/checkout/create', array(
//'checkout_id'=> '12345',
'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' => "test", // a short description of what the payment is for
'reference_id' => "123456", // A reference id for your application to use.
'type' => "SERVICE", // 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/manoj_emts/checkout/sucess.php", // The page where you want clients to go after the transaction is completed.
'callback_uri' => "http://www.mysite.com/manoj_emts/checkout/wepayipn.php", // Location of the file that handles IPN requests
'auto_capture' =>"true"));


//print_r($checkout);exit();
} 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
?>
and in success page just displayin the message successed
and in my callback_uri i had given the my url but it doesnt need it over here for just payment it complete the payment section but i need to visited my wepayipn.php where my code is like this

<?php
//// Wepay IPN
//// written by Alan Pinnt www.alanpinnt.com
//// 2012
//echo('stop');exit;
require 'wepay.php';
 
if (!empty($_POST['checkout_id'])) {$thecheckoutid = $_POST['checkout_id'];}
 
$client_id = "13589";
$client_secret = "1ad42c2dfd";
$access_token = "29d9018a124745d8df4c1062a49b9395517a4e705ef70559e2ea8f638419d6e8";
$account_id = "1791406";
 
/**
* 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") {
    print_r($checkout);exit;
    ///do something here
        } elseif ($checkout->state == "authorized") {
            echo('sorry i didnt');exit;
    ///do something here
        } elseif ($checkout->state == "cancelled") {
            echo('hello there');exit;
    ///do something here
        } elseif ($checkout->state == "refunded") {
            echo('bye there');exit;
    ///do something here
        } elseif ($checkout->state == "expired") {
            echo('hi there');exit;
    ///do something here
        }
?>
this is wepayipn.php i want to write my code after  checkout state is captured but my callback_uri is not visited over here how to make visited please reply me


thanx in advance


aakash

unread,
Sep 10, 2012, 7:16:09 AM9/10/12
to wepa...@googlegroups.com
same problem here did you solve it
Reply all
Reply to author
Forward
0 new messages