Skip to content

Commit

Permalink
Email me
Browse files Browse the repository at this point in the history
  • Loading branch information
vitkx committed Jan 20, 2025
1 parent d6ca1fc commit b7bd335
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions app/controllers/spree/paypal_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,34 @@ def capture_order
order.save
order.next until order.completed? || order.errors.any?
order.finalize!
begin
if params['order']['email_me']
address = order.ship_address
gibbon = ::Gibbon::Request.new(api_key: SpreeMailchimpEcommerce.configuration.mailchimp_api_key)
gibbon.lists(::SpreeMailchimpEcommerce.configuration.mailchimp_list_id)
.members
.create(
body: {
email_address: order.email,
status: "subscribed",
merge_fields: {
FNAME: address.firstname,
LNAME: address.lastname,
ADDRESS: [
address.address1,
address.address2,
address.city,
address.state_name,
address.zipcode,
address.country_name
].compact.join(', '),
PHONE: address.phone
}
}
)
end
rescue
end
render json: { status: 'success', details: response }, status: :ok
else
render json: { error: 'Capture failed' }, status: :unprocessable_entity
Expand Down

0 comments on commit b7bd335

Please sign in to comment.