#BidBird®

1 messages · Page 1 of 1 (latest)

true heraldBOT
stuck jetty
#

Hi there

obsidian yarrow
#

Hi

stuck jetty
#

Not exactly sure what you mean here

#

With the PaymentIntents API the PaymentMethod is created on client-side confirmation

#

As opposed to with the legacy Charge API where you explicitly create a Token client-side then pass that server-side to charge it

obsidian yarrow
#

ahh, ok. Well the stripe object, still has source as a field.

  #_opts: Stripe\Util\RequestOptions {#2111 ▶}
  #_originalValues: array:42 [▶]
  #_values: array:42 [▶]
  #_unsavedValues: Stripe\Util\Set {#2113 ▶}
  #_transientValues: Stripe\Util\Set {#2112 ▶}
  #_retrieveOptions: []
  #_lastResponse: Stripe\ApiResponse {#2115 ▶}
  +saveWithParent: false
  id: "pi_3Mb81UKT8fxib8XB0oodUTqm"
  object: "payment_intent"
  allowed_source_types: array:1 [▶]
  amount: 1099
  amount_capturable: 0
  amount_details: Stripe\StripeObject {#2110 ▶}
  amount_received: 0
  application: null
  application_fee_amount: null
  automatic_payment_methods: null
  canceled_at: null
  cancellation_reason: null
  capture_method: "automatic"
  charges: Stripe\Collection {#2109 ▶}
  client_secret: "pi_3Mb81UKT8fxib8XB0oodUTqm_secret_idJmEz7p0YToTFXFVtMZ0jGl0"
  confirmation_method: "automatic"
  created: 1676317752
  currency: "usd"
  customer: null
  description: null
  invoice: null
  last_payment_error: null
  latest_charge: null
  livemode: false
  metadata: Stripe\StripeObject {#2105 ▶}
  next_action: null
  next_source_action: null
  on_behalf_of: null
  payment_method: null
  payment_method_options: Stripe\StripeObject {#2049 ▼
    #_opts: Stripe\Util\RequestOptions {#2102 ▶}
    #_originalValues: array:1 [▶]
    #_values: array:1 [▶]
    #_unsavedValues: Stripe\Util\Set {#2099 ▶}
    #_transientValues: Stripe\Util\Set {#2046 ▶}
    #_retrieveOptions: []
    #_lastResponse: null
    card: Stripe\StripeObject {#2101 ▶}
  }
  payment_method_types: array:1 [▼
    0 => "card"
  ]
  processing: null
  receipt_email: null
  review: null
  setup_future_usage: null
  shipping: null
  source: null
  statement_descriptor: null
  statement_descriptor_suffix: null
  status: "requires_source"
  transfer_data: null
  transfer_group: null
}

`

stuck jetty
#

That is the Charge object that you are looking at

#

A Charge object will exist within a PaymentIntent object (if you expand the Charge)

obsidian yarrow
#

Interesting. Ok. I did update the charge code to:

            $stripeIntent = \Stripe\PaymentIntent::create([                'amount' => 1099,                'currency' => 'usd',
//                'source' => $token,            ], ['api_key' => $this->apiKey]);            dd($stripeIntent);   
         return new PaymentIntent([                'amount' => $stripeIntent['amount'],                'card_last_four' => $stripeIntent['source']['last4'],            ]);        } catch (InvalidRequestException $e) {            throw new PaymentFailedException;

See here I commented out the 'source'

#

So, I'm getting this error: Trying to access array offset on value of type null Because source has no token. Is Token no longer necessary?

stuck jetty
#

Okay so the PaymentIntents API is backward compatible so you don't want to use source at all here

#

Instead, you can pass a Token to the payment_method parameter and it will work fine

#

Really though the recommendation here is to get rid of using Tokens altogether

#

And just confirm client-side