4

我正在尝试将 Cyber​​Source 的 REST API 集成到 Django (Python) 应用程序中。我正在关注这个GitHub 示例示例。它就像一个魅力,但从示例或文档中我不清楚如何指定设备的指纹 ID。

这是我发送的请求的一个片段,以防它有用(注意:这只是一个存在于 POPO 中的方法):

def authorize_payment(self, card_token: str, total_amount: Money, customer: CustomerInformation = None,
                      merchant: MerchantInformation = None):
    try:
        request = {
            'payment_information': {
                # NOTE: REQUIRED.
                'card': None,
                'tokenized_card': None,
                'customer': {
                    'customer_id': card_token,
                },
            },
            'order_information': {
                'amount_details': {
                    'total_amount': str(total_amount.amount),
                    'currency': str(total_amount.currency),
                },
            },
        }

        if customer:
            request['order_information'].update({
                'bill_to': {
                    'first_name': customer.first_name,
                    'last_name': customer.last_name,
                    'company': customer.company,
                    'address1': customer.address1,
                    'address2': customer.address2,
                    'locality': customer.locality,
                    'country': customer.country,
                    'email': customer.email,
                    'phone_number': customer.phone_number,
                    'administrative_area': customer.administrative_area,
                    'postalCode': customer.zip_code,
                }
            })

        serialized_request = json.dumps(request)
        data, status, body = self._payment_api_client.create_payment(create_payment_request=serialized_request)

        return data.id
    except Exception as e:
        raise AuthorizePaymentError from e
4

0 回答 0