-
Notifications
You must be signed in to change notification settings - Fork 111
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: add partner's api's #351
Conversation
Codecov Report
@@ Coverage Diff @@
## master #351 +/- ##
==========================================
- Coverage 93.02% 91.44% -1.58%
==========================================
Files 21 27 +6
Lines 961 1076 +115
==========================================
+ Hits 894 984 +90
- Misses 67 92 +25
|
return { | ||
create(params, callback) { | ||
let { notes, ...rest } = params | ||
let data = Object.assign(rest, normalizeNotes(notes)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this normalizeNotes
do? I saw the implementation, it just adds notes
to every key? The curl request didn't have this in req body.
var data = { "phone": "9000090000" } ;
// gets converted to
var normalised = { "notes[phone]" : "9000090000" } ;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@1995navinkumar i had checked this one, but notes are not working without normalizeNotes
.
sending notes without normalizeNotes , its throw error
sending notes with normalizeNotes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ankitdas13 How did you test this? Using a test account? Also, can you share the request payload before and after normalizeNotes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@1995navinkumar Yes, I have a test key, instead of creating a new object by Object.assign
, I pass the params to data and it's working without normalizeNotes
create(params, callback) {
return api.post({
version: 'v2',
url: `${BASE_URL}`,
data: params
}, callback);
},
payload
{
url: '/v2/accounts',
form: {
email: '[email protected]',
phone: '9000090000',
legal_business_name: 'Acme Corp',
business_type: 'partnership',
customer_facing_business_name: 'Example',
profile: {
category: 'healthcare',
subcategory: 'clinic',
description: 'Healthcare E-commerce platform',
addresses: [Object],
business_model: 'Online Clothing ( men, women, ethnic, modern ) fashion and lifestyle, accessories, t-shirt, shirt, track pant, shoes.'
},
legal_info: { pan: 'AAACL1234C', gst: '18AABCU9603R1ZM' },
brand: { color: 'FFFFFF' },
notes: { internal_ref_id: '123123' },
contact_name: 'Gaurav Kumar',
contact_info: { chargeback: [Object], refund: [Object], support: [Object] },
apps: { websites: [Array], android: [Array], ios: [Array] }
}
}
Should I remove the normalizeNotes from other methods after testing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@1995navinkumar reverted previous changes except client validation
lib/resources/accounts.js
Outdated
uploadAccountDoc(accountId, params, callback) { | ||
|
||
if (!accountId) { | ||
return Promise.reject("Account Id is mandatroy"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question : Do we usually validate params in client? Why do we have validation only for this method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@1995navinkumar We only validate the id, Is this the right way to do it or should we remove it ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't the API return an error if account id is not passed? If yes, should we just throw the error which API returns?
Also, I don't see the account ID check in other functions in this file. Account id should be mandatory in all cases right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dhwanilvyas yes its manadatory in all also if the account id is not passed then api throw The requested URL was not found on the server.
let { amount, currency, receipt, partial_payment,payment_capture, notes, method, | ||
...otherParams } = params | ||
currency = currency || 'INR' | ||
|
||
if(params.hasOwnProperty("first_payment_min_amount")){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: is this param first_payment_min_amount
removed from api request?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dhwanilvyas earlier if the param has first_payment_min_amount
property then we had to send the data in body
otherwise it's not working. for your reference.
but know it is working without this check, even the param has first_payment_min_amount
@@ -305,7 +305,7 @@ module.exports = function subscriptionsApi (api) { | |||
}, normalizeNotes(notes)) | |||
|
|||
return api.post({ | |||
url: 'subscription_registration/auth_links', | |||
url: '/subscription_registration/auth_links', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please test this before merging if double slash goes in request, it might fail
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
method: 'POST' | ||
}) | ||
|
||
rzpInstance.accounts.create(mockRequest).then((response) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ankitdas13 What exactly are we testing here? If we are testing for response, then we should not Mock it. It defeats the purpose of API testing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@1995navinkumar We are only testing API methods here by checking the URL and methods with mock url and method and we are following this in all API entity test cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. But IMO, since we are integration something, we would also need to ensure the integration actually works instead of just testing the implementation details.
We can just write test cases for happy flows and check whether we get status 200 for all requests. We can take this up as a separate discussion as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Just added one opinion.Take final approval from Dhwanil.
}; | ||
document_type: string; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@1995navinkumar added form-data params type check for document upload api
@@ -47,7 +48,7 @@ export declare namespace Stakeholders { | |||
|
|||
interface RazorpayStakeholderCreateRequestBody extends RazorpayStakeholderBaseRequestBody { } | |||
|
|||
interface RazorpayStakeholderUpdateRequestBody extends Omit<RazorpayStakeholderBaseRequestBody, 'email'> { } | |||
interface RazorpayStakeholderUpdateRequestBody extends Partial<Omit<RazorpayStakeholderBaseRequestBody, 'email'>> { } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@1995navinkumar added partial because all params is optional , also checked with empty objects as well in postmen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Do create separate task for using correct Content-Type
for request and for testing the integration with a test account instead of mocking.
Links for api reference you can also check this doc for more details
Account : https://razorpay.com/docs/api/partners/account-onboarding
Stakeholder : https://razorpay.com/docs/api/partners/stakeholder
Product configuration : https://razorpay.com/docs/api/partners/product-configuration
Webhook : https://razorpay.com/docs/api/partners/webhooks/#create-a-webhook
Terms & condition : https://razorpay.com/docs/api/partners/terms-conditions
Linked accont : https://razorpay.com/docs/partners/route/linked-accounts
Token Sharing : https://razorpay.com/docs/partners/aggregators/partner-auth/token-sharing
Documents:https://razorpay.com/docs/api/partners/upload-document/
Iin validation : https://razorpay.com/docs/payments/payment-methods/cards/token-hq/merchant-requestor-with-network-tokens/iin-validation
Card fingerprints : https://razorpay.com/docs/api/payments/cards/fingerprints#using-card-number