Zapier fixes

This commit is contained in:
Hillel Coren 2015-10-02 11:32:13 +03:00
parent 04dfaf9b49
commit 6d7f0d6611
9 changed files with 47 additions and 10 deletions

View File

@ -97,7 +97,11 @@ class AccountGatewayController extends BaseController
$data['url'] = 'gateways'; $data['url'] = 'gateways';
$data['method'] = 'POST'; $data['method'] = 'POST';
$data['title'] = trans('texts.add_gateway'); $data['title'] = trans('texts.add_gateway');
$data['selectGateways'] = Gateway::where('payment_library_id', '=', 1)->where('id', '!=', GATEWAY_PAYPAL_EXPRESS)->where('id', '!=', GATEWAY_PAYPAL_EXPRESS)->orderBy('name')->get(); $data['selectGateways'] = Gateway::where('payment_library_id', '=', 1)
->where('id', '!=', GATEWAY_PAYPAL_EXPRESS)
->where('id', '!=', GATEWAY_BITPAY)
->where('id', '!=', GATEWAY_DWOLLA)
->orderBy('name')->get();
$data['hiddenFields'] = Gateway::$hiddenFields; $data['hiddenFields'] = Gateway::$hiddenFields;
return View::make('accounts.account_gateway', $data); return View::make('accounts.account_gateway', $data);

View File

@ -13,10 +13,11 @@ class IntegrationController extends Controller
$eventId = Utils::lookupEventId(trim(Input::get('event'))); $eventId = Utils::lookupEventId(trim(Input::get('event')));
if (!$eventId) { if (!$eventId) {
return Response::json('', 500); return Response::json('Event is invalid', 500);
} }
$subscription = Subscription::where('account_id', '=', Auth::user()->account_id)->where('event_id', '=', $eventId)->first(); $subscription = Subscription::where('account_id', '=', Auth::user()->account_id)
->where('event_id', '=', $eventId)->first();
if (!$subscription) { if (!$subscription) {
$subscription = new Subscription(); $subscription = new Subscription();
@ -27,6 +28,10 @@ class IntegrationController extends Controller
$subscription->target_url = trim(Input::get('target_url')); $subscription->target_url = trim(Input::get('target_url'));
$subscription->save(); $subscription->save();
if (!$subscription->id) {
return Response::json('Failed to create subscription', 500);
}
return Response::json('{"id":'.$subscription->id.'}', 201); return Response::json('{"id":'.$subscription->id.'}', 201);
} }
} }

View File

@ -368,7 +368,8 @@ class PaymentController extends BaseController
'message' => $affiliate->payment_subtitle, 'message' => $affiliate->payment_subtitle,
'license' => $licenseKey, 'license' => $licenseKey,
'hideHeader' => true, 'hideHeader' => true,
'productId' => $license->product_id 'productId' => $license->product_id,
'price' => $affiliate->price,
]; ];
$name = "{$license->first_name} {$license->last_name}"; $name = "{$license->first_name} {$license->last_name}";

View File

@ -599,7 +599,6 @@ class Utils
public static function notifyZapier($subscription, $data) public static function notifyZapier($subscription, $data)
{ {
$curl = curl_init(); $curl = curl_init();
$jsonEncodedData = json_encode($data->toPublicArray()); $jsonEncodedData = json_encode($data->toPublicArray());
$opts = [ $opts = [
@ -635,14 +634,23 @@ class Utils
return $return; return $return;
} }
public static function hideIds($data) public static function hideIds($data, $mapped = false)
{ {
$publicId = null; $publicId = null;
if (!$mapped) {
$mapped = [];
}
foreach ($data as $key => $val) { foreach ($data as $key => $val) {
if (is_array($val)) { if (is_array($val)) {
$data[$key] = Utils::hideIds($val); if ($key == 'account' || isset($mapped[$key])) {
} else if ($key == 'id' || strpos($key, '_id')) { unset($data[$key]);
} else {
$mapped[$key] = true;
$data[$key] = Utils::hideIds($val, $mapped);
}
} elseif ($key == 'id' || strpos($key, '_id')) {
if ($key == 'public_id') { if ($key == 'public_id') {
$publicId = $val; $publicId = $val;
} }

View File

@ -13,6 +13,7 @@ class Account extends Eloquent
{ {
use SoftDeletes; use SoftDeletes;
protected $dates = ['deleted_at']; protected $dates = ['deleted_at'];
protected $hidden = ['ip'];
/* /*
protected $casts = [ protected $casts = [

View File

@ -24,7 +24,6 @@ class AddZapierSupport extends Migration {
$table->string('target_url'); $table->string('target_url');
$table->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade'); $table->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade');
$table->unique( ['account_id', 'event_id'] );
}); });
} }

View File

@ -123,6 +123,7 @@
success: function(result) { success: function(result) {
if (result) { if (result) {
localStorage.setItem('guest_key', ''); localStorage.setItem('guest_key', '');
fbq('track', 'CompleteRegistration');
trackEvent('/account', '/signed_up'); trackEvent('/account', '/signed_up');
NINJA.isRegistered = true; NINJA.isRegistered = true;
$('#signUpButton').hide(); $('#signUpButton').hide();
@ -164,6 +165,7 @@
NINJA.proPlanFeature = ''; NINJA.proPlanFeature = '';
function showProPlan(feature) { function showProPlan(feature) {
$('#proPlanModal').modal('show'); $('#proPlanModal').modal('show');
fbq('track', 'InitiateCheckout');
trackEvent('/account', '/show_pro_plan/' + feature); trackEvent('/account', '/show_pro_plan/' + feature);
NINJA.proPlanFeature = feature; NINJA.proPlanFeature = feature;
} }
@ -178,6 +180,7 @@
@if (Auth::check() && !Auth::user()->isPro()) @if (Auth::check() && !Auth::user()->isPro())
function submitProPlan() { function submitProPlan() {
fbq('track', 'AddPaymentInfo');
trackEvent('/account', '/submit_pro_plan/' + NINJA.proPlanFeature); trackEvent('/account', '/submit_pro_plan/' + NINJA.proPlanFeature);
if (NINJA.isRegistered) { if (NINJA.isRegistered) {
$.ajax({ $.ajax({

View File

@ -63,6 +63,21 @@
</script> </script>
<!-- Facebook Pixel Code -->
<script>
!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;
n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,
document,'script','//connect.facebook.net/en_US/fbevents.js');
fbq('init', '{{ env('FACEBOOK_PIXEL') }}');
fbq('track', "PageView");</script>
<noscript><img height="1" width="1" style="display:none"
src="https://www.facebook.com/tr?id=770151509796760&ev=PageView&noscript=1"
/></noscript>
<!-- End Facebook Pixel Code -->
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries --> <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script> <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>

View File

@ -112,6 +112,7 @@ header h3 em {
<script type="text/javascript"> <script type="text/javascript">
$(function() { $(function() {
fbq('track', 'Purchase', {value: '{{ $price }}', currency: 'USD'});
trackEvent('/license', '/product_{{ $productId }}'); trackEvent('/license', '/product_{{ $productId }}');
@if (isset($redirectTo)) @if (isset($redirectTo))