Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 2 additions & 100 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,105 +1,7 @@
## Description
## Short Description / Link to Ticket

<!-- Provide a brief description of the changes in this PR -->

## Type of Change
## Testing

<!-- Mark the relevant option(s) with an "x" -->

- [ ] 🐛 Bug fix (non-breaking change which fixes an issue)
- [ ] ✨ New feature (non-breaking change which adds functionality)
- [ ] 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] 📚 Documentation update
- [ ] 🔧 Configuration change
- [ ] ♻️ Refactoring (no functional changes)
- [ ] ✅ Test updates
- [ ] 🎨 Style/formatting changes
- [ ] ⚡️ Performance improvement

## Related Issue(s)

<!-- Link to related issue(s), e.g., "Fixes #123" or "Closes #456" -->

Fixes #

## Motivation and Context

<!-- Why is this change required? What problem does it solve? -->

## Changes Made

<!-- List the specific changes made in this PR -->

-
-
-

## Testing

<!-- Describe the tests you ran to verify your changes -->

### Test Coverage

- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] I have run the full test suite (`bundle exec rspec`)

### Manual Testing

<!-- Describe any manual testing you performed -->

```ruby
# Example code showing how you tested this
```

## Code Quality Checklist

- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings or errors
- [ ] I have checked my code and corrected any misspellings
- [ ] All RuboCop offenses have been resolved (if applicable)

## Documentation

- [ ] I have updated the README.md (if applicable)
- [ ] I have updated the CHANGELOG.md
- [ ] I have updated the API documentation (if applicable)
- [ ] I have added/updated code examples (if applicable)

## Breaking Changes

<!-- If this is a breaking change, describe the impact and migration path -->

- [ ] This PR introduces breaking changes
- [ ] I have documented the breaking changes and migration path

**Breaking Change Details:**

<!-- Describe what breaks and how users should update their code -->

## Additional Notes

<!-- Any additional information that reviewers should know -->

## Screenshots (if applicable)

<!-- Add screenshots to help explain your changes -->

## Checklist Before Requesting Review

- [ ] I have read the [CONTRIBUTING](../CONTRIBUTING.md) guide
- [ ] My branch is up to date with the main branch
- [ ] All commits follow the project's commit message conventions
- [ ] I have added appropriate labels to this PR
- [ ] I have requested review from relevant maintainers

---

<!--
Thank you for contributing to zai_payment! 🙏
Your time and effort are greatly appreciated.
-->

4 changes: 2 additions & 2 deletions IMPLEMENTATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,8 @@ The implementation is complete and ready for use. Recommended next steps:

## References

- [Zai: Onboarding a Payin User](https://developer.hellozai.com/docs/onboarding-a-payin-user)
- [Zai: Onboarding a Payout User](https://developer.hellozai.com/docs/onboarding-a-payout-user)
- [Zai: Onboarding a Payin User](https://developer.hellozai.com/docs/onboarding-a-pay-in-user)
- [Zai: Onboarding a Payout User](https://developer.hellozai.com/docs/onboarding-a-pay-out-user)
- [Zai API Reference](https://developer.hellozai.com/reference)

## Support
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ response = ZaiPayment.users.update('user_id', mobile: '+9876543210')
**📚 Documentation:**
- 📖 [User Management Guide](docs/USERS.md) - Complete guide for payin and payout users
- 💡 [User Examples](examples/users.md) - Real-world usage patterns and Rails integration
- 🔗 [Zai: Onboarding a Payin User](https://developer.hellozai.com/docs/onboarding-a-payin-user)
- 🔗 [Zai: Onboarding a Payout User](https://developer.hellozai.com/docs/onboarding-a-payout-user)
- 🔗 [Zai: Onboarding a Payin User](https://developer.hellozai.com/docs/onboarding-a-pay-in-user)
- 🔗 [Zai: Onboarding a Payout User](https://developer.hellozai.com/docs/onboarding-a-pay-out-user)

### Webhooks

Expand Down
4 changes: 2 additions & 2 deletions docs/USERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ Both user types use the same endpoints but have different required information b

## References

- [Onboarding a Payin User](https://developer.hellozai.com/docs/onboarding-a-payin-user)
- [Onboarding a Payout User](https://developer.hellozai.com/docs/onboarding-a-payout-user)
- [Onboarding a Payin User](https://developer.hellozai.com/docs/onboarding-a-pay-in-user)
- [Onboarding a Payout User](https://developer.hellozai.com/docs/onboarding-a-pay-out-user)

## Usage

Expand Down
2 changes: 1 addition & 1 deletion docs/USER_ID_FIELD.md
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ old_user.update(zai_user_id: new_response.data['id'])

## References

- [Zai Developer Documentation](https://developer.hellozai.com/docs/onboarding-a-payin-user)
- [Zai Developer Documentation](https://developer.hellozai.com/docs/onboarding-a-pay-in-user)
- [Zai API Reference](https://developer.hellozai.com/reference/createuser)
- [User Management Guide](USERS.md)

Expand Down
4 changes: 2 additions & 2 deletions docs/USER_QUICK_REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,8 @@ ruby examples/user_demo.rb

- [Full User Guide](USERS.md)
- [Usage Examples](../examples/users.md)
- [Zai: Payin User](https://developer.hellozai.com/docs/onboarding-a-payin-user)
- [Zai: Payout User](https://developer.hellozai.com/docs/onboarding-a-payout-user)
- [Zai: Payin User](https://developer.hellozai.com/docs/onboarding-a-pay-in-user)
- [Zai: Payout User](https://developer.hellozai.com/docs/onboarding-a-pay-out-user)

## Support

Expand Down
8 changes: 4 additions & 4 deletions lib/zai_payment/resources/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ module ZaiPayment
module Resources
# User resource for managing Zai users (payin and payout)
#
# @see https://developer.hellozai.com/docs/onboarding-a-payin-user
# @see https://developer.hellozai.com/docs/onboarding-a-payout-user
# @see https://developer.hellozai.com/docs/onboarding-a-pay-in-user
# @see https://developer.hellozai.com/docs/onboarding-a-pay-out-user
class User
attr_reader :client

Expand Down Expand Up @@ -197,8 +197,8 @@ def show(user_id)
# )
#
# @see https://developer.hellozai.com/reference/createuser
# @see https://developer.hellozai.com/docs/onboarding-a-payin-user
# @see https://developer.hellozai.com/docs/onboarding-a-payout-user
# @see https://developer.hellozai.com/docs/onboarding-a-pay-in-user
# @see https://developer.hellozai.com/docs/onboarding-a-pay-out-user
def create(**attributes)
validate_create_attributes!(attributes)

Expand Down
15 changes: 14 additions & 1 deletion lib/zai_payment/response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,23 @@ def error_class_for_status

def extract_error_message
if body.is_a?(Hash)
body['error'] || body['message'] || body['errors']&.join(', ') || "HTTP #{status}"
body['error'] || body['message'] || format_errors(body['errors']) || "HTTP #{status}"
else
"HTTP #{status}: #{body}"
end
end

def format_errors(errors)
return nil if errors.nil?

case errors
when Array
errors.join(', ')
when Hash
errors.map { |key, value| "#{key}: #{value}" }.join(', ')
else
errors.to_s
end
end
end
end