How to retrieve all details of a stripe paymentintent?

444 views Asked by At

I am using stipe php api for retrieving the details of a PaymentIntent that has previously been created. Using this

$stripe->paymentIntents->retrieve(
  'pi_1HC8egG7NsTelwXIddIlYyrX',
  []
);

Then I am looking for the charge node to obtain payment method details when I use my test account I get a json with more information

{
    "id": "pi_3O9eZKG7NsTelwXI1CD28Owb",
    "object": "payment_intent",
    "amount": 2000,
    "amount_capturable": 0,
    "amount_details": {
        "tip": []
    },
    "amount_received": 2000,
    "application": null,
    "application_fee_amount": null,
    "automatic_payment_methods": null,
    "canceled_at": null,
    "cancellation_reason": null,
    "capture_method": "automatic",
    "charges": {
        "object": "list",
        "data": [
            {
                "id": "ch_3O9eZKG7NsTelwXI1dkaat0T",
                "object": "charge",
                "amount": 2000,
                "amount_captured": 2000,
                "amount_refunded": 0,
                "application": null,
                "application_fee": null,
                "application_fee_amount": null,
                "balance_transaction": "txn_3O9eZKG7NsTelwXI1wSjxTZb",
                "billing_details": {
                    "address": {
                        "city": null,
                        "country": null,
                        "line1": null,
                        "line2": null,
                        "postal_code": null,
                        "state": null
                    },
                    "email": null,
                    "name": null,
                    "phone": null
                },
                "calculated_statement_descriptor": "VENDEMAS MARKETPLACE",
                "captured": true,
                "created": 1699322346,
                "currency": "usd",
                "customer": null,
                "description": "(created by Stripe CLI)",
                "destination": null,
                "dispute": null,
                "disputed": false,
                "failure_balance_transaction": null,
                "failure_code": null,
                "failure_message": null,
                "fraud_details": [],
                "invoice": null,
                "livemode": false,
                "metadata": [],
                "on_behalf_of": null,
                "order": null,
                "outcome": {
                    "network_status": "approved_by_network",
                    "reason": null,
                    "risk_level": "normal",
                    "risk_score": 4,
                    "seller_message": "Payment complete.",
                    "type": "authorized"
                },
                "paid": true,
                "payment_intent": "pi_3O9eZKG7NsTelwXI1CD28Owb",
                "payment_method": "pm_1O9eZKG7NsTelwXIERNQOLK7",
                "payment_method_details": {
                    "card": {
                        "amount_authorized": 2000,
                        "brand": "visa",
                        "checks": {
                            "address_line1_check": null,
                            "address_postal_code_check": null,
                            "cvc_check": "pass"
                        },
                        "country": "US",
                        "exp_month": 11,
                        "exp_year": 2024,
                        "extended_authorization": {
                            "status": "disabled"
                        },
                        "fingerprint": "r4GYLqkSFntmfS5K",
                        "funding": "credit",
                        "incremental_authorization": {
                            "status": "unavailable"
                        },
                        "installments": null,
                        "last4": "4242",
                        "mandate": null,
                        "multicapture": {
                            "status": "unavailable"
                        },
                        "network": "visa",
                        "network_token": {
                            "used": false
                        },
                        "overcapture": {
                            "maximum_amount_capturable": 2000,
                            "status": "unavailable"
                        },
                        "three_d_secure": null,
                        "wallet": null
                    },
                    "type": "card"
                },
                "receipt_email": null,
                "receipt_number": null,
                "receipt_url": "https:\/\/pay.stripe.com\/receipts\/payment\/CAcaFwoVYWNjdF8xSEJ2cm9HN05zVGVsd1hJKOuzpqoGMgZPLCVOBUQ6LBbsXcqxkUfCY_oWo2yj4BGC0BnoZeuRp_tIvZevoapuurH3fllUVQdDWrmv",
                "refunded": false,
                "refunds": {
                    "object": "list",
                    "data": [],
                    "has_more": false,
                    "total_count": 0,
                    "url": "\/v1\/charges\/ch_3O9eZKG7NsTelwXI1dkaat0T\/refunds"
                },
                "review": null,
                "shipping": {
                    "address": {
                        "city": "San Francisco",
                        "country": "US",
                        "line1": "510 Townsend St",
                        "line2": null,
                        "postal_code": "94103",
                        "state": "CA"
                    },
                    "carrier": null,
                    "name": "Jenny Rosen",
                    "phone": null,
                    "tracking_number": null
                },
                "source": null,
                "source_transfer": null,
                "statement_descriptor": null,
                "statement_descriptor_suffix": null,
                "status": "succeeded",
                "transfer_data": null,
                "transfer_group": null
            }
        ],
        "has_more": false,
        "total_count": 1,
        "url": "\/v1\/charges?payment_intent=pi_3O9eZKG7NsTelwXI1CD28Owb"
    },
    "client_secret": "pi_3O9eZKG7NsTelwXI1CD28Owb_secret_rtG1vZ2j1mozAncsJOK04xyNR",
    "confirmation_method": "automatic",
    "created": 1699322346,
    "currency": "usd",
    "customer": null,
    "description": "(created by Stripe CLI)",
    "invoice": null,
    "last_payment_error": null,
    "latest_charge": "ch_3O9eZKG7NsTelwXI1dkaat0T",
    "livemode": false,
    "metadata": [],
    "next_action": null,
    "on_behalf_of": null,
    "payment_method": "pm_1O9eZKG7NsTelwXIERNQOLK7",
    "payment_method_configuration_details": null,
    "payment_method_options": {
        "card": {
            "installments": null,
            "mandate_options": null,
            "network": null,
            "request_three_d_secure": "automatic"
        }
    },
    "payment_method_types": [
        "card"
    ],
    "processing": null,
    "receipt_email": null,
    "review": null,
    "setup_future_usage": null,
    "shipping": {
        "address": {
            "city": "San Francisco",
            "country": "US",
            "line1": "510 Townsend St",
            "line2": null,
            "postal_code": "94103",
            "state": "CA"
        },
        "carrier": null,
        "name": "Jenny Rosen",
        "phone": null,
        "tracking_number": null
    },
    "source": null,
    "statement_descriptor": null,
    "statement_descriptor_suffix": null,
    "status": "succeeded",
    "transfer_data": null,
    "transfer_group": null
}

than using the client account which only retrieves a small json like this

{
    "id": "pi_3O9YaRCeJLlbGRXS0Hkp8g78",
    "object": "payment_intent",
    "amount": 1000,
    "amount_capturable": 0,
    "amount_details": {
        "tip": []
    },
    "amount_received": 1000,
    "application": null,
    "application_fee_amount": null,
    "automatic_payment_methods": {
        "allow_redirects": "always",
        "enabled": true
    },
    "canceled_at": null,
    "cancellation_reason": null,
    "capture_method": "automatic",
    "client_secret": "pi_3O9YaRCeJLlbGRXS0Hkp8g78_secret_JCCFWZ5tfRuh2rn4QALvWHm5d",
    "confirmation_method": "automatic",
    "created": 1699299351,
    "currency": "mxn",
    "customer": null,
    "description": null,
    "invoice": null,
    "last_payment_error": null,
    "latest_charge": "ch_3O9YaRCeJLlbGRXS0r0Fctrf",
    "livemode": false,
    "metadata": [],
    "next_action": null,
    "on_behalf_of": null,
    "payment_method": "pm_1O9YadCeJLlbGRXSXD3t4lTO",
    "payment_method_configuration_details": null,
    "payment_method_options": {
        "card": {
            "installments": {
                "available_plans": [],
                "enabled": false,
                "plan": null
            },
            "mandate_options": null,
            "network": null,
            "request_three_d_secure": "automatic"
        }
    },
    "payment_method_types": [
        "card"
    ],
    "processing": null,
    "receipt_email": null,
    "review": null,
    "setup_future_usage": null,
    "shipping": null,
    "source": null,
    "statement_descriptor": null,
    "statement_descriptor_suffix": null,
    "status": "succeeded",
    "transfer_data": null,
    "transfer_group": null
}

Has anyone had the same problem? Did I missed some configuration in the client account to retrieve more details of the payment or why is this difference happening? Thanks in advance

1

There are 1 answers

0
Marisol vega On BEST ANSWER

Someone has given me the solution in discord. Using expand api function allows you to retrieve linked objects in a single call. More info here stripe expand