Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,9 @@ const SFPaymentsExpressButtons = ({
}
}
return {
client_secret: updatedPaymentInstrument.paymentReference.clientSecret,
client_secret:
updatedPaymentInstrument.paymentReference.gatewayProperties?.stripe

Choose a reason for hiding this comment

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

I actually addressed this in my PR since it was blocking me testing the fail order if I didn't.

?.clientSecret,
id: updatedPaymentInstrument.paymentReference.paymentReferenceId
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,8 @@ const SFPaymentsSheet = forwardRef((props, ref) => {

// Track created payment intent
const paymentIntent = {
client_secret: orderPaymentInstrument.paymentReference.clientSecret,
client_secret:
orderPaymentInstrument.paymentReference.gatewayProperties?.stripe?.clientSecret,
Copy link
Author

Choose a reason for hiding this comment

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

This is obviously very stripe specific. I dont think the branch supports Adyen in any way yet but keep me honest

Choose a reason for hiding this comment

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

I actually addressed this in my PR since it was blocking me testing the fail order if I didn't. I created a separate util function so that we can add gateway specific logic the instead

id: orderPaymentInstrument.paymentReference.paymentReferenceId
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,12 @@ describe('SFPaymentsSheet', () => {
paymentInstrumentId: 'PI123',
paymentMethodId: 'Salesforce Payments',
paymentReference: {
clientSecret: 'secret123',
gateway: 'stripe',
gatewayProperties: {
stripe: {
clientSecret: 'secret123'
}
},
paymentReferenceId: 'ref123'
}
}
Expand All @@ -478,7 +483,12 @@ describe('SFPaymentsSheet', () => {
paymentInstrumentId: 'PI123',
paymentMethodId: 'Salesforce Payments',
paymentReference: {
clientSecret: 'secret123',
gateway: 'stripe',
gatewayProperties: {
stripe: {
clientSecret: 'secret123'
}
},
paymentReferenceId: 'ref123'
}
}
Expand Down Expand Up @@ -533,7 +543,12 @@ describe('SFPaymentsSheet', () => {
paymentInstrumentId: 'PI123',
paymentMethodId: 'Salesforce Payments',
paymentReference: {
clientSecret: 'secret123',
gateway: 'stripe',
gatewayProperties: {
stripe: {
clientSecret: 'secret123'
}
},
paymentReferenceId: 'ref123'
}
}
Expand Down Expand Up @@ -602,7 +617,12 @@ describe('SFPaymentsSheet', () => {
paymentInstrumentId: 'PI123',
paymentMethodId: 'Salesforce Payments',
paymentReference: {
clientSecret: 'secret123',
gateway: 'stripe',
gatewayProperties: {
stripe: {
clientSecret: 'secret123'
}
},
paymentReferenceId: 'ref123'
}
}
Expand All @@ -617,7 +637,12 @@ describe('SFPaymentsSheet', () => {
paymentInstrumentId: 'PI123',
paymentMethodId: 'Salesforce Payments',
paymentReference: {
clientSecret: 'secret123',
gateway: 'stripe',
gatewayProperties: {
stripe: {
clientSecret: 'secret123'
}
},
paymentReferenceId: 'ref123'
}
}
Expand Down Expand Up @@ -664,7 +689,12 @@ describe('SFPaymentsSheet', () => {
paymentInstrumentId: 'PI123',
paymentMethodId: 'Salesforce Payments',
paymentReference: {
clientSecret: 'secret123',
gateway: 'stripe',
gatewayProperties: {
stripe: {
clientSecret: 'secret123'
}
},
paymentReferenceId: 'ref123'
}
}
Expand All @@ -682,7 +712,12 @@ describe('SFPaymentsSheet', () => {
paymentInstrumentId: 'PI123',
paymentMethodId: 'Salesforce Payments',
paymentReference: {
clientSecret: 'secret123',
gateway: 'stripe',
gatewayProperties: {
stripe: {
clientSecret: 'secret123'
}
},
paymentReferenceId: 'ref123'
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,23 @@ export const createPaymentInstrumentBody = (
zoneId,
shippingPreference
) => {
const paymentReferenceRequest = {
paymentMethodType: paymentMethodType,
zoneId: zoneId ?? 'default'
}

if (shippingPreference != null) {
paymentReferenceRequest.gatewayProperties = {
paypal: {
shippingPreference
}
}
}

return {
paymentMethodId: 'Salesforce Payments',
amount: amount,
paymentReferenceRequest: {
paymentMethodType: paymentMethodType,
zoneId: zoneId ?? 'default',
shippingPreference: shippingPreference
}
paymentReferenceRequest
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,12 @@ describe('sf-payments-utils', () => {
paymentInstrumentId: 'test-id',
paymentReference: {
paymentReferenceId: 'ref-123',
clientSecret: 'secret-abc'
gateway: 'stripe',
gatewayProperties: {
stripe: {
clientSecret: 'secret-abc'
}
}
},
customProperty: 'custom-value'
}
Expand Down Expand Up @@ -1112,7 +1117,7 @@ describe('sf-payments-utils', () => {
'GET_FROM_FILE'
)

expect(result.paymentReferenceRequest.shippingPreference).toBe('GET_FROM_FILE')
expect(result.paymentReferenceRequest.gatewayProperties.paypal.shippingPreference).toBe('GET_FROM_FILE')
})
})
})
Loading