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

feat: added cancellation reasons #406

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Conversation

od-hunter
Copy link

@od-hunter od-hunter commented Jan 29, 2025

By submitting a PR, I agree to Paycrest's Contributor Code of Conduct and Contribution Guide.

Description

I updated LockPaymentOrderResponse type to include cancellation_reasons field

I updated GetLockPaymentOrders controller to include cancellation reasons in response

I updated GetLockPaymentOrderByID controller to include cancellation reasons in response

References

closes #400

Testing

  • This change adds test coverage for new/changed/fixed functionality

Checklist

  • I have added documentation and tests for new/changed functionality in this PR
  • All active GitHub checks for tests, formatting, and security are passing
  • The correct base branch is being used, if not main

@Atanda1
Copy link
Collaborator

Atanda1 commented Jan 29, 2025

The PR message doesn't have any details. Update the PR template for Description.

@od-hunter
Copy link
Author

The PR message doesn't have any details. Update the PR template for Description.

Done

Copy link
Contributor

@chibie chibie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

can you resolve these failing tests?

  • try running the tests locally to ensure they pass before pushing

you can install ganache and run a local blockchain with HD_WALLET_MNEMONIC="media nerve fog identify typical physical aspect doll bar fossil frost because"; ganache -m "$HD_WALLET_MNEMONIC" --chain.chainId 1337 -l 21000000

then run the tests with go tests -v ./...

Comment on lines 186 to 226
// t.Run("fetch orders with cancellation reasons", func(t *testing.T) {
// // Create a test order with cancellation reasons
// order, err := test.CreateTestLockPaymentOrder(map[string]interface{}{
// "gateway_id": uuid.New().String(),
// "provider": testCtx.provider,
// "cancellation_reasons": []string{"Out of stock", "Payment failed"},
// })
// assert.NoError(t, err)

// var payload = map[string]interface{}{
// "timestamp": time.Now().Unix(),
// }

// signature := token.GenerateHMACSignature(payload, testCtx.apiKeySecret)

// headers := map[string]string{
// "Authorization": "HMAC " + testCtx.apiKey.ID.String() + ":" + signature,
// "Client-Type": "backend",
// }

// res, err := test.PerformRequest(t, "GET", fmt.Sprintf("/orders?timestamp=%v", payload["timestamp"]), nil, headers, router)
// assert.NoError(t, err)

// // Assert the response body
// assert.Equal(t, http.StatusOK, res.Code)

// var response types.Response
// err = json.Unmarshal(res.Body.Bytes(), &response)
// assert.NoError(t, err)
// assert.Equal(t, "Orders successfully retrieved", response.Message)

// data, ok := response.Data.(map[string]interface{})
// assert.True(t, ok, "response.Data is not of type map[string]interface{}")
// assert.NotNil(t, data, "response.Data is nil")

// // Check cancellation_reasons for the first order
// orders := data["orders"].([]interface{})
// assert.Greater(t, len(orders), 0)
// cancellationReasons := orders[0].(map[string]interface{})["cancellationReasons"].([]interface{})
// assert.Equal(t, []string{"Out of stock", "Payment failed"}, cancellationReasons)
// })
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove unnecessary comment

@chibie
Copy link
Contributor

chibie commented Feb 6, 2025

@od-hunter can you attend to the above requests?

@Atanda1
Copy link
Collaborator

Atanda1 commented Feb 14, 2025

@sundayonah are you taking this ticket over the finish line.

@sundayonah
Copy link
Collaborator

@sundayonah are you taking this ticket over the finish line.
Fix the error already.

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

Successfully merging this pull request may close these issues.

Add Cancellation Reasons to Lock Payment Order Endpoints
5 participants