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 =
<<-EOXML
  <payment:authorise xmlns:payment="http://payment.services.adyen.com" xmlns:recurring="http://recurring.services.adyen.com" xmlns:common="http://common.services.adyen.com">
    <payment:paymentRequest>
      <payment:merchantAccount>%s</payment:merchantAccount>
      <payment:reference>%s</payment:reference>
      %s
    </payment:paymentRequest>
  </payment:authorise>
EOXML
AMOUNT_PARTIAL =
<<-EOXML
  <payment:amount>
    <common:currency>%s</common:currency>
    <common:value>%s</common:value>
  </payment:amount>
EOXML
CARD_PARTIAL =
<<-EOXML
  <payment:card>
    <payment:holderName>%s</payment:holderName>
    <payment:number>%s</payment:number>
    <payment:cvc>%s</payment:cvc>
    <payment:expiryYear>%s</payment:expiryYear>
    <payment:expiryMonth>%02d</payment:expiryMonth>
  </payment:card>
EOXML
ONE_CLICK_CARD_PARTIAL =
<<-EOXML
  <payment:card>
    <payment:cvc>%s</payment:cvc>
  </payment:card>
EOXML
INSTALLMENTS_PARTIAL =
<<-EOXML
  <payment:installments>
    <common:value>%s</common:value>
  </payment:installments>
EOXML
SOCIAL_SECURITY_NUMBER_PARTIAL =
<<-EOXML
  <payment:socialSecurityNumber>%s</payment:socialSecurityNumber>
EOXML
DELIVERY_DATE_PARTIAL =
<<-EOXML
  <deliveryDate xmlns="http://payment.services.adyen.com">%s</deliveryDate>
EOXML
SELECTED_BRAND_PARTIAL =
<<-EOXML
  <payment:selectedBrand>%s</payment:selectedBrand>
EOXML
SHOPPER_NAME_PARTIAL =
<<-EOXML
  <payment:shopperName>
    <common:firstName>%s</common:firstName>
    <common:lastName>%s</common:lastName>
  </payment:shopperName>
EOXML
ENCRYPTED_CARD_PARTIAL =
<<-EOXML
  <additionalAmount xmlns="http://payment.services.adyen.com" xsi:nil="true" />
  <additionalData xmlns="http://payment.services.adyen.com">
    <entry>
      <key xsi:type="xsd:string">card.encrypted.json</key>
      <value xsi:type="xsd:string">%s</value>
    </entry>
  </additionalData>
EOXML
ENABLE_RECURRING_CONTRACTS_PARTIAL =
<<-EOXML
  <payment:recurring>
    <payment:contract>RECURRING,ONECLICK</payment:contract>
  </payment:recurring>
EOXML
RECURRING_PAYMENT_BODY_PARTIAL =
<<-EOXML
  <payment:recurring>
    <payment:contract>RECURRING</payment:contract>
  </payment:recurring>
  <payment:selectedRecurringDetailReference>%s</payment:selectedRecurringDetailReference>
  <payment:shopperInteraction>ContAuth</payment:shopperInteraction>
EOXML
ONE_CLICK_PAYMENT_BODY_PARTIAL =
<<-EOXML
  <payment:recurring>
    <payment:contract>ONECLICK</payment:contract>
  </payment:recurring>
  <payment:selectedRecurringDetailReference>%s</payment:selectedRecurringDetailReference>
EOXML
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>'

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

See Also:

  • API.authorise_one_click_payment


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

See Also:

  • API.authorise_payment


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

See Also:

  • API.authorise_recurring_payment


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

See Also:

  • API.cancel_payment


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

See Also:

  • API.cancel_or_refund_payment


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

See Also:

  • API.capture_payment


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

def capture
  make_payment_request(capture_request_body, CaptureResponse)
end

#generate_billetObject

See Also:

  • API.generate_billet


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

See Also:

  • API.refund_payment


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

def refund
  make_payment_request(refund_request_body, RefundResponse)
end