﻿// JScript 文件

function paypal(config)
{
    var obj = config;
    obj.business= "ssegold4u@gmail.com";                  //商户
    
    obj.cancle_return = "http://www.ssegold.com";                   //支付取消后的页面
    obj.notify_url = "http://www.ssegames.com/ipn/ipntriger.aspx";  //通知地址
    obj.cpp_header_image = "http://www.ssegold.com/images/pp_logo.jpg";     //公司logo地址
    
    obj.rm = 2;                                                             //返回类别
    payToPaypal(obj);
}
function payToPaypal(config)
//function MfcreateFormAndSubmit(item_name,amount,currency_code)
{
    var submitForm = getNewSubmitForm("Paypalform");
    createNewFormElement(submitForm, "cmd", "_xclick");         //固定的
    createNewFormElement(submitForm,"return","http://www.ssegold.com/AccountBuy.aspx"); //支付成功后的反馈页面
    for(var name in config)
    {
        createNewFormElement(submitForm,name,config[name]); 
    }
    //submitForm.action= "https://www.sandbox.paypal.com/cgi-bin/webscr";
    submitForm.action= "https://www.paypal.com/cgi-bin/webscr?locale.x=en_GB";
    
    submitForm.submit();   
}
function moneybooks(config)
{
    config.pay_to_email = "moneybookersok@gmail.com";
    config.status_url = "moneybookersok@gmail.com";
    config.language = "EN";
    config.detail1_description = "account";
    payToMoneyBooks(config);
}
function payToMoneyBooks(config)
{

    var submitForm = getNewSubmitForm("Paypalform");
    for(var name in config)
    {
        createNewFormElement(submitForm,name,config[name]); 
    }
    submitForm.action= "https://www.moneybookers.com/app/payment.pl";
    submitForm.submit();
}
function getNewSubmitForm(sid)
{            
    var submitForm = document.createElement("FORM");
    document.body.appendChild(submitForm);
    submitForm.id=sid;                                
    submitForm.method = "POST";               
    submitForm.target="_self";
    return submitForm;
}
   
function createNewFormElement(inputForm, elementName, elementValue)
{

     var newElement = document.createElement("input");

     newElement.name = elementName;

     newElement.type ="hidden";

     newElement.value = elementValue;

     inputForm.appendChild(newElement);

     return newElement;
}
