paypal-wrapper
Advanced tools
Comparing version
{ | ||
"name": "paypal-wrapper", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "Paypal REST API Wrapper", | ||
@@ -5,0 +5,0 @@ "main": "paypalwrapper.js", |
@@ -42,5 +42,8 @@ ((paypalWrapper, request)=>{ | ||
buildPayerObjPaypal : ()=>{ | ||
buildPayerObjPaypal : (email)=>{ | ||
return { | ||
"payment_method": "paypal" | ||
"payment_method": "paypal", | ||
"payer_info": { | ||
"email": email | ||
} | ||
}; | ||
@@ -341,2 +344,268 @@ }, | ||
paypalWrapper.billingplans = { | ||
buildChargeModelObj : (type, amount, value, currency)=>{ | ||
return { | ||
"type": type, | ||
"amount": { | ||
"value": value, | ||
"currency": currency | ||
} | ||
}; | ||
}, | ||
buikdPaymentDef : (name, type, frequency, interval, amount, currency, cycles, chargeModelsArray)=>{ | ||
return { | ||
"name": name, | ||
"type": type, | ||
"frequency": frequency, | ||
"frequency_interval": interval, | ||
"amount": { | ||
"value": amount, | ||
"currency": currency | ||
}, | ||
"cycles": cycles, | ||
"charge_models": chargeModelsArray | ||
}; | ||
}, | ||
buildBillingPlanObj : (name, descript, type, paymentDefsArray, merchantPrefsObj, setupFee, currency, | ||
returnUrl, cancelUrl, autobill, initFailAction, maxFail)=>{ | ||
return { | ||
"name": name, | ||
"description": descript, | ||
"type": type, | ||
"payment_definitions": paymentDefsArray, | ||
"merchant_preferences": { | ||
"setup_fee": { | ||
"value": setupFee, | ||
"currency": currency | ||
}, | ||
"return_url": returnUrl, | ||
"cancel_url": cancelUrl, | ||
"auto_bill_amount": autobill, | ||
"initial_fail_amount_action": initFailAction, | ||
"max_fail_attempts": maxFail | ||
} | ||
}; | ||
}, | ||
buildOpsObjReplace : (prop, valueObj)=>{ | ||
return { | ||
"op": "replace", | ||
"path": prop, | ||
"value": valueObj | ||
}; | ||
}, | ||
create : (billingPlanOBj, cb)=>{ | ||
var path = ""; | ||
var headers = { }; | ||
var body = billingPlanOBj; | ||
AJAX(path, "POST", headers, body, cb); | ||
}, | ||
update : (opsArray, cb)=>{ | ||
var path = "/v1/payments/billing-plans/plan-id"; | ||
var headers = { }; | ||
var body = opsArray; | ||
AJAX(path, "PATCH", headers, body, cb); | ||
}, | ||
details : (planID, cb)=>{ | ||
var path = "/v1/payments/billing-plans/" + planID; | ||
var headers = { }; | ||
var body = undefined; | ||
AJAX(path, "GET", headers, body, cb); | ||
}, | ||
list : (cb, queryString)=>{ | ||
var path = "/v1/payments/billing-plans"; | ||
if(queryString !== undefined){ | ||
path += "?" + queryString; | ||
} | ||
var headers = { }; | ||
var body = undefined; | ||
AJAX(path, "GET", headers, body, cb); | ||
}, | ||
}; | ||
paypalWrapper.billingagreements = { | ||
buildBillingAgreementPlanObj : (planID, name, descript, type)=>{ | ||
return { | ||
"id": planID, | ||
"name": name, | ||
"description": descript, | ||
"type": type | ||
}; | ||
}, | ||
buildBillingAgreementChargeModelObj : (chargeID, amount, currency)=>{ | ||
return { | ||
"charge_id": chargeID, | ||
"amount": { | ||
"value": amount, | ||
"currency": currency | ||
} | ||
}; | ||
}, | ||
buildBillingAgreementObj : (name, descript, startDate, payerObj, planObj, shippingObj, | ||
setupFee, currency, returnUrl, cancelUrl, autobill, initialFailAction, | ||
maxFail, chargeModelsArray)=>{ | ||
return { | ||
"name": name, | ||
"description": descript, | ||
"start_date": startDate, | ||
"payer": payerObj, | ||
"plan": planObj, | ||
"shipping_address": shippingObj, | ||
"override_merchant_preferences": { | ||
"setup_fee": { | ||
"value": setupFee, | ||
"currency": currency | ||
}, | ||
"return_url": returnUrl, | ||
"cancel_url": cancelUrl, | ||
"auto_bill_amount": autobill, | ||
"initial_fail_amount_action": initialFailAction, | ||
"max_fail_attempts": maxFail | ||
}, | ||
"override_charge_models": chargeModelsArray | ||
}; | ||
}, | ||
buildUpdateObj : (valueObj)=>{ | ||
return { | ||
"op": "replace", | ||
"path": "/", | ||
"value": valueObj | ||
}; | ||
}, | ||
create : (billingAgreementObj, cb)=>{ | ||
var path = "/v1/payments/billing-agreements"; | ||
var headers = { }; | ||
var body = billingAgreementObj; | ||
AJAX(path, "POST", headers, body, cb); | ||
}, | ||
update : (agreementID, updateOpArray, cb)=>{ | ||
var path = "/v1/payments/billing-agreements/" + agreementID; | ||
var headers = { }; | ||
var body = updateOpArray; | ||
AJAX(path, "PATCH", headers, body, cb); | ||
}, | ||
find : (agreementID, cb)=>{ | ||
var path = "/v1/payments/billing-agreements/" + agreementID; | ||
var headers = { }; | ||
var body = undefined; | ||
AJAX(path, "GET", headers, body, cb); | ||
}, | ||
balance : (agreementID, note, amount, currency,cb)=>{ | ||
var path = "/v1/payments/billing-agreements/" + agreementID + "/bill-balance"; | ||
var headers = { }; | ||
var body = { | ||
"note": note, | ||
"amount": { | ||
"value": amount, | ||
"currency": currency | ||
} | ||
}; | ||
AJAX(path, "POST", headers, body, cb); | ||
}, | ||
cancel : (agreementID, note, cb)=>{ | ||
var path = "/v1/payments/billing-agreements/" + agreementID + "/cancel"; | ||
var headers = { }; | ||
var body = { | ||
note: note | ||
}; | ||
AJAX(path, "POST", headers, body, cb); | ||
}, | ||
reactivate: (agreementID, note, cb)=>{ | ||
var path = "/v1/payments/billing-agreements/" + agreementID + "/re-activate"; | ||
var headers = { }; | ||
var body = { | ||
note : note | ||
}; | ||
AJAX(path, "POST", headers, body, cb); | ||
}, | ||
setbalance : (agreementID, amount, currency, cb)=>{ | ||
var path = "/v1/payments/billing-agreements/agreement_id/set-balance"; | ||
var headers = { }; | ||
var body = { | ||
"value": amount, | ||
"currency": currency | ||
}; | ||
AJAX(path, "POST", headers, body, cb); | ||
}, | ||
suspend : (agreementID, note, cb)=>{ | ||
var path = "/v1/payments/billing-agreements/agreement_id/suspend"; | ||
var headers = { }; | ||
var body = { | ||
note: note | ||
}; | ||
AJAX(path, "POST", headers, body, cb); | ||
}, | ||
listtransactions : (agreementID, cb, queryString)=>{ | ||
var path = "/v1/payments/billing-agreements/" + agreementID + "/transactions"; | ||
if(queryString !== undefined){ | ||
path += "?" + queryString; | ||
} | ||
var headers = { }; | ||
var body = undefined; | ||
AJAX(path, "GET", headers, body, cb); | ||
}, | ||
execute : (paymentToken, cb)=>{ | ||
var path = "/v1/payments/billing-agreements/" + paymentToken + "/agreement-execute"; | ||
var headers = { }; | ||
var body = undefined; | ||
AJAX(path, "POST", headers, body, cb); | ||
}, | ||
}; | ||
}) | ||
@@ -343,0 +612,0 @@ ( |
14470
80.6%469
81.08%