Good progession
This commit is contained in:
@@ -276,3 +276,33 @@ def capture_authorized_transaction(transaction_req: schemas.TransactionCapture):
|
||||
controller = createTransactionController(createtransactionrequest)
|
||||
controller.execute()
|
||||
return controller.getresponse()
|
||||
|
||||
|
||||
def charge_customer_profile(customer_profile_id: str, payment_profile_id: str, transaction_req: schemas.TransactionCreateByCardID):
|
||||
"""
|
||||
Creates an AUTH_CAPTURE transaction (charge now) against a customer profile.
|
||||
This charges the customer immediately for the full amount.
|
||||
"""
|
||||
logger.info(f"Charging profile {customer_profile_id} / payment {payment_profile_id} for ${transaction_req.charge_amount}")
|
||||
|
||||
merchantAuth = apicontractsv1.merchantAuthenticationType(name=API_LOGIN_ID, transactionKey=TRANSACTION_KEY)
|
||||
|
||||
profile_to_charge = apicontractsv1.customerProfilePaymentType()
|
||||
profile_to_charge.customerProfileId = customer_profile_id
|
||||
profile_to_charge.customerPaymentProfileId = payment_profile_id
|
||||
|
||||
transactionRequest = apicontractsv1.transactionRequestType(
|
||||
transactionType="authCaptureTransaction",
|
||||
amount=f"{transaction_req.charge_amount:.2f}",
|
||||
profile=profile_to_charge
|
||||
)
|
||||
|
||||
createtransactionrequest = apicontractsv1.createTransactionRequest(
|
||||
merchantAuthentication=merchantAuth,
|
||||
transactionRequest=transactionRequest
|
||||
)
|
||||
|
||||
controller = createTransactionController(createtransactionrequest)
|
||||
controller.execute()
|
||||
# The response is returned directly to the router to be parsed there
|
||||
return controller.getresponse()
|
||||
|
||||
Reference in New Issue
Block a user