Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

json: cannot unmarshal number into Go struct field LinkEntity.cf_link_id of type string #79

Open
vizvasrj opened this issue Nov 18, 2024 · 2 comments

Comments

@vizvasrj
Copy link

i am getting error "json: cannot unmarshal number into Go struct field LinkEntity.cf_link_id of type string"

func CreatePGLink() (any, error) {
	clientId := "TESTXXXXX"
	clientSecret := "TESTXXXX"
	cashfree.XClientId = &clientId
	cashfree.XClientSecret = &clientSecret
	cashfree.XEnvironment = cashfree.SANDBOX
	expiryTime := time.Now().Add(10 * time.Minute).Format("2006-01-02T15:04:05Z")
	link, response, err := cashfree.PGCreateLink(
		cashfree.PtrString("2022-09-01"),
		&cashfree.CreateLinkRequest{
			LinkAmount:   100.0,
			LinkCurrency: "INR",
			LinkId:       "TEST17",
			CustomerDetails: cashfree.LinkCustomerDetailsEntity{
				CustomerEmail: cashfree.PtrString("[email protected]"),
				CustomerPhone: "1234567890",
			},
			LinkMeta: &cashfree.LinkMetaResponseEntity{
				ReturnUrl: cashfree.PtrString("http://127.0.0.1:8080/cart/payment/callback?order_id={order_id}"),
			},
			LinkNotify: &cashfree.LinkNotifyEntity{
				SendEmail: cashfree.PtrBool(true),
				SendSms:   cashfree.PtrBool(true),
			},
			LinkExpiryTime: cashfree.PtrString(expiryTime),
			LinkPurpose:    "Test Order",
		},
		nil,
		nil,
		nil,
	)
	if err != nil {
		l.DebugF("Error: %s", err.Error())
		return nil, err
	}
	l.DebugF("Response: %#v", response.StatusCode)
	l.InfoF("Link: %#v", link)
	return link, nil
}

output

└─# godotenv go test ./.../payment -v
=== RUN   TestCreatePaymentLink
2024-11-19T04:00:55.666+0530    DEBUG   payment/route.go:88     Error: json: cannot unmarshal number into Go struct field LinkEntity.cf_link_id of type string
    route_test.go:9: json: cannot unmarshal number into Go struct field LinkEntity.cf_link_id of type string
--- FAIL: TestCreatePaymentLink (0.36s)
FAIL
FAIL    src/pkg/module/payment  0.363s
FAIL
2024/11/19 04:00:55 exit status 1

there is one possible solution is that i have change it to int from *string then it works here https://github.com/cashfree/cashfree-pg/blob/main/model_link_entity.go line number 23 on struct LinkEntity and it work

@suhas-cashfree
Copy link
Collaborator

suhas-cashfree commented Nov 19, 2024

cashfree.PtrString("2023-08-01")

@vizvasrj use this version, it will work.
Our backend version and sdk versions are tightly coupled

@vizvasrj
Copy link
Author

do you have rust Library for cashfree sdk?
are you planning to get rust library.
if you need any help with it you can ask me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants