Skip to content

Commit

Permalink
Fix: return donation billing address in Stripe Payment Element Gateway (
Browse files Browse the repository at this point in the history
#7395)

Co-authored-by: Jon Waldstein <[email protected]>
Co-authored-by: Jon Waldstein <[email protected]>
  • Loading branch information
3 people authored Jun 3, 2024
1 parent da11d76 commit 7a2a8a5
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ public function formSettings(int $formId): array
}

/**
* @unreleased updated to send billing address details to Stripe
* @since 3.0.0
* @inheritDoc
* @throws ApiErrorException
*/
Expand Down Expand Up @@ -144,7 +146,15 @@ public function createPayment(Donation $donation, $gatewayData): GatewayCommand
'returnUrl' => $stripeGatewayData->successUrl,
'billingDetails' => [
'name' => trim("$donation->firstName $donation->lastName"),
'email' => $donation->email
'email' => $donation->email,
'address' => [
'city' => $donation->billingAddress->city,
'country' => $donation->billingAddress->country,
'line1' => $donation->billingAddress->address1,
'line2' => $donation->billingAddress->address2,
'postal_code' => $donation->billingAddress->zip,
'state' => $donation->billingAddress->state,
],
],
]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ interface StripeGateway extends Gateway {
settings?: StripeSettings;
}

/**
* @unreleased updated afterCreatePayment response type to include billing details address
* @since 3.0.0
*/
const stripePaymentElementGateway: StripeGateway = {
id: 'stripe_payment_element',
initialize() {
Expand Down Expand Up @@ -135,6 +139,14 @@ const stripePaymentElementGateway: StripeGateway = {
billingDetails: {
name: string;
email: string;
address?: {
city?: string;
country?: string;
line1?: string;
line2?: string;
postal_code?: string;
state?: string;
}
};
};
}): Promise<void> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public function testFormSettingsShouldReturnData()
}

/**
* @unreleased updated to send billing address details to Stripe
* @since 3.0.0
*
* @throws \Give\Framework\Exceptions\Primitives\Exception
Expand Down Expand Up @@ -140,7 +141,15 @@ public function testCreatePaymentShouldReturnRespondToBrowserCommand()
'returnUrl' => $gatewayData['successUrl'],
'billingDetails' => [
'name' => trim("$donation->firstName $donation->lastName"),
'email' => $donation->email
'email' => $donation->email,
'address' => [
'city' => $donation->billingAddress->city,
'country' => $donation->billingAddress->country,
'line1' => $donation->billingAddress->address1,
'line2' => $donation->billingAddress->address2,
'postal_code' => $donation->billingAddress->zip,
'state' => $donation->billingAddress->state,
],
]
])
);
Expand Down

0 comments on commit 7a2a8a5

Please sign in to comment.