Comments (7)
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.
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.
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.
OK, great. I'll go ahead and close your issue then. Thanks for using Amazon Pay.
from amazon-pay-sdk-samples.
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.
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.
Thank you.
Where can I put this code into? ConfirmPaymentAndAuthorize.php?
from amazon-pay-sdk-samples.
Related Issues (20)
- Remove all unnecessary JavaScript and use PHP instead of it HOT 3
- CSharp example has issue HOT 1
- login window not appearing in popup (despite being set to true) HOT 4
- Python: incorrect `redirect_url`? HOT 1
- Java: Missing closing curly brace in OneTimePayments/Widgets.js, line 132 HOT 1
- C# Sample doesn't show live responses HOT 1
- Button and other widgets for React HOT 3
- Transactions from made from a billing agreement should return the billing agreement id HOT 2
- Login with Amazon callback/event if popup is closed HOT 4
- Wallet Widget error: InvalidOrderReferenceId - The OrderReferenceID is invalid. HOT 1
- Amazon Pay Strong Customer Authentication (SCA) Upgrade HOT 9
- Update Fork Link
- Can not callback when clicked the consent widgets ( throw error 400 bad request ) in PHP example recurring payment HOT 8
- devlop code in android
- The Wallet widget should use the Address Book's order reference Id HOT 2
- Amazon Pay Strong Customer Authentication (SCA) example code for PHP
- Python -recurring payment - Access to OffAmazonPayments_Sandbox.ConfirmBillingAgreement is denied
- Recurring payment frequency
- Seller Details not provided HOT 3
- Error handling code HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from amazon-pay-sdk-samples.