Skip to content

Commit

Permalink
feat: sipay added
Browse files Browse the repository at this point in the history
  • Loading branch information
onurkanbakirci committed Dec 25, 2023
1 parent f923ce4 commit 86fcb8e
Show file tree
Hide file tree
Showing 39 changed files with 1,116 additions and 15 deletions.
94 changes: 94 additions & 0 deletions .github/workflows/sipay-integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: Integration.PaymentGateways.Sipay

on:
workflow_dispatch:
workflow_call:
push:
branches:
- main

paths:
- src/Integration.Hub/**
- src/PaymentGateways/Integration.PaymentGateways.Sipay/**
- .github/workflows/sipay-integration.yml
- .github/workflows/composite/**

env:
#For build process
owner: onurkanbakirci
repo: Integration

project_path: ./src/PaymentGateways/Integration.PaymentGateways.Sipay/
nupkg_path: ./src/PaymentGateways/Integration.PaymentGateways.Sipay/bin/Release/Integration.PaymentGateways.Sipay.1.0.0.nupkg
nupkg_github_secret: ${{ secrets.GITHUB_TOKEN }}
nupkg_nuget_secret: ${{ secrets.NUGET_API_KEY }}
github_registry_url: https://nuget.pkg.github.com/onurkanbakirci/index.json
nuget_registry_url: https://api.nuget.org/v3/index.json

jobs:
build_lib:
name: Build Lib
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x

- name: Restore dependencies
run: dotnet restore

- name: Build
run: |
cd ${{env.project_path}}
dotnet build --no-restore
test_lib:
name: Test Lib
runs-on: ubuntu-latest
needs: build_lib

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Test
run: |
publish_lib_to_github:
name: Publish Lib to Github
runs-on: ubuntu-latest
needs: test_lib

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Push nuget package to github registry
uses: ./.github/workflows/composite/publish-lib
with:
package_source: ${{ env.github_registry_url }}
path: ${{ env.project_path }}
nupkg_path: ${{ env.nupkg_path }}
api_key: ${{ env.nupkg_github_secret }}

publish_lib_to_nuget:
name: Publish Lib to Nuget
runs-on: ubuntu-latest
needs: test_lib

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Push nuget package to nuget registry
uses: ./.github/workflows/composite/publish-lib
with:
package_source: ${{ env.nuget_registry_url }}
path: ${{ env.project_path }}
nupkg_path: ${{ env.nupkg_path }}
api_key: ${{ env.nupkg_nuget_secret }}
14 changes: 14 additions & 0 deletions Integration.sln
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "PaymentGateways", "PaymentG
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PaynetIntegrationSampleConsoleApp", "samples\PaymentGateways\PaynetIntegrationSampleConsoleApp\PaynetIntegrationSampleConsoleApp.csproj", "{E9D8CC15-86F9-4BCD-903A-689112662FE8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Integration.PaymentGateways.Sipay", "src\PaymentGateways\Integration.PaymentGateways.Sipay\Integration.PaymentGateways.Sipay.csproj", "{D881792A-2FF3-42C8-AD85-70A5F279D6DD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SipayIntegrationSampleConsoleApp", "samples\PaymentGateways\SipayIntegrationSampleConsoleApp\SipayIntegrationSampleConsoleApp.csproj", "{E6169DA7-4B5C-49AF-90E3-57D55FA554C4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -66,6 +70,14 @@ Global
{E9D8CC15-86F9-4BCD-903A-689112662FE8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E9D8CC15-86F9-4BCD-903A-689112662FE8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E9D8CC15-86F9-4BCD-903A-689112662FE8}.Release|Any CPU.Build.0 = Release|Any CPU
{D881792A-2FF3-42C8-AD85-70A5F279D6DD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D881792A-2FF3-42C8-AD85-70A5F279D6DD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D881792A-2FF3-42C8-AD85-70A5F279D6DD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D881792A-2FF3-42C8-AD85-70A5F279D6DD}.Release|Any CPU.Build.0 = Release|Any CPU
{E6169DA7-4B5C-49AF-90E3-57D55FA554C4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E6169DA7-4B5C-49AF-90E3-57D55FA554C4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E6169DA7-4B5C-49AF-90E3-57D55FA554C4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E6169DA7-4B5C-49AF-90E3-57D55FA554C4}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{2E841AED-7444-4875-8D11-D756A01105FD} = {8D1AC917-32E3-4579-9A06-B6190C1B9F31}
Expand All @@ -79,5 +91,7 @@ Global
{3B5D9A6A-FA30-42C6-8C3D-7A38314B64D3} = {D54A7D33-8E81-413F-B1D5-D9DF65BA1D83}
{572AD2AF-7896-4707-8D3A-8EAFF16991C0} = {51C29F15-6693-428D-9705-1986F8C71428}
{E9D8CC15-86F9-4BCD-903A-689112662FE8} = {572AD2AF-7896-4707-8D3A-8EAFF16991C0}
{D881792A-2FF3-42C8-AD85-70A5F279D6DD} = {D54A7D33-8E81-413F-B1D5-D9DF65BA1D83}
{E6169DA7-4B5C-49AF-90E3-57D55FA554C4} = {572AD2AF-7896-4707-8D3A-8EAFF16991C0}
EndGlobalSection
EndGlobal
112 changes: 109 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
</a>
<img src="https://yt3.googleusercontent.com/tOTacHyEgTXLN6JWT8ftiZ-xtHnX0R_XFRRS-AB_A9FXVrTC5-QhAWNF0pfWi2yi_APG3Q4N1Q=s900-c-k-c0x00ffffff-no-rj" width="48">
<img src="https://media.licdn.com/dms/image/C4D0BAQE1iTu5X4_WDw/company-logo_200_200/0/1679918244582?e=1710979200&v=beta&t=CccfF3oAMI5QYf_LWKzcvfAocW7x_1aIzXGpgFbueZo" width="48">
<img src="https://pbs.twimg.com/profile_images/1723743306796953601/ETtAZnlV_400x400.jpg" width="48">
<img src="https://www.paynet.com.tr/themes/custom/paynet/images/og.jpg" width="90">
</p>

Expand All @@ -21,6 +22,7 @@ Enhance your integration workflows by leveraging the Integration Library, which
**Integration.Marketplaces.Trendyol** | ![build](https://github.com/onurkanbakirci/Integration/actions/workflows/trendyol-integration.yml/badge.svg) | 1.0.1
**Integration.Marketplaces.Hepsiburada** | ![build](https://github.com/onurkanbakirci/Integration/actions/workflows/hepsiburada-integration.yml/badge.svg) | 1.0.1
**Integration.PaymentGateways.Paynet** | ![build](https://github.com/onurkanbakirci/Integration/actions/workflows/paynet-integration.yml/badge.svg) | 1.0.0
**Integration.PaymentGateways.Sipay** | ![build](https://github.com/onurkanbakirci/Integration/actions/workflows/sipay-integration.yml/badge.svg) | 1.0.0

## Table of contents

Expand All @@ -32,6 +34,7 @@ Enhance your integration workflows by leveraging the Integration Library, which
- [Trendyol](#trendyol)
- [Hepsiburada](#hepsiburada)
- [Paynet](#paynet)
- [Sipay](#sipay)


## Introduction
Expand Down Expand Up @@ -148,10 +151,9 @@ var securePaymentInitialResponse = await paynetPaymentIntegration.SecurePaymentI
Console.WriteLine(securePaymentInitialResponse.HtmlContent);

// 3. After successfull 3d confirmation, secure payment charge
var securePaymentChargeRequest = new SecurePaymentChargeRequestModel(
var securePaymentChargeRequest = await paynetPaymentIntegration.SecurePaymentChargeAsync(new SecurePaymentChargeRequestModel(
sessionId: securePaymentInitialResponse.SessionId,
tokenId: securePaymentInitialResponse.TokenId);

tokenId: securePaymentInitialResponse.TokenId));

// Cancel payment
var cancelResponse = await paynetPaymentIntegration.CancelAsync(new CancellationRequestModel(
Expand All @@ -165,4 +167,108 @@ var refundResponse = await paynetPaymentIntegration.RefundAsync(new RefundReques
amount: "100",
succeedUrl: "succeedUrl"
));
```

### Sipay

```
dotnet add package Integration.PaymentGateways.Sipay --version 1.0.0
```

```c#
using Integration.PaymentGateways.Sipay.Infrastructure.PaymentIntegration.Models.Request;
using Integration.PaymentGateways.Sipay.Infrastructure.PaymentIntegration.Models.Response;

var sipayPaymentIntegration = new SipayPaymentIntegration(
merchantKey: "merchantKey",
appKey: "appKey",
appSecret: "appSecret",
merchantId: 0,
isInProduction: false
);

// Get installments
var installments = await sipayPaymentIntegration.CheckInstallmentsAsync(new CheckInstallmentRequestModel(
creaditCard: "123456",
amount: 100,
currenyCode: "TRY"
));

// Non secure payment
var nonSecurePaymentResponse = await sipayPaymentIntegration.NonSecurePaymentAsync(new NonSecurePaymentRequestModel(
ccHolderName: "John Doe",
ccNo: "123456",
expiryMonth: 12,
expiryYear: 2022,
cvv: 123,
currencyCode: "TRY",
installmentsNumber: 1,
invoiceId: 1,
invoiceDescription: "Invoice description",
name: "John",
surname: "Doe",
total: 100,
items: "items",
cancelUrl: "https://cancelUrl.com",
returnUrl: "https://returnUrl.com",
hashKey: "hashKey",
ip: "",
orderType: 0
));

// Secure payment
// 1. Get secure payment hmtl content and show to user
var securePaymentInitialHtml = sipayPaymentIntegration.SecurePaymentInitial(new SecurePaymentInitialRequestModel(
ccHolderName: "John Doe",
ccNo: "123456",
expiryMonth: 12,
expiryYear: 2022,
cvv: 123,
currencyCode: "TRY",
installmentsNumber: 1,
invoiceId: "1",
invoiceDescription: "Invoice description",
name: "John",
surname: "Doe",
total: 100,
items: "items",
cancelUrl: "https://cancelUrl.com",
returnUrl: "https://returnUrl.com",
hashKey: "hashKey",
orderType: 0,
recurringPaymentNumber: 0,
recurringPaymentCycle: "",
recurringPaymentInterval: "",
recurringWebHookKey: "",
maturityPeriod: 0,
paymentFrequency: 0
));

// 2. Show 3ds html content to user
Console.WriteLine(securePaymentInitialHtml);

// 3. After successfull 3d confirmation, secure payment charge
var securePaymentChargeRequest = await sipayPaymentIntegration.SecurePaymentChargeAsync(new SecurePaymentChargeRequestModel(
invoiceId: "1",
orderId: "1",
status: "1",
hashKey: ""));


// Cancel payment
var cancelResponse = await sipayPaymentIntegration.CancelAsync(new CancellationRequestModel(
invoiceId: "",
hashKey: "",
refundTransactionId: "",
refundWebhookKey: ""
));

// Refund payment
var refundResponse = await sipayPaymentIntegration.RefundAsync(new RefundRequestModel(
invoiceId: "",
amount: 100,
hashKey: "",
refundTransactionId: "",
refundWebhookKey: ""
));
```
4 changes: 2 additions & 2 deletions docs/integration/docs/payment-gateways/paynet.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ Console.WriteLine(securePaymentInitialResponse.HtmlContent);

3. **After successfull 3d confirmation, secure payment charge**
```csharp
var securePaymentChargeRequest = new SecurePaymentChargeRequestModel(
var securePaymentChargeRequest = await paynetPaymentIntegration.SecurePaymentChargeAsync(new SecurePaymentChargeRequestModel(
sessionId: securePaymentInitialResponse.SessionId,
tokenId: securePaymentInitialResponse.TokenId);
tokenId: securePaymentInitialResponse.TokenId));
```

### Cancel payment
Expand Down
Loading

0 comments on commit 86fcb8e

Please sign in to comment.