Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PayPal Debug ID to log entries #52

Merged
merged 1 commit into from
Jul 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Deface::Override.new(
name: "payments/log_entries/add_paypal_debug_id",
virtual_path: "spree/admin/payments/_log_entries",
original: "5eb2952fa4ba1484a63e5abf53e4ed735761a7b2",
replace: "#listing_log_entries",
partial: "solidus_paypal_commerce_platform/admin/payments/log_entries"
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<table class='index' id='listing_log_entries'>
<colgroup>
<col style="width: 30%" />
<col style="width: 40%" />
<col style="width: 20%" />
<col style="width: 10%" />
</colgroup>
<thead>
<tr>
<th><%= Spree::LogEntry.human_attribute_name(:created_at) %></th>
<th><%= Spree::LogEntry.human_attribute_name(:details) %></th>
<th><%= I18n.t("paypal_debug_id") %></th>
<th></th>
</tr>
</thead>
<tbody>
<% log_entries.each do |entry| %>
<tr class="log_entry <%= entry.parsed_details.success? ? 'success' : 'fail' %>">
<td>
<%= pretty_time(entry.created_at) %>
</td>
<td>
<pre><%= entry.parsed_details.message %></pre>
</td>
<td><%= entry.parsed_details.params["paypal_debug_id"] %></td>
<td class="text-right">
<i class='fa fa-<%= entry.parsed_details.success? ? 'check' : 'remove' %>'></i>
</td>
</tr>
<% end %>
</tbody>
</table>
1 change: 1 addition & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ en:
sign_up_for_paypal: Setup PayPal Commerce Platform
start_paying_with_paypal: Start paying with Paypal Commerce Platform
paypal_order_id: PayPal Order ID
paypal_debug_id: PayPal Debug ID
virtual_terminal_notice_html: Backend Credit Card payments can only be accepted through PayPal via the <a href="https://www.paypal.com/merchantapps/appcenter/acceptpayments/virtualterminal">PayPal Virtual Terminal</a>.
solidus_paypal_commerce_platform:
responses:
Expand Down
2 changes: 1 addition & 1 deletion lib/solidus_paypal_commerce_platform/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def i18n_scope_for(request)
def wrap_response(response, success_message: nil, failure_message: nil)
if SUCCESS_STATUS_CODES.include? response.status_code
success_message ||= "Success."
ActiveMerchant::Billing::Response.new(true, success_message, result: response.result)
ActiveMerchant::Billing::Response.new(true, success_message, result: response.result, paypal_debug_id: response.headers["paypal-debug-id"])
else
failure_message ||= "A problem has occurred with this payment, please try again."
ActiveMerchant::Billing::Response.new(false, failure_message)
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
describe '#execute_with_response' do
let(:request_class) { SolidusPaypalCommercePlatform::Gateway::OrdersCaptureRequest }
let(:paypal_request) { double(:request, class: request_class) }
let(:paypal_response) { double(:response, status_code: status_code, result: nil) }
let(:paypal_response) { double(:response, status_code: status_code, result: nil, headers: {}) }
let(:status_code) { 201 }

before do
Expand Down
5 changes: 4 additions & 1 deletion spec/models/payment_method_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@
)
)
]
)
),
headers: {
"paypal-debug-id": ["123"]
}
)

allow_any_instance_of(PayPal::PayPalHttpClient).to receive(:execute) { response }
Expand Down