srmklive / laravel-paypal

Laravel plugin for processing payments through PayPal.
https://laravel-paypal-demo.srmk.info/
MIT License
1.03k stars 314 forks source link

No demo or docs on how to use version 3.0, read me is confusing once I'm on the usage part. #407

Closed gr34tnull closed 2 years ago

gr34tnull commented 3 years ago

No demo or docs on how to use version 3.0, read me is confusing once I'm on the usage part.

DeanVanGreunen commented 3 years ago

@gr34tnull bro try watching this. https://www.youtube.com/watch?v=_7YBIRQfSN0

it shouldn't be to different. i myself am also using the 3.0 version, using that video as a guide.

gr34tnull commented 3 years ago

@DeanVanGreunen I already have checked that video, the problem I have in that tutorial is that it doesn't use version 3.0, I'm just a junior and that video is not using this package it uses the paypal\rest-api-sdk-php, Other tutorials still uses the ExpressCheckout header and not the latest ones being described in the read me section, I want to use this specific package on its version 3.0, so I need to understand how this properly works or having better documentation for its usage would be helpful, most tutorials I see is deprecated and the website of paypal documentation is confusing. Most repositories I see on github is using the deprecated version of this package too which I didn't want to use.

farshadff commented 3 years ago

the same issue here there is no proper example or document for version 3 and how to use it . this package is great and good work to the creator really but we need more info about version 3 . thanks in advance

farshadff commented 3 years ago

@gr34tnull bro try watching this. https://www.youtube.com/watch?v=_7YBIRQfSN0

it shouldn't be to different. i myself am also using the 3.0 version, using that video as a guide.

can you please tell us how you are using the version 3 with this video ?? because this video as i see has nothing to do with this package

JexPY commented 3 years ago

@gr34tnull @farshadff Hey guys just check https://stackoverflow.com/questions/40914114/how-to-install-a-specific-version-of-package-using-composer and try to get some more information about using composer. Here is the spoiler: composer require srmklive/paypal "^3.0"

gr34tnull commented 3 years ago

@JexPY we are not asking how to install the latest package we are asking about the usage of the latest package because it has no proper documentation, your comment is useless.

JexPY commented 3 years ago

@gr34tnull I understand what you mean, when I first checked the package had same thoughts as you but trust it's not that hard to understand how it all works if you installed right version just check for functions in classes of source all are traits so after init of main class you will just need to call any of method from traits. If you will not be able to solve your problem until tomorrow I will try to help you with example of code, good luck.

gr34tnull commented 3 years ago

@JexPY yes an example code would be helpful, I hope it's in version 3.0. Thanks.

srmklive commented 3 years ago

Hi guys,

First of all, please accept my apologies for not responding in time. Specifically the documentation part i have been trying to write it down, but simply haven't had the time to do so. @JexPY & @DeanVanGreunen thanks for the help. If possible, can you guys work on the documentation for v2 & v3? I can add you two as contributors & you guys can carry on with the documentation work.

@gr34tnull i understand your frustration. But with v1, i got lot of questions on how to do this & that, while the README was pretty comprehensive with examples. If people don't read the documentation properly, and start asking the package maintainer quite frankly stupid questions. It becomes exasperating. I will try to work on the documentation to make it to a starting point, so its easier to understand.

gr34tnull commented 3 years ago

@srmklive thanks for responding :)

gr34tnull commented 3 years ago

any update on this?

DeanVanGreunen commented 3 years ago

@srmklive Sure, Me and @JexPY can work on the documentation, bro @JexPY would you be will to assists?

JexPY commented 3 years ago

Hello guys, I was not able to write back as I had surgery a week ago, will love to contribute as I will feel better.

Regards,

srmklive commented 3 years ago

@JexPY & @DeanVanGreunen I have invited both of you as collaborators on the repository. Let's get this version documented :laughing:

DeanVanGreunen commented 3 years ago

@srmklive totally, let us do it guys!

srmklive commented 3 years ago

@DeanVanGreunen There is already a documentation branch or gh-pages branch. Its upto you whatever you think is the best way to move forward.

kobazzo commented 3 years ago

hi everyone, I would also need the version 3 documentation. There is no way to use it without docs.

kobazzo commented 3 years ago

@DeanVanGreunen I already have checked that video, the problem I have in that tutorial is that it doesn't use version 3.0, I'm just a junior and that video is not using this package it uses the paypal\rest-api-sdk-php, Other tutorials still uses the ExpressCheckout header and not the latest ones being described in the read me section, I want to use this specific package on its version 3.0, so I need to understand how this properly works or having better documentation for its usage would be helpful, most tutorials I see is deprecated and the website of paypal documentation is confusing. Most repositories I see on github is using the deprecated version of this package too which I didn't want to use.

Hi, were you able to use the library?

DeanVanGreunen commented 3 years ago

Ho Kobazzo.

currently, I'm only using the library to get an access token providing my client secrets and client API key. For the rest I use normal post/get requests using curl taken from teh paypal docs.

When i have free time i'll update the documentation for this paypal library

On Sat, Mar 13, 2021 at 1:01 PM kobazzo @.***> wrote:

@DeanVanGreunen https://github.com/DeanVanGreunen I already have checked that video, the problem I have in that tutorial is that it doesn't use version 3.0, I'm just a junior and that video is not using this package it uses the paypal\rest-api-sdk-php, Other tutorials still uses the ExpressCheckout header and not the latest ones being described in the read me section, I want to use this specific package on its version 3.0, so I need to understand how this properly works or having better documentation for its usage would be helpful, most tutorials I see is deprecated and the website of paypal documentation is confusing. Most repositories I see on github is using the deprecated version of this package too which I didn't want to use.

Hi, were you able to use the library?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/srmklive/laravel-paypal/issues/407#issuecomment-798157618, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFKDMC2CZA3X3GVJVY7E3N3TDNAYLANCNFSM4XEXRBQA .

--

Dean Van Greunen | Senior Software Engineer LinkedIn: deanvangreunen https://www.linkedin.com/in/deanvangreunen/ Mobile: +27663922868 | 0663922868

kobazzo commented 3 years ago

When i have free time i'll update the documentation for this paypal library

I would be very grateful to you. I would like to use the library but doing as described in the documentation, it doesn't work. Something like this in the controller:

$provider = PayPal::setProvider();
 $provider->getAccessToken();
$provider->setCurrency('EUR');
$provider->createOrder([
            "intent"=> "CAPTURE",
            "purchase_units"=> [
                "amount"=> [
                  "currency_code"=> "EUR",
                  "value"=> "100.00"
                ]
            ]
        ]);

I have compiled the paypal.php configuration file. there are probably other instructions to do in the controller but the documentation does not mention it.

kobazzo commented 3 years ago

Ho Kobazzo. currently, I'm only using the library to get an access token providing my client secrets and client API key. For the rest I use normal post/get requests using curl taken from teh paypal docs. When i have free time i'll update the documentation for this paypal library On Sat, Mar 13, 2021 at 1:01 PM kobazzo @.**> wrote: @DeanVanGreunen https://github.com/DeanVanGreunen I already have checked that video, the problem I have in that tutorial is that it doesn't use version 3.0, I'm just a junior and that video is not using this package it uses the paypal\rest-api-sdk-php, Other tutorials still uses the ExpressCheckout header and not the latest ones being described in the read me section, I want to use this specific package on its version 3.0, so I need to understand how this properly works or having better documentation for its usage would be helpful, most tutorials I see is deprecated and the website of paypal documentation is confusing. Most repositories I see on github is using the deprecated version of this package too which I didn't want to use. Hi, were you able to use the library? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#407 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFKDMC2CZA3X3GVJVY7E3N3TDNAYLANCNFSM4XEXRBQA . -- Dean Van Greunen* | Senior Software Engineer LinkedIn: deanvangreunen https://www.linkedin.com/in/deanvangreunen/ Mobile: +27663922868 | 0663922868

even if I try to get the token back in my controller, without creating the order, like this:

$provider = PayPal::setProvider();
$paypalToken = $provider->getAccessToken();

I have the error: Trying to access array offset on value of type null in srmklive\paypal\src\Traits\PayPalAPI.php:38, the row with error is:

$this->apiUrl = collect([$this->config['api_url'], $this->apiEndPoint])->implode('/');

in my code do I have to make some other settings to avoid this error?

Faks commented 3 years ago

Basic Setup on v3 is the following... PayPal::setProvider(); $paypalProvider = PayPal::getProvider(); $paypalProvider->setApiCredentials(config('paypal')); $paypalProvider->setAccessToken($paypalProvider->getAccessToken()); furhter on can work with variable $paypalProvider trough facade ... functions of class.

Faks commented 3 years ago

Ho Kobazzo. currently, I'm only using the library to get an access token providing my client secrets and client API key. For the rest I use normal post/get requests using curl taken from teh paypal docs. When i have free time i'll update the documentation for this paypal library On Sat, Mar 13, 2021 at 1:01 PM kobazzo @.***> wrote: @DeanVanGreunen https://github.com/DeanVanGreunen I already have checked that video, the problem I have in that tutorial is that it doesn't use version 3.0, I'm just a junior and that video is not using this package it uses the paypal\rest-api-sdk-php, Other tutorials still uses the ExpressCheckout header and not the latest ones being described in the read me section, I want to use this specific package on its version 3.0, so I need to understand how this properly works or having better documentation for its usage would be helpful, most tutorials I see is deprecated and the website of paypal documentation is confusing. Most repositories I see on github is using the deprecated version of this package too which I didn't want to use. Hi, were you able to use the library? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#407 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFKDMC2CZA3X3GVJVY7E3N3TDNAYLANCNFSM4XEXRBQA . -- Dean Van Greunen | Senior Software Engineer LinkedIn: deanvangreunen https://www.linkedin.com/in/deanvangreunen/ Mobile: +27663922868 | 0663922868

even if I try to get the token back in my controller, without creating the order, like this:

$provider = PayPal::setProvider();
$paypalToken = $provider->getAccessToken();

I have the error: Trying to access array offset on value of type null in srmklive\paypal\src\Traits\PayPalAPI.php:38, the row with error is:

$this->apiUrl = collect([$this->config['api_url'], $this->apiEndPoint])->implode('/');

in my code do I have to make some other settings to avoid this error?

I was checking the source code of this package and have issues with how initially it was implemented. should be some part of it rewritten, at least init...

kobazzo commented 3 years ago

Basic Setup on v3 is the following... PayPal::setProvider(); $paypalProvider = PayPal::getProvider(); $paypalProvider->setApiCredentials(config('paypal')); $paypalProvider->setAccessToken($paypalProvider->getAccessToken()); furhter on can work with variable $paypalProvider trough facade ... functions of class.

Thank you, it's work to get the access token, now i can create an order like this?

        $provider->setCurrency('EUR');
        $provider->createOrder([
            "intent"=> "CAPTURE",
            "purchase_units"=> [
                "amount"=> [
                  "currency_code"=> "EUR",
                  "value"=> "100.00"
                ]
            ]
        ]);

But creating an order with this code i have this response:

"type" => "error" "message" => "{"intent":"CAPTURE","purchase_units":{"amount":{"currency_code":"EUR","value":"100.00"}}} {"name":"INVALID_REQUEST","message":"Request is not well-formed, syntactically incorrect, or violates schema.","debug_id":"c211b69a1e46d","details":[{"field":"/purchase_units","location":"body","issue":"INVALID_SYNTAX","description":"MALFORMED_REQUEST_JSON"}],"links":[{"href":"https://developer.paypal.com/docs/api/orders/v2/#error-INVALID_SYNTAX","rel":"information_link","encType":"application/json"}]}

kobazzo commented 3 years ago

This is the correct format:

$order = $provider->createOrder([
            "intent"=> "CAPTURE",
            "purchase_units"=> [[
                "amount"=> [
                    "currency_code"=> "EUR",
                    "value"=> "100.00"
                ]
            ]
        ]]);
Faks commented 3 years ago

This is the correct format:

$order = $provider->createOrder([
            "intent"=> "CAPTURE",
            "purchase_units"=> [[
                "amount"=> [
                    "currency_code"=> "EUR",
                    "value"=> "100.00"
                ]
            ]
        ]]);

Yup, that's right you can take original docs and convert JSON (data) to the array and you will have the proper data for the request.

keon99 commented 3 years ago

after I create the order which data response should I redirect? Seem like I unable to find the payment link.

kobazzo commented 3 years ago

This is the response, you can use "rel": "approve" link to redirect the user. This: "href": "https://www.paypal.com/checkoutnow?token=5O190127TN364715T"

{
  "id": "5O190127TN364715T",
  "status": "CREATED",
  "links": [
    {
      "href": "https://api-m.paypal.com/v2/checkout/orders/5O190127TN364715T",
      "rel": "self",
      "method": "GET"
    },
    {
      "href": "https://www.paypal.com/checkoutnow?token=5O190127TN364715T",
      "rel": "approve",
      "method": "GET"
    },
    {
      "href": "https://api-m.paypal.com/v2/checkout/orders/5O190127TN364715T",
      "rel": "update",
      "method": "PATCH"
    },
    {
      "href": "https://api-m.paypal.com/v2/checkout/orders/5O190127TN364715T/capture",
      "rel": "capture",
      "method": "POST"
    }
  ]
}
keon99 commented 3 years ago

Thanks ya

On Mon, 15 Mar 2021 at 5:10 PM, kobazzo @.***> wrote:

This is the response, you can use "rel": "approve" link to redirect the user.

{ "id": "5O190127TN364715T", "status": "CREATED", "links": [ { "href": "https://api-m.paypal.com/v2/checkout/orders/5O190127TN364715T", "rel": "self", "method": "GET" }, { "href": "https://www.paypal.com/checkoutnow?token=5O190127TN364715T", "rel": "approve", "method": "GET" }, { "href": "https://api-m.paypal.com/v2/checkout/orders/5O190127TN364715T", "rel": "update", "method": "PATCH" }, { "href": "https://api-m.paypal.com/v2/checkout/orders/5O190127TN364715T/capture", "rel": "capture", "method": "POST" } ] }

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/srmklive/laravel-paypal/issues/407#issuecomment-799250123, or unsubscribe https://github.com/notifications/unsubscribe-auth/APDUASQV67OGES2UGLOMR2TTDXFJXANCNFSM4XEXRBQA .

kobazzo commented 3 years ago

I managed to complete the payment flow on paypal, but when the user is redirected to my site the paypal request seems to have only two values: PayerID and Token. Where is the order ID? It does not seem to be there but I need it to recover the pending payment and place it in Paid/Completed.

esponges commented 3 years ago

Thanks @Faks for the guidance. It helped me a lot to make this work in my project.

In my case I'm using Laravel for back-end and React as front-end.

This is how my code looks and works right now:


`$this->preparePurchaseUnits` function is simply the array with required body data. You can use as example from PayPal docs this one: https://github.com/paypal/Checkout-PHP-SDK/blob/develop/samples/CaptureIntentExamples/CreateOrder.php

*This route is called via `axios` in my front end in the `createOrder` method.

const createOrder = (data, actions) => { return axios.post('your-route', { data: some-data }, { headers: { 'content-type': 'application/json" }) .then( res => { return res.data.id // $order['id'] from the above response }); };


After this steps, you can proceed to do whatever you want in the `onApprove` and `onCancel` methods.

_***You will have to also do some research by yourself. Dont expect just to copy paste this code and make it work instantly._ 

More info about how to set SPA:

https://developer.paypal.com/docs/business/javascript-sdk/javascript-sdk-reference/
https://developer.paypal.com/demo/checkout/#/pattern/server
mohamedalaa80000 commented 3 years ago

This is the worst package I have seen in my life

gr34tnull commented 3 years ago

It's been months still no official documentation? Even if the community keeps on commenting here, some of us needs the complete and official documentation for this package.

314pi commented 3 years ago

@DeanVanGreunen We are new people, I hope you show us (the simplest one can understand):

  1. Create a checkout button.
  2. Link to the paypal payment page
  3. Get the results Thank you very much, brother!
DeanVanGreunen commented 3 years ago
  1. Create a checkout button.
  2. on the approve method (on the checkout button) just send the order_id, etc info that you need to your backend
  3. then use your access token (via the config)
  4. and query the paypal order api with you access token and order_id, then read the repsonse and work from there.

read this: https://developer.paypal.com/docs/api/orders/v2/#orders_get

On Mon, Mar 29, 2021 at 1:06 PM Pilikeyou @.***> wrote:

@DeanVanGreunen https://github.com/DeanVanGreunen We are new people, I hope you show us (the simplest one can understand):

  1. Create a checkout button.
  2. Link to the paypal payment page
  3. Get the results Thank you very much, brother!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/srmklive/laravel-paypal/issues/407#issuecomment-809290850, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFKDMC4PS4O366JJUQRE443TGBNJVANCNFSM4XEXRBQA .

--

Dean Van Greunen | Senior Software Engineer LinkedIn: deanvangreunen https://www.linkedin.com/in/deanvangreunen/ Mobile: +27663922868 | 0663922868

314pi commented 3 years ago
  1. Create a checkout button. 2. on the approve method (on the checkout button) just send the order_id, etc info that you need to your backend 3. then use your access token (via the config) 4. and query the paypal order api with you access token and order_id, then read the repsonse and work from there. read this: https://developer.paypal.com/docs/api/orders/v2/#orders_get On Mon, Mar 29, 2021 at 1:06 PM Pilikeyou @.**> wrote: @DeanVanGreunen https://github.com/DeanVanGreunen We are new people, I hope you show us (the simplest one can understand): 1. Create a checkout button. 2. Link to the paypal payment page 3. Get the results Thank you very much, brother! — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#407 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFKDMC4PS4O366JJUQRE443TGBNJVANCNFSM4XEXRBQA . -- Dean Van Greunen* | Senior Software Engineer LinkedIn: deanvangreunen https://www.linkedin.com/in/deanvangreunen/ Mobile: +27663922868 | 0663922868

Thanks brother !

esponges commented 3 years ago

What you guys are asking for is a tutorial, not documentation. I don't think it's a good idea to use this package without understading some of the basics of the Paypal SDK, or the PayPal Smart Payment Button, since payments are very sensitive and critical part of the app.

Following this thread, plus the -yeah, short- documentation, along PayPal docs I've been able to make it work. I'm happy that I was forced to do some research in order to be more prepared to deploy correctly the SDK.

By the way, I'm also up to colaborate with the new docs mentioned in this thread.

gr34tnull commented 3 years ago

What you guys are asking for is a tutorial, not documentation. I don't think it's a good idea to use this package without understading some of the basics of the Paypal SDK, or the PayPal Smart Payment Button, since payments are very sensitive and critical part of the app.

Following this thread, plus the -yeah, short- documentation, along PayPal docs I've been able to make it work. I'm happy that I was forced to do some research in order to be more prepared to deploy correctly the SDK.

By the way, I'm also up to colaborate with the new docs mentioned in this thread.

Tutorial = Documentation, Documentation = Tutorial, How would you create, use and customize any code if you do not have the right knowledge you seek of using the said package? The users, specially the junior devs who wants to use the LATEST package wants to know how it works, what functions to call, etc., and they want to see it in an OFFICIAL Documentation, not here on threads, because if we wanted to just read the threads we could have just followed something that can be seen in stack overflow and wouldn't bother the creator of the package anymore., To all who comments and would like to answer this thread, I get that I could have just used the documentation from paypal dev, and I already did and use that instead, but this Issue is not related to Paypal dev but is related to THIS PACKAGE, it would be a waste not to use this package who works well in its previous iterations, AGAIN what we want is an official DOCUMENTAION for THIS package, the LATEST VERSION. This goes to all. I hope the creator of this package answers again.

esponges commented 3 years ago

What you guys are asking for is a tutorial, not documentation. I don't think it's a good idea to use this package without understading some of the basics of the Paypal SDK, or the PayPal Smart Payment Button, since payments are very sensitive and critical part of the app. Following this thread, plus the -yeah, short- documentation, along PayPal docs I've been able to make it work. I'm happy that I was forced to do some research in order to be more prepared to deploy correctly the SDK. By the way, I'm also up to colaborate with the new docs mentioned in this thread.

Tutorial = Documentation, Documentation = Tutorial, How would you create, use and customize any code if you do not have the right knowledge you seek of using the said package? The users, specially the junior devs who wants to use the LATEST package wants to know how it works, what functions to call, etc., and they want to see it in an OFFICIAL Documentation, not here on threads, because if we wanted to just read the threads we could have just followed something that can be seen in stack overflow and wouldn't bother the creator of the package anymore., To all who comments and would like to answer this thread, I get that I could have just used the documentation from paypal dev, and I already did and use that instead, but this Issue is not related to Paypal dev but is related to THIS PACKAGE, it would be a waste not to use this package who works well in its previous iterations, AGAIN what we want is an official DOCUMENTAION for THIS package, the LATEST VERSION. This goes to all. I hope the creator of this package answers again.

I understand your frustration. But we all know that a tutorial -yeah, those from youtube and medium- are not the same than Documentation. Most of the documenation is for a general use of the package. You don't get guided step by step by stuff that are not from the package itself. If it was the case, the documenation would have to cover all the PayPal Smart Button setup, which is also a bunch of detail and it depends very much of the front end that you are using.

In this case, we don't even have that, but we can't force anyone to do anything when nobody is paying a dime for this package. This is a shame, since I'm certain that this package would be widely more adopted if it had a decent documentation. I'm my case, I'm happy that I had to be forced to dig in by myself, since that made me be aware of possible issues that might arise and build the code accordingly.

gr34tnull commented 3 years ago

What you guys are asking for is a tutorial, not documentation. I don't think it's a good idea to use this package without understading some of the basics of the Paypal SDK, or the PayPal Smart Payment Button, since payments are very sensitive and critical part of the app. Following this thread, plus the -yeah, short- documentation, along PayPal docs I've been able to make it work. I'm happy that I was forced to do some research in order to be more prepared to deploy correctly the SDK. By the way, I'm also up to colaborate with the new docs mentioned in this thread.

Tutorial = Documentation, Documentation = Tutorial, How would you create, use and customize any code if you do not have the right knowledge you seek of using the said package? The users, specially the junior devs who wants to use the LATEST package wants to know how it works, what functions to call, etc., and they want to see it in an OFFICIAL Documentation, not here on threads, because if we wanted to just read the threads we could have just followed something that can be seen in stack overflow and wouldn't bother the creator of the package anymore., To all who comments and would like to answer this thread, I get that I could have just used the documentation from paypal dev, and I already did and use that instead, but this Issue is not related to Paypal dev but is related to THIS PACKAGE, it would be a waste not to use this package who works well in its previous iterations, AGAIN what we want is an official DOCUMENTAION for THIS package, the LATEST VERSION. This goes to all. I hope the creator of this package answers again.

I understand your frustration. But we all know that a tutorial -yeah, those from youtube and medium- are not the same than Documentation. Most of the documenation is for a general use of the package. You don't get guided step by step by stuff that are not from the package itself. If it was the case, the documenation would have to cover all the PayPal Smart Button setup, which is also a bunch of detail and it depends very much of the front end that you are using.

In this case, we don't even have that, but we can't force anyone to do anything when nobody is paying a dime for this package. This is a shame, since I'm certain that this package would be widely more adopted if it had a decent documentation. I'm my case, I'm happy that I had to be forced to dig in by myself, since that made me be aware of possible issues that might arise and build the code accordingly.

I understand that and I am sorry if I came up frustrated, actually, I am not frustrated with the creator of this package, I understand that he has a lot of work to do on his own, so is everyone else, what frustrates me is the people answering this thread that does not concern/answers the issue, the main issue here is that this package doesn't have its OFFICIAL DOCUMENTATION, so if it's not related to that I hope everyone would not comment on this issue because this thread is addressed directly to the creator and its collaborators. Reading along the thread with a lot of unnecessary comments confuses those who seek answers to the main issue, which again is the OFFICIAL DOCUMENTATION. I respect the creator of this package and he can take as much time as he wants, all I am doing is monitoring this thread so that he could give an update when he already has the OFFICIAL DOCUMENTATION for this package. Thanks.

gr34tnull commented 3 years ago

I do hope that soon the creator would provide proper documentation for the USAGE of this package. That all is being asked for this thread, I hope I do not sound demanding or anything, I'm a big fan of this package and I hope the USAGE will be updated on the OFFICIAL DOCUMENTATION, and I hope it doesn't confuse the people answering this thread to provide tutorials or provide outdated links from the previous versions of this package, the package in question here is the 3rd version, and as you can see on the official documentation it hasn't been updated yet, and yes, I could just create my own custom PayPal button, I get that, and thats what I am doing with my current projects, but as a fan of this package, I just want the documentation to be properly updated. Nothing wrong with that. Cheers to everyone.

shankhadevpadam commented 3 years ago

There is no proper example for express checkout in v3. So I reverted back to v1.

yob-yob commented 3 years ago

@srmklive @DeanVanGreunen @JexPY any news on the docs?

to all those who are planning to use v1 or v2, you should not, it's not advisable, there's a reason why v3 exists. v3 is built to support the latest version of PayPal's REST API.

srmklive commented 3 years ago

@yob-yob @gr34tnull @DeanVanGreunen @JexPY @farshadff

The documentation can be found at the following link:

https://srmklive.github.io/laravel-paypal/docs.html

Please note this is under progress. I will gradually add items over the week.

lovecoding-git commented 3 years ago

@srmklive Thank you!

shankhadevpadam commented 3 years ago

@srmklive can you make some proper use case example or demo. so it is easy to implement.

gorge2004 commented 3 years ago

hello how to notifyl_url ? how do i confirm payment?

keon99 commented 3 years ago

Anyone encounter live credential getAccessToken method success rate only 1/3 and usually get errors cURL error 28: Failed to connect to api.paypal.com port 443: Timed out (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://api.paypal.com/v1/oauth2/token

robertholf commented 3 years ago

Hello everyone, I hope this is useful:

NOTE: The "Enrollment" model is application specific to me, you can ignore the enrollment thing but i needed to store the token somewhere and determine if they paid or not.

    public function paymentProcess()
    {
        // Check if User has Enrollment
        $enrollment = Enrollment::where('user_id', auth()->id())->firstOrCreate(['user_id' => auth()->id()]);

        // Init PayPal
        $provider = \PayPal::setProvider();
        $provider->setApiCredentials(config('paypal')); // Pull values from Config
        $token = $provider->getAccessToken();
        $provider->setAccessToken($token);

        // Prepare Order
        $order = $provider->createOrder([
            'intent'=> 'CAPTURE',
            'purchase_units'=> [[
                'reference_id' => 'transaction_test_number'. $enrollment->id,
                'amount'=> [
                  'currency_code'=> 'USD',
                  'value'=> '20.00'
                ]
            ]],
            'application_context' => [
                 'cancel_url' => 'http://myproject.test/dashboard/payment/cancel',
                 'return_url' => 'http://myproject.test/dashboard/payment/success'
            ]
        ]);

        // Store Token so we can retrieve after PayPal sends them back to us
        $enrollment->payment_transaction = $order['id'];
        $enrollment->save();

        // Send user to PayPal to confirm payment
        return redirect($order['links'][1]['href'])->send();

@srmklive what is missing from the documentation is the application_context which i found by reviewing: https://github.com/paypal/Checkout-PHP-SDK#code

            'application_context' => [
                 'cancel_url' => 'http://myproject.test/dashboard/payment/cancel',
                 'return_url' => 'http://myproject.test/dashboard/payment/success'
            ]

Then on the Payment Success (the return URL)

    public function paymentSuccess() {
        // Check if User has Enrollment
        $enrollment = Enrollment::where('user_id', auth()->id())->firstOrCreate(['user_id' => auth()->id()]);

        // Init PayPal 
        $provider = \PayPal::setProvider();
        $provider->setApiCredentials(config('paypal'));
        $token = $provider->getAccessToken();
        $provider->setAccessToken($token);

        // Get PaymentOrder using our transaction ID
        $order = $provider->capturePaymentOrder($enrollment->payment_transaction);

        // Save that payment was made (example)
        $enrollment->payment_at = Carbon::now();
        $enrollment->save();

        // Return Redirect
        return redirect()->route('my.route.to.dashboard')->withFlashSuccess('Payment Confirmed!');
    }
shankhadevpadam commented 3 years ago

@robertholf

// Send user to PayPal to confirm payment
return redirect($order['links'][1]['href']);

Should be

return redirect($order['links'][1]['href'])->send();

Otherwise, you get 302 HTTP notice while redirecting.