-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds Juzdan integration to Node.js client (#173)
- Loading branch information
1 parent
277e711
commit 56a1cbc
Showing
8 changed files
with
112 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
const Craftgate = require("../../dist"); | ||
|
||
const craftgate = new Craftgate.Client({ | ||
apiKey: "api-key", | ||
secretKey: "secret-key", | ||
baseUrl: "https://sandbox-api.craftgate.io" | ||
}); | ||
|
||
const request = { | ||
price: 100.0, | ||
paidPrice: 100.0, | ||
currency: Craftgate.Model.Currency.TRY, | ||
paymentGroup: Craftgate.Model.PaymentGroup.ListingOrSubscription, | ||
conversationId: '456d1297-908e-4bd6-a13b-4be31a6e47d5', | ||
externalId: 'testExternalId', | ||
callbackUrl: 'https://www.your-website.com/juzdan-payment-callback', | ||
paymentPhase: Craftgate.Model.PaymentPhase.Auth, | ||
paymentChannel: 'testPaymentChannel', | ||
bankOrderId: 'testBankOrderID', | ||
items: [ | ||
{ | ||
name: 'Item 1', | ||
price: 30.0, | ||
externalId: '123d1297-839e-4bd6-a13b-4be31a6e12a8' | ||
} | ||
], | ||
clientType: Craftgate.Model.ClientType.W, | ||
loanCampaignId: 1 | ||
}; | ||
|
||
craftgate.juzdan().initJuzdanPayment(request) | ||
.then(result => console.info("Juzdan Payment init successful, qrUrl is generated", result)) | ||
.catch(err => console.error("Juzdan Payment init failed", err)); |
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,13 @@ | ||
const Craftgate = require("../../dist"); | ||
|
||
const craftgate = new Craftgate.Client({ | ||
apiKey: "api-key", | ||
secretKey: "secret-key", | ||
baseUrl: "https://sandbox-api.craftgate.io" | ||
}); | ||
|
||
const referenceId = "testReferenceId" | ||
|
||
craftgate.juzdan().retrieveJuzdanPayment(referenceId) | ||
.then(result => console.info("Retrieve Juzdan payment is successful", result)) | ||
.catch(err => console.error("Retrieve Juzdan payment failed", err)); |
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import {ClientCreationOptions} from '../lib/HttpClient'; | ||
|
||
import PaymentResponse from '../response/PaymentResponse'; | ||
import BaseAdapter from './BaseAdapter'; | ||
import InitJuzdanPaymentRequest from '../request/InitJuzdanPaymentRequest'; | ||
import InitJuzdanPaymentResponse from '../response/InitJuzdanPaymentResponse'; | ||
|
||
export default class JuzdanPaymentAdapter extends BaseAdapter { | ||
constructor(options: ClientCreationOptions) { | ||
super(options); | ||
} | ||
|
||
async initJuzdanPayment(request: InitJuzdanPaymentRequest): Promise<InitJuzdanPaymentResponse> { | ||
return this._client.post('/payment/v1/juzdan-payments/init', request); | ||
} | ||
|
||
async retrieveJuzdanPayment(referenceId: string): Promise<PaymentResponse> { | ||
return this._client.get(`/payment/v1/juzdan-payments/${referenceId}`); | ||
} | ||
} |
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,6 @@ | ||
enum ClientType { | ||
W = 'W', | ||
M = 'M' | ||
} | ||
|
||
export default ClientType; |
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import Currency from '../model/Currency'; | ||
import PaymentGroup from '../model/PaymentGroup'; | ||
import PaymentPhase from '../model/PaymentPhase'; | ||
import PaymentItem from './dto/PaymentItem'; | ||
import ClientType from '../model/ClientType'; | ||
|
||
type InitJuzdanPaymentRequest = { | ||
price: number; | ||
paidPrice: number; | ||
currency: Currency; | ||
paymentGroup: PaymentGroup; | ||
conversationId?: string; | ||
externalId?: string; | ||
callbackUrl: string; | ||
paymentPhase: PaymentPhase; | ||
paymentChannel?: string; | ||
buyerMemberId?: number; | ||
bankOrderId?: string; | ||
items: PaymentItem[]; | ||
loanCampaignId?: number; | ||
clientType: ClientType; | ||
}; | ||
|
||
export default InitJuzdanPaymentRequest; |
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,6 @@ | ||
type InitJuzdanPaymentResponse = { | ||
referenceId: string; | ||
juzdanQrUrl: string; | ||
}; | ||
|
||
export default InitJuzdanPaymentResponse; |