GithubHelp home page GithubHelp logo

ozgur-yalcin / paycell.go Goto Github PK

View Code? Open in Web Editor NEW
0.0 0.0 1.0 82 KB

Turkcell (Paycell) API with golang

Home Page: https://paycell.com.tr/paycell-api/

License: MIT License

Go 100.00%
turkcell paycell

paycell.go's Introduction

license documentation

Paycell.go

Turkcell (Paycell) API with golang

Installation

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

Satış

package main

import (
	"context"
	"encoding/json"
	"fmt"

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

// Pos bilgileri
const (
	envmode  = "TEST"                // Çalışma ortamı (Production : "PROD" - Test : "TEST")
	merchant = "9998"                // İşyeri numarası
	appname  = "PAYCELLTEST"         // Uygulama adı
	apppass  = "PaycellTestPassword" // Uygulama şifresi
	storekey = "PAYCELL12345"        // İşyeri anahtarı
	prefix   = "666"                 // Referans no ilk 3 hanesi
)

func main() {
	api, req := paycell.Api(merchant, apppass, appname)
	api.SetStoreKey(storekey)
	api.SetPrefix(prefix)
	api.SetMode(envmode)
	api.SetIPAddress("127.0.0.1")         // IP adresi (zorunlu)
	api.SetPhoneNumber("905305289290")    // Müşteri numarası (zorunlu)
	api.SetAmount("1.00", "TRY")          // Satış tutarı (zorunlu)
	req.SetCardNumber("4355084355084358") // Kart numarası (zorunlu)
	req.SetCardExpiry("12", "26")         // Son kullanma tarihi - AA,YY (zorunlu)
	req.SetCardCode("000")                // Kart arkasındaki 3 haneli numara (zorunlu)
	req.Provision.Installment = "0"       // Taksit sayısı (varsa)

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

İade

package main

import (
	"context"
	"encoding/json"
	"fmt"

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

// Pos bilgileri
const (
	envmode  = "TEST"                // Çalışma ortamı (Production : "PROD" - Test : "TEST")
	merchant = "9998"                // İşyeri numarası
	appname  = "PAYCELLTEST"         // Uygulama adı
	apppass  = "PaycellTestPassword" // Uygulama şifresi
	storekey = "PAYCELL12345"        // İşyeri anahtarı
	prefix   = "666"                 // Referans no ilk 3 hanesi
)

func main() {
	api, req := paycell.Api(merchant, apppass, appname)
	api.SetStoreKey(storekey)
	api.SetPrefix(prefix)
	api.SetMode(envmode)
	api.SetPhoneNumber("905305289290") // Müşteri numarası (zorunlu)
	api.SetIPAddress("127.0.0.1")      // IP adresi (zorunlu)
	api.SetAmount("1.00", "TRY")       // İade tutarı (zorunlu)
	req.Refund.OriginalRefNo = ""      // Referans numarası (zorunlu)

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

İptal

package main

import (
	"context"
	"encoding/json"
	"fmt"

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

// Pos bilgileri
const (
	envmode  = "TEST"                // Çalışma ortamı (Production : "PROD" - Test : "TEST")
	merchant = "9998"                // İşyeri numarası
	appname  = "PAYCELLTEST"         // Uygulama adı
	apppass  = "PaycellTestPassword" // Uygulama şifresi
	storekey = "PAYCELL12345"        // İşyeri anahtarı
	prefix   = "666"                 // Referans no ilk 3 hanesi
)

func main() {
	api, req := paycell.Api(merchant, apppass, appname)
	api.SetStoreKey(storekey)
	api.SetPrefix(prefix)
	api.SetMode(envmode)
	api.SetPhoneNumber("905305289290") // Müşteri numarası (zorunlu)
	api.SetIPAddress("127.0.0.1")      // IP adresi (zorunlu)
	req.Cancel.OriginalRefNo = ""      // Referans numarası (zorunlu)

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

Mobil ödemeyi etkinleştirme

package main

import (
	"context"
	"encoding/json"
	"fmt"

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

// Pos bilgileri
const (
	envmode  = "TEST"                // Çalışma ortamı (Production : "PROD" - Test : "TEST")
	merchant = "9998"                // İşyeri numarası
	appname  = "PAYCELLTEST"         // Uygulama adı
	apppass  = "PaycellTestPassword" // Uygulama şifresi
	storekey = "PAYCELL12345"        // İşyeri anahtarı
	prefix   = "666"                 // Referans no ilk 3 hanesi
)

func main() {
	api, req := paycell.Api(merchant, apppass, appname)
	api.SetStoreKey(storekey)
	api.SetPrefix(prefix)
	api.SetMode(envmode)
	api.SetPhoneNumber("905305289290") // Müşteri numarası (zorunlu)
	api.SetIPAddress("127.0.0.1")      // IP adresi (zorunlu)

	ctx := context.Background()
	if get, err := api.GetPaymentMethods(ctx, req); err == nil {
		if get.PaymentMethods.MobilePayment != nil {
			if !get.PaymentMethods.MobilePayment.IsDcbOpen {
				if get.PaymentMethods.MobilePayment.IsEulaExpired {
					req.MobilePayment.EulaID = get.PaymentMethods.MobilePayment.EulaId
				}
				if open, err := api.OpenMobilePayment(ctx, req); err == nil {
					pretty, _ := json.MarshalIndent(open.MobilePayment, " ", " ")
					fmt.Println(string(pretty))
				} else {
					fmt.Println(err)
				}
			}
		}
	} else {
		fmt.Println(err)
	}
}

paycell.go's People

Contributors

ozgur-yalcin avatar

Forkers

melkecelioglu

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.