Giter VIP home page Giter VIP logo

paybox-direct-plus's Introduction

Paybox Direct Plus

This is a implementation of Paybox Direct Plus for ActiveMerchant. Paybox Direct Plus is a French payment solution allowing recurring payments, subscriptions, etc.

Setup the gateway

gateway = ActiveMerchant::Billing::PayboxDirectPlusGateway.new(
  login:    '199988899',
  password: '1999888I'
)

Subscribed user functionalities

Create a user profile:

response = gateway.subscriber_create(amount, active_merchant_credit_card, user_reference: 'YOUR_USER_REFERENCE')
response.success?           # check if called succeeded
response.authorization      # authorization number, to be used for capture / void / refund
response.params['porteur']  # credit card reference, to be saved to use with the user reference for future purchases

When creating a user profile, Paybox will do an authorization on the credit card. Paybox recommends that you give the same amount than your transaction so you can simple capture it later.

If you don't know yet how much you'll have to charge the client, you can also send an amount of 0.

After your client is subscribed, you will be able to use several other operations:

credit_card = ActiveMerchant::Billing::CreditCard.new(
  last_name:          client_cc.last_name,
  first_name:         client_cc.first_name,
  verification_value: client_cc.verification_value,
  year:               client_cc.expires_on.year,
  month:              client_cc.expires_on.month
) # notice the absence of credit card number here

purchase = gateway.subscriber_purchase(
  amount, credit_card,
  user_reference:  'YOUR_USER_REFERENCE',
  order_id:        'ORDER_REFERENCE',
  credit_card_reference: subscriber_create_response.params['porteur']
) # authorize + capture in one call

authorize = gateway.subscriber_authorize(
  amount, credit_card,
  user_reference:        'YOUR_USER_REFERENCE',
  order_id:              'ORDER_REFERENCE',
  credit_card_reference: subscriber_create_response.params['porteur']
)

capture = gateway.subscriber_capture(
  amount, authorize.authorization,
  user_reference: 'YOUR_USER_REFERENCE',
  order_id:       'ORDER_REFERENCE'
)

refund = gateway.subscriber_refund(
  amount, authorize.authorization,
  user_reference: 'YOUR_USER_REFERENCE',
  order_id:       'ORDER_REFERENCE'
)

void = gateway.subscriber_void(
  amount, authorize.authorization,
  user_reference: 'YOUR_USER_REFERENCE',
  order_id:       'ORDER_REFERENCE'
)

Using the subscriber_purchase method will do an authorization and a capture. Some banks requires some delay between 2 authorizations on the same card. So, if you register a profile then call subscriber_purchase just after instead of subscriber_capture, it may fail with some banks.

Non subscribed user functionalities

The gateway inherits Donal Piret's Paybox Direct Gateway, so all methods of that gateway are accessible.

Compatibility

For Ruby 1.8, use version 0.1.0

For Ruby 1.9, use version 0.2.0

For Ruby 2.0+, use latest version ~>1.0

Tests

Remote integrations tests using the Paybox tests logins and server are available and should always pass.

bundle install
bundle exec rake test

Credits

The base of all this work is Donald Piret's great work on Paybox Direct Gateway implementation.

Contact

Please don't hesitate to contact me if you have any question, any suggestion or if you found any bug.

paybox-direct-plus's People

Contributors

arambert avatar dependabot[bot] avatar ewalk153 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

paybox-direct-plus's Issues

Error when executing a "credit"

When I try to execute a "credit", I receive the following error: Mandatory values missing keyword:11 Type:21

Here is remote test that I wrote to demonstrate the problem:

  def test_create_profile_capture_and_credit
    assert response = @gateway.create_payment_profile(@amount, @credit_card, @options)
    assert_success response

    credit_card_reference = response.params["credit_card_reference"]
    assert_not_nil credit_card_reference

    assert capture = @gateway.capture(@amount, response.params["authorization"], @options)
    assert_success capture

    assert credit = @gateway.credit(@amount, capture.params["authorization"], @options)
    assert_equal 'The transaction was approved', credit.message
    assert_success credit
  end

NoMethodError "gateway_customer_profile_id"

Hi,
thanks for your work on implementing the "PLUS" feature of Paybox. I'm also working on this :).

In your code you use creditcard.gateway_customer_profile_id.

This attribute is not implemented in ActiveMerchant::Billing::CreditCard object resulting in NoMethodError.

Can you give explanation in the README or in the code on how you implemented this attribute (monkey-patch ?)..?

Thanks,

Nicolas Blanco.

00005: Numéro de question invalide - Increase timeout between first and secondary requests

Hi,

We have sometimes a "00005: Numéro de question invalide" response error when the payment have been set as succeed.

After digging in Paybox logs with Paybox support, we figured out that the problem come from the timeout of the first request to ppps.paybox.com which isn't waiting for 30s at least to call another request to ppps1.paybox.com which is trying to perform the same payment again.

The first request to ppps.paybox.com is succeed.
The second request to pps1.paybox.com have the error "00005: Numéro de question invalide" because already treated by the first request.

My question is, how can I increase the timeout of the first request?

Thanks for any help, and btw thanks for your plugin.

Credit implementation

When I tried to use credit using the implementation provided in the gem, it didn't work for me (Paybox returned me network errors). I had to overload the implementation to make it work (only tested in test mode yet). Here is how I did it :

module ActiveMerchant #:nodoc:
  module Billing #:nodoc:
    class PayboxDirectPlusGateway < Gateway
      def credit(money, creditcard, options = {})
        post = {}
        add_invoice(post, options)
        add_creditcard(post, creditcard, options)
        add_user_reference(post, options)
        commit('subscriber_credit', money, post)
      end
    end
  end
end

Add support for Response.authorization field

A few of the ActiveMerchant::Billing::Response attributes are based on "magic" from the params and options hash.

Moving

            :test => test?,
            :authorization => response[:numappel].to_s + response[:numtrans].to_s,
            :fraud_review => fraud_review?(response),

from params to options enable these fields to be accessible directly. Authorization field example

Options include moving the fields from params to options, or duplicating them for backwards support where people may already be accessing them via Response.params.
Happy to put up a pull request.

Is there a way to simulate errors ?

Hi !

Many thanks for this gem! In the Paybox Direct doc, they say we can simulate error codes by submitting a variable called ERRORCODETEST. Is there a way to this with this library ?

Many thanks by advance.

Sylvain

Emetteur de carte inconnu

Hi,

I'm trying to use your gem but I always get a "Emetteur de carte inconnu" message while running

def credit_card(number = '1111222233334444', options = {})
  defaults = {
    number: number,
    month: '12',
    year: '2016',
    first_name: 'Longbob',
    last_name: 'Longsen',
    verification_value: '123',
    brand: 'visa'
  }.update(options)

  ActiveMerchant::Billing::CreditCard.new(defaults)
end

@gateway = ActiveMerchant::Billing::PayboxDirectPlusGateway.new(
  login:    my_login,
  password: my_password
)


@amount = 100
@credit_card = credit_card

@options = {
  order_id:       "REF#{Time.now.usec}",
  user_reference: "USER#{Time.now.usec}",
  devise: '978',
}

response = @gateway.subscriber_create(@amount, @credit_card, @options)

Any Idea ? I used my credential to enter my prepared admin link.

Notice that devise field looks like a mandatory field !

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.