การคืนเงินลายดาวตก (mrgalaxy:stripe)

จะคืนเงินด้วย mrgalaxy:stripe ได้อย่างไร?

Stripe.refunds.create(refund, function(err, receipt) {
  ...
});

ส่งผลให้ Exception while simulating the effect of invoking 'rejectUserFromProject' TypeError: Cannot read property 'create' of undefined(…) TypeError: Cannot read property 'create' of undefined

ฉันใช้ StripeCheckout สำหรับการเรียกเก็บเงิน และไม่พบว่ามีวิธีการคืนเงินหรือไม่:

StripeCheckout.open({
    key: _key,
    amount: fee * 100,
    currency: 'usd',
    name: 'name',
    description: 'description',
    panelLabel: 'label',
    token: function(receipt) {
      console.info(receipt);
  });

person aug2uag    schedule 03.05.2016    source แหล่งที่มา


คำตอบ (1)


Checkout เป็นโมดูล UX/UI สำหรับธุรกรรม CC และการจัดการขึ้นอยู่กับไลบรารีฝั่งเซิร์ฟเวอร์หรือการเรียก ซึ่งการตรวจสอบสิทธิ์จะรวมความลับของเซิร์ฟเวอร์ด้วย (เช่น Checkout ใช้รหัสสาธารณะ)

mrgalaxy:meteor รวม Node.js Stripe API ไว้ด้วย อย่างไรก็ตาม ฉันใช้เวลาได้ไม่ดีนัก.. ทางออกที่ดีกว่าคือใช้ API จากที่นั่น

วิธีแฮ็กในตอนนี้คือการนำเข้าแพ็คเกจ Stripe npm และโดยใช้แพ็คเกจ meteorhacks:npm

สร้างไฟล์ package.json ด้วย Stripe dep และโค้ดก็พบว่า:

if (Meteor.isServer) {
  var stripe = Meteor.npmRequire("stripe")(
    Meteor.settings.private.testSecretKey
  );

  stripe.refunds.create(returnObj, function(err, refund) {
    // asynchronously called
    if (err) {
      // handle
    };
  });
};

นอกจากนี้ เนื่องจากโค้ดกำลังดำเนินการในการเรียกกลับ จึงอาจมีปัญหาในการใช้วิธีตามสัญญาของ Meteor หรืออื่นๆ อาจกำหนดในขอบเขตหลักแม้ว่าฉันไม่ได้ลอง ดังนั้นจึงจำเป็นต้องห่อหุ้มด้วย Fiber ตามที่เป็นอยู่:

stripe.refunds.create({
  // ...
}, Meteor.bindEnvironment(function (err, refund) {
  // ...
}));

สุดท้ายนี้ Meteor 1.3 รองรับการบูรณาการ npm ดังนั้นคุณจึงไม่จำเป็นต้องใช้อะไรที่ไม่คุ้นเคย:

if (Meteor.isServer) {
  var stripe = require("stripe")(
    Meteor.settings.private.testSecretKey
  );

  stripe.refunds.create(returnObj, function(err, refund) {
    // asynchronously called
    if (err) {
      // handle
    };
  });
};
person aug2uag    schedule 04.05.2016