Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions craftgate/model/apm_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class ApmType(str, Enum):
IWALLET = "IWALLET"
FUND_TRANSFER = "FUND_TRANSFER"
SETCARD = "SETCARD"
SETCARD_GIFT = "SETCARD_GIFT"
PAPEL = "PAPEL"
ALBARAKA = "ALBARAKA"
CASH_ON_DELIVERY = "CASH_ON_DELIVERY"
2 changes: 2 additions & 0 deletions craftgate/model/payment_method.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ class PaymentMethod(str, Enum):
TOKENFLEX_GIFT = "TOKENFLEX_GIFT"
EDENRED = "EDENRED"
EDENRED_GIFT = "EDENRED_GIFT"
SETCARD = "SETCARD"
SETCARD_GIFT = "SETCARD_GIFT"
ALIPAY = "ALIPAY"
PAYPAL = "PAYPAL"
KLARNA = "KLARNA"
Expand Down
37 changes: 37 additions & 0 deletions tests/test_payment_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -1297,6 +1297,43 @@ def test_complete_setcard_pos_apm_payment(self):
self.assertIsNotNone(getattr(resp, "payment_id", None))
self.assertEqual(PaymentStatus.SUCCESS, resp.payment_status)

def test_init_setcard_gift_apm_payment(self):
items = []
for name, price in [("item 1", "0.6"), ("item 2", "0.4")]:
pi = PaymentItem()
pi.name = name
pi.external_id = str(uuid.uuid4())
pi.price = Decimal(price)
items.append(pi)

req = InitApmPaymentRequest()
req.apm_type = ApmType.SETCARD_GIFT
req.price = Decimal("1")
req.paid_price = Decimal("1")
req.currency = Currency.TRY
req.callback_url = "https://www.your-website.com/craftgate-3DSecure-callback"
req.payment_group = PaymentGroup.LISTING_OR_SUBSCRIPTION
req.conversation_id = "conversationId"
req.external_id = "externalId"
req.additional_params = {"cardNumber": "7599640961180814"}
req.items = items

resp = self.payment.init_apm_payment(req)
print(resp)
self.assertIsNotNone(getattr(resp, "payment_id", None))
self.assertEqual(PaymentStatus.WAITING, resp.payment_status)
self.assertEqual(ApmAdditionalAction.OTP_REQUIRED, resp.additional_action)

def test_complete_setcard_gift_pos_apm_payment(self):
req = CompleteApmPaymentRequest()
req.payment_id = 1
req.additional_params = {"otpCode": "123456"}

resp = self.payment.complete_apm_payment(req)
print(resp)
self.assertIsNotNone(getattr(resp, "payment_id", None))
self.assertEqual(PaymentStatus.SUCCESS, resp.payment_status)

def test_complete_pos_apm_payment(self):
req = CompletePosApmPaymentRequest()
req.payment_id = 1
Expand Down
Loading