activemerchant-nsp 1.27.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +952 -0
- data/CONTRIBUTORS +347 -0
- data/MIT-LICENSE +20 -0
- data/README.md +204 -0
- data/gem-public_cert.pem +20 -0
- data/lib/active_merchant.rb +63 -0
- data/lib/active_merchant/billing.rb +9 -0
- data/lib/active_merchant/billing/avs_result.rb +98 -0
- data/lib/active_merchant/billing/base.rb +56 -0
- data/lib/active_merchant/billing/check.rb +68 -0
- data/lib/active_merchant/billing/credit_card.rb +274 -0
- data/lib/active_merchant/billing/credit_card_formatting.rb +21 -0
- data/lib/active_merchant/billing/credit_card_methods.rb +143 -0
- data/lib/active_merchant/billing/cvv_result.rb +38 -0
- data/lib/active_merchant/billing/expiry_date.rb +34 -0
- data/lib/active_merchant/billing/gateway.rb +176 -0
- data/lib/active_merchant/billing/gateways.rb +18 -0
- data/lib/active_merchant/billing/gateways/authorize_net.rb +695 -0
- data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +943 -0
- data/lib/active_merchant/billing/gateways/balanced.rb +462 -0
- data/lib/active_merchant/billing/gateways/barclays_epdq.rb +308 -0
- data/lib/active_merchant/billing/gateways/beanstream.rb +167 -0
- data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +389 -0
- data/lib/active_merchant/billing/gateways/beanstream_interac.rb +54 -0
- data/lib/active_merchant/billing/gateways/blue_pay.rb +492 -0
- data/lib/active_merchant/billing/gateways/bogus.rb +142 -0
- data/lib/active_merchant/billing/gateways/braintree.rb +19 -0
- data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +9 -0
- data/lib/active_merchant/billing/gateways/braintree_blue.rb +389 -0
- data/lib/active_merchant/billing/gateways/braintree_orange.rb +19 -0
- data/lib/active_merchant/billing/gateways/card_save.rb +23 -0
- data/lib/active_merchant/billing/gateways/card_stream.rb +230 -0
- data/lib/active_merchant/billing/gateways/certo_direct.rb +278 -0
- data/lib/active_merchant/billing/gateways/cyber_source.rb +576 -0
- data/lib/active_merchant/billing/gateways/data_cash.rb +597 -0
- data/lib/active_merchant/billing/gateways/efsnet.rb +235 -0
- data/lib/active_merchant/billing/gateways/elavon.rb +137 -0
- data/lib/active_merchant/billing/gateways/epay.rb +276 -0
- data/lib/active_merchant/billing/gateways/eway.rb +287 -0
- data/lib/active_merchant/billing/gateways/eway_managed.rb +265 -0
- data/lib/active_merchant/billing/gateways/exact.rb +227 -0
- data/lib/active_merchant/billing/gateways/fat_zebra.rb +152 -0
- data/lib/active_merchant/billing/gateways/federated_canada.rb +168 -0
- data/lib/active_merchant/billing/gateways/first_pay.rb +177 -0
- data/lib/active_merchant/billing/gateways/garanti.rb +262 -0
- data/lib/active_merchant/billing/gateways/ideal/ideal_base.rb +252 -0
- data/lib/active_merchant/billing/gateways/ideal/ideal_rabobank.pem +13 -0
- data/lib/active_merchant/billing/gateways/ideal/ideal_response.rb +29 -0
- data/lib/active_merchant/billing/gateways/ideal_rabobank.rb +55 -0
- data/lib/active_merchant/billing/gateways/inspire.rb +221 -0
- data/lib/active_merchant/billing/gateways/instapay.rb +164 -0
- data/lib/active_merchant/billing/gateways/iridium.rb +257 -0
- data/lib/active_merchant/billing/gateways/itransact.rb +450 -0
- data/lib/active_merchant/billing/gateways/jetpay.rb +276 -0
- data/lib/active_merchant/billing/gateways/linkpoint.rb +451 -0
- data/lib/active_merchant/billing/gateways/litle.rb +290 -0
- data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +157 -0
- data/lib/active_merchant/billing/gateways/merchant_ware.rb +289 -0
- data/lib/active_merchant/billing/gateways/metrics_global.rb +323 -0
- data/lib/active_merchant/billing/gateways/migs.rb +263 -0
- data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +100 -0
- data/lib/active_merchant/billing/gateways/modern_payments.rb +38 -0
- data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +220 -0
- data/lib/active_merchant/billing/gateways/moneris.rb +250 -0
- data/lib/active_merchant/billing/gateways/moneris_us.rb +211 -0
- data/lib/active_merchant/billing/gateways/nab_transact.rb +257 -0
- data/lib/active_merchant/billing/gateways/net_registry.rb +189 -0
- data/lib/active_merchant/billing/gateways/netaxept.rb +239 -0
- data/lib/active_merchant/billing/gateways/netbilling.rb +196 -0
- data/lib/active_merchant/billing/gateways/nmi.rb +13 -0
- data/lib/active_merchant/billing/gateways/ogone.rb +427 -0
- data/lib/active_merchant/billing/gateways/optimal_payment.rb +277 -0
- data/lib/active_merchant/billing/gateways/orbital.rb +351 -0
- data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +46 -0
- data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +266 -0
- data/lib/active_merchant/billing/gateways/pay_junction.rb +397 -0
- data/lib/active_merchant/billing/gateways/pay_secure.rb +120 -0
- data/lib/active_merchant/billing/gateways/paybox_direct.rb +201 -0
- data/lib/active_merchant/billing/gateways/payflow.rb +268 -0
- data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +212 -0
- data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +39 -0
- data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +13 -0
- data/lib/active_merchant/billing/gateways/payflow_express.rb +224 -0
- data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +15 -0
- data/lib/active_merchant/billing/gateways/payflow_uk.rb +21 -0
- data/lib/active_merchant/billing/gateways/payment_express.rb +282 -0
- data/lib/active_merchant/billing/gateways/paypal.rb +106 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +653 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +49 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb +245 -0
- data/lib/active_merchant/billing/gateways/paypal_ca.rb +13 -0
- data/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +43 -0
- data/lib/active_merchant/billing/gateways/paypal_express.rb +178 -0
- data/lib/active_merchant/billing/gateways/paypal_express_common.rb +30 -0
- data/lib/active_merchant/billing/gateways/paystation.rb +201 -0
- data/lib/active_merchant/billing/gateways/payway.rb +214 -0
- data/lib/active_merchant/billing/gateways/plugnpay.rb +295 -0
- data/lib/active_merchant/billing/gateways/psigate.rb +219 -0
- data/lib/active_merchant/billing/gateways/psl_card.rb +304 -0
- data/lib/active_merchant/billing/gateways/qbms.rb +297 -0
- data/lib/active_merchant/billing/gateways/quantum.rb +282 -0
- data/lib/active_merchant/billing/gateways/quickpay.rb +298 -0
- data/lib/active_merchant/billing/gateways/realex.rb +313 -0
- data/lib/active_merchant/billing/gateways/sage.rb +148 -0
- data/lib/active_merchant/billing/gateways/sage/sage_bankcard.rb +88 -0
- data/lib/active_merchant/billing/gateways/sage/sage_core.rb +115 -0
- data/lib/active_merchant/billing/gateways/sage/sage_virtual_check.rb +97 -0
- data/lib/active_merchant/billing/gateways/sage_pay.rb +322 -0
- data/lib/active_merchant/billing/gateways/sallie_mae.rb +144 -0
- data/lib/active_merchant/billing/gateways/samurai.rb +121 -0
- data/lib/active_merchant/billing/gateways/secure_net.rb +330 -0
- data/lib/active_merchant/billing/gateways/secure_pay.rb +31 -0
- data/lib/active_merchant/billing/gateways/secure_pay_au.rb +284 -0
- data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +113 -0
- data/lib/active_merchant/billing/gateways/skip_jack.rb +458 -0
- data/lib/active_merchant/billing/gateways/smart_ps.rb +273 -0
- data/lib/active_merchant/billing/gateways/stripe.rb +236 -0
- data/lib/active_merchant/billing/gateways/trans_first.rb +127 -0
- data/lib/active_merchant/billing/gateways/transax.rb +23 -0
- data/lib/active_merchant/billing/gateways/trust_commerce.rb +423 -0
- data/lib/active_merchant/billing/gateways/usa_epay.rb +25 -0
- data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +1497 -0
- data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +206 -0
- data/lib/active_merchant/billing/gateways/verifi.rb +233 -0
- data/lib/active_merchant/billing/gateways/viaklix.rb +194 -0
- data/lib/active_merchant/billing/gateways/vindicia.rb +359 -0
- data/lib/active_merchant/billing/gateways/wirecard.rb +313 -0
- data/lib/active_merchant/billing/gateways/worldpay.rb +271 -0
- data/lib/active_merchant/billing/integrations.rb +17 -0
- data/lib/active_merchant/billing/integrations/action_view_helper.rb +73 -0
- data/lib/active_merchant/billing/integrations/authorize_net_sim.rb +38 -0
- data/lib/active_merchant/billing/integrations/authorize_net_sim/helper.rb +228 -0
- data/lib/active_merchant/billing/integrations/authorize_net_sim/notification.rb +340 -0
- data/lib/active_merchant/billing/integrations/bogus.rb +23 -0
- data/lib/active_merchant/billing/integrations/bogus/helper.rb +17 -0
- data/lib/active_merchant/billing/integrations/bogus/notification.rb +11 -0
- data/lib/active_merchant/billing/integrations/bogus/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/chronopay.rb +23 -0
- data/lib/active_merchant/billing/integrations/chronopay/helper.rb +120 -0
- data/lib/active_merchant/billing/integrations/chronopay/notification.rb +158 -0
- data/lib/active_merchant/billing/integrations/chronopay/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/direc_pay.rb +41 -0
- data/lib/active_merchant/billing/integrations/direc_pay/helper.rb +200 -0
- data/lib/active_merchant/billing/integrations/direc_pay/notification.rb +76 -0
- data/lib/active_merchant/billing/integrations/direc_pay/return.rb +32 -0
- data/lib/active_merchant/billing/integrations/direc_pay/status.rb +37 -0
- data/lib/active_merchant/billing/integrations/directebanking.rb +47 -0
- data/lib/active_merchant/billing/integrations/directebanking/helper.rb +90 -0
- data/lib/active_merchant/billing/integrations/directebanking/notification.rb +120 -0
- data/lib/active_merchant/billing/integrations/directebanking/return.rb +11 -0
- data/lib/active_merchant/billing/integrations/dotpay.rb +22 -0
- data/lib/active_merchant/billing/integrations/dotpay/helper.rb +77 -0
- data/lib/active_merchant/billing/integrations/dotpay/notification.rb +86 -0
- data/lib/active_merchant/billing/integrations/dotpay/return.rb +11 -0
- data/lib/active_merchant/billing/integrations/dwolla.rb +30 -0
- data/lib/active_merchant/billing/integrations/dwolla/helper.rb +31 -0
- data/lib/active_merchant/billing/integrations/dwolla/notification.rb +55 -0
- data/lib/active_merchant/billing/integrations/dwolla/return.rb +38 -0
- data/lib/active_merchant/billing/integrations/e_payment_plans.rb +48 -0
- data/lib/active_merchant/billing/integrations/e_payment_plans/helper.rb +34 -0
- data/lib/active_merchant/billing/integrations/e_payment_plans/notification.rb +84 -0
- data/lib/active_merchant/billing/integrations/easy_pay.rb +30 -0
- data/lib/active_merchant/billing/integrations/easy_pay/common.rb +40 -0
- data/lib/active_merchant/billing/integrations/easy_pay/helper.rb +40 -0
- data/lib/active_merchant/billing/integrations/easy_pay/notification.rb +51 -0
- data/lib/active_merchant/billing/integrations/epay.rb +21 -0
- data/lib/active_merchant/billing/integrations/epay/helper.rb +55 -0
- data/lib/active_merchant/billing/integrations/epay/notification.rb +110 -0
- data/lib/active_merchant/billing/integrations/first_data.rb +38 -0
- data/lib/active_merchant/billing/integrations/first_data/helper.rb +63 -0
- data/lib/active_merchant/billing/integrations/first_data/notification.rb +56 -0
- data/lib/active_merchant/billing/integrations/gestpay.rb +25 -0
- data/lib/active_merchant/billing/integrations/gestpay/common.rb +42 -0
- data/lib/active_merchant/billing/integrations/gestpay/helper.rb +70 -0
- data/lib/active_merchant/billing/integrations/gestpay/notification.rb +85 -0
- data/lib/active_merchant/billing/integrations/gestpay/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/helper.rb +117 -0
- data/lib/active_merchant/billing/integrations/hi_trust.rb +27 -0
- data/lib/active_merchant/billing/integrations/hi_trust/helper.rb +58 -0
- data/lib/active_merchant/billing/integrations/hi_trust/notification.rb +59 -0
- data/lib/active_merchant/billing/integrations/hi_trust/return.rb +67 -0
- data/lib/active_merchant/billing/integrations/maksuturva.rb +86 -0
- data/lib/active_merchant/billing/integrations/maksuturva/helper.rb +119 -0
- data/lib/active_merchant/billing/integrations/maksuturva/notification.rb +48 -0
- data/lib/active_merchant/billing/integrations/moneybookers.rb +26 -0
- data/lib/active_merchant/billing/integrations/moneybookers/helper.rb +59 -0
- data/lib/active_merchant/billing/integrations/moneybookers/notification.rb +129 -0
- data/lib/active_merchant/billing/integrations/nelnet.rb +40 -0
- data/lib/active_merchant/billing/integrations/nelnet/helper.rb +34 -0
- data/lib/active_merchant/billing/integrations/nelnet/notification.rb +100 -0
- data/lib/active_merchant/billing/integrations/nochex.rb +88 -0
- data/lib/active_merchant/billing/integrations/nochex/helper.rb +68 -0
- data/lib/active_merchant/billing/integrations/nochex/notification.rb +94 -0
- data/lib/active_merchant/billing/integrations/nochex/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/notification.rb +62 -0
- data/lib/active_merchant/billing/integrations/paxum.rb +44 -0
- data/lib/active_merchant/billing/integrations/paxum/common.rb +24 -0
- data/lib/active_merchant/billing/integrations/paxum/helper.rb +42 -0
- data/lib/active_merchant/billing/integrations/paxum/notification.rb +33 -0
- data/lib/active_merchant/billing/integrations/payflow_link.rb +21 -0
- data/lib/active_merchant/billing/integrations/payflow_link/helper.rb +100 -0
- data/lib/active_merchant/billing/integrations/payflow_link/notification.rb +78 -0
- data/lib/active_merchant/billing/integrations/paypal.rb +39 -0
- data/lib/active_merchant/billing/integrations/paypal/helper.rb +119 -0
- data/lib/active_merchant/billing/integrations/paypal/notification.rb +155 -0
- data/lib/active_merchant/billing/integrations/paypal/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/paypal_payments_advanced.rb +20 -0
- data/lib/active_merchant/billing/integrations/paypal_payments_advanced/helper.rb +15 -0
- data/lib/active_merchant/billing/integrations/pxpay.rb +31 -0
- data/lib/active_merchant/billing/integrations/pxpay/helper.rb +110 -0
- data/lib/active_merchant/billing/integrations/pxpay/notification.rb +157 -0
- data/lib/active_merchant/billing/integrations/pxpay/return.rb +25 -0
- data/lib/active_merchant/billing/integrations/quickpay.rb +21 -0
- data/lib/active_merchant/billing/integrations/quickpay/helper.rb +71 -0
- data/lib/active_merchant/billing/integrations/quickpay/notification.rb +74 -0
- data/lib/active_merchant/billing/integrations/return.rb +42 -0
- data/lib/active_merchant/billing/integrations/robokassa.rb +49 -0
- data/lib/active_merchant/billing/integrations/robokassa/common.rb +19 -0
- data/lib/active_merchant/billing/integrations/robokassa/helper.rb +50 -0
- data/lib/active_merchant/billing/integrations/robokassa/notification.rb +55 -0
- data/lib/active_merchant/billing/integrations/robokassa/return.rb +17 -0
- data/lib/active_merchant/billing/integrations/sage_pay_form.rb +37 -0
- data/lib/active_merchant/billing/integrations/sage_pay_form/encryption.rb +33 -0
- data/lib/active_merchant/billing/integrations/sage_pay_form/helper.rb +129 -0
- data/lib/active_merchant/billing/integrations/sage_pay_form/notification.rb +210 -0
- data/lib/active_merchant/billing/integrations/sage_pay_form/return.rb +31 -0
- data/lib/active_merchant/billing/integrations/two_checkout.rb +44 -0
- data/lib/active_merchant/billing/integrations/two_checkout/helper.rb +91 -0
- data/lib/active_merchant/billing/integrations/two_checkout/notification.rb +139 -0
- data/lib/active_merchant/billing/integrations/two_checkout/return.rb +17 -0
- data/lib/active_merchant/billing/integrations/valitor.rb +33 -0
- data/lib/active_merchant/billing/integrations/valitor/helper.rb +86 -0
- data/lib/active_merchant/billing/integrations/valitor/notification.rb +13 -0
- data/lib/active_merchant/billing/integrations/valitor/response_fields.rb +97 -0
- data/lib/active_merchant/billing/integrations/valitor/return.rb +13 -0
- data/lib/active_merchant/billing/integrations/verkkomaksut.rb +20 -0
- data/lib/active_merchant/billing/integrations/verkkomaksut/helper.rb +87 -0
- data/lib/active_merchant/billing/integrations/verkkomaksut/notification.rb +59 -0
- data/lib/active_merchant/billing/integrations/web_pay.rb +45 -0
- data/lib/active_merchant/billing/integrations/web_pay/common.rb +50 -0
- data/lib/active_merchant/billing/integrations/web_pay/helper.rb +68 -0
- data/lib/active_merchant/billing/integrations/web_pay/notification.rb +51 -0
- data/lib/active_merchant/billing/integrations/world_pay.rb +27 -0
- data/lib/active_merchant/billing/integrations/world_pay/helper.rb +100 -0
- data/lib/active_merchant/billing/integrations/world_pay/notification.rb +160 -0
- data/lib/active_merchant/billing/response.rb +64 -0
- data/lib/active_merchant/version.rb +3 -0
- data/lib/activemerchant.rb +1 -0
- data/lib/support/gateway_support.rb +65 -0
- data/lib/support/outbound_hosts.rb +25 -0
- data/lib/support/ssl_verify.rb +93 -0
- metadata +482 -0
@@ -0,0 +1,155 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
|
3
|
+
module ActiveMerchant #:nodoc:
|
4
|
+
module Billing #:nodoc:
|
5
|
+
module Integrations #:nodoc:
|
6
|
+
module Paypal
|
7
|
+
# Parser and handler for incoming Instant payment notifications from paypal.
|
8
|
+
# The Example shows a typical handler in a rails application. Note that this
|
9
|
+
# is an example, please read the Paypal API documentation for all the details
|
10
|
+
# on creating a safe payment controller.
|
11
|
+
#
|
12
|
+
# Example
|
13
|
+
#
|
14
|
+
# class BackendController < ApplicationController
|
15
|
+
# include ActiveMerchant::Billing::Integrations
|
16
|
+
#
|
17
|
+
# def paypal_ipn
|
18
|
+
# notify = Paypal::Notification.new(request.raw_post)
|
19
|
+
#
|
20
|
+
# order = Order.find(notify.item_id)
|
21
|
+
#
|
22
|
+
# if notify.acknowledge
|
23
|
+
# begin
|
24
|
+
#
|
25
|
+
# if notify.complete? and order.total == notify.amount
|
26
|
+
# order.status = 'success'
|
27
|
+
#
|
28
|
+
# shop.ship(order)
|
29
|
+
# else
|
30
|
+
# logger.error("Failed to verify Paypal's notification, please investigate")
|
31
|
+
# end
|
32
|
+
#
|
33
|
+
# rescue => e
|
34
|
+
# order.status = 'failed'
|
35
|
+
# raise
|
36
|
+
# ensure
|
37
|
+
# order.save
|
38
|
+
# end
|
39
|
+
# end
|
40
|
+
#
|
41
|
+
# render :nothing
|
42
|
+
# end
|
43
|
+
# end
|
44
|
+
class Notification < ActiveMerchant::Billing::Integrations::Notification
|
45
|
+
include PostsData
|
46
|
+
|
47
|
+
# Was the transaction complete?
|
48
|
+
def complete?
|
49
|
+
status == "Completed"
|
50
|
+
end
|
51
|
+
|
52
|
+
# When was this payment received by the client.
|
53
|
+
# sometimes it can happen that we get the notification much later.
|
54
|
+
# One possible scenario is that our web application was down. In this case paypal tries several
|
55
|
+
# times an hour to inform us about the notification
|
56
|
+
def received_at
|
57
|
+
parsed_time_fields = DateTime._strptime(params['payment_date'], "%H:%M:%S %b %d, %Y %z")
|
58
|
+
Time.mktime(*parsed_time_fields.values_at(:year, :mon, :mday, :hour, :min, :sec, :zone))
|
59
|
+
end
|
60
|
+
|
61
|
+
# Status of transaction. List of possible values:
|
62
|
+
# <tt>Canceled-Reversal</tt>::
|
63
|
+
# <tt>Completed</tt>::
|
64
|
+
# <tt>Denied</tt>::
|
65
|
+
# <tt>Expired</tt>::
|
66
|
+
# <tt>Failed</tt>::
|
67
|
+
# <tt>In-Progress</tt>::
|
68
|
+
# <tt>Partially-Refunded</tt>::
|
69
|
+
# <tt>Pending</tt>::
|
70
|
+
# <tt>Processed</tt>::
|
71
|
+
# <tt>Refunded</tt>::
|
72
|
+
# <tt>Reversed</tt>::
|
73
|
+
# <tt>Voided</tt>::
|
74
|
+
def status
|
75
|
+
params['payment_status']
|
76
|
+
end
|
77
|
+
|
78
|
+
# Id of this transaction (paypal number)
|
79
|
+
def transaction_id
|
80
|
+
params['txn_id']
|
81
|
+
end
|
82
|
+
|
83
|
+
# What type of transaction are we dealing with?
|
84
|
+
# "cart" "send_money" "web_accept" are possible here.
|
85
|
+
def type
|
86
|
+
params['txn_type']
|
87
|
+
end
|
88
|
+
|
89
|
+
# the money amount we received in X.2 decimal.
|
90
|
+
def gross
|
91
|
+
params['mc_gross']
|
92
|
+
end
|
93
|
+
|
94
|
+
# the markup paypal charges for the transaction
|
95
|
+
def fee
|
96
|
+
params['mc_fee']
|
97
|
+
end
|
98
|
+
|
99
|
+
# What currency have we been dealing with
|
100
|
+
def currency
|
101
|
+
params['mc_currency']
|
102
|
+
end
|
103
|
+
|
104
|
+
# This is the item number which we submitted to paypal
|
105
|
+
# The custom field is also mapped to item_id because PayPal
|
106
|
+
# doesn't return item_number in dispute notifications
|
107
|
+
def item_id
|
108
|
+
params['item_number'] || params['custom']
|
109
|
+
end
|
110
|
+
|
111
|
+
# This is the invoice which you passed to paypal
|
112
|
+
def invoice
|
113
|
+
params['invoice']
|
114
|
+
end
|
115
|
+
|
116
|
+
# Was this a test transaction?
|
117
|
+
def test?
|
118
|
+
params['test_ipn'] == '1'
|
119
|
+
end
|
120
|
+
|
121
|
+
def account
|
122
|
+
params['business'] || params['receiver_email']
|
123
|
+
end
|
124
|
+
|
125
|
+
# Acknowledge the transaction to paypal. This method has to be called after a new
|
126
|
+
# ipn arrives. Paypal will verify that all the information we received are correct and will return a
|
127
|
+
# ok or a fail.
|
128
|
+
#
|
129
|
+
# Example:
|
130
|
+
#
|
131
|
+
# def paypal_ipn
|
132
|
+
# notify = PaypalNotification.new(request.raw_post)
|
133
|
+
#
|
134
|
+
# if notify.acknowledge
|
135
|
+
# ... process order ... if notify.complete?
|
136
|
+
# else
|
137
|
+
# ... log possible hacking attempt ...
|
138
|
+
# end
|
139
|
+
def acknowledge
|
140
|
+
payload = raw
|
141
|
+
|
142
|
+
response = ssl_post(Paypal.service_url + '?cmd=_notify-validate', payload,
|
143
|
+
'Content-Length' => "#{payload.size}",
|
144
|
+
'User-Agent' => "Active Merchant -- http://activemerchant.org"
|
145
|
+
)
|
146
|
+
|
147
|
+
raise StandardError.new("Faulty paypal result: #{response}") unless ["VERIFIED", "INVALID"].include?(response)
|
148
|
+
|
149
|
+
response == "VERIFIED"
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module ActiveMerchant
|
2
|
+
module Billing
|
3
|
+
module Integrations
|
4
|
+
module PaypalPaymentsAdvanced
|
5
|
+
autoload :Helper, 'active_merchant/billing/integrations/paypal_payments_advanced/helper.rb'
|
6
|
+
|
7
|
+
mattr_accessor :service_url
|
8
|
+
self.service_url = 'https://payflowlink.paypal.com'
|
9
|
+
|
10
|
+
def self.notification(post, options = {})
|
11
|
+
PayflowLink::Notification.new(post)
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.return(query_string, options = {})
|
15
|
+
Return.new(query_string)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module ActiveMerchant
|
2
|
+
module Billing
|
3
|
+
module Integrations
|
4
|
+
module PaypalPaymentsAdvanced
|
5
|
+
class Helper < PayflowLink::Helper
|
6
|
+
|
7
|
+
def initialize(order, account, options)
|
8
|
+
super
|
9
|
+
add_field('partner', 'PayPal')
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
module Integrations #:nodoc:
|
4
|
+
module Pxpay
|
5
|
+
autoload :Helper, 'active_merchant/billing/integrations/pxpay/helper.rb'
|
6
|
+
autoload :Notification, 'active_merchant/billing/integrations/pxpay/notification.rb'
|
7
|
+
autoload :Return, 'active_merchant/billing/integrations/pxpay/return.rb'
|
8
|
+
|
9
|
+
TOKEN_URL = 'https://sec.paymentexpress.com/pxpay/pxaccess.aspx'
|
10
|
+
|
11
|
+
LIVE_URL = 'https://sec.paymentexpress.com/pxpay/pxpay.aspx'
|
12
|
+
|
13
|
+
def self.token_url
|
14
|
+
TOKEN_URL
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.service_url
|
18
|
+
LIVE_URL
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.notification(post, options={})
|
22
|
+
Notification.new(post, options)
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.return(query_string, options={})
|
26
|
+
Return.new(query_string, options)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,110 @@
|
|
1
|
+
require 'active_support/core_ext/float/rounding.rb' # Float#round(precision)
|
2
|
+
|
3
|
+
module ActiveMerchant #:nodoc:
|
4
|
+
module Billing #:nodoc:
|
5
|
+
module Integrations #:nodoc:
|
6
|
+
module Pxpay
|
7
|
+
# An example. Note the username as a parameter and transaction key you
|
8
|
+
# will want to use later. The amount that you pass in will be *rounded*,
|
9
|
+
# so preferably pass in X.2 decimal so that no rounding occurs. You need
|
10
|
+
# to set :credential2 to your PxPay secret key.
|
11
|
+
#
|
12
|
+
# PxPay accounts have Failproof Notification enabled by default which means
|
13
|
+
# in addition to the user being redirected to your return_url, the return_url will
|
14
|
+
# be accessed by the PxPay servers directly, immediately after transaction success.
|
15
|
+
#
|
16
|
+
# payment_service_for('order_id', 'pxpay_user_ID', :service => :pxpay,
|
17
|
+
# :amount => 157.0, :currency => 'USD', :credential2 => 'pxpay_key') do |service|
|
18
|
+
#
|
19
|
+
# service.customer :email => 'customer@email.com'
|
20
|
+
#
|
21
|
+
# service.description 'Order 123 for MyStore'
|
22
|
+
#
|
23
|
+
# # Must specify both a return_url or PxPay will show an error instead of
|
24
|
+
# # capturing credit card details.
|
25
|
+
#
|
26
|
+
# service.return_url "http://t/pxpay/payment_received_notification_sub_step"
|
27
|
+
#
|
28
|
+
# # These fields will be copied verbatim to the Notification
|
29
|
+
# service.custom1 'custom text 1'
|
30
|
+
# service.custom2 ''
|
31
|
+
# service.custom3 ''
|
32
|
+
# # See the helper.rb file for various custom fields
|
33
|
+
# end
|
34
|
+
|
35
|
+
class Helper < ActiveMerchant::Billing::Integrations::Helper
|
36
|
+
include PostsData
|
37
|
+
mapping :account, 'PxPayUserId'
|
38
|
+
mapping :credential2, 'PxPayKey'
|
39
|
+
mapping :currency, 'CurrencyInput'
|
40
|
+
mapping :description, 'MerchantReference'
|
41
|
+
mapping :order, 'TxnId'
|
42
|
+
mapping :customer, :email => 'EmailAddress'
|
43
|
+
|
44
|
+
mapping :custom1, 'TxnData1'
|
45
|
+
mapping :custom2, 'TxnData2'
|
46
|
+
mapping :custom3, 'TxnData3'
|
47
|
+
|
48
|
+
def initialize(order, account, options = {})
|
49
|
+
super
|
50
|
+
add_field 'AmountInput', "%.2f" % options[:amount].to_f.round(2)
|
51
|
+
add_field 'EnableAddBillCard', '0'
|
52
|
+
add_field 'TxnType', 'Purchase'
|
53
|
+
end
|
54
|
+
|
55
|
+
def return_url(url)
|
56
|
+
add_field 'UrlSuccess', url
|
57
|
+
add_field 'UrlFail', url
|
58
|
+
end
|
59
|
+
|
60
|
+
def form_fields
|
61
|
+
# if either return URLs are blank PxPay will generate a token but redirect user to error page.
|
62
|
+
raise "error - must specify return_url" if @fields['UrlSuccess'].blank?
|
63
|
+
raise "error - must specify cancel_return_url" if @fields['UrlFail'].blank?
|
64
|
+
|
65
|
+
result = request_secure_redirect
|
66
|
+
raise "error - failed to get token - message was #{result[:redirect]}" unless result[:valid] == "1"
|
67
|
+
|
68
|
+
url = URI.parse(result[:redirect])
|
69
|
+
|
70
|
+
CGI.parse(url.query)
|
71
|
+
end
|
72
|
+
|
73
|
+
def form_method
|
74
|
+
"GET"
|
75
|
+
end
|
76
|
+
|
77
|
+
private
|
78
|
+
def generate_request
|
79
|
+
xml = REXML::Document.new
|
80
|
+
root = xml.add_element('GenerateRequest')
|
81
|
+
|
82
|
+
@fields.each do | k, v |
|
83
|
+
root.add_element(k).text = v
|
84
|
+
end
|
85
|
+
|
86
|
+
xml.to_s
|
87
|
+
end
|
88
|
+
|
89
|
+
def request_secure_redirect
|
90
|
+
request = generate_request
|
91
|
+
|
92
|
+
response = ssl_post(Pxpay.token_url, request)
|
93
|
+
xml = REXML::Document.new(response)
|
94
|
+
root = REXML::XPath.first(xml, "//Request")
|
95
|
+
valid = root.attributes["valid"]
|
96
|
+
redirect = root.elements["URI"].text
|
97
|
+
|
98
|
+
# example positive response:
|
99
|
+
# <Request valid="1"><URI>https://sec.paymentexpress.com/pxpay/pxpay.aspx?userid=PxpayUser&request=REQUEST_TOKEN</URI></Request>
|
100
|
+
|
101
|
+
# example negative response:
|
102
|
+
# <Request valid="0"><URI>Invalid TxnType</URI></Request>
|
103
|
+
|
104
|
+
{:valid => valid, :redirect => redirect}
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
@@ -0,0 +1,157 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
module Integrations #:nodoc:
|
4
|
+
|
5
|
+
module Pxpay
|
6
|
+
class Notification < ActiveMerchant::Billing::Integrations::Notification
|
7
|
+
include PostsData
|
8
|
+
include RequiresParameters
|
9
|
+
|
10
|
+
def initialize(query_string, options={})
|
11
|
+
# PxPay appends ?result=...&userid=... to whatever return_url was specified, even if that URL ended with a ?query.
|
12
|
+
# So switch the first ? if present to a &
|
13
|
+
query_string[/\?/] = '&' if query_string[/\?/]
|
14
|
+
super
|
15
|
+
|
16
|
+
@encrypted_params = @params
|
17
|
+
@params = {}
|
18
|
+
|
19
|
+
requires! @encrypted_params, "result"
|
20
|
+
requires! @options, :credential1, :credential2
|
21
|
+
|
22
|
+
decrypt_transaction_result(@encrypted_params["result"])
|
23
|
+
end
|
24
|
+
|
25
|
+
# was the notification a validly formed request?
|
26
|
+
def acknowledge
|
27
|
+
@valid == '1'
|
28
|
+
end
|
29
|
+
|
30
|
+
def status
|
31
|
+
return 'Failed' unless success?
|
32
|
+
return 'Completed' if complete?
|
33
|
+
'Error'
|
34
|
+
end
|
35
|
+
|
36
|
+
def complete?
|
37
|
+
@params['TxnType'] == 'Purchase' && success?
|
38
|
+
end
|
39
|
+
|
40
|
+
def cancelled?
|
41
|
+
!success?
|
42
|
+
end
|
43
|
+
|
44
|
+
# for field definitions see
|
45
|
+
# http://www.paymentexpress.com/Technical_Resources/Ecommerce_Hosted/PxPay
|
46
|
+
|
47
|
+
def success?
|
48
|
+
@params['Success'] == '1'
|
49
|
+
end
|
50
|
+
|
51
|
+
def gross
|
52
|
+
@params['AmountSettlement']
|
53
|
+
end
|
54
|
+
|
55
|
+
def currency
|
56
|
+
@params['CurrencySettlement']
|
57
|
+
end
|
58
|
+
|
59
|
+
def account
|
60
|
+
@params['userid']
|
61
|
+
end
|
62
|
+
|
63
|
+
def item_id
|
64
|
+
@params['TxnId']
|
65
|
+
end
|
66
|
+
|
67
|
+
def currency_input
|
68
|
+
@params['CurrencyInput']
|
69
|
+
end
|
70
|
+
|
71
|
+
def auth_code
|
72
|
+
@params['AuthCode']
|
73
|
+
end
|
74
|
+
|
75
|
+
def card_type
|
76
|
+
@params['CardName']
|
77
|
+
end
|
78
|
+
|
79
|
+
def card_holder_name
|
80
|
+
@params['CardHolderName']
|
81
|
+
end
|
82
|
+
|
83
|
+
def card_number
|
84
|
+
@params['CardNumber']
|
85
|
+
end
|
86
|
+
|
87
|
+
def expiry_date
|
88
|
+
@params['DateExpiry']
|
89
|
+
end
|
90
|
+
|
91
|
+
def client_ip
|
92
|
+
@params['ClientInfo']
|
93
|
+
end
|
94
|
+
|
95
|
+
def order_id
|
96
|
+
item_id
|
97
|
+
end
|
98
|
+
|
99
|
+
def payer_email
|
100
|
+
@params['EmailAddress']
|
101
|
+
end
|
102
|
+
|
103
|
+
def transaction_id
|
104
|
+
@params['DpsTxnRef']
|
105
|
+
end
|
106
|
+
|
107
|
+
def settlement_date
|
108
|
+
@params['DateSettlement']
|
109
|
+
end
|
110
|
+
|
111
|
+
# Indication of the uniqueness of a card number
|
112
|
+
def txn_mac
|
113
|
+
@params['TxnMac']
|
114
|
+
end
|
115
|
+
|
116
|
+
def message
|
117
|
+
@params['ResponseText']
|
118
|
+
end
|
119
|
+
|
120
|
+
def optional_data
|
121
|
+
[@params['TxnData1'],@fields['TxnData2'],@fields['TxnData3']]
|
122
|
+
end
|
123
|
+
|
124
|
+
# When was this payment was received by the client.
|
125
|
+
def received_at
|
126
|
+
settlement_date
|
127
|
+
end
|
128
|
+
|
129
|
+
# Was this a test transaction?
|
130
|
+
def test?
|
131
|
+
nil
|
132
|
+
end
|
133
|
+
|
134
|
+
private
|
135
|
+
|
136
|
+
def decrypt_transaction_result(encrypted_result)
|
137
|
+
request_xml = REXML::Document.new
|
138
|
+
root = request_xml.add_element('ProcessResponse')
|
139
|
+
|
140
|
+
root.add_element('PxPayUserId').text = @options[:credential1]
|
141
|
+
root.add_element('PxPayKey').text = @options[:credential2]
|
142
|
+
root.add_element('Response').text = encrypted_result
|
143
|
+
|
144
|
+
@raw = ssl_post(Pxpay.token_url, request_xml.to_s)
|
145
|
+
|
146
|
+
response_xml = REXML::Document.new(@raw)
|
147
|
+
root = REXML::XPath.first(response_xml)
|
148
|
+
@valid = root.attributes["valid"]
|
149
|
+
@params = {}
|
150
|
+
root.elements.each { |e| @params[e.name] = e.text }
|
151
|
+
end
|
152
|
+
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|