Skip to content

ozgur-yalcin/posnet.go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

96 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

license documentation

Posnet.go

Yapı Kredi (Posnet) POS API with golang

Installation

go get github.com/ozgur-yalcin/posnet.go

Satış

package main

import (
	"context"
	"encoding/xml"
	"fmt"

	posnet "github.com/ozgur-yalcin/posnet.go/src"
)

// Üye işyeri bilgileri
const (
	envmode  = "TEST"       // Çalışma ortamı (Production : "PROD" - Test : "TEST")
	merchant = "6706598320" // İşyeri numarası
	terminal = "67005551"   // Terminal numarası
)

func main() {
	api, req := posnet.Api(merchant, terminal)
	api.Mode = envmode
	req.TranDate = "1"
	req.Auth = new(posnet.Auth)
	req.Auth.OrderId = posnet.XID(20)
	req.Auth.Amount = posnet.Amount("1.00")         // Satış tutarı (zorunlu)
	req.Auth.Installment = posnet.Installment("0")  // Taksit sayısı (peşin: "0") (zorunlu)
	req.Auth.Currency = posnet.Currency("TRY")      // Para birimi (zorunlu)
	req.Auth.CardNumber = ""                        // Kart numarası (zorunlu)
	req.Auth.CardExpiry = posnet.Expiry("02", "20") // Son kullanma tarihi - AA,YY (zorunlu)
	req.Auth.CardCode = "123"                       // Kart arkasındaki 3 haneli numara (zorunlu)

	ctx := context.Background()
	if res, err := api.Transaction(ctx, req); err == nil {
		pretty, _ := xml.MarshalIndent(res, " ", " ")
		fmt.Println(string(pretty))
	} else {
		fmt.Println(err)
	}
}

İade

package main

import (
	"context"
	"encoding/xml"
	"fmt"

	posnet "github.com/ozgur-yalcin/posnet.go/src"
)

// Üye işyeri bilgileri
const (
	envmode  = "TEST"       // Çalışma ortamı (Production : "PROD" - Test : "TEST")
	merchant = "6706598320" // İşyeri numarası
	terminal = "67005551"   // Terminal numarası
)

func main() {
	api, req := posnet.Api(merchant, terminal)
	api.Mode = envmode
	req.Refund = new(posnet.Refund)
	req.Refund.Transaction = "sale"              // "sale" : Satış , "auth" : Provizyon
	req.Refund.HostLogKey = ""                   // İşlem numarası
	req.Refund.Amount = posnet.Amount("1.00")    // İade tutarı
	req.Refund.Currency = posnet.Currency("TRY") // Para birimi (zorunlu)

	ctx := context.Background()
	if res, err := api.Transaction(ctx, req); err == nil {
		pretty, _ := xml.MarshalIndent(res, " ", " ")
		fmt.Println(string(pretty))
	} else {
		fmt.Println(err)
	}
}

İptal

package main

import (
	"context"
	"encoding/xml"
	"fmt"

	posnet "github.com/ozgur-yalcin/posnet.go/src"
)

// Üye işyeri bilgileri
const (
	envmode  = "TEST"       // Çalışma ortamı (Production : "PROD" - Test : "TEST")
	merchant = "6706598320" // İşyeri numarası
	terminal = "67005551"   // Terminal numarası
)

func main() {
	api, req := posnet.Api(merchant, terminal)
	api.Mode = envmode
	req.Cancel = new(posnet.Cancel)
	req.Cancel.Transaction = "sale" // "sale" : Satış , "auth" : Provizyon
	req.Cancel.HostLogKey = ""      // İşlem numarası

	ctx := context.Background()
	if res, err := api.Transaction(ctx, req); err == nil {
		pretty, _ := xml.MarshalIndent(res, " ", " ")
		fmt.Println(string(pretty))
	} else {
		fmt.Println(err)
	}
}

About

Yapı Kredi (Posnet) POS API with golang

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages