- Issue created by @mariacha1
- Status changed to Needs review
about 1 year ago 4:15pm 13 September 2023 - last update
about 1 year ago 38 pass - πΊπ¦Ukraine marchuk.vitaliy Rivne, UA
It seems we need to do it like this:
/** @var \Drupal\address\Plugin\Field\FieldType\AddressItem $address */ $address = $profile->get('address')->first();
And then use methods from the AddressItem class, such as $address->getGivenName() and $address->getFamilyName().
A good example of how it should be is here https://git.drupalcode.org/project/commerce_paypal/-/blob/8.x-1.x/src/Ch..., see method formatAddress().
So, in our case, we can also create a general method to format the billing and shipping addresses. The only problem now is that we don't have a file (sdk or api) for it yet. - πΊπ¦Ukraine abramm Lutsk
Note: this is also happening in https://git.drupalcode.org/project/commerce_stripe/-/blame/8.x-1.x/src/P... .
- Status changed to Needs work
about 1 year ago 8:57am 21 September 2023 - Assigned to abramm
- Issue was unassigned.
- Status changed to Needs review
about 1 year ago 12:36pm 21 September 2023 - last update
about 1 year ago 38 pass - πΊπ¦Ukraine abramm Lutsk
Here's the patch unifying address formatting.
A few notes on design decisions:
1) The address formatter is implemented as a Drupal service to allow overriding it.
2) The\Drupal\commerce_stripe\AddressFormatterInterface::format()
method accepts the whole Profile entity to allow customizing the data retrieved; as a common example, sometimes site owners adds phone number field to the customer profile and thus it should be possible to extract it and pass to Stripe. - First commit to issue fork.
- last update
about 1 year ago 38 pass - πΊπΈUnited States gcb
1.1 broke these patches. Here's a try at updating the full refactor one for 1.1. I will also turn this into an issue fork.
- last update
about 1 year ago 38 pass - @vmarchuk opened merge request.
- πΊπ¦Ukraine marchuk.vitaliy Rivne, UA
I realized that a good place for the formatAddress method is the StripePaymentElement plugin. So I moved the code from the separate service to this plugin and updated the corresponding code (+ opened MR).
- last update
about 1 year ago 38 pass - πΊπΈUnited States rszrama
I tested this patch on a local install that I disabled all name and company fields from in the default customer profile type. When I tried to pay, I was shown errors related to a missing
shipping[name]
parameter. How did you test this? Maybe we need some way to still provide a name for a shipment even if this works fine for billing? - last update
about 1 year ago 38 pass - last update
about 1 year ago 38 pass - πΊπ¦Ukraine marchuk.vitaliy Rivne, UA
@rszrama
Yes, you're right, the shipping name field is required https://stripe.com/docs/api/payment_intents/create#create_payment_intent... (if the address is defined, then the name must exist).
I've updated the MR with the necessary fixes. - last update
about 1 year ago 38 pass -
rszrama β
committed e18dc10c on 8.x-1.x authored by
vmarchuk β
Issue #3387109 by vmarchuk, gcb, mariacha1, abramm, rszrama: Warning...
-
rszrama β
committed e18dc10c on 8.x-1.x authored by
vmarchuk β
- Status changed to Fixed
about 1 year ago 10:16pm 15 November 2023 - πΊπΈUnited States rszrama
Thanks, this worked for me. I think we can worry about refactoring the address formatting out to a service in the future that standardizes both this and various other common API features between the payment gateway plugins.
Automatically closed - issue fixed for 2 weeks with no activity.