Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Feb 21 2018 19:27
    swelham closed #22
  • Feb 21 2018 19:27

    swelham on master

    Add CodeTriage badge to swelham… Merge pull request #22 from cod… (compare)

  • Feb 21 2018 19:12
    codetriage-readme-bot opened #22
  • Oct 19 2017 20:21

    swelham on overhaul

    (compare)

  • Apr 20 2017 14:07

    swelham on overhaul

    back to the basics removed missed app in mix file added genstage pipeline and 2 more (compare)

  • Feb 14 2017 09:54
    swelham commented #5
  • Feb 14 2017 09:17
    aseigo commented #5
  • Feb 13 2017 14:55

    swelham on master

    added adding missing asserts (compare)

  • Feb 13 2017 14:25

    swelham on master

    normalise paypal bad request re… (compare)

  • Feb 13 2017 12:21

    swelham on master

    small syntax improvement (compare)

  • Feb 12 2017 13:27
    swelham labeled #21
  • Feb 12 2017 13:27
    swelham opened #21
  • Feb 12 2017 13:24

    swelham on master

    bump version to 0.4.0 (compare)

  • Feb 12 2017 13:19

    swelham on master

    fixes #4 - added common error f… (compare)

  • Feb 12 2017 13:19
    swelham closed #4
  • Feb 12 2017 12:25

    swelham on master

    fixed merge issues (compare)

  • Feb 09 2017 10:12

    swelham on design_refactor

    (compare)

  • Feb 09 2017 10:05

    swelham on master

    started genstage experimenting added passing dummy authorize P… converted dummy gateway and 12 more (compare)

  • Feb 09 2017 10:05
    swelham closed #17
  • Feb 09 2017 10:05
    swelham closed #2
Stuart Welham
@swelham
No prob, let me know if you have any more problems
Zubair Nabi
@zubairshokh
Sure, Thanks @swelham
Stuart Welham
@swelham

@zubairshokh Hi

Just a heads up. I plan on making some breaking changes to the cashier public API in the next few days, which will break any code you have currently written. To combat this I have now published a new version to hex so that you can use this should you not want to update your code to work with the latest in git.

You can now use {:cashier, "~> 0.2.0"} in your deps instead.

Zubair Nabi
@zubairshokh
ok @swelham , thank you for the info
i am already liking your lib. Best of luck
Stuart Welham
@swelham
That's great to hear!
Thank you
Zubair Nabi
@zubairshokh
hello
Zubair Nabi
@zubairshokh
Hello @swelham
hope you are doing good.
i was working on the lib, and wanted to know about the error response format. what i usually get is in this format
"Unexpected status code (400) returned {\"name\":\"VALIDATION_ERROR\",\"details\":[{\"field\":\"transactions[0].amount.details.subtotal\"
,\"issue\":\"Currency amount must be non-negative number and can optionally contain exactly two decimal places separated by '.', optional
thousands separator ',', limited to seven digits before the decimal point.\"},{\"field\":\"transactions[0].amount.total\",\"issue\":\"Cu
rrency amount must be non-negative number and can optionally contain exactly two decimal places separated by '.', optional thousands sepa
rator ',', limited to seven digits before the decimal point.\"}],\"message\":\"Invalid request. See details.\",\"information_link\":\"htt
ps://developer.paypal.com/webapps/developer/docs/api/#VALIDATION_ERROR\",\"debug_id\":\"4cade50453b48\"}"
so, i was wondering, even with the error, i get the 200 status, but with the above response
however, what i am concerned of is "Unexpected status code (400) returned", with the response string
Zubair Nabi
@zubairshokh
is it anytime to be fixed, or any procedure for me to work on it.
thanks
Stuart Welham
@swelham
Hi @zubairshokh
There is an issue open on the report (issue #4) that addresses this and it is on my todo list.
I think the only thing you could probably do with that at the moment is to strip the start of the string off which will just leave the json and then you can parse that into a map using something like the poison library.
I should have some time this weekend to improve this to at least return
the parsed json with the error message
Stuart Welham
@swelham
Sorry about the typos I'm currently on my phone and auto correct is playing it's part! :angry:
Stuart Welham
@swelham

I have just pushed a commit that will split out the errors for an http 400 and return them from the cashier module. If you are on the 0.2.0 release you will need to switch your dep to use the master branch from the git repo and this will initially break any code that expects cashier to return {:ok, result}. You will need to update the broken code to expect a 3 element tuple {:ok, id, result}, result in this case is also a tuple that contains the gateway that handled the request and the raw response (e.g. {:paypal, raw_data}). For some further examples I would suggest taking a look at the either of these test files cashier_test or paypal_test.

Otherwise feel free to give me a shout if you have any issues.

Zubair Nabi
@zubairshokh
Thank you @swelham, i got it. please let me know, if there is any major change in implementing the lib.
Thank you for your work
Zubair Nabi
@zubairshokh
i encountered this error
(FunctionClauseError) no function clause matching in Cashier.Gateways.PayPal.handle_response/2
when i use {:error, :invalid, reason}
Stuart Welham
@swelham
Sorry my bad, I missed a change in the base gateway module. I have just pushed a fix which should solve this issue for you.
Zubair Nabi
@zubairshokh
yea, was checking the code in Base module
thank you
will update it
Stuart Welham
@swelham
No problem, I appear to have a gap in my tests!!
Zubair Nabi
@zubairshokh
sorry, but i am getting the same issue again
(FunctionClauseError) no function clause matching in Cashier.Gateways.PayPal.handle_response/2
(cashier) lib/gateways/paypal.ex:2: Cashier.Gateways.PayPal.handle_response({:error, :invalid, %{"debug_id" => "7b97f0f1af5e0",
"details" => [
even after the update
Stuart Welham
@swelham

Can provide the code you are using for me to reproduce with?

I am currently testing this with the code in this gist using deps [{:cashier, git: "http://github.com/swelham/cashier.git"}] which is returning

%{"debug_id" => "fbb3c70ac78e4",
  "details" => [%{"field" => "payer.funding_instruments[0].credit_card.cvv2",
     "issue" => "Value must be numeric."}],
  "information_link" => "https://developer.paypal.com/webapps/developer/docs/api/#VALIDATION_ERR
OR",
  "message" => "Invalid request. See details.", "name" => "VALIDATION_ERROR"}
Zubair Nabi
@zubairshokh
here is the piece of code that handles it
{:error,:invalid, reason} -> set_error(conn,reason)
case Cashier.purchase(-5.99, card, [billing_address: address]) do
{:ok,id, {:paypal,result}} -> Service.PurchaseService.set_response_to_payment(conn,result)
|> MODULE.create(conn)
{:error,:invalid, reason} -> set_error(conn,reason)
end
Stuart Welham
@swelham
Hmm strange, that looks fine to me. All I can think is the cashier dep hasn't got the latest from master. I am about to publish a 0.3.0 version to hex with this included, give me 5 minutes and then I would suggest using that.
Zubair Nabi
@zubairshokh
sure
thanks
Stuart Welham
@swelham
This is now done @zubairshokh. Hopefully this will solve your issue!
Zubair Nabi
@zubairshokh
yea @swelham , worked now
Thanks
Stuart Welham
@swelham
No problem, I'm happy to have helped.
Computer Nerd
@TheVoriko_twitter
@swelham , I need some assistance regarding the usage of your cashier library
Stuart Welham
@swelham
Hi @TheVoriko_twitter, sorry for the late reply. Gitter never gave me a notification!
I have replied to your dm as well so let me know if I can still help.