ecpay

package
Version: v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 26, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatCreditInstallmentOption

func FormatCreditInstallmentOption(option CreditInstallmentOption) string

FormatCreditInstallmentOption joins the installment options with ','.

func FormatDate

func FormatDate(time time.Time) string

FormatDate convert time.Time into yyyy/MM/dd HH:mm:ss format.

func FormatDatetime

func FormatDatetime(time time.Time) string

FormatDatetime convert time.Time into yyyy/MM/dd HH:mm:ss format.

func FormatIgnorePayment

func FormatIgnorePayment(option IgnorePaymentOption) string

FormatIgnorePayment joins the payments that will be ignored with '#'.

func FormatInvoiceItem

func FormatInvoiceItem(items []string) string

FormatInvoiceItem joins the invoice item name with '|'. Apply to InvoiceItemName, InvoiceItemCount, InvoiceItemWord, InvoiceItemPrice and InvoiceItemTaxType.

func FormatItemName

func FormatItemName(items []string) string

FormatItemName joins an array of item name with '#'.

func GeneratePostForm

func GeneratePostForm(action string, form url.Values) string

func GetCheckMacValue

func GetCheckMacValue(req url.Values, hashKey, hashIV string) string

GetCheckMacValue gets the check mac.

func ParseQueryString

func ParseQueryString(q string) (map[string]interface{}, error)

ParseQueryString parse the query string to map.

func WithSandbox

func WithSandbox(client *Client) error

WithSandbox configures the client, making it sending request to sandbox environment.

Types

type ATMParam

type ATMParam struct {
	// ExpireDate (允許繳費有效天數).
	ExpireDate int `json:"ExpireDate,omitempty"`
	// PaymentInfoURL (Server端回傳付款相關資訊).
	PaymentInfoURL string `json:"PaymentInfoURL,omitempty"`
	// ClientRedirectURL (Client端回傳付款相關資訊).
	ClientRedirectURL string `json:"ClientRedirectURL,omitempty"`
}

ATMParam defines the parameters tailored for ATM transaction.

type ActionType

type ActionType string

ActionType defines the struct of credit card action.

const (
	// ActionTypeC (關帳).
	ActionTypeC ActionType = "C"
	// ActionTypeR (退刷).
	ActionTypeR ActionType = "R"
	// ActionTypeE (取消).
	ActionTypeE ActionType = "E"
	// ActionTypeN (放棄).
	ActionTypeN ActionType = "N"
)

type AllocateStatusType

type AllocateStatusType string
const (
	// AllocateStatusTypeDone (已撥款).
	AllocateStatusTypeDone AllocateStatusType = "0"
	// AllocateStatusTypeNotYet (未撥款).
	AllocateStatusTypeNotYet AllocateStatusType = "1"
)

type BindingCardType

type BindingCardType string

BindingCardType defines the struct of binding card options (記憶卡號).

const (
	BindingCardTypeYes BindingCardType = "1"
	BindingCardTypeNo  BindingCardType = "0"
)

type CVSOrBarcodeParam

type CVSOrBarcodeParam struct {
	// StoreExpireDate (超商繳費截止時間).
	// unit: CVS (min), Barcode (day)
	StoreExpireDate int `json:"StoreExpireDate,omitempty"`
	// Desc1 (交易描述1).
	Desc1 string `json:"Desc1,omitempty"`
	// Desc2 (交易描述2).
	Desc2 string `json:"Desc2,omitempty"`
	// Desc3 (交易描述3).
	Desc3 string `json:"Desc3,omitempty"`
	// Desc4 (交易描述4).
	Desc4 string `json:"Desc4,omitempty"`
	// PaymentInfoURL (Server端回傳付款相關資訊).
	PaymentInfoURL string `json:"PaymentInfoURL,omitempty"`
	// ClientRedirectURL (Client端回傳付款方式相關資訊).
	ClientRedirectURL string `json:"ClientRedirectURL,omitempty"`
}

CVSOrBarcodeParam defines the parameters tailored for CVS or bar code transaction.

type CarrierType

type CarrierType string

CarrierType defines the struct of carrier options(載具類別).

const (
	// CarrierTypeNone none (無載具).
	CarrierTypeNone CarrierType = ""
	// CarrierTypeMember member (特店載具).
	CarrierTypeMember CarrierType = "1"
	// CarrierTypeCitizen citizen (買受人之自然人憑證號碼).
	CarrierTypeCitizen CarrierType = "2"
	// CarrierTypeCellphone phone (買受人之手機條碼資料).
	CarrierTypeCellphone CarrierType = "3"
)

type CharSetType

type CharSetType string
const (
	CharSetTypeBig5 CharSetType = "1"
	CharSetTypeUTF8 CharSetType = "2"
)

type ChoosePaymentType

type ChoosePaymentType string

ChoosePaymentType defines the struct of default payment type options (選擇預設付款方式).

const (
	// ChoosePaymentTypeAll all type.
	ChoosePaymentTypeAll ChoosePaymentType = "ALL"
	// ChoosePaymentTypeCredit credit card (信用卡).
	ChoosePaymentTypeCredit ChoosePaymentType = "Credit"
	// ChoosePaymentTypeWebATM web ATM (網路ATM).
	ChoosePaymentTypeWebATM ChoosePaymentType = "WebATM"
	// ChoosePaymentTypeATM ATM.
	ChoosePaymentTypeATM ChoosePaymentType = "ATM"
	// ChoosePaymentTypeCVS convenience store payment code (超商代碼繳款)
	ChoosePaymentTypeCVS ChoosePaymentType = "CVS"
	// ChoosePaymentTypeBarCode bar code (超商條碼繳款).
	ChoosePaymentTypeBarCode ChoosePaymentType = "BARCODE"
	// ChoosePaymentTypeGooglePay Google Pay.
	ChoosePaymentTypeGooglePay ChoosePaymentType = "GooglePay"
)

type ChooseSubpaymentType

type ChooseSubpaymentType string

ChooseSubpaymentType defines the struct of subpayment type options (付款子項目).

const (
	// ChooseSubpaymentTypeTaishin Taishin Bank (台新銀行).
	ChooseSubpaymentTypeTaishin ChooseSubpaymentType = "TAISHIN"
	// ChooseSubpaymentTypeESUN E.SUN Bank (玉山銀行).
	ChooseSubpaymentTypeESUN ChooseSubpaymentType = "ESUN"
	// ChooseSubpaymentTypeBOT Bank of Taiwan (台灣銀行).
	ChooseSubpaymentTypeBOT ChooseSubpaymentType = "BOT"
	// ChooseSubpaymentTypeFubon Fubon (富邦銀行).
	ChooseSubpaymentTypeFubon ChooseSubpaymentType = "FUBON"
	// ChooseSubpaymentTypeChinaTrust ChinaTrust Bank (中國信託).
	ChooseSubpaymentTypeChinaTrust ChooseSubpaymentType = "CHINATRUST"
	// ChooseSubpaymentTypeFirst First Commercial Bank (第一銀行).
	ChooseSubpaymentTypeFirst ChooseSubpaymentType = "FIRST"
	// ChooseSubpaymentTypeCathay Cathay Bank (花旗銀行).
	ChooseSubpaymentTypeCathay ChooseSubpaymentType = "CATHAY"
	// ChooseSubpaymentTypeMega Mega International Commercial Bank (兆豐銀行).
	ChooseSubpaymentTypeMega ChooseSubpaymentType = "MEGA"
	// ChooseSubpaymentTypeLand Land Bank (土地銀行).
	ChooseSubpaymentTypeLand ChooseSubpaymentType = "LAND"
	// ChooseSubpaymentTypeTachong (大眾銀行).
	ChooseSubpaymentTypeTachong ChooseSubpaymentType = "TACHONG"
	// ChooseSubpaymentTypeSinoPac SinoPac Bank (永豐銀行).
	ChooseSubpaymentTypeSinoPac ChooseSubpaymentType = "SINOPAC"
	// ChooseSubpaymentTypeCVS convenience store payment code (超商代碼繳款).
	ChooseSubpaymentTypeCVS ChooseSubpaymentType = "CVS"
	// ChooseSubpaymentTypeOK OK Mart.
	ChooseSubpaymentTypeOK ChooseSubpaymentType = "OK"
	// ChooseSubpaymentTypeFamily Family mart (全家).
	ChooseSubpaymentTypeFamily ChooseSubpaymentType = "FAMILY"
	// ChooseSubpaymentTypeHiLife HiFife.
	ChooseSubpaymentTypeHiLife ChooseSubpaymentType = "HILIFE"
	// ChooseSubpaymentTypeIBon 7-11 ibon.
	ChooseSubpaymentTypeIBon ChooseSubpaymentType = "IBON"
	// ChooseSubpaymentTypeBarcode barcode.
	ChooseSubpaymentTypeBarcode ChooseSubpaymentType = "BARCODE"
)

type ClearanceMarkType

type ClearanceMarkType string

ClearanceMarkType defines the struct of redeem options (通關方式).

const (
	ClearanceMarkTypeNormal  ClearanceMarkType = "1"
	ClearanceMarkTypeCustoms ClearanceMarkType = "2"
)

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client implements client for making ECPay api.

func NewClient

func NewClient(merchantID, hashKey, hashIV string, options ...ClientOption) (*Client, error)

NewClient create a client for communicating to ECPay server.

Example
package main

import (
	"fmt"
	"log"

	"github.com/toastcheng/ecpay-sdk-go/ecpay"
)

func main() {
	client, err := ecpay.NewClient("<MERCHANT_ID>", "<HASH_KEY>", "<HASH_IV>", ecpay.WithSandbox)
	if err != nil {
		log.Fatalf("failed to new client: %s", err)
	}

	info := client.Info()
	fmt.Println(info["merchantID"])
	fmt.Println(info["hashKey"])
	fmt.Println(info["hashIV"])
	fmt.Println(info["endpoint"])
	fmt.Println(info["vendor"])
}
Output:

<MERCHANT_ID>
<HASH_KEY>
<HASH_IV>
https://payment-stage.ecpay.com.tw
https://vendor-stage.ecpay.com.tw

func (*Client) AioCheckOut

func (c *Client) AioCheckOut(order Order) (string, error)

AioCheckOut sends an order to ECPay server (產生訂單).

Example (All)
package main

import (
	"fmt"
	"log"
	"time"

	"github.com/toastcheng/ecpay-sdk-go/ecpay"

	"github.com/google/uuid"
)

func main() {
	client, err := ecpay.NewClient("<MERCHANT_ID>", "<HASH_KEY>", "<HASH_IV>", ecpay.WithSandbox)
	if err != nil {
		log.Fatalf("failed to new client: %s", err)
	}

	order := ecpay.Order{
		MerchantTradeNo:   fmt.Sprintf("%s%d", uuid.New().String()[:5], time.Now().Unix()%10000),
		StoreID:           "",
		MerchantTradeDate: ecpay.FormatDatetime(time.Now()),
		PaymentType:       ecpay.PaymentTypeAIO,
		TotalAmount:       2000,
		TradeDesc:         "訂單測試",
		ItemName:          ecpay.FormatItemName([]string{"商品1*", "商品2"}),
		ReturnURL:         "https://www.ecpay.com.tw/return_url.php",
		ChoosePayment:     ecpay.ChoosePaymentTypeAll,
		ClientBackURL:     "https://www.ecpay.com.tw/client_back_url.php",
		ItemURL:           "https://www.ecpay.com.tw/item_url.php",
		Remark:            "交易備註",
		OrderResultURL:    "https://www.ecpay.com.tw/order_result_url.php",
		NeedExtraPaidInfo: ecpay.NeedExtraPaidInfoTypeYes,
		InvoiceMark:       ecpay.InvoiceMarkTypeNo,
		ATM: &ecpay.ATMParam{
			ExpireDate:     7,
			PaymentInfoURL: "https://www.ecpay.com.tw/payment_info_url.php",
		},
		CVSBarcode: &ecpay.CVSOrBarcodeParam{
			StoreExpireDate: 15,
			PaymentInfoURL:  "https://www.ecpay.com.tw/payment_info_url.php",
		},
		IgnorePayment: ecpay.FormatIgnorePayment(ecpay.IgnorePaymentOption{
			CVS: true,
		}),
		Credit: &ecpay.CreditParam{
			BindingCard: ecpay.BindingCardTypeNo,
		},
	}

	html, err := client.AioCheckOut(order)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(html)
}
Output:

Example (Atm)
package main

import (
	"fmt"
	"log"
	"time"

	"github.com/toastcheng/ecpay-sdk-go/ecpay"

	"github.com/google/uuid"
)

func main() {
	client, err := ecpay.NewClient("<MERCHANT_ID>", "<HASH_KEY>", "<HASH_IV>", ecpay.WithSandbox)
	if err != nil {
		log.Fatalf("failed to new client: %s", err)
	}
	order := ecpay.Order{
		MerchantTradeNo:   fmt.Sprintf("%s%d", uuid.New().String()[:5], time.Now().Unix()%10000),
		StoreID:           "",
		MerchantTradeDate: ecpay.FormatDatetime(time.Now()),
		PaymentType:       ecpay.PaymentTypeAIO,
		TotalAmount:       2000,
		TradeDesc:         "訂單測試",
		ItemName:          ecpay.FormatItemName([]string{"商品1", "商品2"}),
		ReturnURL:         "https://www.ecpay.com.tw/return_url.php",
		ChoosePayment:     ecpay.ChoosePaymentTypeATM,
		ClientBackURL:     "https://www.ecpay.com.tw/client_back_url.php",
		ItemURL:           "https://www.ecpay.com.tw/item_url.php",
		Remark:            "交易備註",
		OrderResultURL:    "https://www.ecpay.com.tw/order_result_url.php",
		NeedExtraPaidInfo: ecpay.NeedExtraPaidInfoTypeYes,
		InvoiceMark:       ecpay.InvoiceMarkTypeNo,
		ATM: &ecpay.ATMParam{
			ExpireDate:     7,
			PaymentInfoURL: "https://www.ecpay.com.tw/payment_info_url.php",
		},
	}

	html, err := client.AioCheckOut(order)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(html)
}
Output:

Example (Barcode)
package main

import (
	"fmt"
	"log"
	"time"

	"github.com/toastcheng/ecpay-sdk-go/ecpay"

	"github.com/google/uuid"
)

func main() {
	client, err := ecpay.NewClient("<MERCHANT_ID>", "<HASH_KEY>", "<HASH_IV>", ecpay.WithSandbox)
	if err != nil {
		log.Fatalf("failed to new client: %s", err)
	}
	order := ecpay.Order{
		MerchantTradeNo:   fmt.Sprintf("%s%d", uuid.New().String()[:5], time.Now().Unix()%10000),
		StoreID:           "",
		MerchantTradeDate: ecpay.FormatDatetime(time.Now()),
		PaymentType:       ecpay.PaymentTypeAIO,
		TotalAmount:       2000,
		TradeDesc:         "訂單測試",
		ItemName:          ecpay.FormatItemName([]string{"商品1", "商品2"}),
		ReturnURL:         "https://www.ecpay.com.tw/return_url.php",
		ChoosePayment:     ecpay.ChoosePaymentTypeBarCode,
		ClientBackURL:     "https://www.ecpay.com.tw/client_back_url.php",
		ItemURL:           "https://www.ecpay.com.tw/item_url.php",
		Remark:            "交易備註",
		OrderResultURL:    "https://www.ecpay.com.tw/order_result_url.php",
		NeedExtraPaidInfo: ecpay.NeedExtraPaidInfoTypeYes,
		InvoiceMark:       ecpay.InvoiceMarkTypeNo,
		CVSBarcode: &ecpay.CVSOrBarcodeParam{
			StoreExpireDate: 15,
			PaymentInfoURL:  "https://www.ecpay.com.tw/payment_info_url.php",
		},
	}

	html, err := client.AioCheckOut(order)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(html)

}
Output:

Example (CreditCard)
package main

import (
	"fmt"
	"log"
	"time"

	"github.com/toastcheng/ecpay-sdk-go/ecpay"

	"github.com/google/uuid"
)

func main() {
	client, err := ecpay.NewClient("<MERCHANT_ID>", "<HASH_KEY>", "<HASH_IV>", ecpay.WithSandbox)
	if err != nil {
		log.Fatalf("failed to new client: %s", err)
	}
	order := ecpay.Order{
		MerchantTradeNo:   fmt.Sprintf("%s%d", uuid.New().String()[:5], time.Now().Unix()%10000),
		StoreID:           "",
		MerchantTradeDate: ecpay.FormatDatetime(time.Now()),
		PaymentType:       ecpay.PaymentTypeAIO,
		TotalAmount:       2000,
		TradeDesc:         "訂單測試",
		ItemName:          ecpay.FormatItemName([]string{"商品1", "商品2"}),
		ReturnURL:         "https://www.ecpay.com.tw/return_url.php",
		ChoosePayment:     ecpay.ChoosePaymentTypeCredit,
		ClientBackURL:     "https://www.ecpay.com.tw/client_back_url.php",
		ItemURL:           "https://www.ecpay.com.tw/item_url.php",
		Remark:            "交易備註",
		OrderResultURL:    "https://www.ecpay.com.tw/order_result_url.php",
		NeedExtraPaidInfo: ecpay.NeedExtraPaidInfoTypeYes,
		InvoiceMark:       ecpay.InvoiceMarkTypeNo,
		Credit: &ecpay.CreditParam{
			BindingCard: ecpay.BindingCardTypeNo,
			Redeem:      ecpay.RedeemTypeNo,
			UnionPay:    ecpay.UnionPayTypeSelect,
		},
	}

	html, err := client.AioCheckOut(order)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(html)

}
Output:

Example (CreditCardPeriod)
package main

import (
	"fmt"
	"log"
	"time"

	"github.com/toastcheng/ecpay-sdk-go/ecpay"

	"github.com/google/uuid"
)

func main() {
	client, err := ecpay.NewClient("<MERCHANT_ID>", "<HASH_KEY>", "<HASH_IV>", ecpay.WithSandbox)
	if err != nil {
		log.Fatalf("failed to new client: %s", err)
	}
	order := ecpay.Order{
		MerchantTradeNo:   fmt.Sprintf("%s%d", uuid.New().String()[:5], time.Now().Unix()%10000),
		StoreID:           "",
		MerchantTradeDate: ecpay.FormatDatetime(time.Now()),
		PaymentType:       ecpay.PaymentTypeAIO,
		TotalAmount:       2000,
		TradeDesc:         "訂單測試",
		ItemName:          ecpay.FormatItemName([]string{"商品1", "商品2"}),
		ReturnURL:         "https://www.ecpay.com.tw/return_url.php",
		ChoosePayment:     ecpay.ChoosePaymentTypeCredit,
		ClientBackURL:     "https://www.ecpay.com.tw/client_back_url.php",
		ItemURL:           "https://www.ecpay.com.tw/item_url.php",
		Remark:            "交易備註",
		OrderResultURL:    "https://www.ecpay.com.tw/order_result_url.php",
		NeedExtraPaidInfo: ecpay.NeedExtraPaidInfoTypeYes,
		InvoiceMark:       ecpay.InvoiceMarkTypeNo,
		Credit: &ecpay.CreditParam{
			BindingCard:     ecpay.BindingCardTypeNo,
			PeriodAmount:    2000,
			PeriodType:      ecpay.PeriodTypeMonth,
			Frequency:       1,
			ExecTimes:       2,
			PeriodReturnURL: "https://www.ecpay.com.tw/receive.php",
		},
	}

	html, err := client.AioCheckOut(order)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(html)

}
Output:

Example (CreditInstallment)
package main

import (
	"fmt"
	"log"
	"time"

	"github.com/toastcheng/ecpay-sdk-go/ecpay"

	"github.com/google/uuid"
)

func main() {
	client, err := ecpay.NewClient("<MERCHANT_ID>", "<HASH_KEY>", "<HASH_IV>", ecpay.WithSandbox)
	if err != nil {
		log.Fatalf("failed to new client: %s", err)
	}
	order := ecpay.Order{
		MerchantTradeNo:   fmt.Sprintf("%s%d", uuid.New().String()[:5], time.Now().Unix()%10000),
		StoreID:           "",
		MerchantTradeDate: ecpay.FormatDatetime(time.Now()),
		PaymentType:       ecpay.PaymentTypeAIO,
		TotalAmount:       2000,
		TradeDesc:         "訂單測試",
		ItemName:          ecpay.FormatItemName([]string{"商品1", "商品2"}),
		ReturnURL:         "https://www.ecpay.com.tw/return_url.php",
		ChoosePayment:     ecpay.ChoosePaymentTypeCredit,
		ClientBackURL:     "https://www.ecpay.com.tw/client_back_url.php",
		ItemURL:           "https://www.ecpay.com.tw/item_url.php",
		Remark:            "交易備註",
		OrderResultURL:    "https://www.ecpay.com.tw/order_result_url.php",
		NeedExtraPaidInfo: ecpay.NeedExtraPaidInfoTypeYes,
		InvoiceMark:       ecpay.InvoiceMarkTypeNo,
		Credit: &ecpay.CreditParam{
			BindingCard: ecpay.BindingCardTypeNo,
			CreditInstallment: ecpay.FormatCreditInstallmentOption(
				ecpay.CreditInstallmentOption{
					Month3:  true,
					Month6:  true,
					Month12: true,
					Month18: true,
					Month24: true,
				},
			),
		},
	}

	html, err := client.AioCheckOut(order)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(html)

}
Output:

Example (Cvs)
package main

import (
	"fmt"
	"log"
	"time"

	"github.com/toastcheng/ecpay-sdk-go/ecpay"

	"github.com/google/uuid"
)

func main() {
	client, err := ecpay.NewClient("<MERCHANT_ID>", "<HASH_KEY>", "<HASH_IV>", ecpay.WithSandbox)
	if err != nil {
		log.Fatalf("failed to new client: %s", err)
	}
	order := ecpay.Order{
		MerchantTradeNo:   fmt.Sprintf("%s%d", uuid.New().String()[:5], time.Now().Unix()%10000),
		StoreID:           "",
		MerchantTradeDate: ecpay.FormatDatetime(time.Now()),
		PaymentType:       ecpay.PaymentTypeAIO,
		TotalAmount:       2000,
		TradeDesc:         "訂單測試",
		ItemName:          ecpay.FormatItemName([]string{"商品1", "商品2"}),
		ReturnURL:         "https://www.ecpay.com.tw/return_url.php",
		ChoosePayment:     ecpay.ChoosePaymentTypeCVS,
		ClientBackURL:     "https://www.ecpay.com.tw/client_back_url.php",
		ItemURL:           "https://www.ecpay.com.tw/item_url.php",
		Remark:            "交易備註",
		OrderResultURL:    "https://www.ecpay.com.tw/order_result_url.php",
		NeedExtraPaidInfo: ecpay.NeedExtraPaidInfoTypeYes,
		InvoiceMark:       ecpay.InvoiceMarkTypeNo,
		CVSBarcode: &ecpay.CVSOrBarcodeParam{
			StoreExpireDate: 300,
			PaymentInfoURL:  "https://www.ecpay.com.tw/payment_info_url.php",
		},
	}

	html, err := client.AioCheckOut(order)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(html)

}
Output:

Example (GooglePay)
package main

import (
	"fmt"
	"log"
	"time"

	"github.com/toastcheng/ecpay-sdk-go/ecpay"

	"github.com/google/uuid"
)

func main() {
	client, err := ecpay.NewClient("<MERCHANT_ID>", "<HASH_KEY>", "<HASH_IV>", ecpay.WithSandbox)
	if err != nil {
		log.Fatalf("failed to new client: %s", err)
	}
	order := ecpay.Order{
		MerchantTradeNo:   fmt.Sprintf("%s%d", uuid.New().String()[:5], time.Now().Unix()%10000),
		StoreID:           "",
		MerchantTradeDate: ecpay.FormatDatetime(time.Now()),
		PaymentType:       ecpay.PaymentTypeAIO,
		TotalAmount:       2000,
		TradeDesc:         "訂單測試",
		ItemName:          ecpay.FormatItemName([]string{"商品1...(*)", "商品2!!"}),
		ReturnURL:         "https://www.ecpay.com.tw/return_url.php",
		ChoosePayment:     ecpay.ChoosePaymentTypeGooglePay,
		ClientBackURL:     "https://www.ecpay.com.tw/client_back_url.php",
		ItemURL:           "https://www.ecpay.com.tw/item_url.php",
		Remark:            "交易備註",
		OrderResultURL:    "https://www.ecpay.com.tw/order_result_url.php",
		NeedExtraPaidInfo: ecpay.NeedExtraPaidInfoTypeYes,
		InvoiceMark:       ecpay.InvoiceMarkTypeNo,
	}

	html, err := client.AioCheckOut(order)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(html)

}
Output:

Example (Invoice)
package main

import (
	"fmt"
	"log"
	"time"

	"github.com/toastcheng/ecpay-sdk-go/ecpay"

	"github.com/google/uuid"
)

func main() {
	client, err := ecpay.NewClient("<MERCHANT_ID>", "<HASH_KEY>", "<HASH_IV>", ecpay.WithSandbox)
	if err != nil {
		log.Fatalf("failed to new client: %s", err)
	}
	order := ecpay.Order{
		MerchantTradeNo:   fmt.Sprintf("%s%d", uuid.New().String()[:5], time.Now().Unix()%10000),
		StoreID:           "",
		MerchantTradeDate: ecpay.FormatDatetime(time.Now()),
		PaymentType:       ecpay.PaymentTypeAIO,
		TotalAmount:       2000,
		TradeDesc:         "訂單測試",
		ItemName:          ecpay.FormatItemName([]string{"商品1", "商品2"}),
		ReturnURL:         "https://www.ecpay.com.tw/return_url.php",
		ChoosePayment:     ecpay.ChoosePaymentTypeATM,
		ClientBackURL:     "https://www.ecpay.com.tw/client_back_url.php",
		ItemURL:           "https://www.ecpay.com.tw/item_url.php",
		Remark:            "交易備註",
		OrderResultURL:    "https://www.ecpay.com.tw/order_result_url.php",
		NeedExtraPaidInfo: ecpay.NeedExtraPaidInfoTypeYes,
		InvoiceMark:       ecpay.InvoiceMarkTypeYes,
		Invoice: &ecpay.InvoiceParam{
			RelateNumber:       "Tea9527",
			CustomerID:         "TEA_0000001",
			CustomerIdentifier: "53348111",
			CustomerName:       "客戶名稱",
			CustomerAddr:       "客戶地址",
			CustomerPhone:      "0912345678",
			CustomerEmail:      "abc@ecpay.com.tw",
			ClearanceMark:      ecpay.ClearanceMarkTypeCustoms,
			TaxType:            ecpay.TaxTypeZero,
			Donation:           ecpay.DonationTypeNo,
			Print:              ecpay.PrintTypeYes,
			InvoiceItemName:    ecpay.FormatInvoiceItem([]string{"測試商品1", "測試商品2"}),
			InvoiceItemCount:   ecpay.FormatInvoiceItem([]string{"2", "3"}),
			InvoiceItemWord:    ecpay.FormatInvoiceItem([]string{"個", "包"}),
			InvoiceItemPrice:   ecpay.FormatInvoiceItem([]string{"35", "10"}),
			InvoiceItemTaxType: ecpay.FormatInvoiceItem([]string{string(ecpay.TaxTypeFree), string(ecpay.TaxTypeFree)}),
			InvoiceRemark:      ecpay.FormatInvoiceItem([]string{"測試商品1的說明", "測試商品2的說明"}),
			DelayDay:           1,
		},
	}

	html, err := client.AioCheckOut(order)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(html)

}
Output:

Example (WebATM)
package main

import (
	"fmt"
	"log"
	"time"

	"github.com/toastcheng/ecpay-sdk-go/ecpay"

	"github.com/google/uuid"
)

func main() {
	client, err := ecpay.NewClient("<MERCHANT_ID>", "<HASH_KEY>", "<HASH_IV>", ecpay.WithSandbox)
	if err != nil {
		log.Fatalf("failed to new client: %s", err)
	}
	order := ecpay.Order{
		MerchantTradeNo:   fmt.Sprintf("%s%d", uuid.New().String()[:5], time.Now().Unix()%10000),
		StoreID:           "",
		MerchantTradeDate: ecpay.FormatDatetime(time.Now()),
		PaymentType:       ecpay.PaymentTypeAIO,
		TotalAmount:       2000,
		TradeDesc:         "訂單測試",
		ItemName:          ecpay.FormatItemName([]string{"商品1", "商品2"}),
		ReturnURL:         "https://www.ecpay.com.tw/return_url.php",
		ChoosePayment:     ecpay.ChoosePaymentTypeWebATM,
		ClientBackURL:     "https://www.ecpay.com.tw/client_back_url.php",
		ItemURL:           "https://www.ecpay.com.tw/item_url.php",
		Remark:            "交易備註",
		OrderResultURL:    "https://www.ecpay.com.tw/order_result_url.php",
		NeedExtraPaidInfo: ecpay.NeedExtraPaidInfoTypeYes,
		InvoiceMark:       ecpay.InvoiceMarkTypeNo,
	}

	html, err := client.AioCheckOut(order)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(html)

}
Output:

func (*Client) DoAction

func (c *Client) DoAction(action CreditCardAction) (map[string]interface{}, error)

DoAction fires an credit card refund action (信用卡請退款功能).

Example
package main

import (
	"fmt"
	"log"

	"github.com/toastcheng/ecpay-sdk-go/ecpay"
)

func main() {
	client, err := ecpay.NewClient("<MERCHANT_ID>", "<HASH_KEY>", "<HASH_IV>", ecpay.WithSandbox)
	if err != nil {
		log.Fatalf("failed to new client: %s", err)
	}
	a := ecpay.CreditCardAction{
		MerchantTradeNo: "2000132",
		TradeNo:         "NO123",
		Action:          ecpay.ActionTypeC,
		TotalAmount:     100,
	}

	resp, err := client.DoAction(a)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(resp)
}
Output:

func (*Client) FundingReconDetail

func (c *Client) FundingReconDetail(statement Statement) (string, error)

FundingReconDetail downloads the member statement (下載信用卡撥款對帳資料檔).

Example
package main

import (
	"fmt"
	"log"

	"github.com/toastcheng/ecpay-sdk-go/ecpay"
)

func main() {
	client, err := ecpay.NewClient("<MERCHANT_ID>", "<HASH_KEY>", "<HASH_IV>", ecpay.WithSandbox)
	if err != nil {
		log.Fatalf("failed to new client: %s", err)
	}
	statement := ecpay.Statement{
		MerchantTradeNo: "NO123",
		PayDateType:     ecpay.PayDateTypeClose,
		BeginDate:       "2018-02-12",
		EndDate:         "2018-02-12",
		MediaFormated:   "1",
	}

	resp, err := client.FundingReconDetail(statement)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(resp)
}
Output:

func (*Client) Info

func (c *Client) Info() map[string]string

func (*Client) QueryCreditCardPeriodInfo

func (c *Client) QueryCreditCardPeriodInfo(info CreditCardPeriodInfo) (map[string]interface{}, error)

QueryCreditCardPeriodInfo queries credit card periodic payment (信用卡定期定額訂單查詢).

Example
package main

import (
	"fmt"
	"log"
	"time"

	"github.com/toastcheng/ecpay-sdk-go/ecpay"
)

func main() {
	client, err := ecpay.NewClient("<MERCHANT_ID>", "<HASH_KEY>", "<HASH_IV>", ecpay.WithSandbox)
	if err != nil {
		log.Fatalf("failed to new client: %s", err)
	}
	info := ecpay.CreditCardPeriodInfo{
		MerchantTradeNo: "kncs20180804103309",
		TimeStamp:       time.Now().Unix(),
	}

	resp, err := client.QueryCreditCardPeriodInfo(info)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(resp)
}
Output:

func (*Client) QueryPaymentInfo

func (c *Client) QueryPaymentInfo(info PaymentInfo) (map[string]interface{}, error)

QueryPaymentInfo queries payment info of ATM/CVS/Barcode (查詢 ATM/CVS/BARCODE 取號結果).

Example
package main

import (
	"fmt"
	"log"
	"time"

	"github.com/toastcheng/ecpay-sdk-go/ecpay"
)

func main() {
	client, err := ecpay.NewClient("<MERCHANT_ID>", "<HASH_KEY>", "<HASH_IV>", ecpay.WithSandbox)
	if err != nil {
		log.Fatalf("failed to new client: %s", err)
	}
	info := ecpay.PaymentInfo{
		MerchantTradeNo: "kncs20180804103309",
		TimeStamp:       time.Now().Unix(),
	}

	resp, err := client.QueryPaymentInfo(info)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(resp)
}
Output:

func (*Client) QueryTrade

func (c *Client) QueryTrade(trade Trade) (map[string]interface{}, error)

QueryTrade queries a single creadit card trade (查詢信用卡單筆明細記錄).

Example
package main

import (
	"fmt"
	"log"

	"github.com/toastcheng/ecpay-sdk-go/ecpay"
)

func main() {
	client, err := ecpay.NewClient("<MERCHANT_ID>", "<HASH_KEY>", "<HASH_IV>", ecpay.WithSandbox)
	if err != nil {
		log.Fatalf("failed to new client: %s", err)
	}
	trade := ecpay.Trade{
		CreditRefundID:  "10123456",
		CreditAmount:    100,
		CreditCheckCode: "59997889",
	}

	resp, err := client.QueryTrade(trade)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(resp)
}
Output:

func (*Client) QueryTradeInfo

func (c *Client) QueryTradeInfo(info TradeInfo) (map[string]interface{}, error)

QueryTradeInfo queries a single trade info (查詢訂單).

Example
package main

import (
	"fmt"
	"log"
	"time"

	"github.com/toastcheng/ecpay-sdk-go/ecpay"
)

func main() {
	client, err := ecpay.NewClient("<MERCHANT_ID>", "<HASH_KEY>", "<HASH_IV>", ecpay.WithSandbox)
	if err != nil {
		log.Fatalf("failed to new client: %s", err)
	}
	info := ecpay.TradeInfo{
		MerchantTradeNo: "kncs20180804103309",
		TimeStamp:       string(time.Now().Unix()),
	}
	resp, err := client.QueryTradeInfo(info)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(resp)
}
Output:

func (*Client) TradeNoAio

func (c *Client) TradeNoAio(statement CreditCardStatement) (string, error)

TradeNoAio downloads the member statement (下載特店對帳媒體檔).

Example
package main

import (
	"fmt"
	"log"

	"github.com/toastcheng/ecpay-sdk-go/ecpay"
)

func main() {
	client, err := ecpay.NewClient("<MERCHANT_ID>", "<HASH_KEY>", "<HASH_IV>", ecpay.WithSandbox)
	if err != nil {
		log.Fatalf("failed to new client: %s", err)
	}
	statement := ecpay.CreditCardStatement{
		DateType:        ecpay.DateTypeOrder,
		BeginDate:       "2018-02-12",
		EndDate:         "2018-02-12",
		PaymentType:     ecpay.MerchantPaymentTypeCreditCard,
		MerchantTradeNo: "NO123",
		MediaFormated:   ecpay.MediaFormatedTypeNew,
		AllocateStatus:  ecpay.AllocateStatusTypeDone,
		PaymentStatus:   ecpay.PaymentStatusTypePaid,
	}

	resp, err := client.TradeNoAio(statement)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(resp)
}
Output:

type ClientOption

type ClientOption func(*Client) error

ClientOption extra option to configure the ECPay client.

type CreditCardAction

type CreditCardAction struct {
	MerchantTradeNo string     `json:"MerchantTradeNo,omitempty"`
	TradeNo         string     `json:"TradeNo,omitempty"`
	Action          ActionType `json:"Action,omitempty"`
	PlatformID      string     `json:"PlatformID,omitempty"`
	TotalAmount     int        `json:"TotalAmount,omitempty"`
}

CreditCardAction defines the struct of trade info.

func (CreditCardAction) ToFormData

func (a CreditCardAction) ToFormData() url.Values

ToFormData transform the Trade struct to url.Values

func (CreditCardAction) Validate

func (a CreditCardAction) Validate() (bool, error)

Validate validate if the trade struct is valid.

type CreditCardPeriodInfo

type CreditCardPeriodInfo struct {
	MerchantTradeNo string `json:"MerchantTradeNo,omitempty"`
	TimeStamp       int64  `json:"TimeStamp,omitempty"`
	PlatformID      string `json:"PlatformID,omitempty"`
}

CreditCardPeriodInfo defines the struct of trade info.

func (CreditCardPeriodInfo) ToFormData

func (c CreditCardPeriodInfo) ToFormData() url.Values

ToFormData transform the Trade struct to url.Values

func (CreditCardPeriodInfo) Validate

func (c CreditCardPeriodInfo) Validate() (bool, error)

Validate validate if the trade struct is valid.

type CreditCardStatement

type CreditCardStatement struct {
	MerchantTradeNo string              `json:"MerchantTradeNo,omitempty"`
	DateType        DateType            `json:"DateType,omitempty"`
	BeginDate       string              `json:"BeginDate,omitempty"`
	EndDate         string              `json:"EndDate,omitempty"`
	PaymentType     MerchantPaymentType `json:"PaymentType,omitempty"`
	PlatformStatus  PlatformStatusType  `json:"PlatformStatus,omitempty"`
	PaymentStatus   PaymentStatusType   `json:"PaymentStatus,omitempty"`
	AllocateStatus  AllocateStatusType  `json:"AllocateStatus,omitempty"`
	MediaFormated   MediaFormatedType   `json:"MediaFormated,omitempty"`
	CharSet         CharSetType         `json:"CharSet,omitempty"`
}

CreditCardStatement defines the struct of trade info.

func (CreditCardStatement) ToFormData

func (s CreditCardStatement) ToFormData() url.Values

ToFormData transform the Trade struct to url.Values

func (CreditCardStatement) Validate

func (s CreditCardStatement) Validate() (bool, error)

Validate validate if the trade struct is valid.

type CreditInstallmentOption

type CreditInstallmentOption struct {
	Month3  bool
	Month6  bool
	Month9  bool
	Month12 bool
	Month18 bool
	Month24 bool
}

type CreditParam

type CreditParam struct {
	// BindingCard (記憶卡號).
	BindingCard BindingCardType `json:"BindingCard,omitempty"`
	// MerchantMemberID (記憶卡號識別碼).
	MerchantMemberID string `json:"MerchantMemberID,omitempty"`
	// Language (語系設定).
	Language string `json:"Language,omitempty"`

	// 一次付清
	// Redeem (信用卡是否使用紅利折抵).
	Redeem RedeemType `json:"Redeem,omitempty"`
	// UnionPay (銀聯卡交易選項).
	UnionPay UnionPayType `json:"UnionPay,omitempty"`

	// 分期付款
	// CreditInstallment (刷卡分期期數).
	CreditInstallment string `json:"CreditInstallment,omitempty"`

	// 定期定額
	PeriodAmount int `json:"PeriodAmount,omitempty"`
	// PeriodType (週期種類).
	PeriodType PeriodType `json:"PeriodType,omitempty"`
	// Frequency (執行頻率).
	Frequency int `json:"Frequency,omitempty"`
	// ExecTimes (執行次數).
	ExecTimes int `json:"ExecTimes,omitempty"`
	// PeriodReturnURL (定期定額的執行結果回應URL).
	PeriodReturnURL string `json:"PeriodReturnURL,omitempty"`
}

CreditParam defines the parameters tailored for credit card transaction.

type DateType

type DateType string

DateType defines the struct of pay date type options (查詢日期類別).

const (
	// DateTypePayment (付款日期).
	DateTypePayment DateType = "2"
	// DateTypeAllocation (撥款日期).
	DateTypeAllocation DateType = "4"
	// DateTypeOrder (訂單日期).
	DateTypeOrder DateType = "6"
)

type DonationType

type DonationType string

DonationType defines the struct of donation options (捐贈).

const (
	// DonationTypeYes yes (捐贈).
	DonationTypeYes DonationType = "1"
	// DonationTypeNo no (不捐贈或統一編號CustomerIdentifier有值).
	DonationTypeNo DonationType = "2"
)

type IgnorePaymentOption

type IgnorePaymentOption struct {
	Credit  bool
	WebATM  bool
	ATM     bool
	CVS     bool
	Barcode bool
}

type InvoiceMarkType

type InvoiceMarkType string

InvoiceMarkType defines the struct of invoice options (電子發票開立註記).

const (
	InvoiceMarkTypeYes InvoiceMarkType = "Y"
	InvoiceMarkTypeNo  InvoiceMarkType = "N"
)

type InvoiceParam

type InvoiceParam struct {
	// RelateNumber (特店自訂編號).
	RelateNumber string `json:"RelateNumber,omitempty"`
	// TaxType (課稅類別).
	TaxType TaxType `json:"TaxType,omitempty"`
	// Donation (捐贈註記).
	Donation DonationType `json:"Donation,omitempty"`
	// Print (列印註記).
	Print PrintType `json:"Print,omitempty"`
	// InvoiceItemName (商品名稱).
	InvoiceItemName string `json:"InvoiceItemName,omitempty"`
	// InvoiceItemCount (商品數量).
	InvoiceItemCount string `json:"InvoiceItemCount,omitempty"`
	// DelayDay (延遲天數).
	DelayDay int `json:"DelayDay,omitempty"`
	// InvType (字軌類別).
	InvType string `json:"InvType,omitempty"`

	// CustomerID (客戶編號).
	CustomerID string `json:"CustomerID,omitempty"`
	// CustomerIdentifier (統一編號).
	CustomerIdentifier string `json:"CustomerIdentifier,omitempty"`
	// CustomerName (客戶名稱).
	CustomerName string `json:"CustomerName,omitempty"`
	// CustomerAddr (客戶地址).
	CustomerAddr string `json:"CustomerAddr,omitempty"`
	// CustomerPhone (客戶手機號碼).
	CustomerPhone string `json:"CustomerPhone,omitempty"`
	// CustomerEmail (客戶電子信箱).
	CustomerEmail string `json:"CustomerEmail,omitempty"`
	// ClearanceMark (通關方式).
	ClearanceMark ClearanceMarkType `json:"ClearanceMark,omitempty"`
	// CarrierType (載具類別).
	CarrierType CarrierType `json:"CarruerType,omitempty"`
	// CarrierNum (載具編號).
	CarrierNum string `json:"CarruerNum,omitempty"`
	// LoveCode (捐贈碼).
	LoveCode string `json:"LoveCode,omitempty"`
	// InvoiceItemWord (商品單位).
	InvoiceItemWord string `json:"InvoiceItemWord,omitempty"`
	// InvoiceItemPrice (商品價格).
	InvoiceItemPrice string `json:"InvoiceItemPrice,omitempty"`
	// InvoiceItemTaxType (商品課稅別).
	InvoiceItemTaxType string `json:"InvoiceItemTaxType,omitempty"`
	// InvoiceRemark (備註).
	InvoiceRemark string `json:"InvoiceRemark,omitempty"`
}

InvoiceParam defines the parameters for invoice specific settings.

type InvoiceType

type InvoiceType string

InvoiceType defines the struct of invoice options (發票).

const (
	// InvoiceTypeGeneral 一般稅額
	InvoiceTypeGeneral InvoiceType = "07"
	// InvoiceTypeSpecial 特種稅額
	InvoiceTypeSpecial InvoiceType = "08"
)

type LanguageType

type LanguageType string

LanguageType defines the struct of language options (語系設定).

const (
	LanguageTypeEnglish           LanguageType = "ENG"
	LanguageTypeKorean            LanguageType = "KOR"
	LanguageTypeJapanese          LanguageType = "JPN"
	LanguageTypeSimplifiedChinese LanguageType = "CHI"
)

type MediaFormatedType

type MediaFormatedType string
const (
	// MediaFormatedTypeOld (舊版格式).
	MediaFormatedTypeOld MediaFormatedType = "0"
	// MediaFormatedTypeNew (新版格式).
	MediaFormatedTypeNew MediaFormatedType = "1"
)

type MerchantPaymentType

type MerchantPaymentType string

MerchantPaymentType defines the struct of pay date type options (查詢日期類別).

const (
	// MerchantPaymentTypeCreditCard (付款日期).
	MerchantPaymentTypeCreditCard MerchantPaymentType = "01"
	// DateTypeApproriation (網路ATM).
	MerchantPaymentTypeWebATM MerchantPaymentType = "02"
	// MerchantPaymentTypeATM (ATM).
	MerchantPaymentTypeATM MerchantPaymentType = "03"
	// MerchantPaymentTypeCVS (超商代碼).
	MerchantPaymentTypeCVS MerchantPaymentType = "04"
	// MerchantPaymentTypeBarcode (超商條碼).
	MerchantPaymentTypeBarcode MerchantPaymentType = "05"
)

type NeedExtraPaidInfoType

type NeedExtraPaidInfoType string

NeedExtraPaidInfoType defines the struct of extra payment info options (是否需要額外的付款資訊).

const (
	NeedExtraPaidInfoTypeYes NeedExtraPaidInfoType = "Y"
	NeedExtraPaidInfoTypeNo  NeedExtraPaidInfoType = "N"
)

type Order

type Order struct {
	// MerchantTradeNo (特店交易編號).
	MerchantTradeNo string `json:"MerchantTradeNo,omitempty"`
	// StoreID (特店旗下店舖代號).
	StoreID string `json:"StoreID,omitempty"`
	// MerchantTradeDate yyyy/MM/dd HH:mm:ss (特店交易時間).
	MerchantTradeDate string `json:"MerchantTradeDate,omitempty"`
	// TotalAmount (交易金額).
	TotalAmount int `json:"TotalAmount,omitempty"`
	// TradeDesc (交易描述).
	TradeDesc string `json:"TradeDesc,omitempty"`
	// ItemName (商品名稱).
	ItemName string `json:"ItemName,omitempty"`
	// ItemURL (商品銷售網址).
	ItemURL string `json:"ItemURL,omitempty"`
	// ReturnURL (付款完成通知回傳網址).
	ReturnURL string `json:"ReturnURL,omitempty"`
	// ClientBackURL (Client端返回特店的按鈕連結).
	ClientBackURL string `json:"ClientBackURL,omitempty"`
	// OrderResultURL (Client端回傳付款結果網址).
	OrderResultURL string `json:"OrderResultURL,omitempty"`
	// PaymentType (交易類型).
	PaymentType PaymentType `json:"PaymentType,omitempty"`
	// ChoosePayment (選擇預設付款方式).
	ChoosePayment ChoosePaymentType `json:"ChoosePayment,omitempty"`
	// ChooseSubPayment (付款子項目).
	ChooseSubPayment ChooseSubpaymentType `json:"ChooseSubPayment,omitempty"`
	// Remark (備註欄位).
	Remark string `json:"Remark,omitempty"`
	// NeedExtraPaidInfo (是否需要額外的付款資訊).
	NeedExtraPaidInfo NeedExtraPaidInfoType `json:"NeedExtraPaidInfo,omitempty"`
	// DeviceSource (裝置來源).
	DeviceSource string `json:"DeviceSource,omitempty"`
	// IgnorePayment (隱藏付款).
	IgnorePayment string `json:"IgnorePayment,omitempty"`
	// PlatformID (特約合作平台商代號).
	PlatformID string `json:"PlatformID,omitempty"`
	// InvoiceMark (電子發票開立註記).
	InvoiceMark InvoiceMarkType `json:"InvoiceMark,omitempty"`
	// CustomField1 (自訂名稱欄位1).
	CustomField1 string `json:"CustomField1,omitempty"`
	// CustomField2 (自訂名稱欄位2).
	CustomField2 string `json:"CustomField2,omitempty"`
	// CustomField3 (自訂名稱欄位3).
	CustomField3 string `json:"CustomField3,omitempty"`
	// CustomField4 (自訂名稱欄位4).
	CustomField4 string `json:"CustomField4,omitempty"`
	// EncryptType (CheckMacValue 加密類型).
	EncryptType string `json:"EncryptType,omitempty"`
	// Language (語系設定).
	Language LanguageType `json:"Language,omitempty"`

	ATM        *ATMParam          `json:"ATM,omitempty"`
	CVSBarcode *CVSOrBarcodeParam `json:"CVSBarcode,omitempty"`
	Credit     *CreditParam       `json:"Credit,omitempty"`
	Invoice    *InvoiceParam      `json:"Invoice,omitempty"`
}

Order defines the structure of an order.

func (Order) ToFormData

func (o Order) ToFormData() url.Values

ToFormData transform the Order struct to url.Values

func (Order) Validate

func (o Order) Validate() (bool, error)

Validate validate if the order struct is valid.

type PayDateType

type PayDateType string

PayDateType defines the struct of pay date type options (查詢日期類別).

const (
	PayDateTypeFund  PayDateType = "fund"
	PayDateTypeClose PayDateType = "close"
	PayDateTypeEnter PayDateType = "enter"
)

type Payload

type Payload interface {
	Validate() (bool, error)
	ToFormData() url.Values
}

Payload defines the interface of payload for communicate with ECPay server.

type PaymentInfo

type PaymentInfo struct {
	MerchantTradeNo string `json:"MerchantTradeNo,omitempty"`
	TimeStamp       int64  `json:"TimeStamp,omitempty"`
	PlatformID      string `json:"PlatformID,omitempty"`
}

PaymentInfo defines the struct of trade info.

func (PaymentInfo) ToFormData

func (t PaymentInfo) ToFormData() url.Values

ToFormData transform the Trade struct to url.Values

func (PaymentInfo) Validate

func (t PaymentInfo) Validate() (bool, error)

Validate validate if the trade struct is valid.

type PaymentStatusType

type PaymentStatusType string
const (
	// PaymentStatusTypeUnpaid (未付款).
	PaymentStatusTypeUnpaid PaymentStatusType = "0"
	// PaymentStatusTypePaid (已付款).
	PaymentStatusTypePaid PaymentStatusType = "1"
	// PaymentStatusTypeFailed (訂單失敗).
	PaymentStatusTypeFailed PaymentStatusType = "2"
)

type PaymentType

type PaymentType string

PaymentType defines the struct of payment type options (銀聯卡交易選項).

const (
	// PaymentTypeAIO all in one.
	PaymentTypeAIO PaymentType = "aio"
	// PaymentTypeWebATMTaishin Taishin Bank (台新銀行).
	PaymentTypeWebATMTaishin PaymentType = "WebATM_TAISHIN"
	// PaymentTypeWebATMBOT Bank of Taiwan (台灣銀行).
	PaymentTypeWebATMBOT PaymentType = "WebATM_BOT"
	// PaymentTypeWebATMChinaTrust ChinaTrust Bank (中國信託).
	PaymentTypeWebATMChinaTrust PaymentType = "WebATM_CHINATRUST"
	// PaymentTypeWebATMCathay Cathay Bank (花旗銀行).
	PaymentTypeWebATMCathay PaymentType = "WebATM_CATHAY"
	// PaymentTypeWebATMLand Land Bank (土地銀行).
	PaymentTypeWebATMLand PaymentType = "WebATM_LAND"
	// PaymentTypeWebATMSinoPac SinoPac Bank (永豐銀行).
	PaymentTypeWebATMSinoPac PaymentType = "WebATM_SINOPAC"
	// PaymentTypeATMESUN E.SUN Bank (玉山銀行).
	PaymentTypeATMESUN PaymentType = "ATM_ESUN"
	// PaymentTypeATMFubon Fubon (富邦銀行).
	PaymentTypeATMFubon PaymentType = "ATM_FUBON"
	// PaymentTypeATMFirst First Commercial Bank (第一銀行).
	PaymentTypeATMFirst PaymentType = "ATM_FIRST"
	// PaymentTypeATMCathay Cathay Bank (花旗銀行).
	PaymentTypeATMCathay PaymentType = "ATM_CATHAY"
	// PaymentTypeCVSCVS convenience store payment code (超商代碼繳款).
	PaymentTypeCVSCVS PaymentType = "CVS_CVS"
	// PaymentTypeCVSFamily Family mart (全家).
	PaymentTypeCVSFamily PaymentType = "CVS_FAMILY"
	// PaymentTypeCVSIbon 7-11 ibon.
	PaymentTypeCVSIbon PaymentType = "CVS_IBON"
	// PaymentTypeCreditCreditCard credit card (信用卡).
	PaymentTypeCreditCreditCard PaymentType = "Credit_CreditCard"
)

type PeriodType

type PeriodType string

PeriodType defines the struct of period options (週期種類).

const (
	// PeriodTypeYear year.
	PeriodTypeYear PeriodType = "Y"
	// PeriodTypeMonth month.
	PeriodTypeMonth PeriodType = "M"
	// PeriodTypeDay day.
	PeriodTypeDay PeriodType = "D"
)

type PlatformStatusType

type PlatformStatusType string
const (
	// PlatformStatusTypeAll (全部).
	PlatformStatusTypeAll PlatformStatusType = "0"
	// PlatformStatusTypeNormal (一般).
	PlatformStatusTypeNormal PlatformStatusType = "1"
	// PlatformStatusTypePlatform (平台).
	PlatformStatusTypePlatform PlatformStatusType = "2"
)

type PrintType

type PrintType string

PrintType defines the struct of redeem options (列印註記).

const (
	PrintTypeYes PrintType = "1"
	PrintTypeNo  PrintType = "0"
)

type RedeemType

type RedeemType string

RedeemType defines the struct of redeem options (信用卡是否使用紅利折抵).

const (
	RedeemTypeYes RedeemType = "Y"
	RedeemTypeNo  RedeemType = "N"
)

type Statement

type Statement struct {
	MerchantTradeNo string      `json:"MerchantTradeNo,omitempty"`
	PayDateType     PayDateType `json:"PayDateType,omitempty"`
	BeginDate       string      `json:"BeginDate,omitempty"`
	EndDate         string      `json:"EndDate,omitempty"`
	PaymentType     string      `json:"PaymentType,omitempty"`
	PlatformStatus  string      `json:"PlatformStatus,omitempty"`
	PaymentStatus   string      `json:"PaymentStatus,omitempty"`
	AllocateStatus  string      `json:"AllocateStatus,omitempty"`
	MediaFormated   string      `json:"MediaFormated,omitempty"`
	CharSet         string      `json:"CharSet,omitempty"`
}

Statement defines the struct of trade info.

func (Statement) ToFormData

func (s Statement) ToFormData() url.Values

ToFormData transform the Trade struct to url.Values

func (Statement) Validate

func (s Statement) Validate() (bool, error)

Validate validate if the trade struct is valid.

type TaxType

type TaxType string

TaxType defines the struct of tax type options (課稅類別).

const (
	// TaxTypeDutiable (應稅).
	TaxTypeDutiable TaxType = "1"
	// TaxTypeZero (零稅率).
	TaxTypeZero TaxType = "2"
	// TaxTypeFree (免稅).
	TaxTypeFree TaxType = "3"
	// TaxTypeMix (若為混合應稅與免稅或零稅率時,限收銀機發票無法分辨時使用,且需通過申請核可).
	TaxTypeMix TaxType = "9"
)

type Trade

type Trade struct {
	CreditRefundID  string `json:"CreditRefundId,omitempty"`
	CreditAmount    int    `json:"CreditAmount,omitempty"`
	CreditCheckCode string `json:"CreditCheckCode,omitempty"`
}

Trade defines the struct of trade.

func (Trade) ToFormData

func (o Trade) ToFormData() url.Values

ToFormData transform the Trade struct to url.Values

func (Trade) Validate

func (o Trade) Validate() (bool, error)

Validate validate if the trade struct is valid.

type TradeInfo

type TradeInfo struct {
	MerchantTradeNo string `json:"MerchantTradeNo,omitempty"`
	TimeStamp       string `json:"TimeStamp,omitempty"`
	PlatformID      string `json:"PlatformID,omitempty"`
}

TradeInfo defines the struct of trade info.

func (TradeInfo) ToFormData

func (t TradeInfo) ToFormData() url.Values

ToFormData transform the Trade struct to url.Values

func (TradeInfo) Validate

func (t TradeInfo) Validate() (bool, error)

Validate validate if the trade struct is valid.

type UnionPayType

type UnionPayType string

UnionPayType defines the struct of UnionPay options (銀聯卡交易選項).

const (
	// UnionPayTypeSelect customer choose whether use UnionPay or not in webpage (消費者於交易頁面可選擇是否使用銀聯交易).
	UnionPayTypeSelect UnionPayType = "0"
	// UnionPayTypeOnly use UnionPay (只使用銀聯卡交易,且綠界會將交易頁面直接導到銀聯網站).
	UnionPayTypeOnly UnionPayType = "1"
	// UnionPayTypeHidden do not use UnionPay (不可使用銀聯卡,綠界會將交易頁面隱藏銀聯選項).
	UnionPayTypeHidden UnionPayType = "2"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL