-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from AltaPay/agreement_engine_and_apple_pay
support agreement parameters & new endpoints for Apple Pay
- Loading branch information
Showing
20 changed files
with
284 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
load('tests/basetest.js'); | ||
|
||
var factory = new RhinoAltaPayFactory(new AltaPayFactory()); | ||
|
||
var mapi = factory.getMerchantApi('shop api', 'testpassword', 'https://testgateway.altapaysecure.com'); | ||
|
||
var request = factory.getPaymentRequest(); | ||
request.terminal = 'AltaPay Test Terminal'; | ||
request.shopOrderid = "JS_AUI_simple_create_payment_"+makeid(16); | ||
request.amount = '700'; | ||
request.currency = 'DKK'; | ||
request.type = AuthType.subscription; | ||
var agreementConfig = factory.getAgreementConfig(); | ||
agreementConfig.agreementType = AgreementType.unscheduled; | ||
agreementConfig.agreementUnscheduledType = AgreementUnscheduledType.incremental; | ||
request.agreementConfig = agreementConfig; | ||
var response = mapi.createPaymentRequest(request); | ||
if(response.success()==true){ | ||
console.log("SimpleCreatePaymentRequestWithAgreementExample: success"); | ||
} | ||
else { | ||
console.log("SimpleCreatePaymentRequestWithAgreementExample: failed : "+response.getErrorMessage()); | ||
} | ||
|
||
function makeid(length) { | ||
var text = ""; | ||
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; | ||
for (var i = 0; i < length; i++) | ||
text += possible.charAt(Math.floor(Math.random() * possible.length)); | ||
return text; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
|
||
function AgreementConfig() { | ||
this.agreementId = null; | ||
this.agreementType = null; | ||
this.agreementUnscheduledType = null; | ||
this.agreementExpiry = null; | ||
this.agreementFrequency = null; | ||
this.agreementNextChargeDate = null; | ||
this.agreementAdminUrl = null; | ||
this.agreementRetentionPeriod = null; | ||
} | ||
|
||
AgreementConfig.prototype.toHash = function() { | ||
var result = {}; | ||
|
||
result.id = this.agreementId; | ||
result.type = this.agreementType; | ||
result.unscheduled_type = this.agreementUnscheduledType; | ||
result.expiry = this.agreementExpiry; | ||
result.frequency = this.agreementFrequency; | ||
result.next_charge_date = this.agreementNextChargeDate; | ||
result.admin_url = this.agreementAdminUrl; | ||
result.retention_period = this.agreementRetentionPeriod; | ||
|
||
return result; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/** | ||
* Recognized agreement types (aka AgreementConfig.agreementType) | ||
* @type {{recurring: string, instalment: string, unscheduled: string}} | ||
*/ | ||
AgreementType = { | ||
recurring: 'recurring' | ||
, instalment: 'instalment' | ||
, unscheduled: 'unscheduled' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/** | ||
* Recognized agreement unscheduled types (aka AgreementConfig.agreementUnscheduledType) | ||
* @type {{incremental: string, resubmission: string, delayedCharges: string, reauthorisation: string, noShow: string, charge: string}} | ||
*/ | ||
AgreementUnscheduledType = { | ||
incremental: 'incremental' | ||
, resubmission: 'resubmission' | ||
, delayedCharges: 'delayedCharges' | ||
, reauthorisation: 'reauthorisation' | ||
, noShow: 'noShow' | ||
, charge: 'charge' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/** | ||
* @extends PaymentRequest | ||
* @extends BaseRequest | ||
* @constructor | ||
* @param providerData | ||
* @param terminal | ||
* @param shopOrderid | ||
* @param amount | ||
* @param currency | ||
*/ | ||
function CardWalletAuthorizeRequest(providerData, terminal, shopOrderid, amount, currency) { | ||
|
||
// Required: | ||
this.providerData = providerData; | ||
this.terminal = terminal; | ||
this.shopOrderid = shopOrderid; | ||
this.amount = amount; | ||
this.currency = currency; | ||
|
||
// Optional: | ||
this.paymentInfos = []; // transaction info | ||
this.fraudService = null; | ||
this.shippingMethod = null; | ||
this.saleReconciliationIdentifier = null; | ||
this.salesInvoiceNumber = null; | ||
this.salesTax = null; | ||
this.customerCreatedDate = null; | ||
this.cookie = null; | ||
this.language = null; | ||
|
||
/** | ||
* @type {CustomerInfo} | ||
*/ | ||
this.customerInfo = null; | ||
|
||
/** | ||
* @type {OrderLine[]} | ||
*/ | ||
this.orderLines = []; | ||
|
||
// the order below matters: | ||
ObjectHelper.extend(this, new PaymentRequest(new PaymentRequestBase(new PaymentRequestConfig(), new PaymentInfo()), this.customerInfo)); | ||
ObjectHelper.extend(this, new BaseRequest()); | ||
|
||
} | ||
|
||
/** | ||
* @param key {string} | ||
* @returns {string} | ||
*/ | ||
CardWalletAuthorizeRequest.prototype.transformHashKey = function(key) { | ||
|
||
if (key == 'paymentInfos') { | ||
return 'transaction_info'; | ||
} | ||
|
||
return key.replace(/([a-z])([A-Z])/g,'$1_$2').toLowerCase(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/** | ||
* @param responseObject | ||
* @extends BaseResponse | ||
* @constructor | ||
*/ | ||
function CardWalletAuthorizeResponse(responseObject) | ||
{ | ||
this.responseObject = responseObject; | ||
|
||
ObjectHelper.extend(this, new BaseResponse()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/** | ||
* @constructor | ||
* @param terminal | ||
* @param validationUrl | ||
* @param domain | ||
*/ | ||
function CardWalletSessionRequest(terminal, validationUrl, domain) | ||
{ | ||
this.terminal = terminal; | ||
this.validationUrl = validationUrl; | ||
this.domain = domain; | ||
|
||
ObjectHelper.extend(this, new BaseRequest()); | ||
} | ||
|
||
/** | ||
* | ||
* @param key {string} | ||
* @returns {string} | ||
* @private | ||
*/ | ||
CardWalletSessionRequest.prototype.transformHashKey = function(key) { | ||
if(key == 'validationUrl') | ||
{ | ||
return 'validationUrl'; | ||
} | ||
|
||
return key.replace(/([a-z])([A-Z])/g,'$1_$2').toLowerCase(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/** | ||
* @param responseObject | ||
* @extends BaseResponse | ||
* @constructor | ||
*/ | ||
function CardWalletSessionResponse(responseObject) | ||
{ | ||
this.responseObject = responseObject; | ||
|
||
ObjectHelper.extend(this, new BaseResponse()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
|
||
JssdkVersion = { | ||
VERSION : 'sdk-js/1.0.4' | ||
VERSION : 'sdk-js/1.0.5' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.