paymill / paymill-js Goto Github PK
View Code? Open in Web Editor NEWParse.com and NodeJS wrapper for PAYMILL API
License: MIT License
Parse.com and NodeJS wrapper for PAYMILL API
License: MIT License
It is not possible to create a payment on parse.com with token.
Hey,
what's up with the error objects returned in the promise?
They are not really helpful in my case because 'message' as well as 'detailMessage' do not contain well-formed json.
{
"message": "API Error:{\n\t"exception":"subscription_already_connected",\n\t"error":"Subscription already connected"\n}",
"detailMessage": "http status code:400\nheaders:[object Object]\ndata:{\n\t"exception":"subscription_already_connected",\n\t"error":"Subscription already connected"\n}",
"type": "API Error"
}
Is this on purpose? Is there another way to identify which error I am dealing with?
Add the field in the model and create methods
Instead, the wrapper should lookup if there is a data field in the reponse, if so - deserialize, if there is an error field - handle as exception
I have a weird issue. I'm calling payments.remove to delete a payment. The payment id is correct, the payment is removed (checking with the Merchant Centre website) as it should but the promise is rejected. Error callback is called with the error:
PMError: API Error:{
"data":null,
"mode":"test"
}
I'm using "paymill-wrapper": "^2.2.0"
This is my code:
function createOrUpdatePaymentForClient(clientId, token, paymentId) {
var deferred = when.defer();
var promise = deferred.promise;
var removeResult = pm.payments.remove(paymentId).then(function (payment) {
///this is never called, WHY ?
console.log('Payment with id removed {' + payment.id + '} for client {' + clientId + '}');
pm.payments.create(token, clientId).then(function (payment) {
deferred.resolve(payment);
}, function (error) {
deferred.reject(error);
});
}, function (err) {
//this is always called and payment got deleted, BUG ?
console.log(arguments);
console.log('........\n')
console.log('Could not delete payment :');
console.log(err);
pm.payments.create(token, clientId).then(function (payment) {
deferred.resolve(payment);
}, function (error) {
deferred.reject(error);
});
});
console.log('Remove result: ');
console.log(removeResult);
return promise;
}
Whenever I load the paymill-js module in npm, it overwrites the original javascript global Error
object. Every single generic error now has PMError
as their name. I believe the following line is wrong: https://github.com/paymill/paymill-js/blob/master/paymill.node.js#L276
PMError.prototype = Error.prototype;
should be
PMError.prototype.__proto__ = Error.prototype;
or
PMError.prototype = new Error();
Hey guys,
I fixed a bug where you couldn't create a checksum using the paymill wrapper for nodejs.
In the "ChecksumService.prototype.create" function.
I'm wondering whether this thing had ever worked? Can't imagine that I'm the first ever noticing it?!
Anyway I'll provide a pull request so I don't need to monkey patch your wrapper.
Best,
Flo
Update project dependencies.
I'm currently trying to implement behavior that pauses/unpauses a subscription based on what internal plan the user chose. This is my code:
const pm = paymill.getContext(paymillPrivateKey);
if (plan.paymillOfferId) {
// update old subscription
const updatedSubscription =
await pm.subscriptions.changeOfferChangeCaptureDateAndRefund(
subscriptionId,
plan.paymillOfferId,
);
if (updatedSubscription.status === 'inactive') {
await pm.subscriptions.unpause(updatedSubscription.id);
}
} else {
// Allow for free plans to be purchased
await pm.subscriptions.pause(subscriptionId);
}
While that code can pause the subscription just fine, calling pm.subscriptions.unpause()
never managed to set the status to 'active' again. I dug through the source code and found this piece here at line 3950:
SubscriptionService.prototype.unpause = function(obj, cb) {
var map = { "pause" : true };
return this._updateWithMap(obj, map, cb);
};
I guess it really should be
SubscriptionService.prototype.unpause = function(obj, cb) {
var map = { "pause" : false };
return this._updateWithMap(obj, map, cb);
};
What do you think?
Test suite should clean up all objects, that can be deleted, most importantly all webhooks.
Hello
I can't create multiple payButtons via an Angular directive because all buttons will be append to the latest form and I can just buy the latest product. Do you know anything about it?
Directive template:
<form method="post" ng-submit="submit($event)">
<script
src="https://button.paymill.com/v1/"
id="button-{{product.id}}"
data-title="{{ product.title }}"
data-description="{{ product.description }}"
data-amount="{{ product.amount }}"
data-elv="{{ config.elv }}"
data-label="{{ config.label }}"
data-submit-button="{{ config.submitBtnText }}"
data-inline="{{ config.submitBtnInline }}"
data-public-key="{{ paymill.publicKey }}"
data-lang="{{ paymill.language }}"
data-logo="{{ paymill.logoUrl }}"
data-currency="{{ paymill.currency }}"
>
</script>
</form>
Currently, only requests with no params work on Parse.
You have an error line 4367 and 4392:
return this._createTransaction(map, amount, currency, description, client, fee_amount, fee_payment, cb);
Should be:
return this._createTransaction(map, amount, currency, description, client, fee_amount, fee_payment, fee_currency, cb);
Otherwise callback isn't called!
First i try:
const data = {
amount: 100,
currency: 'usd',
checksum_type: 'paypal',
description: 'Test Transaction',
first_name: 'Paymill',
last_name: 'Test',
street_address: 'Test street 123',
postal_code: 12345,
country: 'DE', //
city: 'Munich',
email: '[email protected]',
return_url: 'https://www.example.com/store/checkout/result',
cancel_url: 'https://www.example.com/store/checkout/retry'
}
try {
const result = await pm.checksums.forPaypal(data)
response.send(result)
} catch (error) {
console.log(error) // Invalid arguments:currency is mandatory'
}
Second try
var pass = ''
var header = paymillKey + ':' + (pass || '')
try {
const result = await axios.post(
'https://api.paymill.com/v2.1/checksums',
data,
{
headers: {
Authorization: `Basic ${toBase64(header)}`
}
}
)
response.send(result)
} catch (error) {
console.log(error.response) //Invalid arguments:checksum_type is mandatory'
response.send('wtf')
}
function toBase64 (str) {
return Buffer.from(str || '', 'utf8').toString('base64')
}
i have no plan what goes up
Add PayPal support
A new optional parameter is available for both Transaction and Subscriptions
"mandate_reference" - non empty string.
For transactions:
Update the Transaction model ( add mandateReference String)
Update the create method(s) (as optional parameter)
For Subscriptions
Update the Subscription model ( add mandateReference String)
Update the create method(s) (as optional parameter)
Update the update method (make Subscrition.mandateReference @Updateable )
Template: paymill/paymill-php@51800d6
in transactions it is now possible to define a fee_currency if you do Unite transactions. This parameter has to be added
Hey,
I am trying to update a sub's period_of_validity
paymillSdk.subscriptions.detail(subId)
.then(function(sub) {
//sub['period_of_validity'] = days + ' DAY'
sub['period_of_validity'] = '2 MONTH'
sub.name = 'i changed this one'
log(colors.FgCyan, sub)
return paymillSdk.subscriptions.update(sub)
})
.then(function(sub) {
done(null, 'paymill', sub)
},
function(err) {
done(err)
});
This is the input json:
{ id: 'sub_bf336fe5883b5df76795',
offer:
{ id: 'offer_277bcb600c0a3ce7d974',
name: 'Das Monatspaket',
amount: 3000,
currency: 'EUR',
interval:
{ length: 1,
unit: 'MONTH',
chargeday: undefined,
originalJson: '1 MONTH' },
trial_period_days: 0,
created_at: Tue Oct 28 2014 18:17:34 GMT+0100 (CET),
updated_at: Mon Nov 17 2014 12:20:20 GMT+0100 (CET),
subscription_count: { active: '131', inactive: '8', originalJson: [Object] },
app_id: null,
originalJson:
{ id: 'offer_277bcb600c0a3ce7d974',
name: 'Das Monatspaket',
amount: 3000,
currency: 'EUR',
interval: '1 MONTH',
trial_period_days: 0,
created_at: 1414516654,
updated_at: 1416223220,
subscription_count: [Object],
app_id: null } },
livemode: false,
amount: 3000,
temp_amount: null,
currency: 'EUR',
name: 'i changed this one',
interval:
{ length: 1,
unit: 'MONTH',
chargeday: undefined,
originalJson: '1 MONTH' },
trial_start: null,
trial_end: null,
period_of_validity: '2 MONTH',
end_of_period: null,
next_capture_at: Sat Dec 27 2014 11:20:00 GMT+0100 (CET),
created_at: Thu Nov 27 2014 11:20:00 GMT+0100 (CET),
updated_at: Thu Nov 27 2014 11:20:00 GMT+0100 (CET),
canceled_at: null,
payment:
{ id: 'pay_f63fddd433460a370ee7414c',
type: 'debit',
client: 'client_c491d47a4b28fb38960a',
holder: 'Chris Hansen',
account: '*****9890',
updated_at: Thu Nov 27 2014 11:19:59 GMT+0100 (CET),
created_at: Thu Nov 27 2014 11:19:59 GMT+0100 (CET),
app_id: null,
originalJson:
{ id: 'pay_f63fddd433460a370ee7414c',
type: 'debit',
client: 'client_c491d47a4b28fb38960a',
code: '50010517',
holder: 'Chris Hansen',
account: '*****9890',
iban: null,
bic: null,
updated_at: 1417083599,
created_at: 1417083599,
app_id: null,
is_recurring: true,
is_usable_for_preauthorization: true } },
app_id: null,
is_canceled: false,
is_deleted: false,
status: 'active',
client:
{ id: 'client_c491d47a4b28fb38960a',
email: '[email protected]',
description: 'subscription customer',
app_id: null,
updated_at: Thu Nov 27 2014 11:19:59 GMT+0100 (CET),
created_at: Thu Nov 27 2014 11:19:59 GMT+0100 (CET),
payment: [ [Object] ],
subscription: [ [Object] ],
originalJson:
{ id: 'client_c491d47a4b28fb38960a',
email: '[email protected]',
description: 'subscription customer',
app_id: null,
updated_at: 1417083599,
created_at: 1417083599,
payment: [Object],
subscription: [Object] } },
originalJson:
{ id: 'sub_bf336fe5883b5df76795',
offer:
{ id: 'offer_277bcb600c0a3ce7d974',
name: 'Das Monatspaket',
amount: 3000,
currency: 'EUR',
interval: '1 MONTH',
trial_period_days: 0,
created_at: 1414516654,
updated_at: 1416223220,
subscription_count: [Object],
app_id: null },
livemode: false,
amount: 3000,
temp_amount: null,
currency: 'EUR',
name: 'Box of Germany - Das Monatspaket',
interval: '1 MONTH',
trial_start: null,
trial_end: null,
period_of_validity: null,
end_of_period: null,
next_capture_at: 1419675600,
created_at: 1417083600,
updated_at: 1417083600,
canceled_at: null,
payment:
{ id: 'pay_f63fddd433460a370ee7414c',
type: 'debit',
client: 'client_c491d47a4b28fb38960a',
code: '50010517',
holder: 'Chris Hansen',
account: '*****9890',
iban: null,
bic: null,
updated_at: 1417083599,
created_at: 1417083599,
app_id: null,
is_recurring: true,
is_usable_for_preauthorization: true },
app_id: null,
is_canceled: false,
is_deleted: false,
status: 'active',
client:
{ id: 'client_c491d47a4b28fb38960a',
email: '[email protected]',
description: 'subscription customer',
app_id: null,
updated_at: 1417083599,
created_at: 1417083599,
payment: [Object],
subscription: [Object] } } }
This is the result aka. the updated sub:
{ id: 'sub_bf336fe5883b5df76795',
offer:
{ id: 'offer_277bcb600c0a3ce7d974',
name: 'Das Monatspaket',
amount: 3000,
currency: 'EUR',
interval:
{ length: 1,
unit: 'MONTH',
chargeday: undefined,
originalJson: '1 MONTH' },
trial_period_days: 0,
created_at: Tue Oct 28 2014 18:17:34 GMT+0100 (CET),
updated_at: Mon Nov 17 2014 12:20:20 GMT+0100 (CET),
subscription_count: { active: '131', inactive: '8', originalJson: [Object] },
app_id: null,
originalJson:
{ id: 'offer_277bcb600c0a3ce7d974',
name: 'Das Monatspaket',
amount: 3000,
currency: 'EUR',
interval: '1 MONTH',
trial_period_days: 0,
created_at: 1414516654,
updated_at: 1416223220,
subscription_count: [Object],
app_id: null } },
livemode: false,
amount: 3000,
temp_amount: null,
currency: 'EUR',
name: 'i changed this one',
interval:
{ length: 1,
unit: 'MONTH',
chargeday: undefined,
originalJson: '1 MONTH' },
trial_start: null,
trial_end: null,
period_of_validity: null,
end_of_period: null,
next_capture_at: Sat Dec 27 2014 11:20:00 GMT+0100 (CET),
created_at: Thu Nov 27 2014 11:20:00 GMT+0100 (CET),
updated_at: Thu Nov 27 2014 11:29:50 GMT+0100 (CET),
canceled_at: null,
payment:
{ id: 'pay_f63fddd433460a370ee7414c',
type: 'debit',
client: 'client_c491d47a4b28fb38960a',
holder: 'Chris Hansen',
account: '*****9890',
updated_at: Thu Nov 27 2014 11:19:59 GMT+0100 (CET),
created_at: Thu Nov 27 2014 11:19:59 GMT+0100 (CET),
app_id: null,
originalJson:
{ id: 'pay_f63fddd433460a370ee7414c',
type: 'debit',
client: 'client_c491d47a4b28fb38960a',
code: '50010517',
holder: 'Chris Hansen',
account: '*****9890',
iban: null,
bic: null,
updated_at: 1417083599,
created_at: 1417083599,
app_id: null,
is_recurring: true,
is_usable_for_preauthorization: true } },
app_id: null,
is_canceled: false,
is_deleted: false,
status: 'active',
client:
{ id: 'client_c491d47a4b28fb38960a',
email: '[email protected]',
description: 'subscription customer',
app_id: null,
updated_at: Thu Nov 27 2014 11:19:59 GMT+0100 (CET),
created_at: Thu Nov 27 2014 11:19:59 GMT+0100 (CET),
payment: [ [Object] ],
subscription: [ [Object] ],
originalJson:
{ id: 'client_c491d47a4b28fb38960a',
email: '[email protected]',
description: 'subscription customer',
app_id: null,
updated_at: 1417083599,
created_at: 1417083599,
payment: [Object],
subscription: [Object] } },
originalJson:
{ id: 'sub_bf336fe5883b5df76795',
offer:
{ id: 'offer_277bcb600c0a3ce7d974',
name: 'Das Monatspaket',
amount: 3000,
currency: 'EUR',
interval: '1 MONTH',
trial_period_days: 0,
created_at: 1414516654,
updated_at: 1416223220,
subscription_count: [Object],
app_id: null },
livemode: false,
amount: 3000,
temp_amount: null,
currency: 'EUR',
name: 'i changed this one',
interval: '1 MONTH',
trial_start: null,
trial_end: null,
period_of_validity: null,
end_of_period: null,
next_capture_at: 1419675600,
created_at: 1417083600,
updated_at: 1417084190,
canceled_at: null,
payment:
{ id: 'pay_f63fddd433460a370ee7414c',
type: 'debit',
client: 'client_c491d47a4b28fb38960a',
code: '50010517',
holder: 'Chris Hansen',
account: '*****9890',
iban: null,
bic: null,
updated_at: 1417083599,
created_at: 1417083599,
app_id: null,
is_recurring: true,
is_usable_for_preauthorization: true },
app_id: null,
is_canceled: false,
is_deleted: false,
status: 'active',
client:
{ id: 'client_c491d47a4b28fb38960a',
email: '[email protected]',
description: 'subscription customer',
app_id: null,
updated_at: 1417083599,
created_at: 1417083599,
payment: [Object],
subscription: [Object] } } }
Or am I doing something wrong here?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.