|
| 1 | +package main |
| 2 | + |
| 3 | +import ( |
| 4 | + "context" |
| 5 | + "fmt" |
| 6 | + "log" |
| 7 | + |
| 8 | + "github.com/parevo-lab/iyzipay-go" |
| 9 | +) |
| 10 | + |
| 11 | +func main() { |
| 12 | + // İyzipay client oluşturma |
| 13 | + client := iyzipay.NewClient(&iyzipay.Config{ |
| 14 | + APIKey: "sandbox-afXhZPW0MQlE4dCUUlHcEopnMBgXnAZI", |
| 15 | + SecretKey: "sandbox-wbwpzKIiplZxI3hh5ALI4FJyAcZKL6kq", |
| 16 | + BaseURL: "https://sandbox-api.iyzipay.com", |
| 17 | + }) |
| 18 | + |
| 19 | + ctx := context.Background() |
| 20 | + |
| 21 | + // Abonelik başlatmak için gerekli bilgiler |
| 22 | + request := &iyzipay.CreateSubscriptionInitRequest{ |
| 23 | + Locale: iyzipay.LocaleTR, |
| 24 | + ConversationID: "123456789", |
| 25 | + PricingPlanReferenceCode: "plan_ref_code", // Buraya İyzipay panelinden aldığınız plan kodunu girin |
| 26 | + SubscriptionInitialStatus: iyzipay.SubscriptionInitialStatusActive, |
| 27 | + Customer: &iyzipay.SubscriptionCustomer{ |
| 28 | + Name: "Ahmet", |
| 29 | + Surname: "Can", |
| 30 | + IdentityNumber: "12345678901", |
| 31 | + Email: "ahmet@email.com", |
| 32 | + GsmNumber: "+905555555555", |
| 33 | + BillingAddress: &iyzipay.SubscriptionAddress{ |
| 34 | + Address: "Adres", |
| 35 | + ZipCode: "34000", |
| 36 | + ContactName: "Ahmet Can", |
| 37 | + City: "İstanbul", |
| 38 | + Country: "Türkiye", |
| 39 | + District: "Kadıköy", |
| 40 | + }, |
| 41 | + ShippingAddress: &iyzipay.SubscriptionAddress{ |
| 42 | + Address: "Adres", |
| 43 | + ZipCode: "34000", |
| 44 | + ContactName: "Ahmet Can", |
| 45 | + City: "İstanbul", |
| 46 | + Country: "Türkiye", |
| 47 | + District: "Kadıköy", |
| 48 | + }, |
| 49 | + }, |
| 50 | + PaymentCard: &iyzipay.SubscriptionCard{ |
| 51 | + CardHolderName: "Ahmet Can", |
| 52 | + CardNumber: "5528790000000008", |
| 53 | + ExpireMonth: "12", |
| 54 | + ExpireYear: "2030", |
| 55 | + CVC: "123", |
| 56 | + }, |
| 57 | + } |
| 58 | + |
| 59 | + response, err := client.Subscription.Initialize(ctx, request) |
| 60 | + if err != nil { |
| 61 | + log.Fatalf("Abonelik başlatılamadı: %v", err) |
| 62 | + } |
| 63 | + |
| 64 | + fmt.Println("Abonelik Başlatıldı!") |
| 65 | + fmt.Printf("SubscriptionReferenceCode: %s\n", response.SubscriptionReferenceCode) |
| 66 | + fmt.Printf("Durum: %s\n", response.SubscriptionStatus) |
| 67 | + fmt.Printf("Başlangıç Tarihi: %s\n", response.StartDate) |
| 68 | + fmt.Printf("Bitiş Tarihi: %s\n", response.EndDate) |
| 69 | +} |
0 commit comments