-
Notifications
You must be signed in to change notification settings - Fork 16
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 3DS session support and update to cards endpoint #983
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
34 changes: 34 additions & 0 deletions
34
src/Payments/ThreeDSecureSessions/ThreeDSecureSessions.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import nock from 'nock' | ||
import { Duffel } from '../../index' | ||
|
||
const duffel = new Duffel({ token: 'mockToken' }) | ||
describe('ThreeDSecureSessions', () => { | ||
afterEach(() => { | ||
nock.cleanAll() | ||
}) | ||
|
||
it('should create a 3DS session record when `create` is called', async () => { | ||
const MOCK_ID = '3ds_00009hthhsUZ8W4LxQgkjb' | ||
nock(/(.*)/) | ||
.post('/payments/three_d_secure_sessions') | ||
.reply(200, { | ||
data: { | ||
id: MOCK_ID, | ||
liveMode: false, | ||
expiresAt: '2024-01-01T00:00:00', | ||
status: 'ready_for_payment', | ||
resourceId: 'off_00009hthhsUZ8W4LxQgkjb', | ||
clientId: 'tds_57aa862f8bf7', | ||
cardId: 'tcd_00009hthhsUZ8W4LxQgkjb', | ||
}, | ||
}) | ||
|
||
const response = await duffel.three_d_secure_sessions.create({ | ||
resource_id: 'off_00009hthhsUZ8W4LxQgkjb', | ||
card_id: 'tcd_00009hthhsUZ8W4LxQgkjb', | ||
services: [{ quantity: 1, id: 'ser_00009UhD4ongolulWd9123' }], | ||
exception: 'secure_corporate_payment', | ||
}) | ||
expect(response.data.id).toBe(MOCK_ID) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { Resource } from '../../Resource' | ||
import { DuffelResponse } from '../../types' | ||
|
||
interface Service { | ||
/** | ||
* The quantity of the service ID to pay for | ||
*/ | ||
quantity: number | ||
/** | ||
* The ID of the service to pay for | ||
*/ | ||
id: string | ||
} | ||
|
||
interface ThreeDSecureSessionParameters { | ||
/** | ||
* The offer ID, order ID, order change ID or quote ID intended to pay | ||
*/ | ||
resource_id: string | ||
|
||
/** | ||
* The services inteded to pay | ||
*/ | ||
services: Service[] | ||
|
||
/** | ||
* The card ID | ||
*/ | ||
card_id: string | ||
|
||
/** | ||
* The exception name for the 3DS session | ||
*/ | ||
exception: string | ||
} | ||
|
||
interface ThreeDSecureSessionRecord { | ||
id: string | ||
resource_id: string | ||
card_id: string | ||
live_mode: boolean | ||
expires_at: string | ||
status: string | ||
client_id: string | ||
} | ||
|
||
export class ThreeDSecureSessions extends Resource { | ||
/** | ||
* Endpoint path | ||
*/ | ||
path: string | ||
|
||
constructor(args: any) { | ||
super(args) | ||
this.path = 'payments/three_d_secure_sessions' | ||
} | ||
|
||
/** | ||
* Create a Duffel ThreeDSecureSession record | ||
*/ | ||
public create = async ( | ||
data: ThreeDSecureSessionParameters, | ||
): Promise<DuffelResponse<ThreeDSecureSessionRecord>> => | ||
this.request({ method: 'POST', path: this.path, data }) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './ThreeDSecureSessions' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './Cards' | ||
export * from './ThreeDSecureSessions' |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@alan: This looks like a typo?
https://duffel.com/docs/api/v2/card/schema#card-schema-unavailable-at