Skip to content

Commit

Permalink
BKM Express flow improvements (#225)
Browse files Browse the repository at this point in the history
  • Loading branch information
deryacakmak authored Jan 3, 2025
1 parent c8c6605 commit d59b72b
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 0 deletions.
18 changes: 18 additions & 0 deletions samples/bkmExpress/CompleteBkmExpressPaymentByToken.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const Craftgate = require("../../dist");

const craftgate = new Craftgate.Client({
apiKey: "api-key",
secretKey: "secret-key",
baseUrl: "https://sandbox-api.craftgate.io"
});

const request = {
status: true,
message: "İşlem başarılı",
ticketId: "7c0f7c89-e954-46d5-ad37-2a5c0b5f0356",
bkmExpressPaymentToken: "23f4e147-2c4e-4a2c-8a67-9c783d813b79"
};

craftgate.bkmExpress().complete(request)
.then(result => console.info("Bkm Express payment complete successful", result))
.catch(err => console.error("Bkm Express payment complete failed", err));
12 changes: 12 additions & 0 deletions samples/bkmExpress/RetrieveBkmExpressPaymentByToken.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const Craftgate = require("../../dist");

const craftgate = new Craftgate.Client({
apiKey: "api-key",
secretKey: "secret-key",
baseUrl: "https://sandbox-api.craftgate.io"
});

craftgate.bkmExpress().retrievePaymentByToken("23f4e147-2c4e-4a2c-8a67-9c783d813b79")
.then(result => console.info("Payment retrieve successful", result))
.catch(err => console.error("Payment retrieve failed", err));

4 changes: 4 additions & 0 deletions src/adapter/BkmExpressPaymentAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,8 @@ export default class BkmExpressPaymentAdapter extends BaseAdapter {
async retrievePayment(ticketId: string): Promise<ReportingPaymentResponse> {
return this._client.get(`/payment/v1/bkm-express/payments/${ticketId}`);
}

async retrievePaymentByToken(token: string): Promise<ReportingPaymentResponse> {
return this._client.get(`/payment/v1/bkm-express/${token}`);
}
}
1 change: 1 addition & 0 deletions src/request/CompleteBkmExpressRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ type CompleteBkmExpressRequest = {
status: boolean;
message: string;
ticketId?: string;
bkmExpressPaymentToken?: string;
};

export default CompleteBkmExpressRequest;

0 comments on commit d59b72b

Please sign in to comment.