-
-
Notifications
You must be signed in to change notification settings - Fork 37
11 Captures examples
Victor Hugo Avelar Ossorio edited this page Mar 3, 2024
·
1 revision
package main
import (
"context"
"log"
"github.com/VictorAvelar/mollie-api-go/v4/mollie"
)
func main() {
config := mollie.NewAPITestingConfig(true)
client, err := mollie.NewClient(nil, config)
if err != nil {
log.Fatal(err)
}
ctx := context.Background()
paymentID := "tr_example_payment_id"
response, capture, err := client.Captures.Create(ctx, paymentID, createCapture())
if err != nil {
log.Fatal(err)
}
log.Println(response.Body)
log.Println(capture)
}
func createCapture() mollie.CreateCapture {
return mollie.CreateCapture{
Description: "example capture",
Metadata: map[string]any{"order_id": "1234"},
Amount: &mollie.Amount{
Value: "20.00",
Currency: "EUR",
},
}
}
package main
import (
"context"
"log"
"github.com/VictorAvelar/mollie-api-go/v4/mollie"
)
func main() {
config := mollie.NewAPITestingConfig(true)
client, err := mollie.NewClient(nil, config)
if err != nil {
log.Fatal(err)
}
ctx := context.Background()
paymentID := "tr_example_payment_id"
response, captures, err := client.Captures.List(ctx, paymentID, &mollie.CaptureOptions{
Embed: []mollie.EmbedValue{mollie.EmbedPayment},
})
if err != nil {
log.Fatal(err)
}
log.Println(response.Body)
for _, capture := range captures.Embedded.Captures {
log.Println(capture)
}
}