1

I am trying to integrate Pin.net.au CC processing into my site. I am using Omnipay library to make the calls.

To not store CC details in my server, I am using the Pin.js token method.

On form submit page (after user fills in personal and CC details) javascript does a 'prevent default' and sends the data from forms (browser) straight to pin.net.au servers. Server sends a card_token in response and resubmits the form to my server.

This token is recieved successfully and I can output it in my tests.

I get into trouble when I take that token and send a purchase request to pin.net.au. According to the API docs, I need not send user and card details when I send the token (the entire point of the token, really). I send this token along with other compulsory bits like email, amount, description etc.

This works when I cURL on my terminal and I get a charge success.

However, sending this purchase/charge request using the Omnipay library, each time I get a 422 (invalid resource) that asks for the user details and CC information. It should have populated this stuff from the token I sent.

I have scoured the API docs of both Omnipay and Pin.net.au. I don't seem to be doing anything wrong. What am I missing?

Here's my charge request:

$gateway = GatewayFactory::create('Pin');
$gateway->setSecretKey('MY_SECRET_KEY');
$response = $gateway->purchase([
  'email'       => 'user@email.com',
  'description' => 'Package',
  'amount'      => '99',
  'currency'    => 'AUD',
  'card_token'  => Input::get('card_token'),
  'ip_address'  => Input::get('ip_address')
 ])->send();

Finally, it shouldn't really matter but if you'd like to know, I'm using Laravel 4.

Prashant
  • 47
  • 6

2 Answers2

1

Your example request has an amount of 99, the minimum amount for a Pin Payments charge is $1 (amount = 100).

I don't think this is the problem you are referring to though, it looks like Omnipay does not support using the card_token gear. If you go look over here - https://github.com/adrianmacneil/omnipay/blob/master/src/Omnipay/Pin/Message/PurchaseRequest.php#L34 - you can see Omnipay isn't sending the card_token field with it's request, it only tries to send card details, which obviously aren't present from your example!

Perhaps you could get in touch with the Omnipay developers or write a pull request yourself!

Justin Jones
  • 91
  • 1
  • 2
  • > you're right about the amount (I have used a higher amount in my actual code - i think I just changed the amount when I was pasting here). Your suggestion makes sense! The good folks at pin.net.au have also responded and are looking into it. But you're right, this might be an Omnipay issue rather than pin.net.au Which is interesting because pin.net.au DOES reccomend omnipay on their docs. And the sample code there is shown using the token! [https://pin.net.au/language-support/php](https://pin.net.au/language-support/php) – Prashant Sep 20 '13 at 07:40
  • 1
    @Prashant I am actually a developer at Pin Payments, that example was obviously made in error! We're gonna get that fixed up. In the meantime, I had a stab at adding card token support to Omnipay myself, which you can find here: https://github.com/adrianmacneil/omnipay/pull/128 You may be able to use my git fork in the meantime while you wait for the pull request to be accepted (I did test it!) – Justin Jones Sep 20 '13 at 09:03
  • cheers for the help mate. i got your twitter message too - thanks for the pull request. yes please do update the docs.. that it was in the official docs kinda makes you think that probably the mistake is your own! from the git it looks like the omnipay author is on it too. should be accepted soon I hope. – Prashant Sep 20 '13 at 09:29
  • Thanks for the PR @JustinJones - I've merged it and released v1.0.4 which has your changes. Also note in Omnipay the amount is passed as a decimal string, so the OP's usage is correct. – Adrian Macneil Sep 21 '13 at 01:29
  • @JustinJones to avoid discrepancies like these (decimal string in libraries like Omnipay vs cent value in Pin), it might be worth the time to release a clean little official package on Composer specifically for Pin customers - which could also make sense for all future changes. Just an idea... – Prashant Sep 21 '13 at 09:54
1

This is fixed in Omnipay v1.0.4 - you should be able to use the token like this:

$gateway = GatewayFactory::create('Pin');
$gateway->setSecretKey('MY_SECRET_KEY');
$response = $gateway->purchase([
  'description' => 'Package',
  'amount'      => '99.00',
  'currency'    => 'AUD',
  'token'       => Input::get('token'),
  'ip_address'  => Input::get('ip_address'),
  'card'        => ['email' => 'user@email.com'],
 ])->send();
Adrian Macneil
  • 13,017
  • 5
  • 57
  • 70