Skip to content

Commit

Permalink
Merge branch 'master' into bkm-express-flow-improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
deryacakmak authored Jan 3, 2025
2 parents 0f533f5 + c8c6605 commit c312781
Show file tree
Hide file tree
Showing 24 changed files with 98 additions and 44 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@craftgate/craftgate",
"version": "1.0.52",
"version": "1.0.54",
"description": "Craftgate API JavaScript Client",
"main": "dist/index.js",
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ const request = {
]
};

craftgate
.payment()
.initApmPayment(request)
craftgate.payment().initApmPayment(request)
.then(result => console.info('Instant Transfer Apm payment successful', result))
.catch(err => console.error('Failed to create Instant Transfer Apm payment', err));
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ const craftgate = new Craftgate.Client({
baseUrl: 'https://sandbox-api.craftgate.io'
});

craftgate
.payment()
.retrieveActiveBanks()
craftgate.payment().retrieveActiveBanks()
.then(results => console.info('Retrieve instant transfer active banks response ', results))
.catch(err => console.error('Failed to retrieve instant transfer active banks', err));
4 changes: 1 addition & 3 deletions samples/onboarding/CreateBuyer.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ const request = {
address: 'Suadiye Mah. Örnek Cd. No:23, 34740 Kadıköy/İstanbul'
};

craftgate
.onboarding()
.createMember(request)
craftgate.onboarding().createMember(request)
.then(result => console.info('Buyer member created', result))
.catch(err => console.error('Failed to create buyer member', err));
4 changes: 1 addition & 3 deletions samples/onboarding/CreateMemberAsBuyerAndSubMerchant.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ const request = {
address: 'Suadiye Mah. Örnek Cd. No:23, 34740 Kadıköy/İstanbul'
};

craftgate
.onboarding()
.createMember(request)
craftgate.onboarding().createMember(request)
.then(result => console.info('Member created', result))
.catch(err => console.error('Failed to create member', err));
4 changes: 1 addition & 3 deletions samples/onboarding/CreateSubMerchant.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ const request = {
address: 'Suadiye Mah. Örnek Cd. No:23, 34740 Kadıköy/İstanbul'
};

craftgate
.onboarding()
.createMember(request)
craftgate.onboarding().createMember(request)
.then(result => console.info('Sub merchant member created', result))
.catch(err => console.error('Failed to create sub merchant member', err));
4 changes: 1 addition & 3 deletions samples/onboarding/UpdateBuyer.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ const request = {
};

// change the memberId (displayed as 1 below) with a valid id to run the sample
craftgate
.onboarding()
.updateMember(1, request)
craftgate.onboarding().updateMember(1, request)
.then(result => console.info('Buyer member updated', result))
.catch(err => console.error('Failed to update buyer member', err));
4 changes: 1 addition & 3 deletions samples/onboarding/UpdateSubMerchant.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ const request = {
};

// change the memberId (displayed as 1 below) with a valid id to run the sample
craftgate
.onboarding()
.updateMember(1, request)
craftgate.onboarding().updateMember(1, request)
.then(result => console.info('Sub merchant member updated', result))
.catch(err => console.error('Failed to update sub merchant member', err));
33 changes: 33 additions & 0 deletions samples/payment/InitBizumApmPayment.js
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 = {
apmType: Craftgate.Model.ApmType.Bizum,
price: 1.0,
paidPrice: 1.0,
currency: Craftgate.Model.Currency.EUR,
paymentGroup: Craftgate.Model.PaymentGroup.ListingOrSubscription,
conversationId: 'conversationId',
items: [
{
name: 'Item 1',
price: 0.4,
externalId: '123d1297-839e-4bd6-a13b-4be31a6e12a8'
},
{
name: 'Item 2',
price: 0.6,
externalId: '789d1297-839e-4bd6-a13b-4be31a6e13f7'
}
],
additionalParams: {"buyerPhoneNumber": "34700000000"}
};

craftgate.payment().initApmPayment(request)
.then(result => console.info('Bizum Apm init payment successful', result))
.catch(err => console.error('Failed to init Bizum Apm payment', err));
1 change: 1 addition & 0 deletions samples/payment/InitGarantiPayPayment.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const request = {
totalPrice: 125
}
],
enabledInstallments: [2,3],
conversationId: '456d1297-908e-4bd6-a13b-4be31a6e47d5',
currency: Craftgate.Model.Currency.TRY,
paymentGroup: Craftgate.Model.PaymentGroup.ListingOrSubscription,
Expand Down
4 changes: 1 addition & 3 deletions samples/payment/InitKlarnaApmPayment.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ const request = {
}
};

craftgate
.payment()
.initApmPayment(request)
craftgate.payment().initApmPayment(request)
.then(result => console.info('Klarna Apm init payment successful', result))
.catch(err => console.error('Failed to init Klarna Apm payment', err));
36 changes: 36 additions & 0 deletions samples/payment/InitPaymobApmPayment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const Craftgate = require('../../dist');

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

const request = {
apmType: Craftgate.Model.ApmType.Paymob,
price: 1.0,
paidPrice: 1.0,
currency: Craftgate.Model.Currency.EGP,
paymentGroup: Craftgate.Model.PaymentGroup.ListingOrSubscription,
conversationId: 'conversationId',
callbackUrl: 'https://www.your-website.com/craftgate-apm-callback',
items: [
{
name: 'Item 1',
price: 0.4,
externalId: '123d1297-839e-4bd6-a13b-4be31a6e12a8'
},
{
name: 'Item 2',
price: 0.6,
externalId: '789d1297-839e-4bd6-a13b-4be31a6e13f7'
}
],
additionalParams: {
"integrationId": "11223344"
},
};

craftgate.payment().initApmPayment(request)
.then(result => console.info('Paymob Apm init payment successful', result))
.catch(err => console.error('Failed to init Paymob Apm payment', err));
4 changes: 1 addition & 3 deletions samples/settlement/CreateInstantWalletSettlement.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ const request = {
excludedSubMerchantMemberIds: [] // you can add member ids for excluding from settlement
};

craftgate
.settlement()
.createInstantWalletSettlement(request)
craftgate.settlement().createInstantWalletSettlement(request)
.then(result => console.info('Instant wallet settlement create response', result))
.catch(err => console.error('Failed to create instant wallet settlement', err));
4 changes: 1 addition & 3 deletions samples/settlement/CreatePayoutAccountForMerchant.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ const request = {
accountOwner: Craftgate.Model.AccountOwner.MERCHANT
};

craftgate
.settlement()
.createPayoutAccount(request)
craftgate.settlement().createPayoutAccount(request)
.then(result => console.info('Payout Account create response', result))
.catch(err => console.error('Failed to create payout account', err));
4 changes: 1 addition & 3 deletions samples/settlement/CreatePayoutAccountForSubMerchant.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ const request = {
subMerchantMemberId: 1
};

craftgate
.settlement()
.createPayoutAccount(request)
craftgate.settlement().createPayoutAccount(request)
.then(result => console.info('Payout Account create response', result))
.catch(err => console.error('Failed to create payout account', err));
4 changes: 1 addition & 3 deletions samples/settlement/DeletePayoutAccount.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,5 @@ const craftgate = new Craftgate.Client({
baseUrl: 'https://sandbox-api.craftgate.io'
});

craftgate
.settlement()
.deletePayoutAccount(11)
craftgate.settlement().deletePayoutAccount(11)
.catch(err => console.error('Failed to delete payout account', err));
4 changes: 1 addition & 3 deletions samples/settlement/UpdatePayoutAccount.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,5 @@ const request = {
externalAccountId: 'wiseRecipientId2'
};

craftgate
.settlement()
.updatePayoutAccount(11, request)
craftgate.settlement().updatePayoutAccount(11, request)
.catch(err => console.error('Failed to update payout account', err));
2 changes: 1 addition & 1 deletion src/adapter/SettlementAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default class SettlementAdapter extends BaseAdapter {
}

async createInstantWalletSettlement(request: CreateInstantWalletSettlementRequest): Promise<SettlementResponse> {
return this._client.get('/settlement/v1/instant-wallet-settlements', request);
return this._client.post('/settlement/v1/instant-wallet-settlements', request);
}

async createPayoutAccount(request: CreatePayoutAccountRequest): Promise<PayoutAccountResponse> {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/HttpClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export class HttpClient {
config.headers[API_KEY_HEADER_NAME] = this._options.apiKey;
config.headers[RANDOM_HEADER_NAME] = randomStr;
config.headers[AUTH_VERSION_HEADER_NAME] = '1';
config.headers[CLIENT_VERSION_HEADER_NAME] = 'craftgate-node-client:1.0.52';
config.headers[CLIENT_VERSION_HEADER_NAME] = 'craftgate-node-client:1.0.54';
if (this._options.language) {
config.headers[LANGUAGE_HEADER_NAME] = this._options.language;
}
Expand Down
4 changes: 3 additions & 1 deletion src/model/ApmType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ enum ApmType {
Multinet = 'MULTINET',
MultinetGift = 'MULTINET_GIFT',
IsPay = 'ISPAY',
Chippin = 'CHIPPIN'
Chippin = 'CHIPPIN',
Bizum = 'BIZUM',
Paymob = 'PAYMOB'
}

export default ApmType;
3 changes: 3 additions & 0 deletions src/model/PaymentProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ enum PaymentProvider {
Haso = 'HASO',
Multinet = 'MULTINET',
IsPay = 'ISPAY',
Chippin = 'CHIPPIN',
Paymob = 'PAYMOB',
Bizum = 'BIZUM',
Offline = 'OFFLINE'
}

Expand Down
4 changes: 3 additions & 1 deletion src/model/WebhookEventType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ enum WebhookEventType {
Autopilot = 'AUTOPILOT',
WalletCreated = 'WALLET_CREATED',
WalletTxCreated = 'WALLET_TX_CREATED',
BnplNotification = 'BNPL_NOTIFICATION'
BnplNotification = 'BNPL_NOTIFICATION',
MultiPaymentCompleted = 'MULTI_PAYMENT_COMPLETED',
BkmExpressPaymentNotification = 'BKM_EXPRESS_PAYMENT_NOTIFICATION'
}

export default WebhookEventType;
1 change: 1 addition & 0 deletions src/request/InitGarantiPayPaymentRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type InitGarantiPayPaymentRequest = {
bankOrderId?: string;
posAlias?: string;
items: PaymentItem[];
enabledInstallments: number[];
};

export default InitGarantiPayPaymentRequest;
2 changes: 2 additions & 0 deletions src/response/dto/InstallmentPrice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ type InstallmentPrice = {
totalPrice: number;
installmentLabel: string;
loyaltySupported: boolean;
force3ds: boolean;
cvcRequired: boolean;
};

export default InstallmentPrice;

0 comments on commit c312781

Please sign in to comment.