Skip to content

Commit

Permalink
Add Venmo as payment option on checkout
Browse files Browse the repository at this point in the history
Resolves issue/ticket:
- solidusio#136

Setting the payment method preference `enable_venmo` to true will now
show a Venmo payment option on checkout for customers whom it is
available to (currently only US).
  • Loading branch information
RyanofWoods committed Nov 26, 2021
1 parent 3b274cb commit 14a2552
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,16 @@ With product and cart page checkout, the user is directed to the checkout confir

PayPals API does not allow for admin-side payments. Instead, backend users taking payments for customers will need to use the PayPal Virtual Terminal to take payments. [More info is available on the PayPal website.](https://www.paypal.com/merchantapps/appcenter/acceptpayments/virtualterminal?locale.x=en_US)

## Venmo
You can enable Venmo to appear as a funding source/a button below PayPal's button, by updating the Solidus PayPal Commerce `Payment Method`'s preference `enable_venmo` to `true`. See more about preferences below.

Please note, there are prerequisites you must meet for Venmo to be available to your store and customers. [Read more here](https://developer.paypal.com/docs/business/checkout/pay-with-venmo/#eligibility).

## Configuration
The easiest way to change the `Payment Method`'s preferences is through admin: `Settings > Payments > "PayPal Commerce Platform" > Edit`.

See more about preferences [here](https://guides.solidus.io/developers/preferences/add-model-preferences.html#access-your-preferences)/

## Development

### Testing the extension
Expand Down
2 changes: 2 additions & 0 deletions app/models/solidus_paypal_commerce_platform/payment_method.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class PaymentMethod < SolidusSupport.payment_method_parent_class
preference :display_on_cart, :boolean, default: true
preference :display_on_product_page, :boolean, default: true
preference :display_credit_messaging, :boolean, default: true
preference :enable_venmo, :boolean, default: false

def partial_name
"paypal_commerce_platform"
Expand Down Expand Up @@ -73,6 +74,7 @@ def javascript_sdk_url(order: nil, currency: nil)
}

parameters[:shipping_preference] = 'NO_SHIPPING' if step_names.exclude? 'delivery'
parameters['enable-funding'] = 'venmo' if options[:enable_venmo]

"https://www.paypal.com/sdk/js?#{parameters.to_query}"
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,22 @@ def Struct(data) # rubocop:disable Naming/MethodName
expect(url.query.split("&")).to include("components=buttons")
end
end

context 'when enable_venmo is false' do
before { paypal_payment_method.preferences.update(enable_venmo: false) }

it 'does not include the "enable-funding=venmo" parameter' do
expect(url.query.split('&')).not_to include('enable-funding=venmo')
end
end

context 'when enable_venmo is true' do
before { paypal_payment_method.preferences.update(enable_venmo: true) }

it 'includes "enable-funding=venmo" as a parameter' do
expect(url.query.split('&')).to include('enable-funding=venmo')
end
end
end

private
Expand Down

0 comments on commit 14a2552

Please sign in to comment.