Class: Adyen::API::PaymentService

Inherits:
SimpleSOAPClient show all
Extended by:
TestHelpers
Defined in:
lib/adyen/api/payment_service.rb,
lib/adyen/api/test_helpers.rb,
lib/adyen/api/templates/payment_service.rb

Overview

This is the class that maps actions to Adyen’s Payment SOAP service.

It’s encouraged to use the shortcut methods on the Adyen::API module, which abstracts away the difference between this service and the RecurringService. Henceforth, for extensive documentation you should look at the Adyen::API documentation.

The most important difference is that you instantiate a PaymentService with the parameters that are needed for the call that you will eventually make.

Examples:

payment = Adyen::API::PaymentService.new({
  :reference => invoice.id,
  :amount => {
    :currency => 'EUR',
    :value => invoice.amount,
  },
  :shopper => {
    :email => user.email,
    :reference => user.id,
    :ip => request.ip,
    :statement => 'Invoice number 123456'
  },
  :card => {
    :expiry_month => 12,
    :expiry_year => 2012,
    :holder_name => 'Simon Hopper',
    :number => '4444333322221111',
    :cvc => '737'
  }
})
response = payment.authorise_payment
response.authorised? # => true

Defined Under Namespace

Modules: TestHelpers Classes: AuthorisationResponse, BilletResponse, CancelOrRefundResponse, CancelResponse, CaptureResponse, ModificationResponse, RefundResponse

Constant Summary

ENDPOINT_URI =

The Adyen Payment SOAP service endpoint uri.

'https://pal-%s.adyen.com/pal/servlet/soap/Payment'
CAPTURE_LAYOUT =
modification_request_with_amount(:capture)
REFUND_LAYOUT =
modification_request_with_amount(:refund)
CANCEL_LAYOUT =
modification_request(:cancel)
CANCEL_OR_REFUND_LAYOUT =
modification_request(:cancelOrRefund)
LAYOUT =
"<payment:authorise xmlns:payment=\"http://payment.services.adyen.com\" xmlns:recurring=\"http://recurring.services.adyen.com\" xmlns:common=\"http://common.services.adyen.com\">\n<payment:paymentRequest>\n<payment:merchantAccount>%s</payment:merchantAccount>\n<payment:reference>%s</payment:reference>\n%s\n</payment:paymentRequest>\n</payment:authorise>\n"
AMOUNT_PARTIAL =
"<payment:amount>\n<common:currency>%s</common:currency>\n<common:value>%s</common:value>\n</payment:amount>\n"
CARD_PARTIAL =
"<payment:card>\n<payment:holderName>%s</payment:holderName>\n<payment:number>%s</payment:number>\n<payment:expiryYear>%s</payment:expiryYear>\n<payment:expiryMonth>%02d</payment:expiryMonth>\n%s\n</payment:card>\n"
CARD_CVC_PARTIAL =
"<payment:cvc>%s</payment:cvc>\n"
ONE_CLICK_CARD_PARTIAL =
"<payment:card>\n<payment:cvc>%s</payment:cvc>\n</payment:card>\n"
INSTALLMENTS_PARTIAL =
"<payment:installments>\n<common:value>%s</common:value>\n</payment:installments>\n"
SOCIAL_SECURITY_NUMBER_PARTIAL =
"<payment:socialSecurityNumber>%s</payment:socialSecurityNumber>\n"
DELIVERY_DATE_PARTIAL =
"<deliveryDate xmlns=\"http://payment.services.adyen.com\">%s</deliveryDate>\n"
SELECTED_BRAND_PARTIAL =
"<payment:selectedBrand>%s</payment:selectedBrand>\n"
SHOPPER_NAME_PARTIAL =
"<payment:shopperName>\n<common:firstName>%s</common:firstName>\n<common:lastName>%s</common:lastName>\n</payment:shopperName>\n"
ENCRYPTED_CARD_PARTIAL =
"<additionalAmount xmlns=\"http://payment.services.adyen.com\" xsi:nil=\"true\" />\n<additionalData xmlns=\"http://payment.services.adyen.com\">\n<entry>\n<key xsi:type=\"xsd:string\">card.encrypted.json</key>\n<value xsi:type=\"xsd:string\">%s</value>\n</entry>\n</additionalData>\n"
ENABLE_RECURRING_CONTRACTS_PARTIAL =
"<payment:recurring>\n<payment:contract>RECURRING,ONECLICK</payment:contract>\n</payment:recurring>\n"
RECURRING_PAYMENT_BODY_PARTIAL =
"<payment:recurring>\n<payment:contract>RECURRING</payment:contract>\n</payment:recurring>\n<payment:selectedRecurringDetailReference>%s</payment:selectedRecurringDetailReference>\n<payment:shopperInteraction>ContAuth</payment:shopperInteraction>\n"
ONE_CLICK_PAYMENT_BODY_PARTIAL =
"<payment:recurring>\n<payment:contract>ONECLICK</payment:contract>\n</payment:recurring>\n<payment:selectedRecurringDetailReference>%s</payment:selectedRecurringDetailReference>\n"
SHOPPER_PARTIALS =
{
  :reference => '        <payment:shopperReference>%s</payment:shopperReference>',
  :email     => '        <payment:shopperEmail>%s</payment:shopperEmail>',
  :ip        => '        <payment:shopperIP>%s</payment:shopperIP>',
  :statement => '        <payment:shopperStatement>%s</payment:shopperStatement>',
}
FRAUD_OFFSET_PARTIAL =
'<payment:fraudOffset>%s</payment:fraudOffset>'
CAPTURE_DELAY_PARTIAL =
'<payment:captureDelayHours>%s</payment:captureDelayHours>'

Constants included from TestHelpers

TestHelpers::AUTHORISATION_REFUSED_RESPONSE, TestHelpers::AUTHORISATION_REQUEST_INVALID_RESPONSE, TestHelpers::AUTHORISE_RESPONSE

Constants inherited from SimpleSOAPClient

SimpleSOAPClient::CACERT, SimpleSOAPClient::ENVELOPE

Instance Attribute Summary

Attributes inherited from SimpleSOAPClient

#params

Instance Method Summary collapse

Methods included from TestHelpers

invalid_stub, refused_stub, stub_invalid!, stub_refused!, stub_success!, success_stub

Methods inherited from SimpleSOAPClient

#call_webservice_action, endpoint, #initialize, #validate_parameter_value!, #validate_parameters!

Constructor Details

This class inherits a constructor from Adyen::API::SimpleSOAPClient

Instance Method Details

#authorise_one_click_paymentObject



59
60
61
# File 'lib/adyen/api/payment_service.rb', line 59

def authorise_one_click_payment
  make_payment_request(authorise_one_click_payment_request_body, AuthorisationResponse)
end

#authorise_paymentObject



49
50
51
# File 'lib/adyen/api/payment_service.rb', line 49

def authorise_payment
  make_payment_request(authorise_payment_request_body, AuthorisationResponse)
end

#authorise_recurring_paymentObject



54
55
56
# File 'lib/adyen/api/payment_service.rb', line 54

def authorise_recurring_payment
  make_payment_request(authorise_recurring_payment_request_body, AuthorisationResponse)
end

#cancelObject



74
75
76
# File 'lib/adyen/api/payment_service.rb', line 74

def cancel
  make_payment_request(cancel_request_body, CancelResponse)
end

#cancel_or_refundObject



79
80
81
# File 'lib/adyen/api/payment_service.rb', line 79

def cancel_or_refund
  make_payment_request(cancel_or_refund_request_body, CancelOrRefundResponse)
end

#captureObject



64
65
66
# File 'lib/adyen/api/payment_service.rb', line 64

def capture
  make_payment_request(capture_request_body, CaptureResponse)
end

#generate_billetObject



44
45
46
# File 'lib/adyen/api/payment_service.rb', line 44

def generate_billet
  make_payment_request(generate_billet_request_body, BilletResponse)
end

#refundObject



69
70
71
# File 'lib/adyen/api/payment_service.rb', line 69

def refund
  make_payment_request(refund_request_body, RefundResponse)
end