Skip to content

Commit 632537f

Browse files
@basefy/subscription (#105)
* Refactored `IyzipayResource` to remove v1 auth structure and redundant PKI string generation methods and streamline the signature calculation process across payment operations. * Added missing `api_key` and `secret_key` to API test configuration. * Updated image path in sample scripts to use `./images/` directory and added missing sample image. * Added `ThreedsV2Payment` resource and sample script for 3D Secure v2 payments. * Updated sample `create_threeds_v2_payment.py` with realistic test data for `paymentId` and `basketId`. * Added `fast_link` method to `IyziLinkProduct` and sample script for generating fast links. * Added `update_product_status` method to `IyziLinkProduct` and sample script for updating product status. * Added `update_item` method for Marketplace sub merchants and a sample script for updating sub-merchant items. * Added `refund` Payment service method to `IyzipayResource` and sample script for refunding payments. * Added `PayWithIyzico` resource and sample script for initializing Pay With Iyzico payments. * Updated `RetrievePaymentDetails` method to support `paymentId` as an optional parameter and modified the sample script accordingly. * Added `ReportingScrollTransaction` resource to retrieve paginated transaction reports. * Added `SubscriptionProduct` resource and sample script for creating subscription products. * Added `list` method to `SubscriptionProduct` and sample script for listing subscription products. * Added `retrieve` method to `SubscriptionProduct` and sample script for retrieving subscription products. * Added `delete` method to `SubscriptionProduct` and sample script for deleting subscription products. * Added `update` method to `SubscriptionProduct` and sample script for updating subscription products. * Added `SubscriptionPricingPlan` resource and sample script for creating subscription pricing plans. * Added `list` method to `SubscriptionPricingPlan` and sample script for listing subscription pricing plans. * Added `update` method to `SubscriptionPricingPlan` and sample script for updating subscription pricing plans. * Added `retrieve` method to `SubscriptionPricingPlan` and sample script for retrieving subscription pricing plans. * Added `delete` method to `SubscriptionPricingPlan` and sample script for deleting subscription pricing plans * Added `create` method to `SubscriptionCheckoutForm` and sample script for initializing subscription checkout forms * Added `retrieve` method to `SubscriptionCheckoutForm` and sample script for retrieving subscription checkout forms * Added `retrieve` method to `Subscription` and sample script for listing subscriptions * Refactored variable names in subscription samples for clarity and consistency * Added `initialize` method to `Subscription` and sample script for initializing subscriptions * Added `initialize_with_customer` method to `Subscription` and sample script for initializing subscriptions for a specific customer * Renamed `subscription_list.py` to `subscription_retrieve.py` in subscription samples for better alignment with functionality. * Added `payment_card_pki` method to `iyzipay_resource.py` for building PKI strings from payment card details * Added `list` method to `Subscription` and sample script for listing subscriptions with query parameters * Added `activate` method to `Subscription` and sample script for activating subscriptions * Added `retry` method to `Subscription` and sample script for retrying subscription operations * Added `cancel` method to `Subscription` and sample script for canceling subscriptions * Added `upgrade` method to `Subscription` and sample script for upgrading subscriptions * Added `SubscriptionCardUpdate` class with `initialize` and `initialize_with_subscription` methods, and sample scripts for updating subscription cards * Added `SubscriptionCustomer` class with `create` method and sample script for creating subscription customers * Added `update` method to `SubscriptionCustomer` and sample script for updating subscription customer details * Added `retrieve` method to `SubscriptionCustomer` and sample script for retrieving subscription customer details * Added `delete` method to `SubscriptionCustomer` and sample script for deleting subscription customers * Added `list` method to `SubscriptionCustomer` and sample script for listing subscription customers * Added `PayWithIyzico` to imports and corrected HTTP method for `SubscriptionProduct.update` * Removed debug print statement from `delete` method in `iyzipay_resource` * Fixed incorrect print statement in `subscription_pricing_plan_delete.py` sample script. * Updated Python version classifiers in `setup.py`, added support for Python 3.13, and removed deprecated versions. * Updated GitHub Actions: Upgraded `actions/checkout` to v4, `actions/setup-python` to v5, expanded matrix to include Python 3.9–3.13 --------- Signed-off-by: Bünyamin Yaşar <33955141+byasarcse@users.noreply.github.com> Co-authored-by: Osman Keser <osman@basefy.com>
1 parent 166a788 commit 632537f

43 files changed

Lines changed: 973 additions & 643 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/github_master.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ jobs:
1313
runs-on: ubuntu-latest
1414

1515
steps:
16-
- uses: actions/checkout@v3
16+
- uses: actions/checkout@v4
1717
- name: Set up Python
18-
uses: actions/setup-python@v3
18+
uses: actions/setup-python@v5
1919
with:
2020
python-version: '3.x'
2121

.github/workflows/github_pull_request.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ jobs:
1414

1515
strategy:
1616
matrix:
17-
python-version: ['3.12', '3.13', '3.14']
17+
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
1818

1919
steps:
20-
- uses: actions/checkout@v3
20+
- uses: actions/checkout@v4
2121
- name: Set up Python
22-
uses: actions/setup-python@v3
22+
uses: actions/setup-python@v5
2323
with:
2424
python-version: ${{ matrix.python-version }}
2525
- name: Install dependencies

iyzipay/__init__.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
Payment,
2222
ThreedsInitialize,
2323
ThreedsPayment,
24+
ThreedsV2Payment,
2425
Cancel,
2526
Refund,
2627
Card,
@@ -49,11 +50,19 @@
4950
BasicBkmInitialize,
5051
RetrievePaymentDetails,
5152
RetrieveTransactions,
53+
ReportingScrollTransaction,
5254
IyziLinkProduct,
5355
IyziFileBase64Encoder,
54-
RetrieveLoyalty)
56+
RetrieveLoyalty,
57+
PayWithIyzico,
58+
SubscriptionProduct,
59+
SubscriptionPricingPlan,
60+
SubscriptionCheckoutForm,
61+
Subscription,
62+
SubscriptionCardUpdate,
63+
SubscriptionCustomer
64+
)
5565

5666
from iyzipay.pki_builder import ( # noqa
5767
PKIBuilder,
5868
)
59-

iyzipay/iyzipay_resource.py

Lines changed: 246 additions & 628 deletions
Large diffs are not rendered by default.

samples/api_test.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import iyzipay
22

33
options = {
4-
'base_url': iyzipay.base_url
4+
'secret_key': iyzipay.secret_key,
5+
'api_key': iyzipay.api_key,
6+
'base_url': iyzipay.base_url,
57
}
68

79
api_test = iyzipay.ApiTest().retrieve(options)
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import json
2+
import iyzipay
3+
4+
options = {
5+
'api_key': iyzipay.api_key,
6+
'secret_key': iyzipay.secret_key,
7+
'base_url': iyzipay.base_url
8+
}
9+
10+
request = {
11+
'locale': 'tr',
12+
'conversationId': '123456789',
13+
'paymentId': '1',
14+
'paidPrice': 1.2,
15+
'basketId': 'B67832',
16+
'currency': 'TRY'
17+
}
18+
19+
threeds_payment = iyzipay.ThreedsV2Payment()
20+
threeds_payment_result = threeds_payment.create(request, options)
21+
threeds_payment_response = json.load(threeds_payment_result)
22+
print('response:', threeds_payment_response)
23+
24+
if threeds_payment_response['status'] == 'success':
25+
secret_key = options['secret_key']
26+
paymentId = threeds_payment_response['paymentId']
27+
currency = threeds_payment_response['currency']
28+
basketId = threeds_payment_response['basketId']
29+
conversationId = threeds_payment_response['conversationId']
30+
paidPrice = threeds_payment.strip_zero(str(threeds_payment_response['paidPrice']))
31+
price = threeds_payment.strip_zero(str(threeds_payment_response['price']))
32+
signature = threeds_payment_response['signature']
33+
threeds_payment.verify_signature([paymentId, currency, basketId, conversationId, paidPrice, price], secret_key, signature)

samples/images/image.png

3.95 KB
Loading
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import iyzipay
2+
3+
options = {
4+
'api_key': iyzipay.api_key,
5+
'secret_key': iyzipay.secret_key,
6+
'base_url': iyzipay.base_url
7+
}
8+
9+
buyer = {
10+
"id": "buyerID",
11+
"name": "buyerName",
12+
"surname": "buyerSurname",
13+
"identityNumber": "11111",
14+
"email": "test@gmail.com",
15+
"gsmNumber": "+905554443322",
16+
"registrationAddress": "Burhaniye Mahallesi Atilla Sokak No:7 Üsküdar",
17+
"city": "Istanbul",
18+
"country": "Turkey",
19+
"ip": "85.34.78.112"
20+
}
21+
22+
address = {
23+
"address": "Burhaniye Mahallesi Atilla Sokak No:7 Üsküdar",
24+
"contactName": "Contact Name",
25+
"city": "Istanbul",
26+
"country": "Turkey"
27+
}
28+
29+
basket_items = [
30+
{
31+
"id": "ItemID",
32+
"price": "1000.0",
33+
"name": "IPHONE 11 64GB WHITE NON ACC Beden:KK06 ,Renk:Beyaz",
34+
"category1": "IPHONE 11",
35+
"itemType": "PHYSICAL",
36+
"chargedFromMerchant": "True"
37+
}
38+
]
39+
40+
request = {
41+
"locale": "tr",
42+
"conversationId": "conversationID",
43+
"price": "1000.0",
44+
"basketId": "B67832",
45+
"paymentGroup": "PRODUCT",
46+
"callbackUrl": "https://callback.requestcatcher.com/test",
47+
"currency": "TRY",
48+
"cancelUrl": "https://www.cancelUrl.com/",
49+
"paidPrice": "30.0",
50+
"enabledInstallments": [
51+
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12
52+
],
53+
'buyer': buyer,
54+
'shippingAddress': address,
55+
'billingAddress': address,
56+
'basketItems': basket_items
57+
}
58+
59+
report = iyzipay.PayWithIyzico().create(request, options)
60+
61+
print(report.read().decode('utf-8'))

samples/iyzilink_create_product.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"conversationId": "123456789",
1212
"currencyCode": "TRY",
1313
"description": "test product new",
14-
"encodedImageFile": iyzipay.IyziFileBase64Encoder.encode("image.png"),
14+
"encodedImageFile": iyzipay.IyziFileBase64Encoder.encode("./images/image.png"),
1515
"installmentRequested": False,
1616
"locale": "tr",
1717
"name": "awsome product",

samples/iyzilink_fast_link.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import iyzipay
2+
3+
options = {
4+
'api_key': iyzipay.api_key,
5+
'secret_key': iyzipay.secret_key,
6+
'base_url': iyzipay.base_url
7+
}
8+
9+
request = {
10+
"description": "ft-description-fast-link",
11+
"price": 10,
12+
"currencyCode": "TRY",
13+
"sourceType": "WEB",
14+
"locale": "tr",
15+
"conversationId": "123456789"
16+
}
17+
18+
report = iyzipay.IyziLinkProduct().fast_link(request, options)
19+
print(report.read().decode('utf-8'))

0 commit comments

Comments
 (0)