mirror of
https://github.com/rjNemo/rentease.git
synced 2026-06-06 02:36:49 +00:00
Some checks failed
CI / checks (push) Has been cancelled
Refactored payment link creation to ensure booking_id is set in both the PaymentLink and PaymentIntent metadata. Extracted parameter building logic into a helper for improved testability. Added a unit test to verify metadata propagation.
28 lines
803 B
Go
28 lines
803 B
Go
package stripe
|
|
|
|
import "testing"
|
|
|
|
func TestBuildPaymentLinkCreateParamsSetsBookingMetadataOnPaymentIntent(t *testing.T) {
|
|
params, err := buildPaymentLinkCreateParams(CreatePaymentLinkParams{
|
|
Amount: 120.50,
|
|
Currency: "EUR",
|
|
BookingID: 42,
|
|
Description: "Villa booking",
|
|
PaymentMethodTypes: []string{"card"},
|
|
})
|
|
if err != nil {
|
|
t.Fatalf("unexpected error: %v", err)
|
|
}
|
|
|
|
if params.Metadata["booking_id"] != "42" {
|
|
t.Fatalf("payment link metadata missing booking id: %+v", params.Metadata)
|
|
}
|
|
|
|
if params.PaymentIntentData == nil {
|
|
t.Fatal("payment intent data should not be nil")
|
|
}
|
|
|
|
if params.PaymentIntentData.Metadata["booking_id"] != "42" {
|
|
t.Fatalf("payment intent metadata missing booking id: %+v", params.PaymentIntentData.Metadata)
|
|
}
|
|
}
|