Skip to content

Commit

Permalink
Add GarantiPay v2 integration
Browse files Browse the repository at this point in the history
  • Loading branch information
onurpolattimur committed Mar 18, 2024
1 parent 25516e1 commit f713b3d
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 6 deletions.
42 changes: 42 additions & 0 deletions samples/payment/InitGarantiPayPosApmPayment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
const Craftgate = require('../../dist');

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

const request = {
price: 100.0,
paidPrice: 100.0,
currency: Craftgate.Model.Currency.TRY,
paymentGroup: Craftgate.Model.PaymentGroup.ListingOrSubscription,
conversationId: '456d1297-908e-4bd6-a13b-4be31a6e47d5',
paymentProvider: Craftgate.Model.PosApmPaymentProvider.GarantiPay,
callbackUrl: 'https://www.your-website.com/craftgate-pos-apm-callback',
items: [
{
name: 'Item 1',
price: 30.0,
externalId: '123d1297-839e-4bd6-a13b-4be31a6e12a8'
},
{
name: 'Item 2',
price: 50.0,
externalId: '789d1297-839e-4bd6-a13b-4be31a6e13f7'
},
{
name: 'Item 3',
price: 20.0,
externalId: '3a1d1297-839e-4bd6-a13b-4be31a6e18e6'
}
],
additionalParams: {
integrationType: 'WEB2APP'
}
};

craftgate.payment().initPosApmPayment(request)
.then(result => console.info('Payment successful', result))
.catch(err => console.error('Payment failed', err));
File renamed without changes.
2 changes: 1 addition & 1 deletion src/CraftgateClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import FileReportingAdapter from './adapter/FileReportingAdapter';
import FraudAdapter from './adapter/FraudAdapter';
import HookAdapter from './adapter/HookAdapter';
import InstallmentAdapter from './adapter/InstallmentAdapter';
import JuzdanPaymentAdapter from './adapter/JuzdanPaymentAdapter';
import MasterpassPaymentAdapter from './adapter/MasterpassPaymentAdapter';
import MerchantAdapter from './adapter/MerchantAdapter';
import OnboardingAdapter from './adapter/OnboardingAdapter';
Expand All @@ -14,7 +15,6 @@ import SettlementAdapter from './adapter/SettlementAdapter';
import SettlementReportingAdapter from './adapter/SettlementReportingAdapter';
import WalletAdapter from './adapter/WalletAdapter';
import {ClientCreationOptions} from './lib/HttpClient';
import JuzdanPaymentAdapter from './adapter/JuzdanPaymentAdapter';

export default class CraftgateAdapter extends BaseAdapter {
private _installmentAdapter: InstallmentAdapter;
Expand Down
6 changes: 4 additions & 2 deletions src/adapter/JuzdanPaymentAdapter.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import {ClientCreationOptions} from '../lib/HttpClient';

import PaymentResponse from '../response/PaymentResponse';
import BaseAdapter from './BaseAdapter';
import InitJuzdanPaymentRequest from '../request/InitJuzdanPaymentRequest';

import InitJuzdanPaymentResponse from '../response/InitJuzdanPaymentResponse';
import PaymentResponse from '../response/PaymentResponse';

import BaseAdapter from './BaseAdapter';

export default class JuzdanPaymentAdapter extends BaseAdapter {
constructor(options: ClientCreationOptions) {
Expand Down
3 changes: 2 additions & 1 deletion src/model/PosApmPaymentProvider.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
enum PosApmPaymentProvider {
YkbWorldPay = 'YKB_WORLD_PAY',
YkbWorldPayShoppingLoan = 'YKB_WORLD_PAY_SHOPPING_LOAN',
GooglePay = 'GOOGLEPAY',
ApplePay = 'APPLEPAY'
GarantiPay = 'GARANTI_PAY'
}

export default PosApmPaymentProvider;
2 changes: 1 addition & 1 deletion src/model/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import CardAssociation from './CardAssociation';
import CardBrand from './CardBrand';
import CardExpiryStatus from './CardExpiryStatus';
import CardType from './CardType';
import ClientType from './ClientType';
import Currency from './Currency';
import FileStatus from './FileStatus';
import FraudAction from './FraudAction';
Expand Down Expand Up @@ -49,7 +50,6 @@ import WalletTransactionRefundTransactionType from './WalletTransactionRefundTra
import WalletTransactionType from './WalletTransactionType';
import WebhookEventType from './WebhookEventType';
import WebhookStatus from './WebhookStatus';
import ClientType from './ClientType';

export = {
AccountOwner,
Expand Down
3 changes: 2 additions & 1 deletion src/request/InitJuzdanPaymentRequest.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import ClientType from '../model/ClientType';
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;
Expand Down

0 comments on commit f713b3d

Please sign in to comment.