Skip to content
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

Add GarantiPay v2 integration #176

Merged
merged 3 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions samples/payment/CompletePosApmPayment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const Craftgate = require('../../dist');

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

const request = {
paymentId: 1,
};

craftgate.payment().completePosApmPayment(request)
.then(result => console.info('Pos Apm complete payment successful', result))
.catch(err => console.error('Failed to complete Pos Apm payment', err));
41 changes: 41 additions & 0 deletions samples/payment/InitGarantiPayPosApmPayment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
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',
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));
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
Loading