Git Product home page Git Product logo

Comments (7)

bjguillot avatar bjguillot commented on August 16, 2024

There are several different workflows that you could use.

The simplest to implement is to set the $requestParameters['capture_now'] line in Apicalls/ConfirmAndAuthorize.php to true (instead of false).

Setting capture_now to true will attempt to collect payment at the same time as the authorization. This is generally only recommended for digital goods. The best practice for physical goods is to perform the capture of funds immediately prior to shipping the goods to the buyer.

Try that and let us know if it works.

from amazon-pay-sdk-samples.

tarishah avatar tarishah commented on August 16, 2024

As per bjguillot's comment, if you are selling physical goods, you may want to capture funds prior to shipping the goods. Below code sample is something you can add on your end.
This demonstrates Auth and Capture call-

// If the API call was a success make the Authorize API call
if($client->success)
{
$requestParameters['authorization_amount'] = '1.00';
$requestParameters['authorization_reference_id'] = 'Your Unique Reference Id';
$requestParameters['seller_authorization_note'] = 'Authorizing payment';
$requestParameters['transaction_timeout'] = 0;

$response = $client->authorize($requestParameters);
$responsearray['authorize'] = json_decode($response->toJson());

}

// If the Authorize API call was a success, make the Capture API call when you are ready to capture for the order (for example when the order has been dispatched)
if($client->success)
{
$requestParameters['amazon_authorization_id'] = 'Parse the Authorize Response for this id';
$requestParameters['capture_amount'] = '1.00';
$requestParameters['currency_code'] = 'USD';
$requestParameters['capture_reference_id'] = 'Your Unique Reference Id';

$response = $client->capture($requestParameters);
$responsearray['capture'] = json_decode($response->toJson());

}

You can find the above code here- https://amzn.github.io/login-and-pay-with-amazon-sdk-samples/simple.html

Steps- Please login with your test account and click place order. Scroll down to see the sample API calls in PHP.

from amazon-pay-sdk-samples.

webprogrammierer avatar webprogrammierer commented on August 16, 2024

Thank you.
If have set capture_now to true and now it works fine.
And yes, I have digital goods.

from amazon-pay-sdk-samples.

bjguillot avatar bjguillot commented on August 16, 2024

OK, great. I'll go ahead and close your issue then. Thanks for using Amazon Pay.

from amazon-pay-sdk-samples.

webprogrammierer avatar webprogrammierer commented on August 16, 2024

One additional question:

After capture has be done I want to close the order. But I can't find any CloseOrderReference() function call in your example code "SampleCartDemo" - "OneTimePayments".

Can you tell me where in the source code of your example code and how to close the order?
Thank you.

from amazon-pay-sdk-samples.

bjguillot avatar bjguillot commented on August 16, 2024

Below I have pasted some PHP example code to close an order reference. It assumes that your $client is ready and that $orderReference has your S0n-xxx-xxx or P0n-xxx-xxx order reference.

    $configArray = [
            'amazon_order_reference_id' => $orderReference,
            'closure_reason' => 'For Merchant use only, never shown to buyer'];
    $response = $client->closeOrderReference($configArray)->toArray();
    if ($response['ResponseStatus'] != 200)
            print "Error Occurred!\n";
    else
            print "Order Reference Closed\n";

from amazon-pay-sdk-samples.

webprogrammierer avatar webprogrammierer commented on August 16, 2024

Thank you.
Where can I put this code into? ConfirmPaymentAndAuthorize.php?

from amazon-pay-sdk-samples.

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.