-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update CardRoutes.swift #36
Conversation
@Maxim-Inv nice catch! Thanks for this. Can you create a simple issue so it can be linked in a change log I’m planning on adding. |
Yes, of course |
I have optimized the converting of byte buffer to data. |
@Maxim-Inv you don’t need coding keys because on a response we set the key decoding strategy to snake_case so it automatically decodes.
|
Great. I tried to catch webhooks and got decoding issues. I will remove it. |
What errors where you getting? |
TIL this option. Thanks. |
|
And what was your actual json structure being returned by the API? |
"{\n "id": "evt_1GJKgsHHE5YBFDMsP3ecEJ6W",\n "object": "event",\n "api_version": "2019-12-03",\n "created": 1583418526,\n "data": {\n "object": {\n "id": "ch_1GJKgrHHE5YBFDMsVepexjfX",\n "object": "charge",\n "amount": 100,\n "amount_refunded": 0,\n "application": null,\n "application_fee": null,\n "application_fee_amount": null,\n "balance_transaction": "txn_1GJKgsHHE5YBFDMsW1FB59Ic",\n "billing_details": {\n "address": {\n "city": null,\n "country": null,\n "line1": null,\n "line2": null,\n "postal_code": null,\n "state": null\n },\n "email": null,\n "name": null,\n "phone": null\n },\n "captured": true,\n "created": 1583418525,\n "currency": "usd",\n "customer": null,\n "description": "(created by Stripe CLI)",\n "destination": null,\n "dispute": null,\n "disputed": false,\n "failure_code": null,\n "failure_message": null,\n "fraud_details": {\n },\n "invoice": null,\n "livemode": false,\n "metadata": {\n },\n "on_behalf_of": null,\n "order": null,\n "outcome": {\n "network_status": "approved_by_network",\n "reason": null,\n "risk_level": "normal",\n "risk_score": 39,\n "seller_message": "Payment complete.",\n "type": "authorized"\n },\n "paid": true,\n "payment_intent": null,\n "payment_method": "card_1GJKgrHHE5YBFDMsyrtTU0Ms",\n "payment_method_details": {\n "card": {\n "brand": "visa",\n "checks": {\n "address_line1_check": null,\n "address_postal_code_check": null,\n "cvc_check": null\n },\n "country": "US",\n "exp_month": 3,\n "exp_year": 2021,\n "fingerprint": "DSVlgCD7yApjOAEy",\n "funding": "credit",\n "installments": null,\n "last4": "4242",\n "network": "visa",\n "three_d_secure": null,\n "wallet": null\n },\n "type": "card"\n },\n "receipt_email": null,\n "receipt_number": null,\n "receipt_url": "",\n "refunded": false,\n "refunds": {\n "object": "list",\n "data": [\n\n ],\n "has_more": false,\n "total_count": 0,\n "url": "/v1/charges/ch_1GJKgrHHE5YBFDMsVepexjfX/refunds"\n },\n "review": null,\n "shipping": null,\n "source": {\n "id": "card_1GJKgrHHE5YBFDMsyrtTU0Ms",\n "object": "card",\n "address_city": null,\n "address_country": null,\n "address_line1": null,\n "address_line1_check": null,\n "address_line2": null,\n "address_state": null,\n "address_zip": null,\n "address_zip_check": null,\n "brand": "Visa",\n "country": "US",\n "customer": null,\n "cvc_check": null,\n "dynamic_last4": null,\n "exp_month": 3,\n "exp_year": 2021,\n "fingerprint": "DSVlgCD7yApjOAEy",\n "funding": "credit",\n "last4": "4242",\n "metadata": {\n },\n "name": null,\n "tokenization_method": null\n },\n "source_transfer": null,\n "statement_descriptor": null,\n "statement_descriptor_suffix": null,\n "status": "succeeded",\n "transfer_data": null,\n "transfer_group": null\n }\n },\n "livemode": false,\n "pending_webhooks": 2,\n "request": {\n "id": "req_u3etzWjCjvCgbi",\n "idempotency_key": null\n },\n "type": "charge.succeeded"\n}" |
Can you format that not as a single line lol |
@Maxim-Inv Your webhooks data Seemed fine to me. Also I'm not sure why you got a decoding error for that field when all the other fields decode just fine? But this PR looks good so far. |
I hadn't used decoder.keyDecodingStrategy = .convertFromSnakeCase before. It works fine after I added it. |
to fix error