-
Notifications
You must be signed in to change notification settings - Fork 9
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 endpoints about ThreeDSecureRequest object. #63
Changes from 3 commits
d8274c0
659dc8d
921763e
fbee108
75a6974
d89038b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,8 +11,9 @@ | |
import Statements from './statement'; | ||
import Terms from "./term"; | ||
import Balances from "./balance"; | ||
import ThreeDSecureRequests from "./threeDSecureRequest"; | ||
|
||
namespace Payjp { | ||
Check warning on line 16 in src/index.ts GitHub Actions / testing (14)
Check warning on line 16 in src/index.ts GitHub Actions / testing (16)
Check warning on line 16 in src/index.ts GitHub Actions / testing (18)
|
||
export interface PayjpStatic { | ||
(apikey: string, options?: PayjpOptions): Payjp; | ||
} | ||
|
@@ -33,6 +34,7 @@ | |
statements: Statements, | ||
terms: Terms, | ||
balances: Balances, | ||
three_d_secure_requests: ThreeDSecureRequests, | ||
} | ||
|
||
export interface PayjpOptions { | ||
|
@@ -237,6 +239,8 @@ | |
url: string | ||
} | ||
|
||
type ThreeDSecureStatus = null | 'unverified' | 'verified' | 'attempted' | 'failed' | 'error'; | ||
|
||
export interface Charge { | ||
object: "charge", | ||
amount: number, | ||
|
@@ -263,8 +267,8 @@ | |
platform_fee_rate?: string | null, | ||
total_platform_fee?: number, | ||
tenant?: string | null, | ||
product?: any, | ||
Check warning on line 270 in src/index.ts GitHub Actions / testing (14)
Check warning on line 270 in src/index.ts GitHub Actions / testing (16)
Check warning on line 270 in src/index.ts GitHub Actions / testing (18)
|
||
three_d_secure_status: string | null, | ||
three_d_secure_status: ThreeDSecureStatus, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. three_d_secure_statusプロパティは現状chargeとcardにあります。cardも合わせてもらえますか? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fbee108 |
||
term_id: string | null, | ||
} | ||
|
||
|
@@ -544,6 +548,31 @@ | |
bank_info: null | BankInfo | ||
} | ||
|
||
export interface ThreeDSecureRequest { | ||
object: 'three_d_secure_request', | ||
id: string, | ||
resource_id: string, | ||
livemode: boolean, | ||
created: number, | ||
state: 'created' | 'in_progress' | 'result_received' | 'finished', | ||
started_at: null | number, | ||
result_received_at: null | number, | ||
finished_at: null | number, | ||
expired_at: null | number, | ||
tenant_id: null | string, | ||
three_d_secure_status: ThreeDSecureStatus, | ||
} | ||
|
||
export interface ThreeDSecureRequestCreationOptions { | ||
resource_id: string, | ||
tenant_id?: string, | ||
} | ||
|
||
export interface ThreeDSecureRequestListOptions extends ListOptions { | ||
resource_id?: string, | ||
tenant_id?: string, | ||
} | ||
|
||
export interface Deleted { | ||
deleted: boolean, | ||
id: string, | ||
|
@@ -563,11 +592,11 @@ | |
|
||
export interface ResponseError { | ||
status?: number | undefined, | ||
response?: { body?: PayjpError, [propName: string]: any } | undefined, | ||
Check warning on line 595 in src/index.ts GitHub Actions / testing (14)
Check warning on line 595 in src/index.ts GitHub Actions / testing (16)
Check warning on line 595 in src/index.ts GitHub Actions / testing (18)
|
||
message: string, | ||
timeout?: number, | ||
|
||
[propName: string]: any, | ||
Check warning on line 599 in src/index.ts GitHub Actions / testing (14)
Check warning on line 599 in src/index.ts GitHub Actions / testing (16)
Check warning on line 599 in src/index.ts GitHub Actions / testing (18)
|
||
} | ||
} | ||
|
||
|
@@ -605,6 +634,7 @@ | |
statements: new Statements(payjpConfig), | ||
terms: new Terms(payjpConfig), | ||
balances: new Balances(payjpConfig), | ||
three_d_secure_requests: new ThreeDSecureRequests(payjpConfig), | ||
}; | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import Resource from './resource'; | ||
import * as I from './index'; | ||
|
||
export default class ThreeDSecureRequests extends Resource { | ||
resource: string; | ||
|
||
constructor(payjp) { | ||
super(payjp); | ||
this.resource = 'three_d_secure_requests'; | ||
} | ||
|
||
list(query: I.ThreeDSecureRequestListOptions = {}): Promise<I.List<I.ThreeDSecureRequest>> { | ||
return this.request('GET', this.resource, query); | ||
} | ||
|
||
create(query: I.ThreeDSecureRequestCreationOptions): Promise<I.ThreeDSecureRequest> { | ||
return this.request('POST', this.resource, query); | ||
} | ||
|
||
retrieve(id: string): Promise<I.ThreeDSecureRequest> { | ||
return this.request('GET', `${this.resource}/${id}`); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
const assert = require('assert'); | ||
const Payjp = require('../built'); | ||
const config = require('./config'); | ||
|
||
const payjp = Payjp(config.apikey, config); | ||
payjp.three_d_secure_requests.request = (...args) => Promise.resolve(args); | ||
|
||
describe('ThreeDSecureRequest Resource', () => { | ||
describe('list', () => { | ||
it('Sends the correct request', () => { | ||
return payjp.three_d_secure_requests.list().then(([_method, _endpoint]) => { | ||
assert(_method === 'GET'); | ||
assert(_endpoint === 'three_d_secure_requests'); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('create', () => { | ||
it('Sends the correct request', () => { | ||
const query = { | ||
resource_id: 'car_xxxxxxxxxxxxxxxxxxxxxxxxx' | ||
}; | ||
return payjp.three_d_secure_requests.create(query).then(([_method, _endpoint]) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. queryのassertionも足したいですね There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 75a6974 |
||
assert(_method === 'POST'); | ||
assert(_endpoint === 'three_d_secure_requests'); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('retrieve', () => { | ||
it('Sends the correct request', () => { | ||
return payjp.three_d_secure_requests.retrieve('id123').then(([_method, _endpoint]) => { | ||
assert(_method === 'GET'); | ||
assert(_endpoint === 'three_d_secure_requests/id123'); | ||
}); | ||
}); | ||
}); | ||
|
||
}); |
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.
クラス名に合わせてファイルもthreeDSecureRequests(末尾のsつける)がいいんじゃないですかね。
本来は他のリソースもそうすべきに見える
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.
振る舞いに変更は無いので一旦このPRではこのままにしておきたいです。
別 PR で対処させてください。