- Removed Stripe libs from composer requirements

- Checkout and refunds now use Omnipay
This commit is contained in:
Dave 2016-03-07 17:18:55 +00:00
parent b4efd67257
commit ce50408b7e
3 changed files with 87 additions and 70 deletions

View File

@ -23,13 +23,12 @@ use Redirect;
use Request;
use Response;
use Session;
use Stripe;
use Stripe_Charge;
use Stripe_Customer;
use Validator;
use View;
use Omnipay;
class EventCheckoutController extends Controller
{
protected $is_embedded;
@ -474,4 +473,12 @@ class EventCheckoutController extends Controller
return View::make('Public.ViewEvent.Partials.PDFTicket', $data);
}
public function handleStripePayment() {
}
public function handlePaypalPayment() {
}
}

View File

@ -12,10 +12,9 @@ use Input;
use Log;
use Mail;
use Response;
use Stripe;
use Stripe_Charge;
use Validator;
use View;
use Omnipay;
class EventOrdersController extends MyBaseController
{
@ -130,30 +129,50 @@ class EventOrdersController extends MyBaseController
$error_message = 'The maximum amount you can refund is ' . (money($order->organiser_amount - $order->amount_refunded, $order->event->currency->code));
}
if (!$error_message) {
# @todo - remove the code repetition here
try {
Stripe::setApiKey($order->account->stripe_api_key);
$charge = Stripe_Charge::retrieve($order->transaction_id);
$gateway = Omnipay::gateway('stripe');
$gateway->initialize([
'apiKey' => $order->account->stripe_api_key
]);
if ($refund_type === 'full') { /* Full refund */
$refund_amount = $order->organiser_amount - $order->amount_refunded;
$refund = $charge->refund([
'refund_application_fee' => floatval($order->booking_fee) > 0 ? true : false,
$request = $gateway->refund([
'transactionReference' => $order->transaction_id,
'amount' => $refund_amount,
'refundApplicationFee' => floatval($order->booking_fee) > 0 ? true : false
]);
$response = $request->send();
if ($response->isSuccessful()) {
/* Update the event sales volume*/
$order->event->decrement('sales_volume', $refund_amount);
$order->is_refunded = 1;
$order->amount_refunded = $order->organiser_amount;
$order->order_status_id = config('attendize.order_refunded');
} else {
$error_message = $response->getMessage();
}
} else { /* Partial refund */
$refund = $charge->refund([
'amount' => $refund_amount * 100,
'refund_application_fee' => floatval($order->booking_fee) > 0 ? true : false,
$refund = $gateway->refund([
'transactionReference' => $order->transaction_id,
'amount' => floatval($refund_amount),
'refundApplicationFee' => floatval($order->booking_fee) > 0 ? true : false,
]);
$response = $refund->send();
if ($response->isSuccessful()) {
/* Update the event sales volume*/
$order->event->decrement('sales_volume', $refund_amount);
@ -165,24 +184,16 @@ class EventOrdersController extends MyBaseController
}
$order->is_partially_refunded = 1;
} else {
$error_message = $response->getMessage();
}
$order->amount_refunded = round($refund->amount_refunded / 100, 2);
}
$order->amount_refunded = round(($order->amount_refunded + $refund_amount), 2);
$order->save();
} catch (\Stripe_InvalidRequestError $e) {
} catch (\Exeption $e) {
Log::error($e);
$error_message = 'There has been a problem processing your refund. Please check your information and try again.';
} catch (\Stripe_AuthenticationError $e) {
Log::error($e);
$error_message = 'There has been a problem processing your refund. Please try again.';
} catch (\Stripe_ApiConnectionError $e) {
Log::error($e);
$error_message = 'There has been a problem processing your refund. Please try again.';
} catch (\Stripe_Error $e) {
Log::error($e);
$error_message = 'There has been a problem processing your refund. Please try again.';
} catch (Exception $e) {
Log::error($e);
$error_message = 'There has been a problem processing your refund. Please try again.';
}
}

View File

@ -9,7 +9,6 @@
"laravel/framework": "5.1.20",
"illuminate/html": "~5.0",
"milon/barcode": "dev-master",
"stripe/stripe-php": "1.*",
"iron-io/iron_mq": "2.*",
"intervention/image": "dev-master",
"nitmedia/wkhtml2pdf": "dev-master",