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 pay by link multi payment support #183

Merged
merged 1 commit into from
Apr 16, 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
12 changes: 12 additions & 0 deletions samples/payment/RetrieveMultiPayment.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'
});

// change multi payment token below with a valid one
craftgate.payment().retrieveMultiPayment('6d7e66b5-9b1c-4c1d-879a-2557b651096e')
.then(payment => console.info('Multi payment retrieved', payment))
.catch(err => console.error('Failed to retrieve multi payment', err));
5 changes: 5 additions & 0 deletions src/adapter/PaymentAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import InitGarantiPayPaymentResponse from '../response/InitGarantiPayPaymentResp
import InitPosApmPaymentResponse from '../response/InitPosApmPaymentResponse';
import InitThreeDSPaymentResponse from '../response/InitThreeDSPaymentResponse';
import InstantTransferBanksResponse from '../response/InstantTransferBanksResponse';
import MultiPaymentResponse from '../response/MultiPaymentResponse';
import PaymentRefundResponse from '../response/PaymentRefundResponse';
import PaymentResponse from '../response/PaymentResponse';
import PaymentTransactionApprovalListResponse from '../response/PaymentTransactionApprovalListResponse';
Expand Down Expand Up @@ -207,6 +208,10 @@ export default class PaymentAdapter extends BaseAdapter {
return this._client.get(`/payment/v1/instant-transfer-banks`);
}

async retrieveMultiPayment(token: string): Promise<MultiPaymentResponse> {
return this._client.get(`/payment/v1/multi-payments/${token}`);
}

async is3DSecureCallbackVerified(threeDSecureCallbackKey: string, params: Map<string, string>): Promise<boolean> {
const hash = params['hash'];
const hashString: string = [
Expand Down
6 changes: 6 additions & 0 deletions src/model/MultiPaymentStatus.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
enum MultiPaymentStatus {
Created = 'CREATED',
Completed = 'COMPLETED'
}

export default MultiPaymentStatus;
2 changes: 2 additions & 0 deletions src/model/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import FraudValueType from './FraudValueType';
import LoyaltyType from './LoyaltyType';
import MemberType from './MemberType';
import MerchantType from './MerchantType';
import MultiPaymentStatus from './MultiPaymentStatus';
import PaymentAuthenticationType from './PaymentAuthenticationType';
import PaymentGroup from './PaymentGroup';
import PaymentMethod from './PaymentMethod';
Expand Down Expand Up @@ -68,6 +69,7 @@ export = {
LoyaltyType,
MemberType,
MerchantType,
MultiPaymentStatus,
PaymentGroup,
PaymentPhase,
PaymentMethod,
Expand Down
1 change: 1 addition & 0 deletions src/request/CreateProductRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ type CreateProductRequest = {
stock: number;
currency: Currency;
description: string;
multiPayment: boolean;
enabledInstallments: number[];
};

Expand Down
15 changes: 15 additions & 0 deletions src/response/MultiPaymentResponse.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import MultiPaymentStatus from '../model/MultiPaymentStatus';

type MultiPaymentResponse = {
id: number;
multiPaymentStatus: MultiPaymentStatus;
token: string;
conversationId: string;
externalId: string;
paidPrice: number;
remainingAmount: number;
tokenExpireDate: Date;
paymentIds: number[];
};

export default MultiPaymentResponse;
Loading