-
-
Save mknazsky/12b12125591a8226a539 to your computer and use it in GitHub Desktop.
Example of calling Zooz payment gateway and Skypicker payment confirmation endpoint
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
var zoozApi = new zooz.Ext.External({ | |
isSandbox: !!apiSaveBookingResponse.sandbox, // Force boolean | |
uniqueId: config.zoozId | |
}); | |
var _makePayment = function(bookingData, zoozToken) { | |
var paymentRequest = { | |
paymentToken: zoozToken, | |
email: bookingData.contact.eMail, | |
paymentMethod: { | |
paymentMethodType: 'CreditCard', | |
paymentMethodDetails: { | |
cardNumber: bookingData.payment.ccn, | |
/*cardHolderName: bookingData.payment.holder,*/ | |
month: bookingData.payment.expire.month, | |
year: '20'+bookingData.payment.expire.year, | |
cvvNumber: bookingData.payment.cvv, | |
/*userIdNumber: '123456789'*/ | |
}, | |
configuration: { | |
rememberPaymentMethod: true | |
} | |
} | |
}; | |
var deffered = $q.defer(); | |
var status = _zoozApi.addPaymentMethod(paymentRequest, | |
function(addPaymentMethodResponse){ | |
$.ajax({ | |
dataType: "json", | |
url: 'https://booking-api.skypicker.com/api/v0.1/confirm_payment', | |
type: "POST", | |
data: { | |
"paymentToken": apiSaveBookingResponse['zooz_token'], | |
"paymentMethodToken": addPaymentMethodResponse['paymentMethodToken'], | |
"booking_id": apiSaveBookingResponse ['booking_id'] | |
}, | |
success: function (response) { | |
if (parseInt(response.status, 10) === 0) { | |
deffered.resolve(response); | |
} else { | |
deffered.reject(response); | |
}, | |
fail: function (xhr) { | |
deffered.reject(xhr); | |
} | |
}); | |
}, | |
function(data){ | |
deffered.reject(data); | |
} | |
); | |
return deffered.promise; | |
} |
Should i also include their library? Where to find the zooz library?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
can anyone provide this above implementation only in php to generate 'paymentmethodtoken'?