Skip to content

Commit

Permalink
Add ApplePay integration
Browse files Browse the repository at this point in the history
  • Loading branch information
onurpolattimur committed Sep 26, 2023
1 parent ddadee1 commit f0d0fd1
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/adapter/PaymentAdapter.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {ClientCreationOptions} from '../lib/HttpClient';
import {calculateHash} from '../lib/utils';

import ApplePayMerchantSessionCreateRequest from '../request/ApplePayMerchantSessionCreateRequest';
import ApprovePaymentTransactionsRequest from '../request/ApprovePaymentTransactionsRequest';
import CompleteApmPaymentRequest from '../request/CompleteApmPaymentRequest';
import CompletePosApmPaymentRequest from '../request/CompletePosApmPaymentRequest';
Expand Down Expand Up @@ -176,6 +177,10 @@ export default class PaymentAdapter extends BaseAdapter {
return this._client.put(`/payment/v1/payment-transactions/${paymentTransactionId}`, request);
}

async createApplePayMerchantSession(request: ApplePayMerchantSessionCreateRequest): Promise<any> {
return this._client.post(`/payment/v1/apple-pay/merchant-sessions`, request);
}

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

export default TokenizedCardType;
4 changes: 3 additions & 1 deletion src/model/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import SettlementEarningsDestination from './SettlementEarningsDestination';
import SettlementSource from './SettlementSource';
import SettlementType from './SettlementType';
import Status from './Status';
import TokenizedCardType from './TokenizedCardType';
import TransactionPayoutStatus from './TransactionPayoutStatus';
import TransactionStatus from './TransactionStatus';
import WalletTransactionRefundTransactionType from './WalletTransactionRefundTransactionType';
Expand Down Expand Up @@ -79,5 +80,6 @@ export = {
WalletTransactionType,
ReportFileType,
WebhookEventType,
WebhookStatus
WebhookStatus,
TokenizedCardType
};
9 changes: 9 additions & 0 deletions src/request/ApplePayMerchantSessionCreateRequest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
type ApplePayMerchantSessionCreateRequest = {
merchantIdentifier: string;
displayName: string;
initiative: string;
initiativeContext: string;
validationUrl: string;
};

export default ApplePayMerchantSessionCreateRequest;
10 changes: 9 additions & 1 deletion src/request/dto/Card.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {Loyalty} from '../../model/Loyalty';
import TokenizedCardType from '../../model/TokenizedCardType';

export type PaymentCard = {
cardAlias?: string;
Expand All @@ -24,4 +25,11 @@ export type First6Last4CardWithIdentityNumber = {
lastFourDigits: string;
};

export type Card = PaymentCard | StoredCard | First6Last4CardWithIdentityNumber;
export type TokenizedCard = {
tokenizedCard: {
type: TokenizedCardType;
data: any;
};
};

export type Card = PaymentCard | StoredCard | First6Last4CardWithIdentityNumber | TokenizedCard;

0 comments on commit f0d0fd1

Please sign in to comment.