From 6a975fe0602abdd4327f392674ef01649d3b6ecb Mon Sep 17 00:00:00 2001 From: TibebeJs Date: Sat, 16 Jan 2021 17:03:20 +0300 Subject: [PATCH] overall restructuring --- checkout/chkout.go | 60 +++++++++--------- checkout/chkout_test.go | 8 +-- checkout/item.go | 44 +++++++------ checkout/item_test.go | 8 +-- checkout/options.go | 130 +++++++++++++++++++-------------------- checkout/options_test.go | 24 ++++---- checkout/pdt.go | 73 ++++++++++++---------- checkout/pdt_test.go | 18 +++--- checkout/type.go | 11 ++-- main.go | 34 +++++----- 10 files changed, 208 insertions(+), 202 deletions(-) diff --git a/checkout/chkout.go b/checkout/chkout.go index 35492c2..bfd4d39 100644 --- a/checkout/chkout.go +++ b/checkout/chkout.go @@ -21,48 +21,49 @@ import ( ) const ( - CHECKOUT_BASE_URL_PROD = "https://www.yenepay.com/checkout/Home/Process/" - IPN_VERIFY_URL_PROD = "https://endpoints.yenepay.com/api/verify/ipn/" - PDT_URL_PROD = "https://endpoints.yenepay.com/api/verify/pdt/" + checkoutBaseURLProd string = "https://www.yenepay.com/checkout/Home/Process/" + ipnVerifyURLProd string = "https://endpoints.yenepay.com/api/verify/ipn/" + pdtURLProd string = "https://endpoints.yenepay.com/api/verify/pdt/" - CHECKOUT_BASE_URL_SANDBOX = "https://test.yenepay.com/Home/Process/" - IPN_VERIFY_URL_SANDBOX = "https://testapi.yenepay.com/api/verify/ipn/" - PDT_URL_SANDBOX = "https://testapi.yenepay.com/api/verify/pdt/" + checkoutBaseURLSandbox string = "https://test.yenepay.com/Home/Process/" + ipnVerifyURLSandbox string = "https://testapi.yenepay.com/api/verify/ipn/" + pdtURLSandbox string = "https://testapi.yenepay.com/api/verify/pdt/" ) +// YenePayCheckOut - main checkout model type YenePayCheckOut struct { } -// YenePayCheckOut Constructor +// NewYenePayCheckOut - YenePayCheckOut Constructor func NewYenePayCheckOut() *YenePayCheckOut { return &YenePayCheckOut{} } -// Generate Checkout URL for Express Checkout -func (self *YenePayCheckOut) ExpressCheckoutUrl(checkoutOptions *CheckoutOption, checkoutItem *ExpressCheckoutItem) string { +// ExpressCheckoutURL - Generate Checkout URL for Express Checkout +func (checkout *YenePayCheckOut) ExpressCheckoutURL(checkoutOptions *Option, checkoutItem *ExpressCheckoutItem) string { optsQs, _ := query.Values(checkoutOptions.GetExpressFields()) itemQs, _ := query.Values(checkoutItem) - checkoutUrl := CHECKOUT_BASE_URL_PROD + "?" + optsQs.Encode() + "&" + itemQs.Encode() + checkoutURL := checkoutBaseURLProd + "?" + optsQs.Encode() + "&" + itemQs.Encode() if checkoutOptions.UseSandbox { - checkoutUrl = CHECKOUT_BASE_URL_SANDBOX + "?" + optsQs.Encode() + "&" + itemQs.Encode() + checkoutURL = checkoutBaseURLSandbox + "?" + optsQs.Encode() + "&" + itemQs.Encode() } - return checkoutUrl + return checkoutURL } -// Generate Checkout URL for Cart Checkout -func (self *YenePayCheckOut) CartCheckoutUrl(checkoutOptions *CheckoutOption, cartItems []CartCheckoutItem) string { +// CartCheckoutURL - Generate Checkout URL for Cart Checkout +func (checkout *YenePayCheckOut) CartCheckoutURL(checkoutOptions *Option, cartItems []CartCheckoutItem) string { v, _ := query.Values(checkoutOptions) - checkoutUrl := CHECKOUT_BASE_URL_PROD + "?" + v.Encode() + checkoutURL := checkoutBaseURLProd + "?" + v.Encode() if checkoutOptions.UseSandbox { - checkoutUrl = CHECKOUT_BASE_URL_SANDBOX + "?" + v.Encode() + checkoutURL = checkoutBaseURLSandbox + "?" + v.Encode() } for i, item := range cartItems { @@ -70,23 +71,23 @@ func (self *YenePayCheckOut) CartCheckoutUrl(checkoutOptions *CheckoutOption, ca typeOfS := v.Type() for j := 0; j < v.NumField(); j++ { - checkoutUrl += fmt.Sprintf("&Items[%d].%s=%v", i, typeOfS.Field(j).Name, v.Field(j).Interface()) + checkoutURL += fmt.Sprintf("&Items[%d].%s=%v", i, typeOfS.Field(j).Name, v.Field(j).Interface()) } } - return checkoutUrl + return checkoutURL } -// WIP: check IPN authenticity -func (self *YenePayCheckOut) IsIPNAuthentic(ipnModel interface{}, useSandbox bool) (bool, error) { - ipnUrl := IPN_VERIFY_URL_PROD +// IsIPNAuthentic - check IPN authenticity (WIP) +func (checkout *YenePayCheckOut) IsIPNAuthentic(ipnModel interface{}, useSandbox bool) (bool, error) { + ipnURL := ipnVerifyURLProd if useSandbox { - ipnUrl = IPN_VERIFY_URL_SANDBOX + ipnURL = ipnVerifyURLSandbox } reqBody, _ := json.Marshal(ipnModel) - resp, err := http.Post(ipnUrl, "application/json", bytes.NewBuffer(reqBody)) + resp, err := http.Post(ipnURL, "application/json", bytes.NewBuffer(reqBody)) if err != nil { fmt.Print(err) @@ -105,16 +106,16 @@ func (self *YenePayCheckOut) IsIPNAuthentic(ipnModel interface{}, useSandbox boo return true, nil } -// WIP: Request PDT model -func (self *YenePayCheckOut) RequestPDT(pdtReq PdtRequestModel) (interface{}, error) { - pdtUrl := PDT_URL_PROD +// RequestPDT - Request PDT model (WIP) +func (checkout *YenePayCheckOut) RequestPDT(pdtReq PdtRequest) (interface{}, error) { + pdtURL := pdtURLProd if pdtReq.UseSandbox { - pdtUrl = PDT_URL_SANDBOX + pdtURL = pdtURLSandbox } reqBody, _ := json.Marshal(pdtReq) - resp, err := http.Post(pdtUrl, "application/json", bytes.NewBuffer(reqBody)) + resp, err := http.Post(pdtURL, "application/json", bytes.NewBuffer(reqBody)) if err != nil { fmt.Print(err) @@ -128,7 +129,6 @@ func (self *YenePayCheckOut) RequestPDT(pdtReq PdtRequestModel) (interface{}, er if err != nil { return nil, err - } else { - return result, nil } + return result, nil } diff --git a/checkout/chkout_test.go b/checkout/chkout_test.go index 0c8a7e7..89218a5 100644 --- a/checkout/chkout_test.go +++ b/checkout/chkout_test.go @@ -14,9 +14,9 @@ func TestNewYenePayCheckOut(t *testing.T) { assert.Exactly(t, expected, actual) } -func TestGetCheckoutUrlForExpress(t *testing.T) { +func TestGetCheckoutURLForExpress(t *testing.T) { - actual := NewYenePayCheckOut().ExpressCheckoutUrl( + actual := NewYenePayCheckOut().ExpressCheckoutURL( NewCheckoutOption( OptionsParams{ true, @@ -37,7 +37,7 @@ func TestGetCheckoutUrlForExpress(t *testing.T) { ), NewExpressCheckoutItem( ExpressParams{ - ItemId: "544", + ItemID: "544", ItemName: "PC", UnitPrice: 30.0, Quantity: 2, @@ -46,7 +46,7 @@ func TestGetCheckoutUrlForExpress(t *testing.T) { ), ) - expected := "https://test.yenepay.com/Home/Process/?CancelUrl=sdfsd&ExpiresAfter=3&FailureUrl=sdfsd&IPNUrl=sdfsd&MerchantId=222&MerchantOrderId=sdfsdsdfsd&Process=Express&SuccessUrl=sdfsd&UseSandbox=true&DeliveryFee=0&Discount=0.2&HandlingFee=0&ItemId=544&ItemName=PC&Quantity=2&Tax1=0&Tax2=0&UnitPrice=30" + expected := "https://test.yenepay.com/Home/Process/?CancelURL=sdfsd&ExpiresAfter=3&FailureURL=sdfsd&IPNURL=sdfsd&MerchantID=222&MerchantOrderID=sdfsdsdfsd&Process=Express&SuccessURL=sdfsd&UseSandbox=true&DeliveryFee=0&Discount=0.2&HandlingFee=0&ItemID=544&ItemName=PC&Quantity=2&Tax1=0&Tax2=0&UnitPrice=30" assert.Exactly(t, expected, actual) diff --git a/checkout/item.go b/checkout/item.go index 8ac257e..20fdd4c 100644 --- a/checkout/item.go +++ b/checkout/item.go @@ -1,13 +1,8 @@ package checkout -import ( - "encoding/json" - - "github.com/go-playground/validator" -) - +// ExpressCheckoutItem - model type ExpressCheckoutItem struct { - ItemId string `validate:"required,min=1"` + ItemID string `validate:"required,min=1"` ItemName string `validate:"required,min=1"` UnitPrice float64 `validate:"min=0.1"` Quantity int `validate:"min=1"` @@ -18,29 +13,30 @@ type ExpressCheckoutItem struct { Tax2 float64 `validate:"min=0.0"` } -// Validate and Marshal CheckoutItem to JSON format -func (self *ExpressCheckoutItem) ToJSON() (string, error) { - var validate *validator.Validate = validator.New() +// // Validate and Marshal CheckoutItem to JSON format +// func (self *ExpressCheckoutItem) ToJSON() (string, error) { +// var validate *validator.Validate = validator.New() - err := validate.Struct(self) +// err := validate.Struct(self) - if err != nil { - return "", err - } else { - data, _ := json.Marshal(self) +// if err != nil { +// return "", err +// } else { +// data, _ := json.Marshal(self) - return string(data), nil - } -} +// return string(data), nil +// } +// } +// ExpressParams - argument type for constructor type ExpressParams ExpressCheckoutItem -// ExpressCheckoutItem Constructor +// NewExpressCheckoutItem - ExpressCheckoutItem Constructor func NewExpressCheckoutItem( params ExpressParams, ) *ExpressCheckoutItem { return &ExpressCheckoutItem{ - params.ItemId, + params.ItemID, params.ItemName, params.UnitPrice, params.Quantity, @@ -52,19 +48,21 @@ func NewExpressCheckoutItem( } } +// CartCheckoutItem - model type CartCheckoutItem struct { - ItemId string + ItemID string ItemName string UnitPrice float64 Quantity int } +// CartParams - argument for constructor type CartParams CartCheckoutItem -// CartCheckoutItem Constructor +// NewCartCheckoutItem - CartCheckoutItem Constructor func NewCartCheckoutItem(params CartParams) *CartCheckoutItem { return &CartCheckoutItem{ - params.ItemId, + params.ItemID, params.ItemName, params.UnitPrice, params.Quantity, diff --git a/checkout/item_test.go b/checkout/item_test.go index 983b2c4..b1e71c0 100644 --- a/checkout/item_test.go +++ b/checkout/item_test.go @@ -25,7 +25,7 @@ func TestItemToJSON(t *testing.T) { expected := ` { - "ItemId" : "2", + "ItemID" : "2", "ItemName" : "item-name", "UnitPrice": 10.0, "Quantity": 2, @@ -44,8 +44,8 @@ func TestItemToJSON(t *testing.T) { if assert.Error(t, actualError) { for _, err := range actualError.(validator.ValidationErrors) { switch err.Field() { - case "ItemId": - assert.Exactly(t, "ItemId", err.Field()) + case "ItemID": + assert.Exactly(t, "ItemID", err.Field()) assert.Exactly(t, "required", err.Tag()) case "ItemName": assert.Exactly(t, "ItemName", err.Field()) @@ -59,7 +59,7 @@ func TestItemToJSON(t *testing.T) { func TestNewExpressCheckoutItem(t *testing.T) { item := NewExpressCheckoutItem( ExpressParams{ - ItemId: "2", + ItemID: "2", ItemName: "item-name", UnitPrice: 10.0, Quantity: 2, diff --git a/checkout/options.go b/checkout/options.go index 03146ca..2e934e2 100644 --- a/checkout/options.go +++ b/checkout/options.go @@ -1,21 +1,16 @@ package checkout -import ( - "encoding/json" - - "github.com/go-playground/validator" -) - -type CheckoutOption struct { +// Option - checkout option model +type Option struct { UseSandbox bool - Process CheckoutType - MerchantId string `validate:"required"` - SuccessUrl string - CancelUrl string - IPNUrl string - FailureUrl string + Process Type + MerchantID string `validate:"required"` + SuccessURL string + CancelURL string + IPNURL string + FailureURL string ExpiresAfter int - MerchantOrderId string + MerchantOrderID string TotalItemsDeliveryFee float64 TotalItemsTax1 float64 TotalItemsTax2 float64 @@ -23,82 +18,83 @@ type CheckoutOption struct { TotalItemsHandlingFee float64 } -type OptionsParams CheckoutOption +// OptionsParams - arugment for constructor +type OptionsParams Option -// Return Only Required Fields for Express Checkout +// GetExpressFields - Return Only Required Fields for Express Checkout // I.e. Exclude all Fields that start with 'Total' -func (self *CheckoutOption) GetExpressFields() interface{} { +func (option *Option) GetExpressFields() interface{} { return struct { UseSandbox bool - Process CheckoutType - MerchantId string - SuccessUrl string - CancelUrl string - IPNUrl string - FailureUrl string + Process Type + MerchantID string + SuccessURL string + CancelURL string + IPNURL string + FailureURL string ExpiresAfter int - MerchantOrderId string + MerchantOrderID string }{ - self.UseSandbox, - self.Process, - self.MerchantId, - self.SuccessUrl, - self.CancelUrl, - self.IPNUrl, - self.FailureUrl, - self.ExpiresAfter, - self.MerchantOrderId, + option.UseSandbox, + option.Process, + option.MerchantID, + option.SuccessURL, + option.CancelURL, + option.IPNURL, + option.FailureURL, + option.ExpiresAfter, + option.MerchantOrderID, } } -// Validate and Marshal CheckoutOption to JSON format -func (self *CheckoutOption) ToJSON(forCart bool) (string, error) { +// // Validate and Marshal Option to JSON format +// func (option *Option) ToJSON(forCart bool) (string, error) { - var fields interface{} +// var fields interface{} - if !forCart { - fields = self.GetExpressFields() - } else { - fields = self - } +// if !forCart { +// fields = option.GetExpressFields() +// } else { +// fields = option +// } - var validate *validator.Validate = validator.New() +// var validate *validator.Validate = validator.New() - err := validate.Struct(self) +// err := validate.Struct(option) - if err != nil { - return "", err - } else { - data, _ := json.Marshal(fields) +// if err != nil { +// return "", err +// } else { +// data, _ := json.Marshal(fields) - return string(data), nil - } -} +// return string(data), nil +// } +// } -// Set Order Total Fees +// SetOrderFees - Set Order Total Fees // I.e. Set Fields that start with 'Total' -func (self *CheckoutOption) SetOrderFees(totalItemsDeliveryFee float64, totalItemsDiscount float64, totalItemsHandlingFee float64, totalItemsTax1, totalItemsTax2 float64) { - self.TotalItemsDeliveryFee = totalItemsDeliveryFee - self.TotalItemsDiscount = totalItemsDiscount - self.TotalItemsHandlingFee = totalItemsHandlingFee - self.TotalItemsTax1 = totalItemsTax1 - self.TotalItemsTax2 = totalItemsTax2 +func (option *Option) SetOrderFees(totalItemsDeliveryFee float64, totalItemsDiscount float64, totalItemsHandlingFee float64, totalItemsTax1, totalItemsTax2 float64) { + option.TotalItemsDeliveryFee = totalItemsDeliveryFee + option.TotalItemsDiscount = totalItemsDiscount + option.TotalItemsHandlingFee = totalItemsHandlingFee + option.TotalItemsTax1 = totalItemsTax1 + option.TotalItemsTax2 = totalItemsTax2 } -// CheckoutOption Constructor -func NewCheckoutOption( +// NewOption - Option Constructor +func NewOption( params OptionsParams, -) *CheckoutOption { - return &CheckoutOption{ +) *Option { + return &Option{ params.UseSandbox, params.Process, - params.MerchantId, - params.SuccessUrl, - params.CancelUrl, - params.IPNUrl, - params.FailureUrl, + params.MerchantID, + params.SuccessURL, + params.CancelURL, + params.IPNURL, + params.FailureURL, params.ExpiresAfter, - params.MerchantOrderId, + params.MerchantOrderID, params.TotalItemsDeliveryFee, params.TotalItemsTax1, params.TotalItemsTax2, diff --git a/checkout/options_test.go b/checkout/options_test.go index be54750..9c9330f 100644 --- a/checkout/options_test.go +++ b/checkout/options_test.go @@ -71,13 +71,13 @@ func TestOptionsToJSONForExpress(t *testing.T) { { "UseSandbox": true, "Process": "Express", - "MerchantId": "2", - "SuccessUrl": "localhost:8000/success", - "CancelUrl": "localhost:8000/cancel", - "IPNUrl": "localhost:8000/ipn", - "FailureUrl": "localhost:8000/failure", + "MerchantID": "2", + "SuccessURL": "localhost:8000/success", + "CancelURL": "localhost:8000/cancel", + "IPNURL": "localhost:8000/ipn", + "FailureURL": "localhost:8000/failure", "ExpiresAfter": 2, - "MerchantOrderId": "2" + "MerchantOrderID": "2" } ` @@ -108,13 +108,13 @@ func TestOptionsToJSONForCart(t *testing.T) { { "UseSandbox": true, "Process": "Express", - "MerchantId": "2", - "SuccessUrl": "localhost:8000/success", - "CancelUrl": "localhost:8000/cancel", - "IPNUrl": "localhost:8000/ipn", - "FailureUrl": "localhost:8000/failure", + "MerchantID": "2", + "SuccessURL": "localhost:8000/success", + "CancelURL": "localhost:8000/cancel", + "IPNURL": "localhost:8000/ipn", + "FailureURL": "localhost:8000/failure", "ExpiresAfter": 2, - "MerchantOrderId": "2", + "MerchantOrderID": "2", "TotalItemsDeliveryFee": 10.0, "TotalItemsTax1": 2.0, "TotalItemsTax2": 0.0, diff --git a/checkout/pdt.go b/checkout/pdt.go index 912425d..1169df3 100644 --- a/checkout/pdt.go +++ b/checkout/pdt.go @@ -1,46 +1,57 @@ package checkout -import ( - "encoding/json" - - "github.com/go-playground/validator" -) +// { +// RequestType: 'PDT', +// PdtToken: 'VEzzj2vH8mKPde', +// TransactionID: '290f0ecf-ee7d-4684-9841-5c0e0687920a', +// MerchantOrderID: '12-34', +// UseSandbox: true, +// GetPDTDictionary: [Function (anonymous)] +// } + +// PdtRequest - request model for transaction verification +type PdtRequest struct { + PdtToken string `validate:"required,min=1"` + TransactionID string + MerchantOrderID string + UseSandbox bool `json:"-"` + RequestType string +} -type PdtRequestModel struct { +// { +// result: 'SUCCESS', +// TotalAmount: '18.50', +// BuyerID: 'f60502c5-12c8-4f2a-8709-9679fe4a386f', +// MerchantOrderID: '12-34', +// MerchantCode: '0694', +// MerchantID: '333dae30-2611-4fe9-aa7c-d58ea684f041', +// TransactionCode: 'NSLFTQLF', +// TransactionID: '290f0ecf-ee7d-4684-9841-5c0e0687920a', +// Status: 'Paid', +// Currency: 'ETB' +// } + +// PdtResponse - result of transaction verificaiton(pdt request) +type PdtResponse struct { PdtToken string `validate:"required,min=1"` - TransactionId string - MerchantOrderId string + TransactionID string + MerchantOrderID string UseSandbox bool `json:"-"` RequestType string } -type PdtParams PdtRequestModel +// PdtParams - arguments for PDT request constructor. +type PdtParams PdtRequest -// PDT Constructor -func NewPdtRequestModel( +// NewPdtRequest - PDT Constructor +func NewPdtRequest( params PdtParams, -) *PdtRequestModel { - return &PdtRequestModel{ +) *PdtRequest { + return &PdtRequest{ params.PdtToken, - params.TransactionId, - params.MerchantOrderId, + params.TransactionID, + params.MerchantOrderID, params.UseSandbox, "PDT", } } - -// Validate and Marshal PDT to JSON format -func (self *PdtRequestModel) ToJSON() (string, error) { - var validate *validator.Validate = validator.New() - - err := validate.Struct(self) - - if err != nil { - return "", err - } else { - data, _ := json.Marshal(self) - - return string(data), nil - } - -} diff --git a/checkout/pdt_test.go b/checkout/pdt_test.go index 8977e22..90a4447 100644 --- a/checkout/pdt_test.go +++ b/checkout/pdt_test.go @@ -8,12 +8,12 @@ import ( "github.com/stretchr/testify/require" ) -func TestNewPdtRequestModel(t *testing.T) { - pdt := NewPdtRequestModel( +func TestNewPdtRequest(t *testing.T) { + pdt := NewPdtRequest( PdtParams{ PdtToken: "test", - TransactionId: "1234", - MerchantOrderId: "2345", + TransactionID: "1234", + MerchantOrderID: "2345", UseSandbox: true, }, ) @@ -30,11 +30,11 @@ func TestNewPdtRequestModel(t *testing.T) { } func TestPDTToJSON(t *testing.T) { - actual, _ := NewPdtRequestModel( + actual, _ := NewPdtRequest( PdtParams{ PdtToken: "test", - TransactionId: "1234", - MerchantOrderId: "2345", + TransactionID: "1234", + MerchantOrderID: "2345", UseSandbox: true, }, ).ToJSON() @@ -42,8 +42,8 @@ func TestPDTToJSON(t *testing.T) { expected := ` { "PdtToken": "test", - "TransactionId": "1234", - "MerchantOrderId": "2345", + "TransactionID": "1234", + "MerchantOrderID": "2345", "RequestType": "PDT" } ` diff --git a/checkout/type.go b/checkout/type.go index 13d14a0..a348aef 100644 --- a/checkout/type.go +++ b/checkout/type.go @@ -1,9 +1,10 @@ package checkout -type CheckoutType string +// Type - model +type Type string -// Express Checkout Type -const ExpressCheckout CheckoutType = "Express" +// ExpressCheckout - Express Checkout Type +const ExpressCheckout Type = "Express" -// Cart Checkout Type -const CartCheckout CheckoutType = "Cart" +// CartCheckout - Cart Checkout Type +const CartCheckout Type = "Cart" diff --git a/main.go b/main.go index 44dd0dd..5398a2f 100644 --- a/main.go +++ b/main.go @@ -11,45 +11,45 @@ func main() { yenepay := checkout.NewYenePayCheckOut() fmt.Println("***************[ Express Checkout ]***************") - fmt.Println(yenepay.ExpressCheckoutUrl(checkout.NewCheckoutOption( + fmt.Println(yenepay.ExpressCheckoutURL(checkout.NewCheckoutOption( checkout.OptionsParams{ UseSandbox: true, Process: checkout.ExpressCheckout, - MerchantId: "0694", - SuccessUrl: "http://localhost:3000/Home/PaymentSuccessReturnUrl", - CancelUrl: "http://localhost:3000/Home/CancelReturnUrl", - IPNUrl: "http://localhost:3000/Home/IPNUrl", - FailureUrl: "http://localhost:3000/Home/FailureUrl", + MerchantID: "0694", + SuccessURL: "http://localhost:3000/Home/PaymentSuccessReturnURL", + CancelURL: "http://localhost:3000/Home/CancelReturnURL", + IPNURL: "http://localhost:3000/Home/IPNURL", + FailureURL: "http://localhost:3000/Home/FailureURL", ExpiresAfter: 2880, - MerchantOrderId: "ab-cd", + MerchantOrderID: "ab-cd", }, ), checkout.NewExpressCheckoutItem( - checkout.ExpressParams{ItemId: "544", ItemName: "PC", UnitPrice: 30.0, Quantity: 2}, + checkout.ExpressParams{ItemID: "544", ItemName: "PC", UnitPrice: 30.0, Quantity: 2}, ))) fmt.Println("***************[ Cart Checkout ]***************") - fmt.Println(yenepay.CartCheckoutUrl(checkout.NewCheckoutOption( + fmt.Println(yenepay.CartCheckoutURL(checkout.NewCheckoutOption( checkout.OptionsParams{ UseSandbox: true, Process: checkout.ExpressCheckout, - MerchantId: "0694", - SuccessUrl: "http://localhost:3000/Home/PaymentSuccessReturnUrl", - CancelUrl: "http://localhost:3000/Home/CancelReturnUrl", - IPNUrl: "http://localhost:3000/Home/IPNUrl", - FailureUrl: "http://localhost:3000/Home/FailureUrl", + MerchantID: "0694", + SuccessURL: "http://localhost:3000/Home/PaymentSuccessReturnURL", + CancelURL: "http://localhost:3000/Home/CancelReturnURL", + IPNURL: "http://localhost:3000/Home/IPNURL", + FailureURL: "http://localhost:3000/Home/FailureURL", ExpiresAfter: 2880, - MerchantOrderId: "ab-cd", + MerchantOrderID: "ab-cd", }, ), []checkout.CartCheckoutItem{ { - ItemId: "544", + ItemID: "544", ItemName: "PC", UnitPrice: 30.0, Quantity: 2, }, { - ItemId: "541", + ItemID: "541", ItemName: "PC2", UnitPrice: 30.0, Quantity: 2,