From 4c346b953eb7744892ad37c62afe24835d3d6c4d Mon Sep 17 00:00:00 2001 From: akiko-pusu Date: Sun, 22 Nov 2020 22:43:12 +0000 Subject: [PATCH 1/3] Commit for creating PR. Update IPN endpoint. From 98da5547c72386d0dc5665b030c980845843e95a Mon Sep 17 00:00:00 2001 From: akiko-pusu Date: Mon, 23 Nov 2020 00:16:50 +0000 Subject: [PATCH 2/3] Change the url to send message back to Paypal for IPN. Also change module test. --- lib/offsite_payments/integrations/paypal.rb | 6 ++++-- test/unit/integrations/paypal/paypal_module_test.rb | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/offsite_payments/integrations/paypal.rb b/lib/offsite_payments/integrations/paypal.rb index 17c201300..d89d19f6c 100644 --- a/lib/offsite_payments/integrations/paypal.rb +++ b/lib/offsite_payments/integrations/paypal.rb @@ -3,11 +3,13 @@ module Integrations #:nodoc: module Paypal # Overwrite this if you want to change the Paypal test url mattr_accessor :test_url - self.test_url = 'https://www.sandbox.paypal.com/cgi-bin/webscr' + self.test_url = 'https://ipnpb.sandbox.paypal.com/cgi-bin/webscr' # Overwrite this if you want to change the Paypal production url + # NOTE: https://www.paypal.com/ returns dynamic IP addresse. + # Please refer to mattr_accessor :production_url - self.production_url = 'https://www.paypal.com/cgi-bin/webscr' + self.production_url = 'https://ipnpb.paypal.com/cgi-bin/webscr' def self.service_url mode = OffsitePayments.mode diff --git a/test/unit/integrations/paypal/paypal_module_test.rb b/test/unit/integrations/paypal/paypal_module_test.rb index 32826750f..74ada2f63 100644 --- a/test/unit/integrations/paypal/paypal_module_test.rb +++ b/test/unit/integrations/paypal/paypal_module_test.rb @@ -9,12 +9,12 @@ def test_notification_method def test_test_mode OffsitePayments.mode = :test - assert_equal 'https://www.sandbox.paypal.com/cgi-bin/webscr', Paypal.service_url + assert_equal 'https://ipnpb.sandbox.paypal.com/cgi-bin/webscr', Paypal.service_url end def test_production_mode OffsitePayments.mode = :production - assert_equal 'https://www.paypal.com/cgi-bin/webscr', Paypal.service_url + assert_equal 'https://ipnpb.paypal.com/cgi-bin/webscr', Paypal.service_url ensure OffsitePayments.mode = :test end From b0d3cd9fb6ad2fcc909520ae4d3e105bdfb8a0a7 Mon Sep 17 00:00:00 2001 From: akiko-pusu Date: Mon, 23 Nov 2020 14:29:32 +0000 Subject: [PATCH 3/3] Change to use `String#start_with?` instead of `String#starts_with?`. In Rails edge, deprecate `starts_with?` and `ends_with?` for String core extensions. Ref https://github.com/rails/rails/pull/39152. --- lib/offsite_payments/integrations/paxum.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/offsite_payments/integrations/paxum.rb b/lib/offsite_payments/integrations/paxum.rb index 8e9b9a7ca..b798f054f 100644 --- a/lib/offsite_payments/integrations/paxum.rb +++ b/lib/offsite_payments/integrations/paxum.rb @@ -34,9 +34,9 @@ def self.notification(query_string, options = {}) module Common def generate_signature_string - @raw_post.slice!(0) if @raw_post.starts_with?("&") + @raw_post.slice!(0) if @raw_post.start_with?("&") @raw_post = CGI.unescape(@raw_post) - @raw_post = "&#{@raw_post}" unless @raw_post.starts_with?("&") + @raw_post = "&#{@raw_post}" unless @raw_post.start_with?("&") arr = @raw_post.split('&') arr.delete(arr.last) data = arr.join('&')