Skip to content

Commit

Permalink
feat(customer_type): Gocardless add firstname and lastname (#2557)
Browse files Browse the repository at this point in the history
  • Loading branch information
brunomiguelpinto authored Sep 10, 2024
1 parent 1ae3c70 commit 3d638b7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
14 changes: 8 additions & 6 deletions app/services/payment_provider_customers/gocardless_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,14 @@ def client
end

def create_gocardless_customer
client.customers.create(
params: {
email: customer.email&.strip&.split(',')&.first,
company_name: customer.name
}
)
customer_params = {
email: customer.email&.strip&.split(',')&.first,
company_name: customer.name.presence,
given_name: customer.firstname.presence,
family_name: customer.lastname.presence
}.compact

client.customers.create(customer_params)
rescue GoCardlessPro::Error => e
deliver_error_webhook(e)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,20 @@
.and_return(GoCardlessPro::Resources::Customer.new('id' => '123'))
end

context 'when all customer details are present' do
it 'creates a customer with company_name, given_name, and family_name' do
gocardless_service.create
expect(gocardless_customers_service).to have_received(:create).with(
hash_including(
email: customer.email,
company_name: customer.name,
given_name: customer.firstname,
family_name: customer.lastname
)
)
end
end

it 'creates the gocardless customer' do
result = gocardless_service.create

Expand Down

0 comments on commit 3d638b7

Please sign in to comment.