Skip to content

Instantly share code, notes, and snippets.

View EduardoIbarra's full-sized avatar
💭
Always learning new things

EduardoIbarra EduardoIbarra

💭
Always learning new things
View GitHub Profile
@EduardoIbarra
EduardoIbarra / PaymentController.php
Created March 15, 2024 12:20
Example of stripe integration with webhooks
public function handle_webhookOwnAccounts(Request $request)
{
\Stripe\Stripe::setApiKey(env('STRIPE_SECRET'));
// Retrieve the request body and signature header
$payload = $request->getContent();
$sigHeader = $request->header('Stripe-Signature');
$endpointSecret = env('STRIPE_WEBHOOK_OWN_SECRET');
@EduardoIbarra
EduardoIbarra / home.ts
Created July 23, 2018 14:58
merge en home.ts
import {Component, ElementRef, ViewChild} from '@angular/core';
import {IonicPage, ModalController, NavController, NavParams} from 'ionic-angular';
import {LoadingService} from "../../services/loading.service";
import {GymService} from "../../services/gym.service";
import {Geolocation} from '@ionic-native/geolocation';
import {AlertService} from "../../services/alert.service";
import {SharedService} from "../../services/shared.service";
import {PaymentService} from "../../services/payment.service";
declare var google: any;
...
import { ServiceWorkerModule } from '@angular/service-worker';
...
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
ServiceWorkerModule.register('/ngsw-worker.js', { enabled: environment.production })
{
...
"dynamic": {
"group": [
{
"name": "guides",
"urls": {
"/generated/docs/guide": { "match": "prefix" }
},
"cache": {
// ngsw-manifest.json
{
...
"routing": {
"index": "/index.html",
"routes": {
"/blog": {
"prefix": "true" // match '/blog*'
}
}
// ngsw-manifest.json
{
...
"external": {
"urls": [
{ "url": "https://fonts.googleapis.com/css?family=..." },
{ "url": "https://fonts.gstatic.com/s/materialicons/..." }
]
}
}
// ngsw-manifest.json
{
"static": {
"index.html": "9cd2a887...",
"main.bundle.js": "1cab6cf...",
"main.css": "c0ee6a6..."
},
...
}
<!doctype html>
<html>
...
<body>
<aio-shell></aio-shell>
<script src="polyfills.{HASH}.bundle.js"></script>
<script src="sw-register.{HASH}.bundle.js"></script>
<script src="main.{HASH}.bundle.js"></script>
</body>
</html>
// .angular-cli.json
{
...
"apps": [
{
...
"serviceWorker": "true"
}
]
}
self.addEventListener('activate', event => {
const cacheWhitelist = ['nombre-cache-v2'];
event.waitUntil(
caches.keys().then(cacheNames => Promise.all(
cacheNames.map(cacheName => {
if (cacheWhitelist.indexOf(cacheName === -1)) {
return caches.delete(cacheName);
}
})