Stripe Checkout -Sitzung fehlt MetadatenPython

Python-Programme
Anonymous
 Stripe Checkout -Sitzung fehlt Metadaten

Post by Anonymous »

Ich habe versucht, Metadaten durch Stripe.Checkout.Session.create () wie SO:
zu bestehen

Code: Select all

stripe.api_key = STRIPE_SECRET_KEY

payments_blueprint = Blueprint('payments', __name__, url_prefix='/payments')

@payments_blueprint.route('/checkout', methods=['POST'])
def create_checkout_session():

try:
checkout_session = stripe.checkout.Session.create(
metadata=dict(key='val'),
payment_method_types=['card'],
line_items=request.form.get("lineItems", LINE_ITEMS),
success_url=f'{request.environ["HTTP_ORIGIN"]}/success',
cancel_url=f'{request.environ["HTTP_ORIGIN"]}/cancel',
mode='payment'
)

return redirect(checkout_session.url, code=HTTPStatus.SEE_OTHER)

except stripe.error.InvalidRequestError as err:
return redirect(f'{request.environ["HTTP_ORIGIN"]}/error', code=HTTPStatus.MOVED_PERMANENTLY)
< /code>
und weder die Antworten von Stripe noch die Ereignisse, die durch mein Webhook gehen  "metadata": {
"key": "val"
},...
Ich höre alle Ereignisse mit Stripe Listen-Forward-to Localhost: 8000/Hooks/-Print-Json und alles, was der Endpunkt AT/Hooks tut, ist das Drucken des Ereignisses auf StDout. Nichts anderes. < /p>
Ich möchte, dass diese Metadaten durch meine Reihe von Webhooks der Buchung Validierung weitergegeben werden. Auf diese Weise verweisen:
https://stripe.com/docs/api/Checkout/Se ... n-metadata
Grundsätzlich folge ich diese Dokumente, und sende Metadata durch das Rufen. Ich habe versucht, den Konstruktor dict () mit der DICT -Syntax zu verwenden (stattdessen (

Code: Select all

{"key":"val"}
), erstellen Sie eine Variable und setzen Sie sie auf diesen Diktieren ein, bevor Sie sie durch die Funktion übergeben, und in jeder anderen Möglichkeit konnte ich mir vorstellen, dieses Metadaten -Wörterbuch zu übergeben, aber ich habe sie nicht von Stripe zurückgezogen.

Code: Select all

class TestHook(Resource):

def post(self):
event = stripe.Event.construct_from(
json.loads(request.data),
stripe.api_key
).to_dict()

print(event['type'])
pprint(event['data']['object'])
< /code>
und die Ausgabe zu stdout: < /p>
payment_intent.created
{'amount': 20000,
'amount_capturable': 0,
'amount_received': 0,
'application': None,
'application_fee_amount': None,
'canceled_at': None,
'cancellation_reason': None,
'capture_method': 'automatic',
'charges': {},
'client_secret': 'pi_3JTYxxxx7t',
'confirmation_method': 'automatic',
'created': 1630184808,
'currency': 'usd',
'customer': None,
'description': None,
'id': 'pi_3JTYxxxxVm4',
'invoice': None,
'last_payment_error': None,
'livemode': False,
'metadata':  JSON: {},
'next_action': None,
'object': 'payment_intent',
'on_behalf_of': None,
'payment_method': None,
'payment_method_options': {'card': {'installments': None,
'network': None,
'request_three_d_secure': 'automatic'}},
'payment_method_types': ['card'],
'receipt_email': None,
'review': None,
'setup_future_usage': None,
'shipping': None,
'source': None,
'statement_descriptor': None,
'statement_descriptor_suffix': None,
'status': 'requires_payment_method',
'transfer_data': None,
'transfer_group': None}

checkout.session.completed
{'allow_promotion_codes': None,
'amount_subtotal': 20000,
'amount_total': 20000,
'automatic_tax': {'enabled': False,
'status': None},
'billing_address_collection': None,
'cancel_url': 'http://localhost:9000/#/guides/cozumel-buzos-del-caribe/trips/7-day-dive?cancelpayment=true',
'client_reference_id': None,
'currency': 'usd',
'customer': 'cus_K7oxxxguu',
'customer_details': {'email': 'abc@gmail.com',
'tax_exempt': 'none',
'tax_ids': []},
'customer_email': None,
'id': 'cs_test_b1Yxxx9dM',
'livemode': False,
'locale': None,
'metadata':  JSON: {},
'mode': 'payment',
'object': 'checkout.session',
'payment_intent': 'pi_3JTYxxxVm4',
'payment_method_options':  JSON: {},
'payment_method_types': ['card'],
'payment_status': 'paid',
'setup_intent': None,
'shipping': None,
'shipping_address_collection': None,
'submit_type': None,
'subscription': None,
'success_url': 'http://localhost:9000/#/payment/success',
'total_details': {'amount_discount': 0,
'amount_shipping': 0,
'amount_tax': 0},
'url': None}
In all diesen Ereignissen ist Metadaten 'metadata': json: {}

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post