amount := int64(1299)
currency := "USD"
country := "US"
method := components.RedirectPaymentMethodCreateMethodCashappafterpay
redirectUrl := "https://example.com/callback"
redirectPaymentMethodCreate := components.RedirectPaymentMethodCreate{
Method: method,
Country: country,
Currency: currency,
RedirectURL: redirectUrl,
}
paymentMethod := components.CreateTransactionCreatePaymentMethodRedirectPaymentMethodCreate(redirectPaymentMethodCreate)
buyer := components.GuestBuyer{
BillingDetails: &components.BillingDetails{
FirstName: gr4vy.String("John"),
LastName: gr4vy.String("Doe"),
EmailAddress: gr4vy.String("john.doe@example.com"),
Address: &components.Address{
Line1: gr4vy.String("1 Market Street"),
City: gr4vy.String("San Francisco"),
State: gr4vy.String("CA"),
PostalCode: gr4vy.String("94105"),
Country: gr4vy.String("US"),
},
},
}
transactionCreate := components.TransactionCreate{
Amount: amount,
Currency: currency,
Country: &country,
Intent: gr4vy.Pointer(components.TransactionIntentCapture),
PaymentMethod: &paymentMethod,
Buyer: &buyer,
CartItems: []components.CartItem{
{
Name: "Example Product",
Quantity: 1,
UnitAmount: 1299,
},
},
}
transaction, err := client.Transactions.Create(ctx, transactionCreate, nil, nil, nil)