Class: Adyen::API::PaymentService

Inherits:
SimpleSOAPClient show all
Defined in:
lib/adyen/api.rb,
lib/adyen/api.rb

Defined Under Namespace

Classes: AuthorizationResponse

Constant Summary collapse

ENDPOINT_URI =
'https://pal-%s.adyen.com/pal/servlet/soap/Payment'
LAYOUT =
<<EOS
<?xml version="1.0"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <soap:Body>
    <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>
  </soap:Body>
</soap:Envelope>
EOS
AMOUNT_PARTIAL =
<<EOS
        <payment:amount>
          <common:currency>%s</common:currency>
          <common:value>%s</common:value>
        </payment:amount>
EOS
CARD_PARTIAL =
<<EOS
        <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>
EOS
RECURRING_PARTIAL =
<<EOS
        <payment:recurring>
          <payment:contract>RECURRING</payment:contract>
        </payment:recurring>
EOS
RECURRING_PAYMENT_BODY_PARTIAL =
<<EOS
        <payment:recurring>
          <payment:contract>RECURRING</payment:contract>
        </payment:recurring>
        <payment:selectedRecurringDetailReference>%s</payment:selectedRecurringDetailReference>
        <payment:shopperInteraction>ContAuth</payment:shopperInteraction>
EOS
SHOPPER_PARTIALS =
{
  :reference => '        <payment:shopperReference>%s</payment:shopperReference>',
  :email     => '        <payment:shopperEmail>%s</payment:shopperEmail>',
  :ip        => '        <payment:shopperIP>%s</payment:shopperIP>',
}
AUTHORISE_RESPONSE =

Test responses

<<EOS
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <soap:Body>
    <ns1:authoriseResponse xmlns:ns1="http://payment.services.adyen.com">
      <ns1:paymentResult>
        <additionalData xmlns="http://payment.services.adyen.com" xsi:nil="true"/>
        <authCode xmlns="http://payment.services.adyen.com">1234</authCode>
        <dccAmount xmlns="http://payment.services.adyen.com" xsi:nil="true"/>
        <dccSignature xmlns="http://payment.services.adyen.com" xsi:nil="true"/>
        <fraudResult xmlns="http://payment.services.adyen.com" xsi:nil="true"/>
        <issuerUrl xmlns="http://payment.services.adyen.com" xsi:nil="true"/>
        <md xmlns="http://payment.services.adyen.com" xsi:nil="true"/>
        <paRequest xmlns="http://payment.services.adyen.com" xsi:nil="true"/>
        <pspReference xmlns="http://payment.services.adyen.com">9876543210987654</pspReference>
        <refusalReason xmlns="http://payment.services.adyen.com" xsi:nil="true"/>
        <resultCode xmlns="http://payment.services.adyen.com">Authorised</resultCode>
      </ns1:paymentResult>
    </ns1:authoriseResponse>
  </soap:Body>
</soap:Envelope>
EOS
AUTHORISATION_REFUSED_RESPONSE =
<<EOS
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <soap:Body>
    <ns1:authoriseResponse xmlns:ns1="http://payment.services.adyen.com">
      <ns1:paymentResult>
        <additionalData xmlns="http://payment.services.adyen.com" xsi:nil="true"/>
        <authCode xmlns="http://payment.services.adyen.com">1234</authCode>
        <dccAmount xmlns="http://payment.services.adyen.com" xsi:nil="true"/>
        <dccSignature xmlns="http://payment.services.adyen.com" xsi:nil="true"/>
        <fraudResult xmlns="http://payment.services.adyen.com" xsi:nil="true"/>
        <issuerUrl xmlns="http://payment.services.adyen.com" xsi:nil="true"/>
        <md xmlns="http://payment.services.adyen.com" xsi:nil="true"/>
        <paRequest xmlns="http://payment.services.adyen.com" xsi:nil="true"/>
        <pspReference xmlns="http://payment.services.adyen.com">9876543210987654</pspReference>
        <refusalReason xmlns="http://payment.services.adyen.com">You need to actually own money.</refusalReason>
        <resultCode xmlns="http://payment.services.adyen.com">Refused</resultCode>
      </ns1:paymentResult>
    </ns1:authoriseResponse>
  </soap:Body>
</soap:Envelope>
EOS
AUTHORISATION_REQUEST_INVALID_RESPONSE =
<<EOS
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <soap:Body>
    <soap:Fault>
      <faultcode>soap:Server</faultcode>
      <faultstring>validation 101 Invalid card number</faultstring>
    </soap:Fault>
  </soap:Body>
</soap:Envelope>
EOS

Constants inherited from SimpleSOAPClient

SimpleSOAPClient::CACERT

Instance Attribute Summary

Attributes inherited from SimpleSOAPClient

#params

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from SimpleSOAPClient

#call_webservice_action, endpoint, #initialize

Constructor Details

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

Class Method Details

.invalid_stubObject



219
220
221
222
223
# File 'lib/adyen/api.rb', line 219

def invalid_stub
  http_response = Net::HTTPOK.new('1.1', '200', 'OK')
  def http_response.body; AUTHORISATION_REQUEST_INVALID_RESPONSE; end
  AuthorizationResponse.new(http_response)
end

.refused_stubObject



213
214
215
216
217
# File 'lib/adyen/api.rb', line 213

def refused_stub
  http_response = Net::HTTPOK.new('1.1', '200', 'OK')
  def http_response.body; AUTHORISATION_REFUSED_RESPONSE; end
  AuthorizationResponse.new(http_response)
end

.stub_invalid!Object



233
234
235
# File 'lib/adyen/api.rb', line 233

def stub_invalid!
  @stubbed_response = invalid_stub
end

.stub_refused!Object



229
230
231
# File 'lib/adyen/api.rb', line 229

def stub_refused!
  @stubbed_response = refused_stub
end

.stub_success!Object



225
226
227
# File 'lib/adyen/api.rb', line 225

def stub_success!
  @stubbed_response = success_stub
end

.success_stubObject



207
208
209
210
211
# File 'lib/adyen/api.rb', line 207

def success_stub
  http_response = Net::HTTPOK.new('1.1', '200', 'OK')
  def http_response.body; AUTHORISE_RESPONSE; end
  AuthorizationResponse.new(http_response)
end

Instance Method Details

#authorise_paymentObject



238
239
240
# File 'lib/adyen/api.rb', line 238

def authorise_payment
  make_payment_request(authorise_payment_request_body)
end

#authorise_recurring_paymentObject



242
243
244
# File 'lib/adyen/api.rb', line 242

def authorise_recurring_payment
  make_payment_request(authorise_recurring_payment_request_body)
end