Giter Club home page Giter Club logo

Comments (1)

akDeveloper avatar akDeveloper commented on September 21, 2024

Paypal gives you information about what and when to execute a method.

  1. You need to setup an authorize or purchase action. Lets say purchase ok? You need the amount of transaction and 2 urls from your site. In my example is:
    $response = $gateway->setup_purchase($_POST['amount'], array(
      'return_url' => 'http://localhost/merchant/test/paypal_express/index.php',
      'cancel_return_url' => 'http://localhost/merchant/test/paypal_express/index.php?cancel=1',
      )
    );

return_url: the url for success transaction
cancel_url: url to return if customer press cancel on paypal site.

  1. setup_purchase will generate the necessary token and the url to redirect your customer.
die ( header('Location: '. $gateway->url_for_token( $response->token() )) );

Also paypal will sent you some info. make a var_dump to $response or

Merchant_Logger::print_ar($response);

to see additions fields from response.

  1. Your customer pays on paypal site, and paypal will return to your site via return url you send in step 1.
    Now you execute the method:
$response = $gateway->get_details_for( $_GET['token'], $_GET['PayerID']);

Again must see the fields you need from response with

Merchant_Logger::print_ar($response);
.

Gather what you want and proceed to the final transaction.

  1. Final transaction:
$response = $gateway->purchase($response->amount());

Check if it is success via

$response->success() == true; 

from aktive-merchant.

Related Issues (20)

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.