random_data.py 文件源码

python
阅读 30 收藏 0 点赞 0 评论 0

项目:planet-b-saleor 作者: planet-b 项目源码 文件源码
def create_payment(delivery_group):
    order = delivery_group.order
    status = random.choice(
        [PaymentStatus.WAITING, PaymentStatus.PREAUTH, PaymentStatus.CONFIRMED])
    payment = Payment.objects.create(
        order=order,
        status=status,
        variant='default',
        transaction_id=str(fake.random_int(1, 100000)),
        currency=settings.DEFAULT_CURRENCY,
        total=order.get_total().gross,
        delivery=delivery_group.shipping_price.gross,
        customer_ip_address=fake.ipv4(),
        billing_first_name=order.billing_address.first_name,
        billing_last_name=order.billing_address.last_name,
        billing_address_1=order.billing_address.street_address_1,
        billing_city=order.billing_address.city,
        billing_postcode=order.billing_address.postal_code,
        billing_country_code=order.billing_address.country)
    if status == PaymentStatus.CONFIRMED:
        payment.captured_amount = payment.total
        payment.save()
    return payment
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号