-
Notifications
You must be signed in to change notification settings - Fork 215
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(payment): PAYPAL-4937 Update PaymentRequestSender with new GQL API #2754
base: master
Are you sure you want to change the base?
Conversation
…ng an additional 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.
Looks good to me 👍
@@ -0,0 +1,6 @@ | |||
export default interface HeadlessPaymentMethod<T = any> { |
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.
Can any
type be changed to unknown
?
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.
Would be better to use the any
type in this case for matching initializationData
type with PaymentMethod
interface which also uses any
for initializationData
.
@@ -0,0 +1,7 @@ | |||
import HeadlessPaymentMethod from './headless-payment-method'; | |||
|
|||
export interface HeadlessPaymentMethodResponse<T = any> { |
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.
Will it work for you, if any
be changed with unknown
?
export interface HeadlessPaymentMethodResponse<T = any> { | |
export interface HeadlessPaymentMethodResponse<T = unknown> { |
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.
Are we not able to define the actual type here?
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.
@bc-peng removed T parameter as unnecessary in this case. we can define type as string
import HeadlessPaymentMethodConfig from './headless-payment-method-config'; | ||
import { HeadlessPaymentMethodResponse } from './headless-payment-method-response'; | ||
import { HeadlessPaymentMethodType } from './headless-payment-method-type'; | ||
import HeadlessPaymentRequestOptions from './headless-payment-request-options'; |
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.
Can we group them into a headless-payment
folder for better orgnization as I can see things are quite different here?
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.
Moved to the separate folder
methodId: string, | ||
options: HeadlessPaymentRequestOptions, | ||
): Promise<Response<PaymentMethod>> { | ||
const url = `/graphql`; |
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.
Will this be reused?
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.
removed
if (!entityId) { | ||
throw new Error('Unable to get payment entity id.'); | ||
} |
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 would happen after throwing this error?
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.
We are not be able to make a request in this case. It will be catch with PaymentMethodActionCreator
when i add it by the next PR
}; | ||
} | ||
|
||
private getPaymentEntityId(methodId: string): HeadlessPaymentMethodType { |
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.
private getPaymentEntityId(methodId: string): HeadlessPaymentMethodType { | |
private _getPaymentEntityId(methodId: string): HeadlessPaymentMethodType { |
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.
done
.then((response) => this.transformToPaymentMethodResponse(response, methodId)); | ||
} | ||
|
||
private transformToPaymentMethodResponse( |
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.
private transformToPaymentMethodResponse( | |
private _transformToPaymentMethodResponse( |
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.
Also maybe refactor this to a separate transformer file.
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.
Moved to the separate file
const graphQLQuery = ` | ||
query { | ||
site { | ||
paymentWalletWithInitializationData(filter: {paymentWalletEntityId: "${entityId}"}) { |
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.
paymentWalletWithInitializationData(filter: {paymentWalletEntityId: "${entityId}"}) { | |
paymentWalletWithInitializationData(filter: { paymentWalletEntityId: "${entityId}"}) { |
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.
done
What?
Updated
PaymentMethodRequestSender
by adding an additional methodUpdated
PaymentMethodActionCreator
by adding an additional methodWhy?
As part of the implementation of Headless Wallet Buttons (POC)
Testing / Proof
Manual
@bigcommerce/team-checkout @bigcommerce/team-payments