I need to handle a coinbase callback. I am using Route::any() to then use a specified controller method. However, it wants the user to login. Is there a way to bypass this just within the route::any() method rather than trying to struggle through the source? I don't usually use laravel, but my customer wanted me to modify his code to include a coinbase payment gateway. So, I don't really know where everything is because I wasn't able to contact the last developer. Hopefully you all can help... Ok, Here we go.
My controller doesn't inherently use auth:: or anything of the sorts.
Here is the method called when going to the link:
public function getCoinbaseProcess() {
$return_code = 200;
$response = true;
$err = "";
$data = json_decode(file_get_contents('php://input'), TRUE);
$id = intval($data['custom']);
$thisUserPackage = UserPackage::find($id);
if(count($thisUserPackage) == 0) {
$response = false;
$err .= "PACKAGE NOT FOUND | ".$order->id;
}
//Make sure the amount is the same.
if($thisUserPackage->price!=($data['total_native']['cents']/100)){
$response = false;
$err .= "NOT FULLY PAID | PAYMENT ID: ".$order->id;
}
//Make sure the currency is the same.
if($data['total_native']['currency_iso']!="USD"){
$response = false;
$err .= "NOT THE SAME CURRENCY | ".$data['total_native']['currency_iso'];
}
if($response && $data['order']['status']=="completed") {
$thisUserPackage->activated = 1;
$thisUserPackage->transaction_data = json_encode($data);
$thisUserPackage->transaction_id = "COINBASE: ".$data['order']['id'];
$thisUserPackage->fee = 0.00;
$license = "";
while($license == "") {
$newLicense = strtoupper(mySettings::get('companyName').sha1(Hash::make(time().microtime().mySettings::get('companyName').$token.$thisUserPackage->package_name)).packageTool::getProductName($thisUserPackage->product_id));
if(count(UserPackage::where('license_key', '=', $newLicense)->get()) == 0) {
$license = $newLicense;
}
}
$thisUserPackage->license_key = $license;
$thisUserPackage->save();
Event::fire('user.package.activated', array($thisUserPackage->user_id, $thisUserPackage->id));
} else {
myLogs::newLog('CoinBase CRITICAL ERROR ON PAYMENT: '.$err, 2);
}
return $return_code;
}
my routing for this:
Route::any('/callback/coinbase', array('before' => 'guest', 'uses' => 'shopController@getCoinbaseProcess'));
I have a feeling it might be a route:when() or something, but I'm not sure how to allow access to that page to everyone (specifically cURL or derivatives). Any help would be appreciated. I only have a slight suspicion that somewhere in the source there is a filter that has all /* routes some filter. I've been experimenting with cURL, and other pages that only open view DO work in this fashion, so it has to be something to do with the controller.
I can supply more information, you just need to ask for it.
Thanks,
With the help of carbonphyber in the IRC, I was able to figure out the issue. It was a simple route::filter issue.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community