--------------------------------------------------------------

--------------------------------------------------------------

Created : 12 April 2017
Last Modified : 19 Mar 2020

***********************************************************************************
Contents:

A. SUMMARY
B. FILE STRUCTURE
C. INSTALLATION INSTRUCTION
D. HOW IT WORKS
E. FILE NEED TO BE MODIFIED
F. CONFIGURATION SETTINGS
G. DATABASE TABLES MODIFIED
H. LANGUAGE SETTINGS CHANGED
I. CHANGE LOGS
J. TROUBLESHOOTING
K. COPYRIGHT NOTICE
L. TERMS AND CONDITIONS
***********************************************************************************

A. SUMMARY
==========
This interface is for use with Amazon Pay Payment Service.
It is supporting both normal checkout and onepage checkout.

***********************************************************************************

B. FILE STRUCTURE
===================

Files included in the zip are:
- $READ_ME_FIRST_amazonpay900.html
- sha256.wsc
- shopamazonpay_subs.asp
- shopamazonpay_checkout.asp
- shopamazonpay_config.asp
- shopamazonpay_execute.asp
- shopamazonpay_login.asp
- shopamazonpay_payment.asp
- admin\amazonpay_setup.asp
- admin\amazonpay_setup_config.asp
- admin\amazonpay_setup_process.asp
- admin\sqlscripts\amazonpay\*

***********************************************************************************

C. INSTALLATION INSTRUCTION
============================

1. Upload below files to VPCart root folder.
     - shopamazonpay_subs.asp
     - shopamazonpay_checkout.asp
     - shopamazonpay_config.asp
     - shopamazonpay_execute.asp
     - shopamazonpay_login.asp
     - shopamazonpay_payment.asp

1a. Upload below files to your ADMIN folder. If you have renamed your ADMIN folder, then this must be placed in the       renamed folder.
- admin\amazonpay_setup.asp
- admin\amazonpay_setup_config.asp
- admin\amazonpay_setup_process.asp
- admin\sqlscripts\amazonpay\*

2. Please download the files below from your server via FTP and follow the instructions below to modify the files.
- shoponepagecheckout.asp
- shoponepagecheckout_payment_subs.asp
- js/checkout/onepagecheckout.js

2.1 Open the file shoponepagecheckout.asp with your favorite editor and
2.1a. Locate sub validatepaymentmethod routine, add this code below case "paypal":

case "amazonpay"

It should look like this:

case "paypal"
case "amazonpay"

Next, locate this code below inside sub gatewayaction_onepage routine:

case "paypal"
responseredirect "paypal_process.asp"
Below it, please insert:

case "amazonpay"
%> <script type='text/javascript'>
window.top.location="shopamazonpay_login.asp";
</script>
<%
response.end

It should look like this one:

case "paypal"
responseredirect "paypal_process.asp"
case "amazonpay"
%> <script type='text/javascript'>
window.top.location="shopamazonpay_login.asp";
</script>
<%
response.end
end select

2.1b. Save the file

2.2 Open the file shoponepagecheckout_payment_subs.asp with your favorite editor and
2.2a. Locate to last line and before %>, and insert below line:

sub create_onepage_amazonpay_wrapper (idname, passdesc, passvalue)
dim displaystr
displaystr = "style=""display:none;"""
if lcase(passvalue) <> "" then
displaystr = ""
end if
htmlwrite "<div "& displaystr &" id="""& idname &""">"
response.write passdesc
htmlwrite "</div>"
end sub

Next, inside sub display_onepage_payment_section routine, locate this code (approx line 32-35):

if lcase(GetConfig("xpaypal")) = "yes" then
create_onepage_radio getlang("langcommonpaypal"), "payment_method", "payment_method_paypal", "paypal", paypalstr
create_onepage_paypal_wrapper "paypal_desc_wrapper", getlang("langpaypalonepage_desc"), paypalstr
end if

BELOW the code, please insert :

if lcase(GetConfig("xamazonpay")) = "yes" then
create_onepage_radio getlang("langamazonpay"), "payment_method", "payment_method_amazon", "amazonpay", paypalstr
create_onepage_amazonpay_wrapper "amazonpay_desc_wrapper", getlang("langamazonpayonepage_desc"), paypalstr
end if

It should look like this:

if lcase(GetConfig("xpaypal")) = "yes" then
create_onepage_radio getlang("langcommonpaypal"), "payment_method", "payment_method_paypal", "paypal", paypalstr
create_onepage_paypal_wrapper "paypal_desc_wrapper", getlang("langpaypalonepage_desc"), paypalstr
end if
if lcase(GetConfig("xamazonpay")) = "yes" then
create_onepage_radio getlang("langamazonpay"), "payment_method", "payment_method_amazon", "amazonpay", paypalstr
create_onepage_amazonpay_wrapper "amazonpay_desc_wrapper", getlang("langamazonpayonepage_desc"), paypalstr
end if

2.2b. Save the file

2.2c. Open the file plugins/checkout/onepagecheckout.js with your favorite editor
2.2d. Locate code below (approx line 199) :

if ($(this).attr('id') == 'payment_method_other') {

BEFORE the code, please insert this code:

if( $(this).attr('id') == 'payment_method_amazon'){
$('#otherpayment_wrapper').hide();
$('#creditcard_desc_wrapper').hide();
$('#paypal_desc_wrapper').hide();
$('#amazonpay_desc_wrapper').show();
}


2.2e. Locate this code (approx line 189):

$('#paypal_desc_wrapper').show();

Below that, please insert:

$('#amazonpay_desc_wrapper').hide();

Locate this code (Approx line 213):

$('#otherpayment_wrapper').show();

BELOW that, please insert:

$('#amazonpay_desc_wrapper').hide();

Locate this code (Approx line 228):

$('#creditcard_desc_wrapper').show();

BELOW that, please insert:

$('#amazonpay_desc_wrapper').hide();

2.2f. Save the file

3. Upload all amended files above to your server.

4. Log into super admin and execute setup file amazonpay_setup.asp, eg: http://www.yourdomain.com/youradminfolder/amazonpay_setup.asp

Note: Replace url section with your VPCart site url values:
{ www.yourdomain.com } : your site domain
{ youradminfolder } : your admin folder

5. After setup the module, would be redirected to Module configuration page to configure the module.

NOTE:
you will need to access your amazon seller account page admin to get API keys ( https://sellercentral.amazon.com/hz/me/integration/details )

follow the steps to in order to get the api key:

1. In https://sellercentral.amazon.com/gp/homepage.html, select the Production View or Sandbox View option that on the left most field in top right corner of the page.

2. Hover on the Integration menu on the top left corner of the page. look for MWS Access Key and click.

also, you need to put your site domain as value for in Web Settings : Allowed Javascript Origin value in login with amazon (located at the top right dropdown of the amazon seller account after you logged in).

To get this done, follow these steps:

1. https://sellercentral.amazon.com/gp/homepage.html, select the Login with Amazon option that on the left most field in top right corner of the page and click.

2. Locate the Web Settings Section and click edit button.

3. Locate Allowed JavaScript Origins section and click add another option.

4. paste your root domain here. It should be in https domain value.

eg: https://yourdomain.com

5. click save button


***********************************************************************************

D. HOW IT WORKS
===============

On the checkout page (normal checkout and onepage checkout), Amazon Pay gateway will be displayed as an option if Amazon Pay is activated from Modules Manager.
Customers can now checkout and pay through their Amazon Pay account.

***********************************************************************************

E. FILE NEED TO BE MODIFIED
=================

    - shoponepagecheckout.asp
    - shoponepagecheckout_payment_subs.asp
    - js/checkout/onpeagecheckout.js

***********************************************************************************

F. CONFIGURATION SETTINGS
=================

New configs :
xamazonpay
xamazonp_merchantid
xamazonp_secretkey
xamazonp_accesskey
xamazonp_clientid
xamazonp_region
xamazonp_sandbox

***********************************************************************************

G. DATABASE TABLES MODIFIED
===========================

NONE

***********************************************************************************

H. LANGUAGE SETTINGS CHANGED
============================

ADDED:
langamazonpay
langamazonpayonepage_desc

***********************************************************************************

I. CHANGE LOGS
============================

NONE

***********************************************************************************

J. TROUBLESHOOTING
============================

1. Why did the module not working fail?
Please make sure you've entered the correct configuration values and put correct domain value field in your amazon seller account : login with amazon, Allowed JavaScript Origins section.

2. Amazonpay gateway still does not work !
Please submit a ticket to our helpdesk at https://helpdesk.vpcart.com and our support team will assist you.

***********************************************************************************
K. COPYRIGHT NOTICE
============================

Copyright (c) 1999-2020 Rocksalt International Pty. Ltd.
All rights reserved.

This software and documentation constitute a published work and
contains valuable trade secrets and proprietary information
belonging to Rocksalt International Pty. Ltd. .
None of the foregoing material may be copied,
duplicated or disclosed without the express written permission
of Rocksalt International Pty. Ltd. .

LICENSEE ACCEPTS VP-ASP Shopping Cart "AS IS" "WITH ALL FAULTS",
Rocksalt International Pty. Ltd. accepts no responsibility for the
operation or performance of the VP-ASP Shopping Cart.
The entire risk of use and consequences of use of the
VP-ASP Shopping Cart falls completely on the Licensee
and Rocksalt International Pty. Ltd. shall not be liable in any respect
for any claims, loss or injury alleged to have resulted
from use of or in reliance on VP-ASP Shopping Cart.

Licensee acknowledges that it has read the foregoing
disclaimers of warranty and limitation of liability
and understands that Licensee assumes
the entire risk of using VP-ASP Shopping Cart.


***********************************************************************************

L. TERMS AND CONDITIONS
============================
ROCKSALT INTERNATIONAL GRANTS TO THE LICENSEE A NON-EXCLUSIVE,
NON-SUB LICENSABLE, NONTRANSFERABLE LICENSE
TO INSTALL AND USE THIS APPLICATION ON A SINGLE DOMAIN FOR
A SINGLE SHOP.

THE CODE IN THE APPLICATION MAY BE MODIFIED FOR USE IN
SETTING UP A SINGLE SHOPPING SITE ON THE WORLD WIDE WEB.

LICENSEE MAY MAKE A COPY OF THE APPLICATION FOR
BACK-UP AND ARCHIVAL PURPOSES, PROVIDED THAT ANY COPY
MUST CONTAIN ALL PROPRIETARY NOTICES INCLUDED
WITH THE APPLICATION.

LICENSEE IS PROHIBITED FROM SELLING OR DISTRIBUTING
THE APPLICATION IN ANY MANNER.

LIMITATION OF LIABILITY.

ROCKSALT INTERNATIONAL AND ITS LICENSORS SHALL
NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE OR ANY
THIRD PARTY AS A RESULT OF USING OR DISTRIBUTING THIS
APPLICATION.

IN NO EVENT WILL ROCKSALT INTERNATIONAL OR ITS LICENSORS
BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA,
OR FOR DIRECT, INDIRECT, SPECIAL,
CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES,
HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LI
ARISING OUT OF THE USE OF OR INABILITY TO USE THE SOFTWARE,
EVEN IF ROCKSALT INTERNATIONAL HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.