-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Subtract store credit from total sent to PayBright
Since PayBright doesn't allow us to modify payments before capturing them like some other payment methods, we need to ensure we send them the correct amount right away.
- Loading branch information
Luuk Veenis
committed
Jan 16, 2018
1 parent
082ddd1
commit 7a47ec0
Showing
2 changed files
with
13 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
require "spec_helper" | ||
|
||
describe SolidusPaybright::ParamsHelper do | ||
let(:payment_method) { create(:paybright_payment_method, preference_source: "paybright_credentials") } | ||
let(:payment) { create(:paybright_payment, payment_method: payment_method) } | ||
let(:order) { build_stubbed(:order, total: 110, number: "R123456789", email: "[email protected]") } | ||
let(:payment_method) { build_stubbed(:paybright_payment_method, preference_source: "paybright_credentials") } | ||
let(:payment) { build_stubbed(:paybright_payment, order: order, payment_method: payment_method) } | ||
|
||
subject { described_class.new(payment) } | ||
|
||
describe "#new" do | ||
|
@@ -13,14 +15,6 @@ | |
end | ||
|
||
describe "#build_redirect_params" do | ||
before do | ||
allow_any_instance_of(Spree::Order).to receive_messages( | ||
total: 110, | ||
number: "R123456789", | ||
email: "[email protected]" | ||
) | ||
end | ||
|
||
it "build the correct parameters for the order" do | ||
params = subject.build_redirect_params | ||
expect(params["x_account_id"]).to eq("api-key") | ||
|
@@ -40,5 +34,13 @@ | |
allow_any_instance_of(Spree::Order).to receive_messages email: "" | ||
expect(subject.build_redirect_params.key?("x_customer_email")).to be false | ||
end | ||
|
||
context "order has store credit applied" do | ||
before { allow(order).to receive(:total_applicable_store_credit) { 10 } } | ||
|
||
it "subtracts the credit from the total passed to Paybright" do | ||
expect(subject.build_redirect_params["x_amount"]).to eq("100.00") | ||
end | ||
end | ||
end | ||
end |