Skip to content

Instantly share code, notes, and snippets.

View cjavilla-stripe's full-sized avatar

CJ Avilla cjavilla-stripe

View GitHub Profile
@cjavilla-stripe
cjavilla-stripe / webhooks.tsx
Created March 25, 2022 13:11
Handle Stripe webhooks in Remix
import Stripe from 'stripe'
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY)
export const action = async ({request}) => {
const secret = 'whsec_...' // process.env.WEBHOOK_SIGNING_SECRET
const sig = request.headers.get('stripe-signature')
let event;
const payload = await request.text()
@cjavilla-stripe
cjavilla-stripe / tailwind-issuing-elements.html
Created August 12, 2022 21:27
Tailwind CSS to build a visualization for Stripe Issuing Elements
<div class="w-96 h-56 m-auto bg-red-100 rounded-xl relative text-white shadow-2xl transition-transform transform hover:scale-110">
<div class="relative object-cover w-full h-full rounded-xl bg-gradient-to-r from-teal-400 to-blue-400" ></div>
<div class="w-full px-8 absolute top-8">
<div class="flex justify-between">
<div>
<span class="font-light">Name</span>
<p id="cardholder-name" class="font-medium tracking-widest">
Jenny Rosen
</p>
</div>
@cjavilla-stripe
cjavilla-stripe / Program.cs
Created December 27, 2021 17:46
Stripe webhook handler for .NET 6 minimal API
using Stripe;
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();
app.MapPost("/webhook", async (HttpRequest request) =>
{
var json = await new StreamReader(request.Body).ReadToEndAsync();
const string signingSecret = "whsec_...";
@cjavilla-stripe
cjavilla-stripe / payment_intent.succeeded.with_customer.json
Created July 6, 2020 18:45
Fixture for firing payment_intent.succeeded with Customer.
{
"_meta": {
"template_version": 0
},
"fixtures": [
{
"name": "customer",
"path": "/v1/customers",
"method": "post",
"params": {
@cjavilla-stripe
cjavilla-stripe / index.php
Created December 11, 2020 19:11
Simple one button Checkout with php
<?php
require_once('vendor/autoload.php');
\Stripe\Stripe::setApiKey('sk_test_...');
$session = \Stripe\Checkout\Session::create([
'payment_method_types' => ['card'],
'line_items' => [[
'price_data' => [
'currency' => 'usd',
@cjavilla-stripe
cjavilla-stripe / value-based-saas-pricing-seed.json
Last active January 28, 2023 14:46
Stripe CLI fixture for creating value based pricing Stripe test data
{
"_meta": {
"template_version": 0
},
"fixtures": [
{
"name": "startup_product",
"path": "/v1/products",
"method": "post",
"params": {
@app.route('/create-checkout-session', methods=['POST'])
def create_checkout_session():
try:
checkout_session = stripe.checkout.Session.create(
line_items=[
{
'price': '<hard code your price ID here>',
'quantity': 1,
},
],
#card-back {
position: relative;
width: 384px;
height: 244px;
background-image: url("/assets/card-back.png");
background-size: 100%;
background-repeat: no-repeat;
}
#card-details {
require 'stripe'
Stripe.api_key = ENV['STRIPE_SECRET_KEY']
def date_description(dates)
end
def next_dates
# some database stuff
[start_date, end_date]
end
const stripe = require('stripe')(process.env.STRIPE_SECRET_KEY);
/*
* Next available dates loaded from some database
*/
const calendar = require('./data/calendar.json');
exports.handler = async (event) => {
const nextDates = getNextDates(calendar)
const { startDate, endDate } = nextDates;