示例#1
0
    def example(self):
        with self.__get_client() as client:
            hosted_checkout_specific_input = HostedCheckoutSpecificInput()
            hosted_checkout_specific_input.locale = "en_GB"
            hosted_checkout_specific_input.variant = "testVariant"

            amount_of_money = AmountOfMoney()
            amount_of_money.amount = 2345
            amount_of_money.currency_code = "USD"

            billing_address = Address()
            billing_address.country_code = "US"

            customer = Customer()
            customer.billing_address = billing_address
            customer.merchant_customer_id = "1234"

            order = Order()
            order.amount_of_money = amount_of_money
            order.customer = customer

            body = CreateHostedCheckoutRequest()
            body.hosted_checkout_specific_input = hosted_checkout_specific_input
            body.order = order

            response = client.merchant("merchantId").hostedcheckouts().create(
                body)
    def example(self):
        with self.__get_client() as client:
            bank_account_bban = BankAccountBban()
            bank_account_bban.account_number = "0532013000"
            bank_account_bban.bank_code = "37040044"
            bank_account_bban.country_code = "DE"

            amount_of_money = AmountOfMoney()
            amount_of_money.amount = 100
            amount_of_money.currency_code = "EUR"

            billing_address = Address()
            billing_address.country_code = "US"

            customer = CustomerRiskAssessment()
            customer.billing_address = billing_address
            customer.locale = "en_US"

            order = OrderRiskAssessment()
            order.amount_of_money = amount_of_money
            order.customer = customer

            body = RiskAssessmentBankAccount()
            body.bank_account_bban = bank_account_bban
            body.order = order

            response = client.merchant("merchantId").riskassessments().bankaccounts(body)
    def example(self):
        with self.__get_client() as client:
            amount_of_money = AmountOfMoney()
            amount_of_money.amount = 2345
            amount_of_money.currency_code = "EUR"

            bank_account_iban = BankAccountIban()
            bank_account_iban.account_holder_name = "Wile E. Coyote"
            bank_account_iban.iban = "IT60X0542811101000000123456"

            address = Address()
            address.city = "Burbank"
            address.country_code = "US"
            address.house_number = "411"
            address.state = "California"
            address.street = "N Hollywood Way"
            address.zip = "91505"

            company_information = CompanyInformation()
            company_information.name = "Acme Labs"

            contact_details = ContactDetailsBase()
            contact_details.email_address = "*****@*****.**"

            name = PersonalName()
            name.first_name = "Wile"
            name.surname = "Coyote"
            name.surname_prefix = "E."
            name.title = "Mr."

            customer = PayoutCustomer()
            customer.address = address
            customer.company_information = company_information
            customer.contact_details = contact_details
            customer.name = name

            bank_transfer_payout_method_specific_input = BankTransferPayoutMethodSpecificInput()
            bank_transfer_payout_method_specific_input.bank_account_iban = bank_account_iban
            bank_transfer_payout_method_specific_input.customer = customer
            bank_transfer_payout_method_specific_input.payout_date = "20150102"
            bank_transfer_payout_method_specific_input.payout_text = "Payout Acme"
            bank_transfer_payout_method_specific_input.swift_code = "swift"

            references = PayoutReferences()
            references.merchant_reference = "AcmeOrder001"

            body = CreatePayoutRequest()
            body.amount_of_money = amount_of_money
            body.bank_transfer_payout_method_specific_input = bank_transfer_payout_method_specific_input
            body.references = references

            try:
                response = client.merchant("merchantId").payouts().create(body)
            except DeclinedPayoutException as e:
                self.handle_declined_payout(e.payout_result)
            except ApiException as e:
                self.handle_api_errors(e.errors)
示例#4
0
 def from_dictionary(self, dictionary):
     super(RefundRequest, self).from_dictionary(dictionary)
     if 'amountOfMoney' in dictionary:
         if not isinstance(dictionary['amountOfMoney'], dict):
             raise TypeError('value \'{}\' is not a dictionary'.format(
                 dictionary['amountOfMoney']))
         value = AmountOfMoney()
         self.amount_of_money = value.from_dictionary(
             dictionary['amountOfMoney'])
     if 'bankRefundMethodSpecificInput' in dictionary:
         if not isinstance(dictionary['bankRefundMethodSpecificInput'],
                           dict):
             raise TypeError('value \'{}\' is not a dictionary'.format(
                 dictionary['bankRefundMethodSpecificInput']))
         value = BankRefundMethodSpecificInput()
         self.bank_refund_method_specific_input = value.from_dictionary(
             dictionary['bankRefundMethodSpecificInput'])
     if 'customer' in dictionary:
         if not isinstance(dictionary['customer'], dict):
             raise TypeError('value \'{}\' is not a dictionary'.format(
                 dictionary['customer']))
         value = RefundCustomer()
         self.customer = value.from_dictionary(dictionary['customer'])
     if 'refundDate' in dictionary:
         self.refund_date = dictionary['refundDate']
     if 'refundReferences' in dictionary:
         if not isinstance(dictionary['refundReferences'], dict):
             raise TypeError('value \'{}\' is not a dictionary'.format(
                 dictionary['refundReferences']))
         value = RefundReferences()
         self.refund_references = value.from_dictionary(
             dictionary['refundReferences'])
     return self
 def from_dictionary(self, dictionary):
     super(DisputeOutput, self).from_dictionary(dictionary)
     if 'amountOfMoney' in dictionary:
         if not isinstance(dictionary['amountOfMoney'], dict):
             raise TypeError('value \'{}\' is not a dictionary'.format(dictionary['amountOfMoney']))
         value = AmountOfMoney()
         self.amount_of_money = value.from_dictionary(dictionary['amountOfMoney'])
     if 'contactPerson' in dictionary:
         self.contact_person = dictionary['contactPerson']
     if 'creationDetails' in dictionary:
         if not isinstance(dictionary['creationDetails'], dict):
             raise TypeError('value \'{}\' is not a dictionary'.format(dictionary['creationDetails']))
         value = DisputeCreationDetail()
         self.creation_details = value.from_dictionary(dictionary['creationDetails'])
     if 'emailAddress' in dictionary:
         self.email_address = dictionary['emailAddress']
     if 'files' in dictionary:
         if not isinstance(dictionary['files'], list):
             raise TypeError('value \'{}\' is not a list'.format(dictionary['files']))
         self.files = []
         for element in dictionary['files']:
             value = HostedFile()
             self.files.append(value.from_dictionary(element))
     if 'reference' in dictionary:
         if not isinstance(dictionary['reference'], dict):
             raise TypeError('value \'{}\' is not a dictionary'.format(dictionary['reference']))
         value = DisputeReference()
         self.reference = value.from_dictionary(dictionary['reference'])
     if 'replyTo' in dictionary:
         self.reply_to = dictionary['replyTo']
     if 'requestMessage' in dictionary:
         self.request_message = dictionary['requestMessage']
     if 'responseMessage' in dictionary:
         self.response_message = dictionary['responseMessage']
     return self
示例#6
0
 def from_dictionary(self, dictionary):
     super(GiftCardPurchase, self).from_dictionary(dictionary)
     if 'amountOfMoney' in dictionary:
         if not isinstance(dictionary['amountOfMoney'], dict):
             raise TypeError('value \'{}\' is not a dictionary'.format(
                 dictionary['amountOfMoney']))
         value = AmountOfMoney()
         self.amount_of_money = value.from_dictionary(
             dictionary['amountOfMoney'])
     if 'numberOfGiftCards' in dictionary:
         self.number_of_gift_cards = dictionary['numberOfGiftCards']
     return self
示例#7
0
    def test_idempotence(self):
        """Test that the client can successfully detect that an idempotent request is sent twice"""

        amount_of_money = AmountOfMoney()
        amount_of_money.currency_code = "EUR"
        amount_of_money.amount = 100L
        billing_address = Address()
        billing_address.country_code = "NL"
        customer = Customer()
        customer.locale = "en"
        customer.billing_address = billing_address
        order = Order()
        order.amount_of_money = amount_of_money
        order.customer = customer
        payment_product_input = RedirectPaymentProduct809SpecificInput()
        payment_product_input.issuer_id = "INGBNL2A"
        payment_method_input = RedirectPaymentMethodSpecificInput()
        payment_method_input.return_url = "http://example.com"
        payment_method_input.payment_product_id = 809
        payment_method_input.payment_product809_specific_input = payment_product_input
        body = CreatePaymentRequest()
        body.order = order
        body.redirect_payment_method_specific_input = payment_method_input
        idempotence_key = str(uuid.uuid4())
        context = CallContext(idempotence_key)

        with init_utils.create_client() as client:
            def do_create_payment():
                # For this test it doesn't matter if the response is successful or declined,
                # as long as idempotence is handled correctly
                try:
                    return client.merchant(MERCHANT_ID).payments().create(body, context)
                except DeclinedPaymentException as e:
                    return e.create_payment_result

            result = do_create_payment()

            payment_id = result.payment.id
            status = result.payment.status

            self.assertEqual(idempotence_key, context.idempotence_key)
            self.assertIsNone(context.idempotence_request_timestamp)

            result_2 = do_create_payment()

            payment_id_2 = result_2.payment.id
            status_2 = result_2.payment.status
            self.assertEqual(payment_id, payment_id_2)
            self.assertEqual(status, status_2)
            self.assertEqual(idempotence_key, context.idempotence_key)
            self.assertIsNotNone(context.idempotence_request_timestamp)
示例#8
0
 def from_dictionary(self, dictionary):
     super(SettlementDetails, self).from_dictionary(dictionary)
     if 'acquirerReferenceNumber' in dictionary:
         self.acquirer_reference_number = dictionary['acquirerReferenceNumber']
     if 'amountOfMoney' in dictionary:
         if not isinstance(dictionary['amountOfMoney'], dict):
             raise TypeError('value \'{}\' is not a dictionary'.format(dictionary['amountOfMoney']))
         value = AmountOfMoney()
         self.amount_of_money = value.from_dictionary(dictionary['amountOfMoney'])
     if 'paymentId' in dictionary:
         self.payment_id = dictionary['paymentId']
     if 'retrievalReferenceNumber' in dictionary:
         self.retrieval_reference_number = dictionary['retrievalReferenceNumber']
     return self
示例#9
0
 def from_dictionary(self, dictionary):
     super(PaymentContext, self).from_dictionary(dictionary)
     if 'amountOfMoney' in dictionary:
         if not isinstance(dictionary['amountOfMoney'], dict):
             raise TypeError('value \'{}\' is not a dictionary'.format(
                 dictionary['amountOfMoney']))
         value = AmountOfMoney()
         self.amount_of_money = value.from_dictionary(
             dictionary['amountOfMoney'])
     if 'countryCode' in dictionary:
         self.country_code = dictionary['countryCode']
     if 'isRecurring' in dictionary:
         self.is_recurring = dictionary['isRecurring']
     return self
示例#10
0
 def from_dictionary(self, dictionary):
     super(LineItem, self).from_dictionary(dictionary)
     if 'amountOfMoney' in dictionary:
         if not isinstance(dictionary['amountOfMoney'], dict):
             raise TypeError('value \'{}\' is not a dictionary'.format(
                 dictionary['amountOfMoney']))
         value = AmountOfMoney()
         self.amount_of_money = value.from_dictionary(
             dictionary['amountOfMoney'])
     if 'invoiceData' in dictionary:
         if not isinstance(dictionary['invoiceData'], dict):
             raise TypeError('value \'{}\' is not a dictionary'.format(
                 dictionary['invoiceData']))
         value = LineItemInvoiceData()
         self.invoice_data = value.from_dictionary(
             dictionary['invoiceData'])
     if 'level3InterchangeInformation' in dictionary:
         if not isinstance(dictionary['level3InterchangeInformation'],
                           dict):
             raise TypeError('value \'{}\' is not a dictionary'.format(
                 dictionary['level3InterchangeInformation']))
         value = LineItemLevel3InterchangeInformation()
         self.level3_interchange_information = value.from_dictionary(
             dictionary['level3InterchangeInformation'])
     if 'orderLineDetails' in dictionary:
         if not isinstance(dictionary['orderLineDetails'], dict):
             raise TypeError('value \'{}\' is not a dictionary'.format(
                 dictionary['orderLineDetails']))
         value = OrderLineDetails()
         self.order_line_details = value.from_dictionary(
             dictionary['orderLineDetails'])
     return self
示例#11
0
    def example(self):
        with self.__get_client() as client:
            amount_of_money = AmountOfMoney()
            amount_of_money.amount = 1234
            amount_of_money.currency_code = "USD"

            body = CreateDisputeRequest()
            body.amount_of_money = amount_of_money
            body.contact_person = "Wile Coyote"
            body.email_address = "*****@*****.**"
            body.reply_to = "*****@*****.**"
            body.request_message = "This is the message from the merchant to GlobalCollect. It is a a freeform text field."

            response = client.merchant("merchantId").payments().dispute(
                "paymentId", body)
示例#12
0
 def from_dictionary(self, dictionary):
     super(OrderOutput, self).from_dictionary(dictionary)
     if 'amountOfMoney' in dictionary:
         if not isinstance(dictionary['amountOfMoney'], dict):
             raise TypeError('value \'{}\' is not a dictionary'.format(
                 dictionary['amountOfMoney']))
         value = AmountOfMoney()
         self.amount_of_money = value.from_dictionary(
             dictionary['amountOfMoney'])
     if 'references' in dictionary:
         if not isinstance(dictionary['references'], dict):
             raise TypeError('value \'{}\' is not a dictionary'.format(
                 dictionary['references']))
         value = PaymentReferences()
         self.references = value.from_dictionary(dictionary['references'])
     return self
 def from_dictionary(self, dictionary):
     super(CreateDisputeRequest, self).from_dictionary(dictionary)
     if 'amountOfMoney' in dictionary:
         if not isinstance(dictionary['amountOfMoney'], dict):
             raise TypeError('value \'{}\' is not a dictionary'.format(dictionary['amountOfMoney']))
         value = AmountOfMoney()
         self.amount_of_money = value.from_dictionary(dictionary['amountOfMoney'])
     if 'contactPerson' in dictionary:
         self.contact_person = dictionary['contactPerson']
     if 'emailAddress' in dictionary:
         self.email_address = dictionary['emailAddress']
     if 'replyTo' in dictionary:
         self.reply_to = dictionary['replyTo']
     if 'requestMessage' in dictionary:
         self.request_message = dictionary['requestMessage']
     return self
示例#14
0
 def from_dictionary(self, dictionary):
     super(Installments, self).from_dictionary(dictionary)
     if 'amountOfMoneyPerInstallment' in dictionary:
         if not isinstance(dictionary['amountOfMoneyPerInstallment'], dict):
             raise TypeError('value \'{}\' is not a dictionary'.format(
                 dictionary['amountOfMoneyPerInstallment']))
         value = AmountOfMoney()
         self.amount_of_money_per_installment = value.from_dictionary(
             dictionary['amountOfMoneyPerInstallment'])
     if 'frequencyOfInstallments' in dictionary:
         self.frequency_of_installments = dictionary[
             'frequencyOfInstallments']
     if 'interestRate' in dictionary:
         self.interest_rate = dictionary['interestRate']
     if 'numberOfInstallments' in dictionary:
         self.number_of_installments = dictionary['numberOfInstallments']
     return self
 def from_dictionary(self, dictionary):
     super(AbstractThreeDSecure, self).from_dictionary(dictionary)
     if 'authenticationAmount' in dictionary:
         if not isinstance(dictionary['authenticationAmount'], dict):
             raise TypeError('value \'{}\' is not a dictionary'.format(
                 dictionary['authenticationAmount']))
         value = AmountOfMoney()
         self.authentication_amount = value.from_dictionary(
             dictionary['authenticationAmount'])
     if 'authenticationFlow' in dictionary:
         self.authentication_flow = dictionary['authenticationFlow']
     if 'challengeCanvasSize' in dictionary:
         self.challenge_canvas_size = dictionary['challengeCanvasSize']
     if 'challengeIndicator' in dictionary:
         self.challenge_indicator = dictionary['challengeIndicator']
     if 'exemptionRequest' in dictionary:
         self.exemption_request = dictionary['exemptionRequest']
     if 'priorThreeDSecureData' in dictionary:
         if not isinstance(dictionary['priorThreeDSecureData'], dict):
             raise TypeError('value \'{}\' is not a dictionary'.format(
                 dictionary['priorThreeDSecureData']))
         value = ThreeDSecureData()
         self.prior_three_d_secure_data = value.from_dictionary(
             dictionary['priorThreeDSecureData'])
     if 'sdkData' in dictionary:
         if not isinstance(dictionary['sdkData'], dict):
             raise TypeError('value \'{}\' is not a dictionary'.format(
                 dictionary['sdkData']))
         value = SdkDataInput()
         self.sdk_data = value.from_dictionary(dictionary['sdkData'])
     if 'skipAuthentication' in dictionary:
         self.skip_authentication = dictionary['skipAuthentication']
     return self
 def from_dictionary(self, dictionary):
     super(ThreeDSecureResults, self).from_dictionary(dictionary)
     if 'acsTransactionId' in dictionary:
         self.acs_transaction_id = dictionary['acsTransactionId']
     if 'appliedExemption' in dictionary:
         self.applied_exemption = dictionary['appliedExemption']
     if 'authenticationAmount' in dictionary:
         if not isinstance(dictionary['authenticationAmount'], dict):
             raise TypeError('value \'{}\' is not a dictionary'.format(
                 dictionary['authenticationAmount']))
         value = AmountOfMoney()
         self.authentication_amount = value.from_dictionary(
             dictionary['authenticationAmount'])
     if 'cavv' in dictionary:
         self.cavv = dictionary['cavv']
     if 'directoryServerTransactionId' in dictionary:
         self.directory_server_transaction_id = dictionary[
             'directoryServerTransactionId']
     if 'eci' in dictionary:
         self.eci = dictionary['eci']
     if 'exemptionOutput' in dictionary:
         if not isinstance(dictionary['exemptionOutput'], dict):
             raise TypeError('value \'{}\' is not a dictionary'.format(
                 dictionary['exemptionOutput']))
         value = ExemptionOutput()
         self.exemption_output = value.from_dictionary(
             dictionary['exemptionOutput'])
     if 'schemeRiskScore' in dictionary:
         self.scheme_risk_score = dictionary['schemeRiskScore']
     if 'sdkData' in dictionary:
         if not isinstance(dictionary['sdkData'], dict):
             raise TypeError('value \'{}\' is not a dictionary'.format(
                 dictionary['sdkData']))
         value = SdkDataOutput()
         self.sdk_data = value.from_dictionary(dictionary['sdkData'])
     if 'threeDSecureData' in dictionary:
         if not isinstance(dictionary['threeDSecureData'], dict):
             raise TypeError('value \'{}\' is not a dictionary'.format(
                 dictionary['threeDSecureData']))
         value = ThreeDSecureData()
         self.three_d_secure_data = value.from_dictionary(
             dictionary['threeDSecureData'])
     if 'threeDSecureVersion' in dictionary:
         self.three_d_secure_version = dictionary['threeDSecureVersion']
     if 'threeDServerTransactionId' in dictionary:
         self.three_d_server_transaction_id = dictionary[
             'threeDServerTransactionId']
     if 'xid' in dictionary:
         self.xid = dictionary['xid']
     return self
示例#17
0
 def from_dictionary(self, dictionary):
     super(Order, self).from_dictionary(dictionary)
     if 'additionalInput' in dictionary:
         if not isinstance(dictionary['additionalInput'], dict):
             raise TypeError('value \'{}\' is not a dictionary'.format(
                 dictionary['additionalInput']))
         value = AdditionalOrderInput()
         self.additional_input = value.from_dictionary(
             dictionary['additionalInput'])
     if 'amountOfMoney' in dictionary:
         if not isinstance(dictionary['amountOfMoney'], dict):
             raise TypeError('value \'{}\' is not a dictionary'.format(
                 dictionary['amountOfMoney']))
         value = AmountOfMoney()
         self.amount_of_money = value.from_dictionary(
             dictionary['amountOfMoney'])
     if 'customer' in dictionary:
         if not isinstance(dictionary['customer'], dict):
             raise TypeError('value \'{}\' is not a dictionary'.format(
                 dictionary['customer']))
         value = Customer()
         self.customer = value.from_dictionary(dictionary['customer'])
     if 'items' in dictionary:
         if not isinstance(dictionary['items'], list):
             raise TypeError('value \'{}\' is not a list'.format(
                 dictionary['items']))
         self.items = []
         for element in dictionary['items']:
             value = LineItem()
             self.items.append(value.from_dictionary(element))
     if 'references' in dictionary:
         if not isinstance(dictionary['references'], dict):
             raise TypeError('value \'{}\' is not a dictionary'.format(
                 dictionary['references']))
         value = OrderReferences()
         self.references = value.from_dictionary(dictionary['references'])
     if 'seller' in dictionary:
         if not isinstance(dictionary['seller'], dict):
             raise TypeError('value \'{}\' is not a dictionary'.format(
                 dictionary['seller']))
         value = Seller()
         self.seller = value.from_dictionary(dictionary['seller'])
     if 'shipping' in dictionary:
         if not isinstance(dictionary['shipping'], dict):
             raise TypeError('value \'{}\' is not a dictionary'.format(
                 dictionary['shipping']))
         value = Shipping()
         self.shipping = value.from_dictionary(dictionary['shipping'])
     if 'shoppingCart' in dictionary:
         if not isinstance(dictionary['shoppingCart'], dict):
             raise TypeError('value \'{}\' is not a dictionary'.format(
                 dictionary['shoppingCart']))
         value = ShoppingCart()
         self.shopping_cart = value.from_dictionary(
             dictionary['shoppingCart'])
     return self
示例#18
0
    def example(self):
        with self.__get_client() as client:
            amount_of_money = AmountOfMoney()
            amount_of_money.amount = 1
            amount_of_money.currency_code = "EUR"

            bank_account_iban = BankAccountIban()
            bank_account_iban.iban = "NL53INGB0000000036"

            bank_refund_method_specific_input = BankRefundMethodSpecificInput()
            bank_refund_method_specific_input.bank_account_iban = bank_account_iban

            name = PersonalName()
            name.surname = "Coyote"

            address = AddressPersonal()
            address.country_code = "US"
            address.name = name

            contact_details = ContactDetailsBase()
            contact_details.email_address = "*****@*****.**"
            contact_details.email_message_type = "html"

            customer = RefundCustomer()
            customer.address = address
            customer.contact_details = contact_details

            refund_references = RefundReferences()
            refund_references.merchant_reference = "AcmeOrder0001"

            body = RefundRequest()
            body.amount_of_money = amount_of_money
            body.bank_refund_method_specific_input = bank_refund_method_specific_input
            body.customer = customer
            body.refund_date = "20140306"
            body.refund_references = refund_references

            try:
                response = client.merchant("merchantId").payments().refund("paymentId", body)
            except DeclinedRefundException as e:
                self.handle_declined_refund(e.refund_result)
            except ApiException as e:
                self.handle_api_errors(e.errors)
    def example(self):
        with self.__get_client() as client:
            amount_of_money = AmountOfMoney()
            amount_of_money.amount = 500
            amount_of_money.currency_code = "EUR"

            refund_references = RefundReferences()
            refund_references.merchant_reference = "AcmeOrder0001"

            body = RefundRequest()
            body.amount_of_money = amount_of_money
            body.refund_references = refund_references

            try:
                response = client.merchant("merchantId").captures().refund("captureId", body)
            except DeclinedRefundException as e:
                self.handle_declined_refund(e.refund_result)
            except ApiException as e:
                self.handle_api_errors(e.errors)
示例#20
0
def create_request():
    body = CreatePaymentRequest()
    order = Order()
    amount_of_money = AmountOfMoney()
    amount_of_money.amount = 2345L
    amount_of_money.currency_code = "CAD"
    customer = Customer()
    billing_address = Address()
    billing_address.county_code = "CA"
    customer.billing_address = billing_address
    order.customer = customer
    card_payment_method_specific_input = CardPaymentMethodSpecificInput()
    card_payment_method_specific_input.payment_product_id = 1
    card = Card()
    card.cvv = "123"
    card.card_number = "4567350000427977"
    card.expiry_date = "1220"
    card_payment_method_specific_input.card = card
    body.card_payment_method_specific_input = card_payment_method_specific_input
    return body
示例#21
0
    def test_idempotence(self):
        """Test that the client can successfully detect that an idempotent request is sent twice"""

        amount_of_money = AmountOfMoney()
        amount_of_money.currency_code = "EUR"
        amount_of_money.amount = 100L
        billing_address = Address()
        billing_address.country_code = "NL"
        customer = Customer()
        customer.locale = "en"
        customer.billing_address = billing_address
        order = Order()
        order.amount_of_money = amount_of_money
        order.customer = customer
        payment_product_input = RedirectPaymentProduct809SpecificInput()
        payment_product_input.issuer_id = "INGBNL2A"
        payment_method_input = RedirectPaymentMethodSpecificInput()
        payment_method_input.return_url = "http://example.com"
        payment_method_input.payment_product_id = 809
        payment_method_input.payment_product809_specific_input = payment_product_input
        body = CreatePaymentRequest()
        body.order = order
        body.redirect_payment_method_specific_input = payment_method_input
        idempotence_key = str(uuid.uuid4())
        context = CallContext(idempotence_key)

        with init_utils.create_client() as client:
            response = client.merchant(MERCHANT_ID).payments().create(
                body, context)

            payment_id = response.payment.id
            self.assertEqual(idempotence_key, context.idempotence_key)
            self.assertIsNone(context.idempotence_request_timestamp)

            response_2 = client.merchant(MERCHANT_ID).payments().create(
                body, context)

            payment_id_2 = response_2.payment.id
            self.assertEqual(payment_id, payment_id_2)
            self.assertEqual(idempotence_key, context.idempotence_key)
            self.assertIsNotNone(context.idempotence_request_timestamp)
    def test_risk_assessments(self):
        """Test if the risk assessments service functions"""
        bank_account_bban = BankAccountBban()
        bank_account_bban.country_code = "DE"
        bank_account_bban.account_number = "0532013000"
        bank_account_bban.bank_code = "37040044"
        amount_of_money = AmountOfMoney()
        amount_of_money.amount = 100
        amount_of_money.currency_code = "EUR"
        customer = CustomerRiskAssessment()
        customer.locale = "en_GB"
        order = OrderRiskAssessment()
        order.amount_of_money = amount_of_money
        order.customer = customer
        body = RiskAssessmentBankAccount()
        body.order = order
        body.bank_account_bban = bank_account_bban

        with init_utils.create_client() as client:
            response = client.merchant(
                MERCHANT_ID).riskassessments().bankaccounts(body)
        self.assertGreater(len(response.results), 0)
def create_payment_request():
    """Creates a commonly used payment for testing"""
    amount_of_money = AmountOfMoney()
    amount_of_money.currency_code = "CAD"
    amount_of_money.amount = 2345
    billing_address = Address()
    billing_address.country_code = "CA"
    customer = Customer()
    customer.billing_address = billing_address
    order = Order()
    order.amount_of_money = amount_of_money
    order.customer = customer
    card = Card()
    card.cvv = "123"
    card.card_number = "1234567890123456"
    card.expiry_date = "1220"
    payment_specific_input = CardPaymentMethodSpecificInput()
    payment_specific_input.payment_product_id = 1
    payment_specific_input.card = card
    request = CreatePaymentRequest()
    request.order = order
    request.card_payment_method_specific_input = payment_specific_input
    return request
 def from_dictionary(self, dictionary):
     super(OrderRiskAssessment, self).from_dictionary(dictionary)
     if 'additionalInput' in dictionary:
         if not isinstance(dictionary['additionalInput'], dict):
             raise TypeError('value \'{}\' is not a dictionary'.format(dictionary['additionalInput']))
         value = AdditionalOrderInputAirlineData()
         self.additional_input = value.from_dictionary(dictionary['additionalInput'])
     if 'amountOfMoney' in dictionary:
         if not isinstance(dictionary['amountOfMoney'], dict):
             raise TypeError('value \'{}\' is not a dictionary'.format(dictionary['amountOfMoney']))
         value = AmountOfMoney()
         self.amount_of_money = value.from_dictionary(dictionary['amountOfMoney'])
     if 'customer' in dictionary:
         if not isinstance(dictionary['customer'], dict):
             raise TypeError('value \'{}\' is not a dictionary'.format(dictionary['customer']))
         value = CustomerRiskAssessment()
         self.customer = value.from_dictionary(dictionary['customer'])
     if 'shipping' in dictionary:
         if not isinstance(dictionary['shipping'], dict):
             raise TypeError('value \'{}\' is not a dictionary'.format(dictionary['shipping']))
         value = ShippingRiskAssessment()
         self.shipping = value.from_dictionary(dictionary['shipping'])
     return self
 def from_dictionary(self, dictionary):
     super(PayoutDetails, self).from_dictionary(dictionary)
     if 'amountOfMoney' in dictionary:
         if not isinstance(dictionary['amountOfMoney'], dict):
             raise TypeError('value \'{}\' is not a dictionary'.format(
                 dictionary['amountOfMoney']))
         value = AmountOfMoney()
         self.amount_of_money = value.from_dictionary(
             dictionary['amountOfMoney'])
     if 'customer' in dictionary:
         if not isinstance(dictionary['customer'], dict):
             raise TypeError('value \'{}\' is not a dictionary'.format(
                 dictionary['customer']))
         value = PayoutCustomer()
         self.customer = value.from_dictionary(dictionary['customer'])
     if 'references' in dictionary:
         if not isinstance(dictionary['references'], dict):
             raise TypeError('value \'{}\' is not a dictionary'.format(
                 dictionary['references']))
         value = PayoutReferences()
         self.references = value.from_dictionary(dictionary['references'])
     return self
示例#26
0
 def from_dictionary(self, dictionary):
     super(CreatePayoutRequest, self).from_dictionary(dictionary)
     if 'amountOfMoney' in dictionary:
         if not isinstance(dictionary['amountOfMoney'], dict):
             raise TypeError('value \'{}\' is not a dictionary'.format(
                 dictionary['amountOfMoney']))
         value = AmountOfMoney()
         self.amount_of_money = value.from_dictionary(
             dictionary['amountOfMoney'])
     if 'bankAccountBban' in dictionary:
         if not isinstance(dictionary['bankAccountBban'], dict):
             raise TypeError('value \'{}\' is not a dictionary'.format(
                 dictionary['bankAccountBban']))
         value = BankAccountBban()
         self.bank_account_bban = value.from_dictionary(
             dictionary['bankAccountBban'])
     if 'bankAccountIban' in dictionary:
         if not isinstance(dictionary['bankAccountIban'], dict):
             raise TypeError('value \'{}\' is not a dictionary'.format(
                 dictionary['bankAccountIban']))
         value = BankAccountIban()
         self.bank_account_iban = value.from_dictionary(
             dictionary['bankAccountIban'])
     if 'bankTransferPayoutMethodSpecificInput' in dictionary:
         if not isinstance(
                 dictionary['bankTransferPayoutMethodSpecificInput'], dict):
             raise TypeError('value \'{}\' is not a dictionary'.format(
                 dictionary['bankTransferPayoutMethodSpecificInput']))
         value = BankTransferPayoutMethodSpecificInput()
         self.bank_transfer_payout_method_specific_input = value.from_dictionary(
             dictionary['bankTransferPayoutMethodSpecificInput'])
     if 'cardPayoutMethodSpecificInput' in dictionary:
         if not isinstance(dictionary['cardPayoutMethodSpecificInput'],
                           dict):
             raise TypeError('value \'{}\' is not a dictionary'.format(
                 dictionary['cardPayoutMethodSpecificInput']))
         value = CardPayoutMethodSpecificInput()
         self.card_payout_method_specific_input = value.from_dictionary(
             dictionary['cardPayoutMethodSpecificInput'])
     if 'customer' in dictionary:
         if not isinstance(dictionary['customer'], dict):
             raise TypeError('value \'{}\' is not a dictionary'.format(
                 dictionary['customer']))
         value = PayoutCustomer()
         self.customer = value.from_dictionary(dictionary['customer'])
     if 'payoutDate' in dictionary:
         self.payout_date = dictionary['payoutDate']
     if 'payoutDetails' in dictionary:
         if not isinstance(dictionary['payoutDetails'], dict):
             raise TypeError('value \'{}\' is not a dictionary'.format(
                 dictionary['payoutDetails']))
         value = PayoutDetails()
         self.payout_details = value.from_dictionary(
             dictionary['payoutDetails'])
     if 'payoutText' in dictionary:
         self.payout_text = dictionary['payoutText']
     if 'references' in dictionary:
         if not isinstance(dictionary['references'], dict):
             raise TypeError('value \'{}\' is not a dictionary'.format(
                 dictionary['references']))
         value = PayoutReferences()
         self.references = value.from_dictionary(dictionary['references'])
     if 'swiftCode' in dictionary:
         self.swift_code = dictionary['swiftCode']
     return self
示例#27
0
    def example(self):
        with self.__get_client() as client:
            card = Card()
            card.card_number = "4567350000427977"
            card.cardholder_name = "Wile E. Coyote"
            card.cvv = "123"
            card.expiry_date = "1299"

            authentication_amount = AmountOfMoney()
            authentication_amount.amount = 2980
            authentication_amount.currency_code = "EUR"

            redirection_data = RedirectionData()
            redirection_data.return_url = "https://hostname.myownwebsite.url"

            three_d_secure = ThreeDSecure()
            three_d_secure.authentication_amount = authentication_amount
            three_d_secure.authentication_flow = "browser"
            three_d_secure.challenge_canvas_size = "600x400"
            three_d_secure.challenge_indicator = "challenge-requested"
            three_d_secure.exemption_request = "none"
            three_d_secure.redirection_data = redirection_data
            three_d_secure.skip_authentication = False

            card_payment_method_specific_input = CardPaymentMethodSpecificInput(
            )
            card_payment_method_specific_input.card = card
            card_payment_method_specific_input.is_recurring = False
            card_payment_method_specific_input.merchant_initiated_reason_indicator = "delayedCharges"
            card_payment_method_specific_input.payment_product_id = 1
            card_payment_method_specific_input.three_d_secure = three_d_secure
            card_payment_method_specific_input.transaction_channel = "ECOMMERCE"

            amount_of_money = AmountOfMoney()
            amount_of_money.amount = 2980
            amount_of_money.currency_code = "EUR"

            billing_address = Address()
            billing_address.additional_info = "b"
            billing_address.city = "Monument Valley"
            billing_address.country_code = "US"
            billing_address.house_number = "13"
            billing_address.state = "Utah"
            billing_address.street = "Desertroad"
            billing_address.zip = "84536"

            company_information = CompanyInformation()
            company_information.name = "Acme Labs"
            company_information.vat_number = "1234AB5678CD"

            contact_details = ContactDetails()
            contact_details.email_address = "*****@*****.**"
            contact_details.fax_number = "+1234567891"
            contact_details.phone_number = "+1234567890"

            browser_data = BrowserData()
            browser_data.color_depth = 24
            browser_data.java_enabled = False
            browser_data.screen_height = "1200"
            browser_data.screen_width = "1920"

            device = CustomerDevice()
            device.accept_header = "texthtml,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
            device.browser_data = browser_data
            device.ip_address = "123.123.123.123"
            device.locale = "en-US"
            device.timezone_offset_utc_minutes = "420"
            device.user_agent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_4) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1 Safari/605.1.15"

            name = PersonalName()
            name.first_name = "Wile"
            name.surname = "Coyote"
            name.surname_prefix = "E."
            name.title = "Mr."

            personal_information = PersonalInformation()
            personal_information.date_of_birth = "19490917"
            personal_information.gender = "male"
            personal_information.name = name

            customer = Customer()
            customer.account_type = "none"
            customer.billing_address = billing_address
            customer.company_information = company_information
            customer.contact_details = contact_details
            customer.device = device
            customer.locale = "en_US"
            customer.merchant_customer_id = "1234"
            customer.personal_information = personal_information

            invoice_data = OrderInvoiceData()
            invoice_data.invoice_date = "20140306191500"
            invoice_data.invoice_number = "000000123"

            references = OrderReferences()
            references.descriptor = "Fast and Furry-ous"
            references.invoice_data = invoice_data
            references.merchant_order_id = 123456
            references.merchant_reference = "AcmeOrder0001"

            shipping_name = PersonalName()
            shipping_name.first_name = "Road"
            shipping_name.surname = "Runner"
            shipping_name.title = "Miss"

            address = AddressPersonal()
            address.additional_info = "Suite II"
            address.city = "Monument Valley"
            address.country_code = "US"
            address.house_number = "1"
            address.name = shipping_name
            address.state = "Utah"
            address.street = "Desertroad"
            address.zip = "84536"

            shipping = Shipping()
            shipping.address = address

            items = []

            item1_amount_of_money = AmountOfMoney()
            item1_amount_of_money.amount = 2500
            item1_amount_of_money.currency_code = "EUR"

            item1_invoice_data = LineItemInvoiceData()
            item1_invoice_data.description = "ACME Super Outfit"
            item1_invoice_data.nr_of_items = "1"
            item1_invoice_data.price_per_item = 2500

            item1 = LineItem()
            item1.amount_of_money = item1_amount_of_money
            item1.invoice_data = item1_invoice_data

            items.append(item1)

            item2_amount_of_money = AmountOfMoney()
            item2_amount_of_money.amount = 480
            item2_amount_of_money.currency_code = "EUR"

            item2_invoice_data = LineItemInvoiceData()
            item2_invoice_data.description = "Aspirin"
            item2_invoice_data.nr_of_items = "12"
            item2_invoice_data.price_per_item = 40

            item2 = LineItem()
            item2.amount_of_money = item2_amount_of_money
            item2.invoice_data = item2_invoice_data

            items.append(item2)

            shopping_cart = ShoppingCart()
            shopping_cart.items = items

            order = Order()
            order.amount_of_money = amount_of_money
            order.customer = customer
            order.references = references
            order.shipping = shipping
            order.shopping_cart = shopping_cart

            body = CreatePaymentRequest()
            body.card_payment_method_specific_input = card_payment_method_specific_input
            body.order = order

            try:
                response = client.merchant("merchantId").payments().create(
                    body)
            except DeclinedPaymentException as e:
                self.handle_declined_payment(e.create_payment_result)
            except ApiException as e:
                self.handle_api_errors(e.errors)
    def example(self):
        with self.__get_client() as client:
            card = Card()
            card.card_number = "4567350000427977"
            card.cvv = "123"
            card.expiry_date = "0820"

            flight_legs = []

            flight_leg1 = AirlineFlightLeg()
            flight_leg1.airline_class = "1"
            flight_leg1.arrival_airport = "AMS"
            flight_leg1.carrier_code = "KL"
            flight_leg1.date = "20150102"
            flight_leg1.departure_time = "17:59"
            flight_leg1.fare = "fare"
            flight_leg1.fare_basis = "INTERNET"
            flight_leg1.flight_number = "791"
            flight_leg1.number = 1
            flight_leg1.origin_airport = "BCN"
            flight_leg1.stopover_code = "non-permitted"

            flight_legs.append(flight_leg1)

            flight_leg2 = AirlineFlightLeg()
            flight_leg2.airline_class = "1"
            flight_leg2.arrival_airport = "BCN"
            flight_leg2.carrier_code = "KL"
            flight_leg2.date = "20150102"
            flight_leg2.departure_time = "23:59"
            flight_leg2.fare = "fare"
            flight_leg2.fare_basis = "INTERNET"
            flight_leg2.flight_number = "792"
            flight_leg2.number = 2
            flight_leg2.origin_airport = "AMS"
            flight_leg2.stopover_code = "non-permitted"

            flight_legs.append(flight_leg2)

            airline_data = AirlineData()
            airline_data.agent_numeric_code = "123321"
            airline_data.code = "123"
            airline_data.flight_date = "20150102"
            airline_data.flight_legs = flight_legs
            airline_data.invoice_number = "123456"
            airline_data.is_e_ticket = True
            airline_data.is_restricted_ticket = True
            airline_data.is_third_party = True
            airline_data.issue_date = "20150101"
            airline_data.merchant_customer_id = "14"
            airline_data.name = "Air France KLM"
            airline_data.passenger_name = "WECOYOTE"
            airline_data.place_of_issue = "Utah"
            airline_data.pnr = "4JTGKT"
            airline_data.point_of_sale = "IATA point of sale name"
            airline_data.pos_city_code = "AMS"
            airline_data.ticket_delivery_method = "e-ticket"
            airline_data.ticket_number = "KLM20050000"

            additional_input = AdditionalOrderInputAirlineData()
            additional_input.airline_data = airline_data

            amount_of_money = AmountOfMoney()
            amount_of_money.amount = 100
            amount_of_money.currency_code = "EUR"

            billing_address = Address()
            billing_address.country_code = "US"

            customer = CustomerRiskAssessment()
            customer.account_type = "existing"
            customer.billing_address = billing_address
            customer.locale = "en_US"

            order = OrderRiskAssessment()
            order.additional_input = additional_input
            order.amount_of_money = amount_of_money
            order.customer = customer

            body = RiskAssessmentCard()
            body.card = card
            body.order = order

            response = client.merchant("merchantId").riskassessments().cards(
                body)