connections-sdk 3.0.0__tar.gz → 3.2.0__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: connections_sdk
3
- Version: 3.0.0
3
+ Version: 3.2.0
4
4
  Summary: A Python SDK for payment processing
5
5
  Author: Basis Theory
6
6
  Author-email: support@basistheory.com
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
4
4
 
5
5
  [tool.poetry]
6
6
  name = "connections_sdk"
7
- version = "3.0.0"
7
+ version = "3.2.0"
8
8
  description = "A Python SDK for payment processing"
9
9
  authors = ["Basis Theory <support@basistheory.com>"]
10
10
  readme = "README.md"
@@ -123,7 +123,8 @@ class AdyenClient:
123
123
  "merchantAccount": self.merchant_account,
124
124
  "shopperInteraction": "ContAuth" if request.merchant_initiated else "Ecommerce",
125
125
  "storePaymentMethod": request.source.store_with_provider,
126
- "channel": request.customer.channel if request.customer else 'web'
126
+ "channel": request.customer.channel if request.customer else 'web',
127
+ "additionalData": {}
127
128
  }
128
129
 
129
130
  if request.metadata:
@@ -157,7 +158,7 @@ class AdyenClient:
157
158
  payment_method["holderName"] = request.source.holder_name
158
159
 
159
160
  if request.previous_network_transaction_id:
160
- payment_method["networkPaymentReference"] = request. previous_network_transaction_id
161
+ payload["networkPaymentReference"] = request.previous_network_transaction_id
161
162
 
162
163
  payload["paymentMethod"] = payment_method
163
164
 
@@ -310,7 +311,7 @@ class AdyenClient:
310
311
  )
311
312
 
312
313
 
313
- def create_transaction(self, request_data: TransactionRequest) -> TransactionResponse:
314
+ def create_transaction(self, request_data: TransactionRequest, idempotency_key: Optional[str] = None) -> TransactionResponse:
314
315
  """Process a payment transaction through Adyen's API directly or via Basis Theory's proxy."""
315
316
  validate_required_fields(request_data)
316
317
 
@@ -322,6 +323,10 @@ class AdyenClient:
322
323
  "X-API-Key": self.api_key,
323
324
  "Content-Type": "application/json"
324
325
  }
326
+
327
+ # Add idempotency key if provided
328
+ if idempotency_key:
329
+ headers["idempotency-key"] = idempotency_key
325
330
 
326
331
  # Make the request (using proxy for BT tokens, direct for processor tokens)
327
332
  try:
@@ -347,7 +352,7 @@ class AdyenClient:
347
352
  raise TransactionError(self._transform_error_response(e.response, error_data, e.response.headers))
348
353
 
349
354
 
350
- def refund_transaction(self, refund_request: RefundRequest) -> RefundResponse:
355
+ def refund_transaction(self, refund_request: RefundRequest, idempotency_key: Optional[str] = None) -> RefundResponse:
351
356
  """
352
357
  Refund a payment transaction through Adyen's API.
353
358
 
@@ -363,6 +368,10 @@ class AdyenClient:
363
368
  "Content-Type": "application/json"
364
369
  }
365
370
 
371
+ # Add idempotency key if provided
372
+ if idempotency_key:
373
+ headers["idempotency-key"] = idempotency_key
374
+
366
375
  # Prepare the refund payload
367
376
  payload = {
368
377
  "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