diff --git a/samples/FlexMicroform/generate-capture-context-accept-card.py b/samples/FlexMicroform/generate-capture-context-accept-card.py index c5566b1..f0ee378 100644 --- a/samples/FlexMicroform/generate-capture-context-accept-card.py +++ b/samples/FlexMicroform/generate-capture-context-accept-card.py @@ -1,4 +1,5 @@ from CyberSource import * +from CyberSource.utilities.flex.CaptureContextParsingUtility import parse_capture_context_response import os import json from importlib.machinery import SourceFileLoader @@ -62,6 +63,18 @@ def generate_capture_context_accept_card(): print("\nAPI RESPONSE CODE : ", status) print("\nAPI RESPONSE BODY : ", body) + # Parse the capture context response + try: + + parsed_result = parse_capture_context_response( + jwt_value=return_data, + merchant_config=api_instance.api_client.mconfig + ) + + print("\nParsed Capture Context : ", json.dumps(parsed_result, indent=2)) + except Exception as parse_error: + print("\nError in Capture Context Parsing : ", str(parse_error)) + write_log_audit(status) return return_data diff --git a/samples/FlexMicroform/generate-capture-context-accept-check.py b/samples/FlexMicroform/generate-capture-context-accept-check.py index 1138ebb..58dab8a 100644 --- a/samples/FlexMicroform/generate-capture-context-accept-check.py +++ b/samples/FlexMicroform/generate-capture-context-accept-check.py @@ -1,6 +1,7 @@ from CyberSource import * from CyberSource.rest import ApiException from CyberSource import GenerateCaptureContextRequest +from CyberSource.utilities.flex.CaptureContextParsingUtility import parse_capture_context_response import os import json from importlib.machinery import SourceFileLoader @@ -45,6 +46,18 @@ def generate_capture_context_accept_check(): print("\nAPI RESPONSE CODE : ", status) print("\nAPI RESPONSE BODY : ", body) + # Parse the capture context response + try: + + parsed_result = parse_capture_context_response( + jwt_value=return_data, + merchant_config=api_instance.api_client.mconfig + ) + + print("\nParsed Capture Context : ", json.dumps(parsed_result, indent=2)) + except Exception as parse_error: + print("\nError in Capture Context Parsing : ", str(parse_error)) + write_log_audit(status) return return_data diff --git a/samples/TokenManagement/Customer/create-customer.py b/samples/TokenManagement/Customer/create-customer.py index 9f618c0..97acc61 100644 --- a/samples/TokenManagement/Customer/create-customer.py +++ b/samples/TokenManagement/Customer/create-customer.py @@ -19,19 +19,19 @@ def del_none(d): def create_customer(): buyerInformationMerchantCustomerID = "Your customer identifier" buyerInformationEmail = "test@cybs.com" - buyerInformation = Tmsv2customersBuyerInformation( + buyerInformation = Tmsv2tokenizeTokenInformationCustomerBuyerInformation( merchant_customer_id = buyerInformationMerchantCustomerID, email = buyerInformationEmail ) clientReferenceInformationCode = "TC50171_3" - clientReferenceInformation = Tmsv2customersClientReferenceInformation( + clientReferenceInformation = Tmsv2tokenizeTokenInformationCustomerClientReferenceInformation( code = clientReferenceInformationCode ) merchantDefinedInformation = [] - merchantDefinedInformation1 = Tmsv2customersMerchantDefinedInformation( + merchantDefinedInformation1 = Tmsv2tokenizeTokenInformationCustomerMerchantDefinedInformation( name = "data1", value = "Your customer data" ) diff --git a/samples/TokenManagement/Customer/update-customer.py b/samples/TokenManagement/Customer/update-customer.py index f793481..0f1875d 100644 --- a/samples/TokenManagement/Customer/update-customer.py +++ b/samples/TokenManagement/Customer/update-customer.py @@ -20,19 +20,19 @@ def update_customer(): customerTokenId = "AB695DA801DD1BB6E05341588E0A3BDC" buyerInformationMerchantCustomerID = "Your customer identifier" buyerInformationEmail = "test@cybs.com" - buyerInformation = Tmsv2customersBuyerInformation( + buyerInformation = Tmsv2tokenizeTokenInformationCustomerBuyerInformation( merchant_customer_id = buyerInformationMerchantCustomerID, email = buyerInformationEmail ) clientReferenceInformationCode = "TC50171_3" - clientReferenceInformation = Tmsv2customersClientReferenceInformation( + clientReferenceInformation = Tmsv2tokenizeTokenInformationCustomerClientReferenceInformation( code = clientReferenceInformationCode ) merchantDefinedInformation = [] - merchantDefinedInformation1 = Tmsv2customersMerchantDefinedInformation( + merchantDefinedInformation1 = Tmsv2tokenizeTokenInformationCustomerMerchantDefinedInformation( name = "data1", value = "Your customer data" ) diff --git a/samples/TokenManagement/Customer/update-customers-default-payment-instrument.py b/samples/TokenManagement/Customer/update-customers-default-payment-instrument.py index 3ce21ed..d4b5158 100644 --- a/samples/TokenManagement/Customer/update-customers-default-payment-instrument.py +++ b/samples/TokenManagement/Customer/update-customers-default-payment-instrument.py @@ -20,7 +20,7 @@ def update_customers_default_payment_instrument(): customerTokenId = "AB695DA801DD1BB6E05341588E0A3BDC" defaultPaymentInstrumentId = "AB6A54B982A6FCB6E05341588E0A3935" - defaultPaymentInstrument = Tmsv2customersDefaultPaymentInstrument( + defaultPaymentInstrument = Tmsv2tokenizeTokenInformationCustomerDefaultPaymentInstrument( id = defaultPaymentInstrumentId ) diff --git a/samples/TokenManagement/Customer/update-customers-default-shipping-address.py b/samples/TokenManagement/Customer/update-customers-default-shipping-address.py index e581b93..0bc3c79 100644 --- a/samples/TokenManagement/Customer/update-customers-default-shipping-address.py +++ b/samples/TokenManagement/Customer/update-customers-default-shipping-address.py @@ -20,7 +20,7 @@ def update_customers_default_shipping_address(): customerTokenId = "AB695DA801DD1BB6E05341588E0A3BDC" defaultShippingAddressId = "AB6A54B97C00FCB6E05341588E0A3935" - defaultShippingAddress = Tmsv2customersDefaultShippingAddress( + defaultShippingAddress = Tmsv2tokenizeTokenInformationCustomerDefaultShippingAddress( id = defaultShippingAddressId ) diff --git a/samples/TokenManagement/CustomerPaymentInstrument/create-customer-default-payment-instrument-card.py b/samples/TokenManagement/CustomerPaymentInstrument/create-customer-default-payment-instrument-card.py index 5b62694..ea760cb 100644 --- a/samples/TokenManagement/CustomerPaymentInstrument/create-customer-default-payment-instrument-card.py +++ b/samples/TokenManagement/CustomerPaymentInstrument/create-customer-default-payment-instrument-card.py @@ -23,7 +23,7 @@ def create_customer_default_payment_instrument_card(): cardExpirationMonth = "12" cardExpirationYear = "2031" cardType = "001" - card = Tmsv2customersEmbeddedDefaultPaymentInstrumentCard( + card = Tmsv2tokenizeTokenInformationCustomerEmbeddedDefaultPaymentInstrumentCard( expiration_month = cardExpirationMonth, expiration_year = cardExpirationYear, type = cardType @@ -39,7 +39,7 @@ def create_customer_default_payment_instrument_card(): billToCountry = "US" billToEmail = "test@cybs.com" billToPhoneNumber = "4158880000" - billTo = Tmsv2customersEmbeddedDefaultPaymentInstrumentBillTo( + billTo = Tmsv2tokenizeTokenInformationCustomerEmbeddedDefaultPaymentInstrumentBillTo( first_name = billToFirstName, last_name = billToLastName, company = billToCompany, @@ -53,7 +53,7 @@ def create_customer_default_payment_instrument_card(): ) instrumentIdentifierId = "7010000000016241111" - instrumentIdentifier = Tmsv2customersEmbeddedDefaultPaymentInstrumentInstrumentIdentifier( + instrumentIdentifier = Tmsv2tokenizeTokenInformationCustomerEmbeddedDefaultPaymentInstrumentInstrumentIdentifier( id = instrumentIdentifierId ) diff --git a/samples/TokenManagement/CustomerPaymentInstrument/create-customer-nondefault-payment-instrument-card.py b/samples/TokenManagement/CustomerPaymentInstrument/create-customer-nondefault-payment-instrument-card.py index 9b13fbb..c0daf9f 100644 --- a/samples/TokenManagement/CustomerPaymentInstrument/create-customer-nondefault-payment-instrument-card.py +++ b/samples/TokenManagement/CustomerPaymentInstrument/create-customer-nondefault-payment-instrument-card.py @@ -23,7 +23,7 @@ def create_customer_nondefault_payment_instrument_card(): cardExpirationMonth = "12" cardExpirationYear = "2031" cardType = "001" - card = Tmsv2customersEmbeddedDefaultPaymentInstrumentCard( + card = Tmsv2tokenizeTokenInformationCustomerEmbeddedDefaultPaymentInstrumentCard( expiration_month = cardExpirationMonth, expiration_year = cardExpirationYear, type = cardType @@ -39,7 +39,7 @@ def create_customer_nondefault_payment_instrument_card(): billToCountry = "US" billToEmail = "test@cybs.com" billToPhoneNumber = "4158880000" - billTo = Tmsv2customersEmbeddedDefaultPaymentInstrumentBillTo( + billTo = Tmsv2tokenizeTokenInformationCustomerEmbeddedDefaultPaymentInstrumentBillTo( first_name = billToFirstName, last_name = billToLastName, company = billToCompany, @@ -53,7 +53,7 @@ def create_customer_nondefault_payment_instrument_card(): ) instrumentIdentifierId = "7010000000016241111" - instrumentIdentifier = Tmsv2customersEmbeddedDefaultPaymentInstrumentInstrumentIdentifier( + instrumentIdentifier = Tmsv2tokenizeTokenInformationCustomerEmbeddedDefaultPaymentInstrumentInstrumentIdentifier( id = instrumentIdentifierId ) diff --git a/samples/TokenManagement/CustomerPaymentInstrument/create-customer-payment-instrument-bank-account.py b/samples/TokenManagement/CustomerPaymentInstrument/create-customer-payment-instrument-bank-account.py index 9017490..63e2ac8 100644 --- a/samples/TokenManagement/CustomerPaymentInstrument/create-customer-payment-instrument-bank-account.py +++ b/samples/TokenManagement/CustomerPaymentInstrument/create-customer-payment-instrument-bank-account.py @@ -20,7 +20,7 @@ def create_customer_payment_instrument_bank_account(): customerTokenId = "AB695DA801DD1BB6E05341588E0A3BDC" bankAccountType = "savings" - bankAccount = Tmsv2customersEmbeddedDefaultPaymentInstrumentBankAccount( + bankAccount = Tmsv2tokenizeTokenInformationCustomerEmbeddedDefaultPaymentInstrumentBankAccount( type = bankAccountType ) @@ -29,11 +29,11 @@ def create_customer_payment_instrument_bank_account(): buyerInformationDateOfBirth = "2000-12-13" buyerInformationPersonalIdentification = [] - buyerInformationPersonalIdentificationIssuedBy1 = Tmsv2customersEmbeddedDefaultPaymentInstrumentBuyerInformationIssuedBy( + buyerInformationPersonalIdentificationIssuedBy1 = Tmsv2tokenizeTokenInformationCustomerEmbeddedDefaultPaymentInstrumentBuyerInformationIssuedBy( administrative_area = "CA" ) - buyerInformationPersonalIdentification1 = Tmsv2customersEmbeddedDefaultPaymentInstrumentBuyerInformationPersonalIdentification( + buyerInformationPersonalIdentification1 = Tmsv2tokenizeTokenInformationCustomerEmbeddedDefaultPaymentInstrumentBuyerInformationPersonalIdentification( id = "57684432111321", type = "driver license", issued_by = buyerInformationPersonalIdentificationIssuedBy1.__dict__ @@ -41,7 +41,7 @@ def create_customer_payment_instrument_bank_account(): buyerInformationPersonalIdentification.append(buyerInformationPersonalIdentification1.__dict__) - buyerInformation = Tmsv2customersEmbeddedDefaultPaymentInstrumentBuyerInformation( + buyerInformation = Tmsv2tokenizeTokenInformationCustomerEmbeddedDefaultPaymentInstrumentBuyerInformation( company_tax_id = buyerInformationCompanyTaxID, currency = buyerInformationCurrency, date_of_birth = buyerInformationDateOfBirth, @@ -58,7 +58,7 @@ def create_customer_payment_instrument_bank_account(): billToCountry = "US" billToEmail = "test@cybs.com" billToPhoneNumber = "4158880000" - billTo = Tmsv2customersEmbeddedDefaultPaymentInstrumentBillTo( + billTo = Tmsv2tokenizeTokenInformationCustomerEmbeddedDefaultPaymentInstrumentBillTo( first_name = billToFirstName, last_name = billToLastName, company = billToCompany, @@ -81,7 +81,7 @@ def create_customer_payment_instrument_bank_account(): ) instrumentIdentifierId = "A7A91A2CA872B272E05340588D0A0699" - instrumentIdentifier = Tmsv2customersEmbeddedDefaultPaymentInstrumentInstrumentIdentifier( + instrumentIdentifier = Tmsv2tokenizeTokenInformationCustomerEmbeddedDefaultPaymentInstrumentInstrumentIdentifier( id = instrumentIdentifierId ) diff --git a/samples/TokenManagement/CustomerPaymentInstrument/create-customer-payment-instrument-pinless-debit.py b/samples/TokenManagement/CustomerPaymentInstrument/create-customer-payment-instrument-pinless-debit.py index 04c0e4f..3c7ab42 100644 --- a/samples/TokenManagement/CustomerPaymentInstrument/create-customer-payment-instrument-pinless-debit.py +++ b/samples/TokenManagement/CustomerPaymentInstrument/create-customer-payment-instrument-pinless-debit.py @@ -26,7 +26,7 @@ def create_customer_payment_instrument_pinless_debit(): cardStartMonth = "01" cardStartYear = "2020" cardUseAs = "pinless debit" - card = Tmsv2customersEmbeddedDefaultPaymentInstrumentCard( + card = Tmsv2tokenizeTokenInformationCustomerEmbeddedDefaultPaymentInstrumentCard( expiration_month = cardExpirationMonth, expiration_year = cardExpirationYear, type = cardType, @@ -46,7 +46,7 @@ def create_customer_payment_instrument_pinless_debit(): billToCountry = "US" billToEmail = "test@cybs.com" billToPhoneNumber = "4158880000" - billTo = Tmsv2customersEmbeddedDefaultPaymentInstrumentBillTo( + billTo = Tmsv2tokenizeTokenInformationCustomerEmbeddedDefaultPaymentInstrumentBillTo( first_name = billToFirstName, last_name = billToLastName, company = billToCompany, @@ -60,7 +60,7 @@ def create_customer_payment_instrument_pinless_debit(): ) instrumentIdentifierId = "7010000000016241111" - instrumentIdentifier = Tmsv2customersEmbeddedDefaultPaymentInstrumentInstrumentIdentifier( + instrumentIdentifier = Tmsv2tokenizeTokenInformationCustomerEmbeddedDefaultPaymentInstrumentInstrumentIdentifier( id = instrumentIdentifierId ) diff --git a/samples/TokenManagement/CustomerShippingAddress/create-customer-default-shipping-address.py b/samples/TokenManagement/CustomerShippingAddress/create-customer-default-shipping-address.py index 3e7592a..55afa13 100644 --- a/samples/TokenManagement/CustomerShippingAddress/create-customer-default-shipping-address.py +++ b/samples/TokenManagement/CustomerShippingAddress/create-customer-default-shipping-address.py @@ -30,7 +30,7 @@ def create_customer_default_shipping_address(): shipToCountry = "US" shipToEmail = "test@cybs.com" shipToPhoneNumber = "4158880000" - shipTo = Tmsv2customersEmbeddedDefaultShippingAddressShipTo( + shipTo = Tmsv2tokenizeTokenInformationCustomerEmbeddedDefaultShippingAddressShipTo( first_name = shipToFirstName, last_name = shipToLastName, company = shipToCompany, diff --git a/samples/TokenManagement/CustomerShippingAddress/create-customer-nondefault-shipping-address.py b/samples/TokenManagement/CustomerShippingAddress/create-customer-nondefault-shipping-address.py index fe76fdc..2645252 100644 --- a/samples/TokenManagement/CustomerShippingAddress/create-customer-nondefault-shipping-address.py +++ b/samples/TokenManagement/CustomerShippingAddress/create-customer-nondefault-shipping-address.py @@ -30,7 +30,7 @@ def create_customer_nondefault_shipping_address(): shipToCountry = "US" shipToEmail = "test@cybs.com" shipToPhoneNumber = "4158880000" - shipTo = Tmsv2customersEmbeddedDefaultShippingAddressShipTo( + shipTo = Tmsv2tokenizeTokenInformationCustomerEmbeddedDefaultShippingAddressShipTo( first_name = shipToFirstName, last_name = shipToLastName, company = shipToCompany, diff --git a/samples/TokenManagement/PaymentInstrument/create-payment-instrument-bank-account.py b/samples/TokenManagement/PaymentInstrument/create-payment-instrument-bank-account.py index 6e7a143..2aca5ec 100644 --- a/samples/TokenManagement/PaymentInstrument/create-payment-instrument-bank-account.py +++ b/samples/TokenManagement/PaymentInstrument/create-payment-instrument-bank-account.py @@ -20,7 +20,7 @@ def create_payment_instrument_bank_account(): profileid = "93B32398-AD51-4CC2-A682-EA3E93614EB1" bankAccountType = "savings" - bankAccount = Tmsv2customersEmbeddedDefaultPaymentInstrumentBankAccount( + bankAccount = Tmsv2tokenizeTokenInformationCustomerEmbeddedDefaultPaymentInstrumentBankAccount( type = bankAccountType ) @@ -29,11 +29,11 @@ def create_payment_instrument_bank_account(): buyerInformationDateOfBirth = "2000-12-13" buyerInformationPersonalIdentification = [] - buyerInformationPersonalIdentificationIssuedBy1 = Tmsv2customersEmbeddedDefaultPaymentInstrumentBuyerInformationIssuedBy( + buyerInformationPersonalIdentificationIssuedBy1 = Tmsv2tokenizeTokenInformationCustomerEmbeddedDefaultPaymentInstrumentBuyerInformationIssuedBy( administrative_area = "CA" ) - buyerInformationPersonalIdentification1 = Tmsv2customersEmbeddedDefaultPaymentInstrumentBuyerInformationPersonalIdentification( + buyerInformationPersonalIdentification1 = Tmsv2tokenizeTokenInformationCustomerEmbeddedDefaultPaymentInstrumentBuyerInformationPersonalIdentification( id = "57684432111321", type = "driver license", issued_by = buyerInformationPersonalIdentificationIssuedBy1.__dict__ @@ -41,7 +41,7 @@ def create_payment_instrument_bank_account(): buyerInformationPersonalIdentification.append(buyerInformationPersonalIdentification1.__dict__) - buyerInformation = Tmsv2customersEmbeddedDefaultPaymentInstrumentBuyerInformation( + buyerInformation = Tmsv2tokenizeTokenInformationCustomerEmbeddedDefaultPaymentInstrumentBuyerInformation( company_tax_id = buyerInformationCompanyTaxID, currency = buyerInformationCurrency, date_of_birth = buyerInformationDateOfBirth, @@ -58,7 +58,7 @@ def create_payment_instrument_bank_account(): billToCountry = "US" billToEmail = "test@cybs.com" billToPhoneNumber = "4158880000" - billTo = Tmsv2customersEmbeddedDefaultPaymentInstrumentBillTo( + billTo = Tmsv2tokenizeTokenInformationCustomerEmbeddedDefaultPaymentInstrumentBillTo( first_name = billToFirstName, last_name = billToLastName, company = billToCompany, @@ -81,7 +81,7 @@ def create_payment_instrument_bank_account(): ) instrumentIdentifierId = "A7A91A2CA872B272E05340588D0A0699" - instrumentIdentifier = Tmsv2customersEmbeddedDefaultPaymentInstrumentInstrumentIdentifier( + instrumentIdentifier = Tmsv2tokenizeTokenInformationCustomerEmbeddedDefaultPaymentInstrumentInstrumentIdentifier( id = instrumentIdentifierId ) diff --git a/samples/TokenManagement/PaymentInstrument/create-payment-instrument-card.py b/samples/TokenManagement/PaymentInstrument/create-payment-instrument-card.py index 63deff4..b6d101d 100644 --- a/samples/TokenManagement/PaymentInstrument/create-payment-instrument-card.py +++ b/samples/TokenManagement/PaymentInstrument/create-payment-instrument-card.py @@ -22,7 +22,7 @@ def create_payment_instrument_card(): cardExpirationMonth = "12" cardExpirationYear = "2031" cardType = "visa" - card = Tmsv2customersEmbeddedDefaultPaymentInstrumentCard( + card = Tmsv2tokenizeTokenInformationCustomerEmbeddedDefaultPaymentInstrumentCard( expiration_month = cardExpirationMonth, expiration_year = cardExpirationYear, type = cardType @@ -38,7 +38,7 @@ def create_payment_instrument_card(): billToCountry = "US" billToEmail = "test@cybs.com" billToPhoneNumber = "4158880000" - billTo = Tmsv2customersEmbeddedDefaultPaymentInstrumentBillTo( + billTo = Tmsv2tokenizeTokenInformationCustomerEmbeddedDefaultPaymentInstrumentBillTo( first_name = billToFirstName, last_name = billToLastName, company = billToCompany, @@ -52,7 +52,7 @@ def create_payment_instrument_card(): ) instrumentIdentifierId = "7010000000016241111" - instrumentIdentifier = Tmsv2customersEmbeddedDefaultPaymentInstrumentInstrumentIdentifier( + instrumentIdentifier = Tmsv2tokenizeTokenInformationCustomerEmbeddedDefaultPaymentInstrumentInstrumentIdentifier( id = instrumentIdentifierId ) diff --git a/samples/TokenManagement/PaymentInstrument/create-payment-instrument-pinless-debit.py b/samples/TokenManagement/PaymentInstrument/create-payment-instrument-pinless-debit.py index 5a6bb3d..5c67ee1 100644 --- a/samples/TokenManagement/PaymentInstrument/create-payment-instrument-pinless-debit.py +++ b/samples/TokenManagement/PaymentInstrument/create-payment-instrument-pinless-debit.py @@ -26,7 +26,7 @@ def create_payment_instrument_pinless_debit(): cardStartMonth = "01" cardStartYear = "2020" cardUseAs = "pinless debit" - card = Tmsv2customersEmbeddedDefaultPaymentInstrumentCard( + card = Tmsv2tokenizeTokenInformationCustomerEmbeddedDefaultPaymentInstrumentCard( expiration_month = cardExpirationMonth, expiration_year = cardExpirationYear, type = cardType, @@ -47,7 +47,7 @@ def create_payment_instrument_pinless_debit(): billToCountry = "US" billToEmail = "test@cybs.com" billToPhoneNumber = "4158880000" - billTo = Tmsv2customersEmbeddedDefaultPaymentInstrumentBillTo( + billTo = Tmsv2tokenizeTokenInformationCustomerEmbeddedDefaultPaymentInstrumentBillTo( first_name = billToFirstName, last_name = billToLastName, company = billToCompany, @@ -61,7 +61,7 @@ def create_payment_instrument_pinless_debit(): ) instrumentIdentifierId = "7010000000016241111" - instrumentIdentifier = Tmsv2customersEmbeddedDefaultPaymentInstrumentInstrumentIdentifier( + instrumentIdentifier = Tmsv2tokenizeTokenInformationCustomerEmbeddedDefaultPaymentInstrumentInstrumentIdentifier( id = instrumentIdentifierId ) diff --git a/samples/TokenManagement/PaymentInstrument/update-payment-instrument.py b/samples/TokenManagement/PaymentInstrument/update-payment-instrument.py index a2b54f2..811049d 100644 --- a/samples/TokenManagement/PaymentInstrument/update-payment-instrument.py +++ b/samples/TokenManagement/PaymentInstrument/update-payment-instrument.py @@ -23,7 +23,7 @@ def update_payment_instrument(): cardExpirationMonth = "12" cardExpirationYear = "2031" cardType = "visa" - card = Tmsv2customersEmbeddedDefaultPaymentInstrumentCard( + card = Tmsv2tokenizeTokenInformationCustomerEmbeddedDefaultPaymentInstrumentCard( expiration_month = cardExpirationMonth, expiration_year = cardExpirationYear, type = cardType @@ -39,7 +39,7 @@ def update_payment_instrument(): billToCountry = "US" billToEmail = "updatedemail@cybs.com" billToPhoneNumber = "4158888674" - billTo = Tmsv2customersEmbeddedDefaultPaymentInstrumentBillTo( + billTo = Tmsv2tokenizeTokenInformationCustomerEmbeddedDefaultPaymentInstrumentBillTo( first_name = billToFirstName, last_name = billToLastName, company = billToCompany, @@ -53,7 +53,7 @@ def update_payment_instrument(): ) instrumentIdentifierId = "7010000000016241111" - instrumentIdentifier = Tmsv2customersEmbeddedDefaultPaymentInstrumentInstrumentIdentifier( + instrumentIdentifier = Tmsv2tokenizeTokenInformationCustomerEmbeddedDefaultPaymentInstrumentInstrumentIdentifier( id = instrumentIdentifierId ) diff --git a/samples/UnifiedCheckout/generate-capture-context-for-click-to-pay-dropin-ui.py b/samples/UnifiedCheckout/generate-capture-context-for-click-to-pay-dropin-ui.py index 11b39e6..2f06bd8 100644 --- a/samples/UnifiedCheckout/generate-capture-context-for-click-to-pay-dropin-ui.py +++ b/samples/UnifiedCheckout/generate-capture-context-for-click-to-pay-dropin-ui.py @@ -1,6 +1,7 @@ from CyberSource import * from CyberSource.rest import ApiException from CyberSource.models import Upv1capturecontextsCaptureMandate, Upv1capturecontextsOrderInformationAmountDetails, Upv1capturecontextsOrderInformation, GenerateUnifiedCheckoutCaptureContextRequest, Upv1capturecontextsCompleteMandate +from CyberSource.utilities.flex.CaptureContextParsingUtility import parse_capture_context_response from pathlib import Path import os import json @@ -105,6 +106,18 @@ def generate_unified_checkout_capture_context(): print("\nAPI RESPONSE CODE : ", status) print("\nAPI RESPONSE BODY : ", body) + # Parse the capture context response + try: + + parsed_result = parse_capture_context_response( + jwt_value=return_data, + merchant_config=api_instance.api_client.mconfig + ) + + print("\nParsed Capture Context : ", json.dumps(parsed_result, indent=2)) + except Exception as parse_error: + print("\nError in Capture Context Parsing : ", str(parse_error)) + write_log_audit(status) return return_data except Exception as e: diff --git a/samples/UnifiedCheckout/generate-unified-checkout-passing-billing-shipping.py b/samples/UnifiedCheckout/generate-unified-checkout-passing-billing-shipping.py index 909888e..3546fc0 100644 --- a/samples/UnifiedCheckout/generate-unified-checkout-passing-billing-shipping.py +++ b/samples/UnifiedCheckout/generate-unified-checkout-passing-billing-shipping.py @@ -1,5 +1,7 @@ from CyberSource import * from CyberSource.rest import ApiException +from CyberSource.utilities.flex.CaptureContextParsingUtility import parse_capture_context_response +from CyberSource.models import Upv1capturecontextsCaptureMandate, Upv1capturecontextsOrderInformationAmountDetails, Upv1capturecontextsOrderInformation, GenerateUnifiedCheckoutCaptureContextRequest, Upv1capturecontextsCompleteMandate, Upv1capturecontextsDataOrderInformationBillTo, Upv1capturecontextsDataOrderInformationBillToCompany, Upv1capturecontextsDataOrderInformationShipTo from pathlib import Path import os import json @@ -96,7 +98,7 @@ def generate_unified_checkout_capture_context(): orderInformationBillToCompanyDistrict = "district" orderInformationBillToCompanyLocality = "Foster City" orderInformationBillToCompanyPostalCode = "94404" - orderInformationBillToCompany = Upv1capturecontextsOrderInformationBillToCompany( + orderInformationBillToCompany = Upv1capturecontextsDataOrderInformationBillToCompany( name = orderInformationBillToCompanyName, address1 = orderInformationBillToCompanyAddress1, address2 = orderInformationBillToCompanyAddress2, @@ -118,7 +120,7 @@ def generate_unified_checkout_capture_context(): orderInformationBillToTitle = "Mr" orderInformationBillToPhoneNumber = "1234567890" orderInformationBillToPhoneType = "phoneType" - orderInformationBillTo = Upv1capturecontextsOrderInformationBillTo( + orderInformationBillTo = Upv1capturecontextsDataOrderInformationBillTo( address1 = orderInformationBillToAddress1, address2 = orderInformationBillToAddress2, address3 = orderInformationBillToAddress3, @@ -152,7 +154,7 @@ def generate_unified_checkout_capture_context(): orderInformationShipToPostalCode = "BT1 4LS" orderInformationShipToFirstName = "Joe" orderInformationShipToLastName = "Soap" - orderInformationShipTo = Upv1capturecontextsOrderInformationShipTo( + orderInformationShipTo = Upv1capturecontextsDataOrderInformationShipTo( address1 = orderInformationShipToAddress1, address2 = orderInformationShipToAddress2, address3 = orderInformationShipToAddress3, @@ -204,6 +206,17 @@ def generate_unified_checkout_capture_context(): print("\nAPI RESPONSE CODE : ", status) print("\nAPI RESPONSE BODY : ", body) + # Parse the capture context response + try: + parsed_result = parse_capture_context_response( + jwt_value=return_data, + merchant_config=api_instance.api_client.mconfig + ) + + print("\nParsed Capture Context : ", json.dumps(parsed_result, indent=2)) + except Exception as parse_error: + print("\nError in Capture Context Parsing : ", str(parse_error)) + write_log_audit(status) return return_data except Exception as e: diff --git a/samples/UnifiedCheckout/generate-unified-checkout.py b/samples/UnifiedCheckout/generate-unified-checkout.py index 8b64005..1fd103e 100644 --- a/samples/UnifiedCheckout/generate-unified-checkout.py +++ b/samples/UnifiedCheckout/generate-unified-checkout.py @@ -1,4 +1,5 @@ from CyberSource import * +from CyberSource.utilities.flex.CaptureContextParsingUtility import parse_capture_context_response from pathlib import Path import os import json @@ -109,6 +110,17 @@ def generate_unified_checkout_capture_context(): print("\nAPI RESPONSE CODE : ", status) print("\nAPI RESPONSE BODY : ", body) + # Parse the capture context response + try: + parsed_result = parse_capture_context_response( + jwt_value=return_data, + merchant_config=api_instance.api_client.mconfig + ) + + print("\nParsed Capture Context : ", json.dumps(parsed_result, indent=2)) + except Exception as parse_error: + print("\nError in Capture Context Parsing : ", str(parse_error)) + write_log_audit(status) return return_data except Exception as e: