-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from hsndmr/add-retrieve-method-to-payment
Add retrieve method to payment
- Loading branch information
Showing
7 changed files
with
113 additions
and
7 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from './create-payment-request'; | ||
export * from './retrieve-payment-request'; |
32 changes: 32 additions & 0 deletions
32
packages/iyzipay-node/src/lib/requests/retrieve-payment-request.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,32 @@ | ||
import { Locale } from '../models'; | ||
import { RetrievePaymentRequest } from './retrieve-payment-request'; | ||
|
||
describe('RetrievePaymentRequest', () => { | ||
let request: RetrievePaymentRequest; | ||
|
||
beforeEach(() => { | ||
request = new RetrievePaymentRequest(); | ||
request.setLocale(Locale.TR); | ||
request.setConversationId('123456789'); | ||
request.setPaymentId(1); | ||
request.setPaymentConversationId('123456789'); | ||
}); | ||
|
||
it('should get request data', () => { | ||
// Arrange & Act & Assert | ||
const expectedJsonObject = { | ||
locale: request.getLocale(), | ||
conversationId: request.getConversationId(), | ||
paymentId: request.getPaymentId(), | ||
paymentConversationId: request.getPaymentConversationId(), | ||
}; | ||
|
||
expect(request.getRequestData()).toEqual(expectedJsonObject); | ||
}); | ||
|
||
it('should generate PKI request string', () => { | ||
const str = `[locale=tr,conversationId=123456789,paymentId=1,paymentConversationId=123456789]`; | ||
|
||
expect(request.toPKIRequestString()).toEqual(str); | ||
}); | ||
}); |
39 changes: 39 additions & 0 deletions
39
packages/iyzipay-node/src/lib/requests/retrieve-payment-request.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,39 @@ | ||
import { Request } from '../request'; | ||
import { RequestDataBuilder } from '../request-data-builder'; | ||
import { RequestStringBuilder } from '../request-string-builder'; | ||
|
||
export class RetrievePaymentRequest extends Request { | ||
private paymentId; | ||
private paymentConversationId; | ||
|
||
public getPaymentId() { | ||
return this.paymentId; | ||
} | ||
|
||
public setPaymentId(paymentId) { | ||
this.paymentId = paymentId; | ||
} | ||
|
||
public getPaymentConversationId() { | ||
return this.paymentConversationId; | ||
} | ||
|
||
public setPaymentConversationId(paymentConversationId) { | ||
this.paymentConversationId = paymentConversationId; | ||
} | ||
|
||
public getRequestData() { | ||
return RequestDataBuilder.fromObject(super.getRequestData()) | ||
.add('paymentId', this.getPaymentId()) | ||
.add('paymentConversationId', this.getPaymentConversationId()) | ||
.get(); | ||
} | ||
|
||
public toPKIRequestString() { | ||
return RequestStringBuilder.create() | ||
.appendSuper(super.toPKIRequestString()) | ||
.append('paymentId', this.getPaymentId()) | ||
.append('paymentConversationId', this.getPaymentConversationId()) | ||
.getRequestString(); | ||
} | ||
} |