Skip to content

Commit

Permalink
added customer to the example
Browse files Browse the repository at this point in the history
  • Loading branch information
EdwinPB committed Jul 31, 2024
1 parent ce8674d commit b75dd5b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
Binary file modified bin/app
Binary file not shown.
21 changes: 21 additions & 0 deletions internal/element/payment_intent.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"log"
"net/http"
"os"
"stripe-cop/internal/customer"
"stripe-cop/internal/model"

"github.com/stripe/stripe-go/v79"
"github.com/stripe/stripe-go/v79/paymentintent"
Expand All @@ -33,6 +35,25 @@ func HandleCreatePaymentIntent(w http.ResponseWriter, r *http.Request) {
Description: stripe.String("One-time payment example, using Stripe element"),
}

info := model.PaymentInfo{
Amount: amount,
CardHolder: "Edwin Polo",
Email: "[email protected]",

BillingLine: "Theo Parker 123 Pike ST",
BillingCity: "Seatle",
BillingState: "WA",
BillingZip: "98122",
BillingCountry: "United States",
}
c, err := customer.CreateCustomer(info)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
log.Printf("pi.New: %v", err)
return
}
params.Customer = stripe.String(c)

pi, err := paymentintent.New(params)
log.Printf("pi.New: %v", pi.ClientSecret)

Expand Down
2 changes: 1 addition & 1 deletion internal/paymentintent/s_charge_two.html
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ <h3 class="mt-4 text-lg font-medium text-gray-900">Gopher Toy</h3>
<div class="w-full mx-auto rounded-lg bg-white border border-gray-200 p-5 text-gray-800 font-light mb-6">
<div class="w-full flex mb-3 items-center">
<span class="text-gray-600 font-semibold w-32">Contact</span>
<span class="text-sm">Edwin Polo</span>
<span class="text-sm">Javier Hernandez</span>
</div>

<div class="w-full flex mb-3 items-center">
Expand Down

0 comments on commit b75dd5b

Please sign in to comment.