Coder Social home page Coder Social logo

payfor.go's Introduction

license documentation

Payfor.go

QNB Finansbank (PayFor) POS API with golang

Installation

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

Satış

package main

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

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

// Pos bilgileri
const (
	envmode  = "TEST"                    // Çalışma ortamı (Production : "PROD" - Test : "TEST")
	mbr      = "5"                       // Kurum kodu
	merchant = "085300000009704"         // İşyeri numarası
	username = "QNB_API_KULLANICI_3DPAY" // Kullanıcı adı
	password = "UcBN0"                   // Şifre
	lang     = "TR"                      // Dil
)

func main() {
	api, req := payfor.Api(mbr, merchant, username, password)
	api.SetMode(envmode)

	req.SetCardHolder("")                 // Kart sahibi (zorunlu)
	req.SetCardNumber("4155650100416111") // Kart numarası (zorunlu)
	req.SetCardExpiry("01", "25")         // Son kullanma tarihi - AA,YY (zorunlu)
	req.SetCardCode("123")                // Kart arkasındaki 3 haneli numara (zorunlu)
	req.SetAmount("1.00", "TRY")          // Satış tutarı ve para birimi (zorunlu)
	req.SetLang(lang)

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

İade

package main

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

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

// Pos bilgileri
const (
	envmode  = "TEST"                    // Çalışma ortamı (Production : "PROD" - Test : "TEST")
	mbr      = "5"                       // Kurum kodu
	merchant = "085300000009704"         // İşyeri numarası
	username = "QNB_API_KULLANICI_3DPAY" // Kullanıcı adı
	password = "UcBN0"                   // Şifre
	lang     = "TR"                      // Dil
)

func main() {
	api, req := payfor.Api(mbr, merchant, username, password)
	api.SetMode(envmode)

	req.SetOrgOrderId("SYS_")    // Sipariş numarası (zorunlu)
	req.SetAmount("1.00", "TRY") // İade tutarı ve para birimi (zorunlu)
	req.SetLang(lang)

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

İptal

package main

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

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

// Pos bilgileri
const (
	envmode  = "TEST"                    // Çalışma ortamı (Production : "PROD" - Test : "TEST")
	mbr      = "5"                       // Kurum kodu
	merchant = "085300000009704"         // İşyeri numarası
	username = "QNB_API_KULLANICI_3DPAY" // Kullanıcı adı
	password = "UcBN0"                   // Şifre
	lang     = "TR"                      // Dil
)

func main() {
	api, req := payfor.Api(mbr, merchant, username, password)
	api.SetMode(envmode)

	req.SetOrgOrderId("SYS_") // Sipariş numarası (zorunlu)
	req.SetCurrency("TRY")    // Para birimi (zorunlu)
	req.SetLang(lang)

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

payfor.go's People

Contributors

ozgur-yalcin avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.