connections-sdk 3.1.0__tar.gz → 3.2.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {connections_sdk-3.1.0 → connections_sdk-3.2.1}/PKG-INFO +1 -1
- {connections_sdk-3.1.0 → connections_sdk-3.2.1}/pyproject.toml +1 -1
- {connections_sdk-3.1.0 → connections_sdk-3.2.1}/src/connections_sdk/providers/adyen.py +19 -6
- {connections_sdk-3.1.0 → connections_sdk-3.2.1}/src/connections_sdk/providers/checkout.py +12 -5
- {connections_sdk-3.1.0 → connections_sdk-3.2.1}/LICENSE +0 -0
- {connections_sdk-3.1.0 → connections_sdk-3.2.1}/README.md +0 -0
- {connections_sdk-3.1.0 → connections_sdk-3.2.1}/src/connections_sdk/__init__.py +0 -0
- {connections_sdk-3.1.0 → connections_sdk-3.2.1}/src/connections_sdk/client.py +0 -0
- {connections_sdk-3.1.0 → connections_sdk-3.2.1}/src/connections_sdk/config.py +0 -0
- {connections_sdk-3.1.0 → connections_sdk-3.2.1}/src/connections_sdk/exceptions.py +0 -0
- {connections_sdk-3.1.0 → connections_sdk-3.2.1}/src/connections_sdk/models.py +0 -0
- {connections_sdk-3.1.0 → connections_sdk-3.2.1}/src/connections_sdk/utils/__init__.py +0 -0
- {connections_sdk-3.1.0 → connections_sdk-3.2.1}/src/connections_sdk/utils/model_utils.py +0 -0
- {connections_sdk-3.1.0 → connections_sdk-3.2.1}/src/connections_sdk/utils/request_client.py +0 -0
|
@@ -124,7 +124,7 @@ class AdyenClient:
|
|
|
124
124
|
"shopperInteraction": "ContAuth" if request.merchant_initiated else "Ecommerce",
|
|
125
125
|
"storePaymentMethod": request.source.store_with_provider,
|
|
126
126
|
"channel": request.customer.channel if request.customer else 'web',
|
|
127
|
-
|
|
127
|
+
|
|
128
128
|
}
|
|
129
129
|
|
|
130
130
|
if request.metadata:
|
|
@@ -141,6 +141,7 @@ class AdyenClient:
|
|
|
141
141
|
payload["recurringProcessingModel"] = recurring_type
|
|
142
142
|
|
|
143
143
|
# Process source based on type
|
|
144
|
+
|
|
144
145
|
payment_method: Dict[str, Any] = {"type": "scheme"}
|
|
145
146
|
|
|
146
147
|
if request.source.type == SourceType.PROCESSOR_TOKEN:
|
|
@@ -157,11 +158,15 @@ class AdyenClient:
|
|
|
157
158
|
if request.source.holder_name:
|
|
158
159
|
payment_method["holderName"] = request.source.holder_name
|
|
159
160
|
|
|
160
|
-
if request.previous_network_transaction_id:
|
|
161
|
-
payment_method["additionalData"]["networkTxReference"] = request. previous_network_transaction_id
|
|
162
|
-
|
|
163
161
|
payload["paymentMethod"] = payment_method
|
|
164
162
|
|
|
163
|
+
additionalData: Dict[str, Any] = {}
|
|
164
|
+
|
|
165
|
+
if request.previous_network_transaction_id:
|
|
166
|
+
additionalData["networkTxReference"] = request.previous_network_transaction_id
|
|
167
|
+
|
|
168
|
+
payload["additionalData"] = additionalData
|
|
169
|
+
|
|
165
170
|
# Add customer information
|
|
166
171
|
if request.customer:
|
|
167
172
|
if request.customer.reference:
|
|
@@ -311,7 +316,7 @@ class AdyenClient:
|
|
|
311
316
|
)
|
|
312
317
|
|
|
313
318
|
|
|
314
|
-
def create_transaction(self, request_data: TransactionRequest) -> TransactionResponse:
|
|
319
|
+
def create_transaction(self, request_data: TransactionRequest, idempotency_key: Optional[str] = None) -> TransactionResponse:
|
|
315
320
|
"""Process a payment transaction through Adyen's API directly or via Basis Theory's proxy."""
|
|
316
321
|
validate_required_fields(request_data)
|
|
317
322
|
|
|
@@ -323,6 +328,10 @@ class AdyenClient:
|
|
|
323
328
|
"X-API-Key": self.api_key,
|
|
324
329
|
"Content-Type": "application/json"
|
|
325
330
|
}
|
|
331
|
+
|
|
332
|
+
# Add idempotency key if provided
|
|
333
|
+
if idempotency_key:
|
|
334
|
+
headers["idempotency-key"] = idempotency_key
|
|
326
335
|
|
|
327
336
|
# Make the request (using proxy for BT tokens, direct for processor tokens)
|
|
328
337
|
try:
|
|
@@ -348,7 +357,7 @@ class AdyenClient:
|
|
|
348
357
|
raise TransactionError(self._transform_error_response(e.response, error_data, e.response.headers))
|
|
349
358
|
|
|
350
359
|
|
|
351
|
-
def refund_transaction(self, refund_request: RefundRequest) -> RefundResponse:
|
|
360
|
+
def refund_transaction(self, refund_request: RefundRequest, idempotency_key: Optional[str] = None) -> RefundResponse:
|
|
352
361
|
"""
|
|
353
362
|
Refund a payment transaction through Adyen's API.
|
|
354
363
|
|
|
@@ -364,6 +373,10 @@ class AdyenClient:
|
|
|
364
373
|
"Content-Type": "application/json"
|
|
365
374
|
}
|
|
366
375
|
|
|
376
|
+
# Add idempotency key if provided
|
|
377
|
+
if idempotency_key:
|
|
378
|
+
headers["idempotency-key"] = idempotency_key
|
|
379
|
+
|
|
367
380
|
# Prepare the refund payload
|
|
368
381
|
payload = {
|
|
369
382
|
"merchantAccount": self.merchant_account,
|
|
@@ -395,8 +395,10 @@ class CheckoutClient:
|
|
|
395
395
|
"expiry_month": f"{{{{ {token_prefix}: {request.source.id} | json: '$.data.expiration_month'}}}}",
|
|
396
396
|
"expiry_year": f"{{{{ {token_prefix}: {request.source.id} | json: '$.data.expiration_year'}}}}",
|
|
397
397
|
"cvv": f"{{{{ {token_prefix}: {request.source.id} | json: '$.data.cvc'}}}}",
|
|
398
|
-
"store_for_future_use": request.source.store_with_provider
|
|
398
|
+
"store_for_future_use": request.source.store_with_provider,
|
|
399
|
+
"name": request.source.holder_name
|
|
399
400
|
}
|
|
401
|
+
|
|
400
402
|
payload["source"] = source_data
|
|
401
403
|
|
|
402
404
|
# Add customer information if provided
|
|
@@ -564,7 +566,7 @@ class CheckoutClient:
|
|
|
564
566
|
)
|
|
565
567
|
|
|
566
568
|
|
|
567
|
-
def create_transaction(self, request_data: TransactionRequest) -> TransactionResponse:
|
|
569
|
+
def create_transaction(self, request_data: TransactionRequest, idempotency_key: Optional[str] = None) -> TransactionResponse:
|
|
568
570
|
"""Process a payment transaction through Checkout.com's API directly or via Basis Theory's proxy."""
|
|
569
571
|
validate_required_fields(request_data)
|
|
570
572
|
# Transform request to Checkout.com format
|
|
@@ -575,6 +577,10 @@ class CheckoutClient:
|
|
|
575
577
|
"Authorization": f"Bearer {self.api_key}",
|
|
576
578
|
"Content-Type": "application/json"
|
|
577
579
|
}
|
|
580
|
+
|
|
581
|
+
# Add idempotency key if provided
|
|
582
|
+
if idempotency_key:
|
|
583
|
+
headers["cko-idempotency-key"] = idempotency_key
|
|
578
584
|
|
|
579
585
|
try:
|
|
580
586
|
# Make request to Checkout.com
|
|
@@ -588,8 +594,6 @@ class CheckoutClient:
|
|
|
588
594
|
|
|
589
595
|
response_data = response.json()
|
|
590
596
|
|
|
591
|
-
print(f"Response data: {response_data}")
|
|
592
|
-
|
|
593
597
|
except requests.exceptions.HTTPError as e:
|
|
594
598
|
# Check if this is a BT error
|
|
595
599
|
if hasattr(e, 'bt_error_response'):
|
|
@@ -608,7 +612,7 @@ class CheckoutClient:
|
|
|
608
612
|
# Transform response to SDK format
|
|
609
613
|
return self._transform_checkout_response(response.json(), request_data, response.headers)
|
|
610
614
|
|
|
611
|
-
def refund_transaction(self, refund_request: RefundRequest) -> RefundResponse:
|
|
615
|
+
def refund_transaction(self, refund_request: RefundRequest, idempotency_key: Optional[str] = None) -> RefundResponse:
|
|
612
616
|
"""
|
|
613
617
|
Refund a payment transaction through Checkout.com's API.
|
|
614
618
|
|
|
@@ -623,6 +627,9 @@ class CheckoutClient:
|
|
|
623
627
|
"Content-Type": "application/json"
|
|
624
628
|
}
|
|
625
629
|
|
|
630
|
+
if idempotency_key:
|
|
631
|
+
headers["cko-idempotency-key"] = idempotency_key
|
|
632
|
+
|
|
626
633
|
# Prepare the refund payload
|
|
627
634
|
payload = {
|
|
628
635
|
"reference": refund_request.reference,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|